Package org.geotools.map

Examples of org.geotools.map.FeatureLayer


    @Test
    public void testSetStandAlone() throws Exception {
        SimpleFeatureCollection features = FeatureCollections
                .newCollection();
        Style style = mockData.getDefaultStyle().getStyle();
        Layer layer = new FeatureLayer(features, style);

        WMSMapContent mapContent = new WMSMapContent();
        GetMapRequest request = mockData.createRequest();
        mapContent.setRequest(request);
View Full Code Here


        SimpleFeatureSource fs =
            (SimpleFeatureSource) typeInfo.getFeatureSource(null, null);
        SimpleFeatureCollection features = fs.getFeatures();

        Style style = mockData.getDefaultStyle().getStyle();
        Layer layer = new FeatureLayer(features, style);
        layer.setTitle("TestPointsTitle");

        GetMapRequest request = mockData.createRequest();
        request.setLayers(Collections.singletonList(mli));

        request.setMaxFeatures(2);
View Full Code Here

    @Test
    public void testKmltitleFormatOption() throws Exception {
        SimpleFeatureCollection features = FeatureCollections
                .newCollection();
        Style style = mockData.getDefaultStyle().getStyle();
        Layer layer = new FeatureLayer(features, style);

        WMSMapContent mapContent = new WMSMapContent();
        GetMapRequest request = mockData.createRequest();
        mapContent.setRequest(request);
View Full Code Here

            int layerType = mapLayerInfo.getType();
            if (layerType == MapLayerInfo.TYPE_REMOTE_VECTOR) {

                final SimpleFeatureSource source = mapLayerInfo.getRemoteFeatureSource();
                FeatureLayer featureLayer = new FeatureLayer(source, layerStyle);
                featureLayer.setTitle(mapLayerInfo.getRemoteFeatureSource().getSchema().getTypeName());

                final Query definitionQuery = new Query(source.getSchema().getTypeName());
                definitionQuery.setFilter(layerFilter);
                definitionQuery.setVersion(featureVersion);
                int maxFeatures = request.getMaxFeatures() != null ? request.getMaxFeatures()
                        : Integer.MAX_VALUE;
                definitionQuery.setMaxFeatures(maxFeatures);
                featureLayer.setQuery(definitionQuery);
               
                mapContent.addLayer(featureLayer);
               
                layer = featureLayer;
            } else if (layerType == MapLayerInfo.TYPE_VECTOR) {
                FeatureSource<? extends FeatureType, ? extends Feature> source;
                // /////////////////////////////////////////////////////////
                //
                // Adding a feature layer
                //
                // /////////////////////////////////////////////////////////
                try {
                    source = mapLayerInfo.getFeatureSource(true);

                    // NOTE for the feature. Here there was some code that
                    // sounded like:
                    // * get the bounding box from feature source
                    // * eventually reproject it to the actual CRS used for
                    // map
                    // * if no intersection, don't bother adding the feature
                    // source to the map
                    // This is not an optimization, on the contrary,
                    // computing the bbox may be
                    // very expensive depending on the data size. Using
                    // sigma.openplans.org data
                    // and a tiled client like OpenLayers, it dragged the
                    // server to his knees
                    // and the client simply timed out
                } catch (IOException exp) {
                    if (LOGGER.isLoggable(Level.SEVERE)) {
                        LOGGER.log(Level.SEVERE, new StringBuffer("Getting feature source: ")
                                .append(exp.getMessage()).toString(), exp);
                    }

                    throw new ServiceException("Internal error", exp);
                }
                FeatureLayer featureLayer = new FeatureLayer(source, layerStyle);
                featureLayer.setTitle(mapLayerInfo.getFeature().prefixedName());
                featureLayer.getUserData().put("abstract", mapLayerInfo.getDescription());
               
                // mix the dimension related filter with the layer filter
                Filter dimensionFilter = wms.getTimeElevationToFilter(times, elevations, mapLayerInfo.getFeature());
                Filter filter = Filters.and(ff, layerFilter, dimensionFilter);

                final Query definitionQuery = new Query(source.getSchema().getName().getLocalPart());
                definitionQuery.setVersion(featureVersion);
                definitionQuery.setFilter(filter);
              if (viewParams != null) {
                    definitionQuery.setHints(new Hints(Hints.VIRTUAL_TABLE_PARAMETERS, viewParams.get(i)));
              }

                // check for startIndex + offset
                final Integer startIndex = request.getStartIndex();
                if (startIndex != null) {
                    QueryCapabilities queryCapabilities = source.getQueryCapabilities();
                    if (queryCapabilities.isOffsetSupported()) {
                        // fsource is required to support
                        // SortBy.NATURAL_ORDER so we don't bother checking
                        definitionQuery.setStartIndex(startIndex);
                    } else {
                        // source = new PagingFeatureSource(source,
                        // request.getStartIndex(), limit);
                        throw new ServiceException("startIndex is not supported for the "
                                + mapLayerInfo.getName() + " layer");
                    }
                }

                int maxFeatures = request.getMaxFeatures() != null ? request.getMaxFeatures()
                        : Integer.MAX_VALUE;
                definitionQuery.setMaxFeatures(maxFeatures);

                featureLayer.setQuery(definitionQuery);
                mapContent.addLayer(featureLayer);
               
                layer = featureLayer;
            } else if (layerType == MapLayerInfo.TYPE_RASTER) {

View Full Code Here

     * @return
     */
    public static BufferedImage renderIcon(Style style) {
        int size = findIconSize(style)+2; // size is an int because icons are always square
        MapContent mapContent = new MapContent();
        mapContent.addLayer(new FeatureLayer(sampleData, style));
        BufferedImage image = new BufferedImage(size * Icons.RENDER_SCALE_FACTOR,
                size * Icons.RENDER_SCALE_FACTOR, BufferedImage.TYPE_INT_ARGB);
        Graphics2D graphics = image.createGraphics();
        graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        graphics.scale(Icons.RENDER_SCALE_FACTOR, Icons.RENDER_SCALE_FACTOR);
View Full Code Here

     * 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;
    }
View Full Code Here

        DefaultFeatureCollection collection = new DefaultFeatureCollection();
        collection.add(createCrsBoundsFeature(geom, crs));

        Style style = getStyle("crs.sld");

        FeatureLayer ml = new FeatureLayer(collection, style);
        return ml;
    }
View Full Code Here

            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(
View Full Code Here

        map.setMapWidth(mapWidth);
        map.setMapHeight(mapHeight);
        map.setTransparent(false);

        Style basicStyle = getTestStyle("Population.sld");
        map.addLayer(new FeatureLayer(fs, basicStyle));

        EncodeHTMLImageMap imageMap = this.mapProducer.produceMap(map);

        assertTestResult("States", imageMap);
    }
View Full Code Here

        map.setMapWidth(mapWidth);
        map.setMapHeight(mapHeight);
        map.setTransparent(false);

        Style basicStyle = getTestStyle("default.sld");
        map.addLayer(new FeatureLayer(fs, basicStyle));

        EncodeHTMLImageMap result = mapProducer.produceMap(map);
        assertTestResult("BasicPolygons", result);

    }
View Full Code Here

TOP

Related Classes of org.geotools.map.FeatureLayer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.