@Override public Theme build() { List<String> storeIds = config.getLayerStoreId(); Map<String, LayerStore> stores = new LinkedHashMap<String, LayerStore>( storeIds.size() ); for ( String id : storeIds ) { LayerStore store = workspace.getResource( LayerStoreProvider.class, id ); if ( store == null ) { LOG.warn( "Layer store with id {} is not available.", id ); continue; } stores.put( id, store ); } ThemeType root = config.getTheme(); Theme theme; if ( root == null ) { theme = buildAutoTheme( stores ); } else { theme = buildTheme( root, root.getLayer(), root.getTheme(), stores ); } if ( theme == null ) { throw new ResourceInitException( "Root theme contains no layers and no themes." ); } aggregateSpatialMetadata( theme ); return theme; }
private static Envelope aggregateFromTheme( Theme t, Envelope env, List<ICRS> crs ) { aggregateSpatialMetadata( t ); SpatialMetadata smd = t.getLayerMetadata().getSpatialMetadata(); if ( smd.getEnvelope() != null ) { if ( env == null ) { env = smd.getEnvelope(); } else { env = env.merge( smd.getEnvelope() ); } } if ( smd.getCoordinateSystems() != null ) { addAllUncontained( crs, smd.getCoordinateSystems() ); } return env; }
@Override public Theme build() { try { String id = cfg.getRemoteWMSId(); String lid = cfg.getLayerStoreId(); LayerStore store = workspace.getResource( LayerStoreProvider.class, lid ); if ( store == null ) { throw new ResourceInitException( "The layer store with id " + lid + " was not available." ); } RemoteOWS ows = workspace.getResource( RemoteOWSProvider.class, id ); if ( !( ows instanceof RemoteWMS ) ) { throw new ResourceInitException( "The remote OWS store with id " + id + " was not of type WMS or was not available." ); } WMSClient client = ( (RemoteWMS) ows ).getClient(); Tree<LayerMetadata> tree = client.getLayerTree(); Theme theme = buildTheme( tree, store ); aggregateSpatialMetadata( theme ); return theme; } catch ( Exception e ) { throw new ResourceInitException( "Could not parse remote WMS theme config.", e ); } }