/** * Creates a new instance of DefaultMapLayer * * @param featureSource the data source for this layer * @param style the style used to represent this layer * @param title the layer title * @throws NullPointerException DOCUMENT ME! */ @SuppressWarnings("unchecked") public MapLayer(FeatureSource featureSource, Style style, String title) { internal = new FeatureLayer(featureSource, style, title); }
private static FeatureLayer buildNewFeatureLayer(Layer layer, Style style) { FeatureLayer singleGroupLayer = new FeatureLayer(layer.getFeatureSource(), style); SortBy[] sortBy = SLDStyleFactory.getSortBy(style.featureTypeStyles().get(0).getOptions()); Query nativeQuery = layer.getQuery(); Query query = ensureSortProperties(nativeQuery, sortBy); singleGroupLayer.setQuery(query); singleGroupLayer.setTitle(layer.getTitle()); return singleGroupLayer; }
FeatureLayer clone = new FeatureLayer(layer.getFeatureSource(), s); clone.setQuery(layer.getQuery()); clone.setVisible(layer.isVisible()); clone.setSelected(layer.isSelected()); clone.getUserData().putAll(layer.getUserData()); layers.add(clone);
FeatureLayer layer = new FeatureLayer(fs, style); layer.setQuery(new Query(null, CQL.toFilter("id > 5")));
@Test public void testAddLayer() throws Exception { FeatureTypeInfo ft = getCatalog().getFeatureTypeByName(getLayerId(MockData.BRIDGES)); FeatureSource<? extends FeatureType, ? extends Feature> fs = ft.getFeatureSource(null, null); Style style = getCatalog().getStyleByName("point").getStyle(); final FeatureLayer layer = new FeatureLayer(fs, style); layer.setTitle("extra"); TestCallback callback = new TestCallback() { @Override public WMSMapContent beforeRender(WMSMapContent mapContent) { mapContent.addLayer(layer); return super.beforeRender(mapContent); } }; getMap.setGetMapCallbacks(Arrays.asList((GetMapCallback) callback)); // request a layer group with two layers Document dom = getAsDOM("wms?request=reflect&layers=nature&format=rss&version=1.1.0"); // print(dom); assertXpathExists("rss/channel/title[text() = 'cite:Lakes,cite:Forests,extra']", dom); assertEquals(1, callback.requests.size()); assertEquals(1, callback.mapContentsInited.size()); assertEquals(3, callback.layers.size()); assertEquals(1, callback.mapContents.size()); assertEquals(1, callback.maps.size()); assertEquals(0, callback.exceptions.size()); assertEquals(layer, callback.layers.get(2)); }
FeatureLayer featureLayer = new FeatureLayer(source, layerStyle); featureLayer.setTitle( mapLayerInfo.getRemoteFeatureSource().getSchema().getTypeName()); : Integer.MAX_VALUE; definitionQuery.setMaxFeatures(maxFeatures); featureLayer.setQuery(definitionQuery); FeatureLayer featureLayer = new FeatureLayer(source, layerStyle); featureLayer.setTitle(mapLayerInfo.getFeature().prefixedName()); featureLayer.getUserData().put("abstract", mapLayerInfo.getDescription()); definitionQuery.setMaxFeatures(maxFeatures); featureLayer.setQuery(definitionQuery); mapContent.addLayer(featureLayer);
/** * Adds the feature centroids to the output features, without actually adding the full * geometry (used when doing raster overlays of vector data with a desire to retain the * popups) * @param layer * @param folder */ private void addFeatureCentroids(Layer layer, Folder folder) { try { SimpleFeatureSource source = (SimpleFeatureSource) ((FeatureLayer) layer).getFeatureSource(); SimpleFeatureCollection original = source.getFeatures(); SimpleFeatureCollection centroids = new KMLCentroidFeatureCollection(original); context.setCurrentFeatureCollection(centroids); FeatureLayer centroidsLayer = new FeatureLayer(centroids, layer.getStyle(), layer.getTitle()); List<Feature> features = new SequenceList<Feature>( new FeatureSequenceFactory(context, centroidsLayer)); context.addFeatures(folder, features); } catch(IOException e) { throw new ServiceException( "Failed to load vector data during KML generation", e); } }
layer.setQuery(new Query(query)); } else { throw new IllegalStateException("Query not supported by " + internal);
FeatureSource<?, ?> fs = layer.getFeatureSource(); Envelope targetRasterSpace = new Envelope( Query query = layer.getQuery(); BBOX bbox = FF.bbox(FF.property(""), queryBBOX); if (query.getFilter() == null || query.getFilter() == Filter.INCLUDE) {
/** * Returns the current feature type is the current layer is made of vector features, null otherwise * @return */ public SimpleFeatureType getCurrentFeatureType() { if(currentLayer instanceof FeatureLayer) { FeatureLayer fl = (FeatureLayer) currentLayer; return (SimpleFeatureType) fl.getFeatureSource().getSchema(); } return null; }
@Test public void testReprojectedPolygonFromDefinitionQuery() throws Exception { // a spatial filter in a different SRS CoordinateReferenceSystem utm31n = CRS.decode("EPSG:32631"); CoordinateReferenceSystem wgs84 = CRS.decode("EPSG:4326"); ReferencedEnvelope envWgs84 = new ReferencedEnvelope(1, 3, 5, 7, wgs84); ReferencedEnvelope envUTM31N = envWgs84.transform(utm31n, true); // build the style StyleBuilder sb = new StyleBuilder(); Symbolizer ps = sb.createPointSymbolizer(); Style style = sb.createStyle(ps); // build a filter for the layer own definition query FeatureLayer layer = new FeatureLayer(pointFS, style); Polygon polygon = JTS.toGeometry((Envelope) envUTM31N); polygon.setUserData(utm31n); layer.setQuery( new DefaultQuery(null, ff.intersects(ff.property("geom"), ff.literal(polygon)))); content.addLayer(layer); RendererBaseTest.showRender( "Reprojected polygon as a definition query", renderer, TIME, bounds); assertEquals(1, renderedIds.size()); assertEquals("point.4", renderedIds.iterator().next()); } }
FeatureLayer layer = new FeatureLayer(fs, basicStyle); layer.setTitle("Title"); map.addLayer(layer); request.setFormat("application/openlayers");
layer.setQuery( new Query(query));
/** * Creates a new instance of DefaultMapLayer using a non-emtpy feature collection as a parameter * * @param collection the source feature collection * @param style the style used to represent this layer * @param title Title of map layer */ public MapLayer(FeatureCollection collection, Style style, String title) { internal = new FeatureLayer(collection, style, title); }
new FeatureLayer( new UTFGridFeatureSource(layer.getFeatureSource(), null), copy); fl.setQuery(layer.getQuery()); sl = fl; } else if (layer instanceof GridCoverageLayer) {
FeatureLayer layer = new FeatureLayer(fs, basicStyle); layer.setTitle("Title"); map.addLayer(layer); request.setFormat("application/openlayers3");
layer.setQuery(new Query(null, ECQL.toFilter("sp = 'StringProp1_2'")));
/** * Creates a new instance of DefaultMapLayer using a non-emtpy feature collection as a parameter * * @param collection the source feature collection * @param style the style used to represent this layer */ public MapLayer(FeatureCollection collection, Style style) { internal = new FeatureLayer((FeatureCollection) collection, style); }
new FeatureLayer( new FeatureInfoFeatureSource(featureSource, params.getPropertyNames()), style); result.setQuery(definitionQuery);
@Test public void testFilter() throws Exception { // Set up a map context with a filtered layer WMSMapContent map = new WMSMapContent(createGetMapRequest(MockData.BUILDINGS)); Document document; try { FeatureLayer layer = (FeatureLayer) createMapLayer(MockData.BUILDINGS); Filter f = ff.equals(ff.property("ADDRESS"), ff.literal("215 Main Street")); layer.setQuery(new Query(MockData.BUILDINGS.getLocalPart(), f)); map.addLayer(layer); document = getRSSResponse(map, AtomGeoRSSTransformer.GeometryEncoding.LATLONG); } finally { map.dispose(); } NodeList items = document.getDocumentElement().getElementsByTagName("item"); assertEquals(1, items.getLength()); }