Package org.geotools.map

Examples of org.geotools.map.MapLayer


        public KMLRasterTranslator(ContentHandler handler) {
            super(handler);
        }

        public void encode(Object o) throws IllegalArgumentException {
            MapLayer mapLayer = (MapLayer) o;
            int mapLayerOrder = mapContext.indexOf(mapLayer);

            if ( isStandAlone() ) {
                start( "kml" );
            }
           
            //start("Document");
            //element("name", mapLayer.getTitle());

            //start the folder naming it 'layer_<mapLayerOrder>', this is
            // necessary for a GroundOverlay
            start("Folder");
            element("name", "layer_" + mapLayerOrder);
            element("description", mapLayer.getTitle());

            start("GroundOverlay");
            //element( "name", feature.getID() );
            element("name", mapLayer.getTitle());
            element("drawOrder", Integer.toString(mapLayerOrder));

            //encode the icon
            start("Icon");

            encodeHref(mapLayer);

            element("viewRefreshMode", "never");
            element("viewBoundScale", "0.75");
            end("Icon");

            //encde the bounding box
            ReferencedEnvelope box = new ReferencedEnvelope(mapContext.getAreaOfInterest());
            boolean reprojectBBox = (box.getCoordinateReferenceSystem() != null)
            && !CRS.equalsIgnoreMetadata(box.getCoordinateReferenceSystem(), DefaultGeographicCRS.WGS84);
            if (reprojectBBox) {
                try {
                    box = box.transform(DefaultGeographicCRS.WGS84, true);
                } catch(Exception e) {
                    throw new WmsException("Could not transform bbox to WGS84", "ReprojectionError", e);
                }
            }
            start("LatLonBox");
            element("north", Double.toString(box.getMaxY()));
            element("south", Double.toString(box.getMinY()));
            element("east", Double.toString(box.getMaxX()));
            element("west", Double.toString(box.getMinX()));
            end("LatLonBox");

            end("GroundOverlay");

            // if the kmplacemark format option is true, add placemarks to the output
            GetMapRequest request = mapContext.getRequest();
            boolean kmplacemark = request.getWMS().getKmlPlacemark();
            if (request.getFormatOptions().get("kmplacemark") != null)
                kmplacemark = (Boolean) request.getFormatOptions().get("kmplacemark");
            if (kmplacemark) {
                FeatureCollection<SimpleFeatureType, SimpleFeature> features = null;
                try {
                    features = KMLUtils
                            .loadFeatureCollection(
                                    (FeatureSource<SimpleFeatureType, SimpleFeature>) mapLayer
                                            .getFeatureSource(), mapLayer,
                                    mapContext);
                } catch (Exception ex) {
                    String msg = "Error getting features.";
                    LOGGER.log(Level.WARNING, msg, ex);
                }

                if (features != null && features.size() > 0) {
                    Geometry geom = null;
                    Geometry centroidGeom = null;

                    // get geometry of the area of interest
                    Envelope aoi = mapContext.getAreaOfInterest();
                    GeometryFactory factory = new GeometryFactory();
                    Geometry displayGeom = factory.toGeometry(new Envelope(aoi
                            .getMinX(), aoi.getMaxX(), aoi.getMinY(), aoi
                            .getMaxY()));

                    // get the styles for this feature
                    SimpleFeatureType featureType = features.getSchema();
                    FeatureTypeStyle[] fts = KMLUtils.filterFeatureTypeStyles(
                            mapLayer.getStyle(), featureType);

                    Iterator<SimpleFeature> iter = features.iterator();
                    while (iter.hasNext()) {
                        SimpleFeature ftr = iter.next();
                        geom = (Geometry) ftr.getDefaultGeometry();
View Full Code Here


        /**
         * Encodes a KML ScreenOverlay wihch depicts the legend of a map.
         */
        public void encode(Object o) throws IllegalArgumentException {
            MapLayer mapLayer = (MapLayer) o;

            if ( isStandAlone() ) {
                start( "kml" );
            }
           
View Full Code Here

    }
   
    @SuppressWarnings("unchecked")
    public void testExternalGraphicBackround() throws Exception {
        // see http://jira.codehaus.org/browse/GEOS-1947
        MapLayer mapLayer = createMapLayer( MockData.POINTS,  "Bridge");
        WMSMapContext mapContext = new WMSMapContext(createGetMapRequest(MockData.POINTS));
        mapContext.addLayer(mapLayer);
        KMLVectorTransformer transformer = new KMLVectorTransformer(mapContext, mapLayer);
        transformer.setIndentation(2);

        FeatureSource <SimpleFeatureType, SimpleFeature> featureSource;
        featureSource = (FeatureSource<SimpleFeatureType, SimpleFeature>) mapLayer.getFeatureSource();
        int nfeatures = featureSource.getFeatures().size();

        Document document = WMSTestSupport.transform(featureSource.getFeatures(), transformer);

        // make sure we are generating icon styles, but that we're not sticking a color onto them
View Full Code Here

        XMLAssert.assertXpathEvaluatesTo("0", "count(//Style/IconStyle/Icon/color)", document);
    }
   
    @SuppressWarnings("unchecked")
    public void testFilteredData() throws Exception {
        MapLayer mapLayer = createMapLayer( MockData.BASIC_POLYGONS,  "SingleFeature");
       
        WMSMapContext mapContext = new WMSMapContext(createGetMapRequest(MockData.BASIC_POLYGONS));
        mapContext.addLayer(mapLayer);
       
        KMLVectorTransformer transformer = new KMLVectorTransformer(mapContext, mapLayer);
        transformer.setIndentation(2);

        FeatureSource <SimpleFeatureType, SimpleFeature> featureSource;
        featureSource = (FeatureSource<SimpleFeatureType, SimpleFeature>) mapLayer.getFeatureSource();

        Document document = WMSTestSupport.transform(featureSource.getFeatures(), transformer);

        Element element = document.getDocumentElement();
        assertEquals("kml", element.getNodeName());
View Full Code Here

     */
    public void testSetStandAlone() throws Exception {
        FeatureCollection<SimpleFeatureType, SimpleFeature> features = FeatureCollections
                .newCollection();
        Style style = mockData.getDefaultStyle().getStyle();
        MapLayer mapLayer = new DefaultMapLayer(features, style);

        WMSMapContext mapContext = new WMSMapContext();
        GetMapRequest request = mockData.createRequest();
        mapContext.setRequest(request);

View Full Code Here

        FeatureSource<SimpleFeatureType, SimpleFeature> fs =
            (FeatureSource<SimpleFeatureType, SimpleFeature>) typeInfo.getFeatureSource(null, null);
        FeatureCollection<SimpleFeatureType, SimpleFeature> features = fs.getFeatures();

        Style style = mockData.getDefaultStyle().getStyle();
        MapLayer mapLayer = new DefaultMapLayer(features, style);
        mapLayer.setTitle("TestPointsTitle");

        WMSMapContext mapContext = new WMSMapContext();
        GetMapRequest request = mockData.createRequest();
        request.setLayers(new MapLayerInfo[] { layer });
View Full Code Here

    }

    public void testFilter() throws Exception {
        // Set up a map context with a filtered layer
        WMSMapContext map = new WMSMapContext(createGetMapRequest(MockData.BUILDINGS));
        MapLayer layer = createMapLayer(MockData.BUILDINGS);
        Filter f = ff.equals(ff.property("ADDRESS"), ff.literal("215 Main Street"));
        layer.setQuery(new DefaultQuery(MockData.BUILDINGS.getLocalPart(), f));
        map.addLayer(layer);
       
        Document document = getRSSResponse(map, AtomGeoRSSTransformer.GeometryEncoding.LATLONG);
        NodeList items = document.getDocumentElement().getElementsByTagName("item");
        assertEquals(1, items.getLength());
View Full Code Here

        shpfile = getClass().getResource("cities.shp");
        source = getFeatureSource(shpfile);
        style = getStyle("cities.sld");
        mapContext.addLayer(new DefaultMapLayer(source, style));

        MapLayer layer = createCrsLayer(geographicBoundingBox, crs);
        mapContext.addLayer(layer);

        return mapContext;
    }
View Full Code Here

      throw (IOException) new IOException().initCause(e);
    }

    // write the images
    for (int i = 0; i < mapContext.getLayerCount(); i++) {
      MapLayer mapLayer = mapContext.getLayer(i);

      // create a context for this single layer
      WMSMapContext mapContext = new WMSMapContext();
      mapContext.addLayer(mapLayer);
      mapContext.setRequest(this.mapContext.getRequest());
View Full Code Here

     * @return
     */
    protected String getContentDisposition(String extension) {
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < mapContext.getLayerCount(); i++) {
            MapLayer layer = mapContext.getLayer(i);
            String title = layer.getTitle();
            if (title != null && !title.equals("")) {
                sb.append(title).append("_");
            }
        }
        if (sb.length() > 0) {
View Full Code Here

TOP

Related Classes of org.geotools.map.MapLayer

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.