Package org.geotools.map

Examples of org.geotools.map.DefaultMapContext


  @Autowired
  private PipelineService<RasterizingContainer> pipelineService;

  public void writeMap(OutputStream stream, ClientMapInfo clientMapInfo) throws GeomajasException {
    PipelineContext context = pipelineService.createContext();
    DefaultMapContext mapContext = new DefaultMapContext();
    mapContext.setCoordinateReferenceSystem(geoService.getCrs2(clientMapInfo.getCrs()));
    MapRasterizingInfo mapInfo = (MapRasterizingInfo) clientMapInfo.getWidgetInfo(MapRasterizingInfo.WIDGET_KEY);
    mapContext.setAreaOfInterest(new ReferencedEnvelope(dtoConverterService.toInternal(mapInfo.getBounds()),
        mapContext.getCoordinateReferenceSystem()));
    RenderingHints renderingHints = new Hints();
    renderingHints.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    RasterizingContainer response = new RasterizingContainer();
    context.put(RasterizingPipelineCode.CLIENT_MAP_INFO_KEY, clientMapInfo);
    context.put(RasterizingPipelineCode.RENDERING_HINTS, renderingHints);
    context.put(RasterizingPipelineCode.MAP_CONTEXT_KEY, mapContext);
    pipelineService.execute(RasterizingPipelineCode.PIPELINE_RASTERIZING_GET_MAP_IMAGE, null, context, response);
    mapContext.dispose();
    try {
      stream.write(response.getImage());
    } catch (IOException e) {
      throw new RasterException(RasterException.IMAGE_WRITING_FAILED, e);
    }
View Full Code Here


    }
  }

  public void writeLegend(OutputStream stream, ClientMapInfo clientMapInfo) throws GeomajasException {
    PipelineContext context = pipelineService.createContext();
    DefaultMapContext mapContext = new DefaultMapContext();
    mapContext.setCoordinateReferenceSystem(geoService.getCrs2(clientMapInfo.getCrs()));
    MapRasterizingInfo mapInfo = (MapRasterizingInfo) clientMapInfo.getWidgetInfo(MapRasterizingInfo.WIDGET_KEY);
    mapContext.setAreaOfInterest(new ReferencedEnvelope(dtoConverterService.toInternal(mapInfo.getBounds()),
        mapContext.getCoordinateReferenceSystem()));
    RenderingHints renderingHints = new Hints();
    renderingHints.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    RasterizingContainer response = new RasterizingContainer();
    context.put(RasterizingPipelineCode.CLIENT_MAP_INFO_KEY, clientMapInfo);
    context.put(RasterizingPipelineCode.RENDERING_HINTS, renderingHints);
    context.put(RasterizingPipelineCode.MAP_CONTEXT_KEY, mapContext);
    pipelineService.execute(RasterizingPipelineCode.PIPELINE_RASTERIZING_GET_LEGEND_IMAGE, null, context, response);
    mapContext.dispose();
    try {
      stream.write(response.getImage());
    } catch (IOException e) {
      throw new RasterException(RasterException.IMAGE_WRITING_FAILED, e);
    }
View Full Code Here

    mapRasterizingInfo.setBounds(new Bbox(0, 0, 100, 100));
    mapRasterizingInfo.setScale(1);
    mapRasterizingInfo.setTransparent(true);
    mapInfo.getWidgetInfo().put(MapRasterizingInfo.WIDGET_KEY, mapRasterizingInfo);

    DefaultMapContext mapContext = new DefaultMapContext();
    mapContext.setCoordinateReferenceSystem(geoService.getCrs2("EPSG:4326"));
    mapContext.getViewport().setBounds(
        new ReferencedEnvelope(0, 100, 0, 100, mapContext.getCoordinateReferenceSystem()));
    mapContext.getViewport().setCoordinateReferenceSystem(mapContext.getCoordinateReferenceSystem());
    mapContext.getViewport().setScreenArea(new Rectangle(0, 0, 100, 100));
    GeometryDirectLayer layer = (GeometryDirectLayer) layerFactory.createLayer(mapContext, geo);
    BufferedImage image = new BufferedImage(100, 100, BufferedImage.TYPE_4BYTE_ABGR);
    layer.draw(image.createGraphics(), mapContext, mapContext.getViewport());
    new DirectLayerAssert(layer, mapContext).assertEqualImage("polygon.png", writeImages, DELTA);
  }
View Full Code Here

    cl1.setServerLayerId(layerBluemarble.getId());
    RasterLayerRasterizingInfo rr1 = new RasterLayerRasterizingInfo();
    rr1.setCssStyle("opacity:0.75");
    cl1.getWidgetInfo().put(RasterLayerRasterizingInfo.WIDGET_KEY, rr1);

    DefaultMapContext mapContext = new DefaultMapContext();
    mapContext.setCoordinateReferenceSystem(layerBluemarble.getCrs());
    mapContext.getViewport().setCoordinateReferenceSystem(mapContext.getCoordinateReferenceSystem());
    mapContext.getViewport().setScreenArea(new Rectangle(1024, 512));
    mapContext.getViewport().setBounds(new ReferencedEnvelope(-180, 180, -90, 90, layerBluemarble.getCrs()));
    RasterDirectLayer layer = (RasterDirectLayer) layerFactory.createLayer(mapContext, cl1);
    new DirectLayerAssert(layer, mapContext).assertEqualImage("wms.png", writeImages, DELTA);
  }
View Full Code Here

    }

    private MapContext getMapContext(CoordinateReferenceSystem crs, Geometry geographicBoundingBox,
            com.vividsolutions.jts.geom.Envelope areaOfInterest) throws IOException {

        DefaultMapContext mapContext = new DefaultMapContext();

        Style style;
        URL shpfile;
        FeatureSource<SimpleFeatureType, SimpleFeature> source;

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

        source = getLatLonFeatureSource();
        style = getStyle("latlon.sld");
        mapContext.addLayer(new DefaultMapLayer(source, style));

        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

  public MapContext getMapContext() {
    MapContext mapContext = this.getMapPane().getMapContext();

    if (mapContext == null) {
      mapContext = new DefaultMapContext();
    }

    return mapContext;
  }
View Full Code Here

        this.getMap().dispose();

        this.mapDesc = new MapDesc();
        this.getMap().initByMapDesc(mapDesc, getMapDescFilePath());
        this.setMapContext(new DefaultMapContext());
        this.getMapPane().setBackground(mapDesc.getBackgroundColor());
        this.repaint();

        this.getMapConfDialog().setVisible(false);
        jButtonMapConf.setEnabled(true);
View Full Code Here

    private void testRender(SimpleFeatureSource featureSource) throws Exception {
        SimpleFeatureType schema = featureSource.getSchema();
        CoordinateReferenceSystem crs = schema.getCoordinateReferenceSystem();
        ReferencedEnvelope bounds = featureSource.getBounds();

        MapContext context = new DefaultMapContext(crs);
        Style style = new BasicPolygonStyle();
        context.addLayer(featureSource, style);
        context.setAreaOfInterest(bounds);
        StreamingRenderer renderer = new StreamingRenderer();
        renderer.setContext(context);

        BufferedImage image = new BufferedImage(800, 600, BufferedImage.TYPE_INT_ARGB);
        Graphics2D graphics = image.createGraphics();
View Full Code Here

        PropertyDataStore ds = new PropertyDataStore(property.getParentFile());
        squareFS = ds.getFeatureSource("square");
        bounds = new ReferencedEnvelope(0, 10, 0, 10, DefaultGeographicCRS.WGS84);
       
        renderer = new StreamingRenderer();
        context = new DefaultMapContext(DefaultGeographicCRS.WGS84);
        renderer.setContext(context);
        Map hints = new HashMap();
        hints.put("maxFiltersToSendToDatastore", 2);
        hints.put("optimizedDataLoadingEnabled", true);
        renderer.setRendererHints(hints);
View Full Code Here

   
   
    public void testLessFilters() throws Exception {
        Style style = RendererBaseTest.loadStyle(this, "fillSolidTwoRules.sld");
       
        DefaultMapContext mc = new DefaultMapContext(DefaultGeographicCRS.WGS84);
        mc.addLayer(squareFS, style);
       
        renderer.setContext(mc);
        renderer.addRenderListener(new RenderListener() {
       
            public void featureRenderer(SimpleFeature feature) {
View Full Code Here

TOP

Related Classes of org.geotools.map.DefaultMapContext

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.