Package org.geotools.map

Examples of org.geotools.map.MapContext


    // ////////////////////////////////////////////////////////////////////
    //
    // CREATING MAP CONTEXT
    //
    // ////////////////////////////////////////////////////////////////////
    final MapContext map = new DefaultMapContext(DefaultGeographicCRS.WGS84);
    map.addLayer(ft, style);
    map.setAreaOfInterest(map.getLayerBounds());

    // ////////////////////////////////////////////////////////////////////
    //
    // CREATING STREAMING RENDERER
    //
    // ////////////////////////////////////////////////////////////////////
    final StreamingRenderer renderer = new StreamingRenderer();
    renderer.setContext(map);
    renderer.setRendererHints(rendererHints);

    // ////////////////////////////////////////////////////////////////////
    //
    // SHOWING RENDERER
    //
    // ////////////////////////////////////////////////////////////////////
    ReferencedEnvelope env = map.getLayerBounds();
    env = new ReferencedEnvelope(env.getMinX() - 20, env.getMaxX() + 20,
        env.getMinY() - 20, env.getMaxY() + 20, map
            .getCoordinateReferenceSystem());
    RendererBaseTest.showRender("testSimplePointRender", renderer, 1000,
        env);

  }
View Full Code Here


    // //
    //
    // Create the map context
    //
    // //
    MapContext map = new DefaultMapContext();
    map.setCoordinateReferenceSystem(DefaultGeographicCRS.WGS84);
    map.addLayer(ft, style);
    map.setAreaOfInterest(map.getLayerBounds());

    // //
    //
    // Create the streaming renderer
    //
    // //
    StreamingRenderer renderer = new StreamingRenderer();
    renderer.setContext(map);
    renderer.setRendererHints(rendererHints);

    // //
    //
    // Transform the area of interest
    //
    // //
    final CoordinateReferenceSystem crs =  CRS
    .parseWKT("PROJCS[\"NAD83 / BC"
        + "Albers\",GEOGCS[\"NAD83\",DATUM[\"North_American_Datum_1983\",SPHEROID[\"GRS"
        + "1980\",6378137,298.257222101,AUTHORITY[\"EPSG\",\"7019\"]],"
        + "TOWGS84[0,0,0],AUTHORITY[\"EPSG\",\"6269\"]],"
        + "PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],"
        + "UNIT[\"degree\",0.01745329251994328,AUTHORITY[\"EPSG\",\"9122\"]],"
        + "AUTHORITY[\"EPSG\",\"4269\"]],"
        + "PROJECTION[\"Albers_Conic_Equal_Area\"],"
        + "PARAMETER[\"standard_parallel_1\",50],"
        + "PARAMETER[\"standard_parallel_2\",58.5],"
        + "PARAMETER[\"latitude_of_center\",45],"
        + "PARAMETER[\"longitude_of_center\",-126],"
        + "PARAMETER[\"false_easting\",1000000],"
        + "PARAMETER[\"false_northing\",0],"
        + "UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],"
        + "AUTHORITY[\"EPSG\",\"3005\"]]");
    final MathTransform t = CRS.findMathTransform(DefaultGeographicCRS.WGS84, crs,
        true);

    // //
    //
    // Set the new AOI
    //
    // //
    final ReferencedEnvelope env = (ReferencedEnvelope) map
        .getLayerBounds();
    final ReferencedEnvelope bounds = new ReferencedEnvelope(JTS.transform(
        env, null, t, 10), crs);

    RendererBaseTest.showRender("testReprojection", renderer, 1000, bounds);
View Full Code Here

    //
    // CREATE MAP CONTEXT AND RENDERER
    //
    //
    // /////////////////////////////////////////////////////////////////
    final MapContext map = new DefaultMapContext(DefaultGeographicCRS.WGS84);
    map.addLayer(ft, style);

    // ///////////////////////////////////////////////////////////////////
    //
    // CREATE A PROJECTED AOI
    //
    //
    // /////////////////////////////////////////////////////////////////
    final CoordinateReferenceSystem crs =  CRS
    .parseWKT("PROJCS[\"NAD83 / BC"
        + "Albers\",GEOGCS[\"NAD83\",DATUM[\"North_American_Datum_1983\",SPHEROID[\"GRS"
        + "1980\",6378137,298.257222101,AUTHORITY[\"EPSG\",\"7019\"]],"
        + "TOWGS84[0,0,0],AUTHORITY[\"EPSG\",\"6269\"]],"
        + "PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],"
        + "UNIT[\"degree\",0.01745329251994328,AUTHORITY[\"EPSG\",\"9122\"]],"
        + "AUTHORITY[\"EPSG\",\"4269\"]],"
        + "PROJECTION[\"Albers_Conic_Equal_Area\"],"
        + "PARAMETER[\"standard_parallel_1\",50],"
        + "PARAMETER[\"standard_parallel_2\",58.5],"
        + "PARAMETER[\"latitude_of_center\",45],"
        + "PARAMETER[\"longitude_of_center\",-126],"
        + "PARAMETER[\"false_easting\",1000000],"
        + "PARAMETER[\"false_northing\",0],"
        + "UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],"
        + "AUTHORITY[\"EPSG\",\"3005\"]]");

    // /////////////////////////////////////////////////////////////////
    //
    // CREATE MAP CONTEXT AND RENDERER
    //
    //
    // /////////////////////////////////////////////////////////////////
    final StreamingRenderer renderer = new StreamingRenderer();
    renderer.setRendererHints(rendererHints);
    renderer.setContext(map);

    ReferencedEnvelope env = map.getLayerBounds();
    env = new ReferencedEnvelope(env.getMinX() - 20, env.getMaxX() + 20,
        env.getMinY() - 20, env.getMaxY() + 20,
        DefaultGeographicCRS.WGS84);
    final ReferencedEnvelope newbounds = env.transform(crs, true);
    RendererBaseTest.showRender("testLineReprojection", renderer, 1000,
View Full Code Here

    //
    // CREATE MAP CONTEXT AND RENDERER
    //
    //
    // /////////////////////////////////////////////////////////////////
    final MapContext map = new DefaultMapContext(DefaultGeographicCRS.WGS84);
    map.addLayer(ft, style);

    // ///////////////////////////////////////////////////////////////////
    //
    // CREATE A PROJECTED AOI
    //
    //
    // /////////////////////////////////////////////////////////////////
    // //
    //
    // Transform the area of interest
    //
    // //
    final CoordinateReferenceSystem crs =  CRS
    .parseWKT("PROJCS[\"NAD83 / BC"
        + "Albers\",GEOGCS[\"NAD83\",DATUM[\"North_American_Datum_1983\",SPHEROID[\"GRS"
        + "1980\",6378137,298.257222101,AUTHORITY[\"EPSG\",\"7019\"]],"
        + "TOWGS84[0,0,0],AUTHORITY[\"EPSG\",\"6269\"]],"
        + "PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],"
        + "UNIT[\"degree\",0.01745329251994328,AUTHORITY[\"EPSG\",\"9122\"]],"
        + "AUTHORITY[\"EPSG\",\"4269\"]],"
        + "PROJECTION[\"Albers_Conic_Equal_Area\"],"
        + "PARAMETER[\"standard_parallel_1\",50],"
        + "PARAMETER[\"standard_parallel_2\",58.5],"
        + "PARAMETER[\"latitude_of_center\",45],"
        + "PARAMETER[\"longitude_of_center\",-126],"
        + "PARAMETER[\"false_easting\",1000000],"
        + "PARAMETER[\"false_northing\",0],"
        + "UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],"
        + "AUTHORITY[\"EPSG\",\"3005\"]]");

    // /////////////////////////////////////////////////////////////////
    //
    // CREATE MAP CONTEXT AND RENDERER
    //
    //
    // /////////////////////////////////////////////////////////////////
    final StreamingRenderer renderer = new StreamingRenderer();
    renderer.setRendererHints(rendererHints);
    renderer.setContext(map);

    ReferencedEnvelope env = map.getLayerBounds();
    env = new ReferencedEnvelope(env.getMinX() - 20, env.getMaxX() + 20,
        env.getMinY() - 20, env.getMaxY() + 20,
        DefaultGeographicCRS.WGS84);
    final ReferencedEnvelope newbounds = env.transform(crs, true);
    RendererBaseTest.showRender("testPointReprojection", renderer, 1000,
View Full Code Here

   
   

    private void renderEmptyGeometry(SimpleFeature f, Style style) {
        SimpleFeatureCollection fc = DataUtilities.collection(f);
        MapContext mc = new DefaultMapContext();
        mc.addLayer(fc, style);
        StreamingRenderer sr = new StreamingRenderer();
        sr.setContext(mc);
        BufferedImage bi = new BufferedImage(640, 480, BufferedImage.TYPE_4BYTE_ABGR);
        sr.addRenderListener(new RenderListener() {
       
View Full Code Here

        return sb.createStyle(sb.createLineSymbolizer());
    }

    public void testSkipProjectionErrors() throws Exception {
        // build map context
        MapContext mapContext = new DefaultMapContext(DefaultGeographicCRS.WGS84);
        mapContext.addLayer(createLineCollection(), createLineStyle());

        // build projected envelope to work with (small one around the area of
        // validity of utm zone 1, which being a Gauss projection is a vertical
        // slice parallel to the central meridian, -177°)
        ReferencedEnvelope reWgs = new ReferencedEnvelope(new Envelope(-180, -170, 20, 40),
View Full Code Here

    //
    // MAP CONTEXT
    //
    //
    // /////////////////////////////////////////////////////////////////
    final MapContext context = new DefaultMapContext(DefaultGeographicCRS.WGS84);
    final Style style = getStyle();
    context.addLayer(gc, style);

    // /////////////////////////////////////////////////////////////////
    //
    // Streaming renderer
    //
    //
    // ///////////////////////////////////////////////////////////////
    final StreamingRenderer renderer = new StreamingRenderer();
    renderer.setContext(context);
    RendererBaseTest.showRender("testGridCoverage", renderer, 1000, context.getLayerBounds());
  }
View Full Code Here

   * @throws Exception
   */
  @Test
    public void paintWrongStyle() throws Exception {
        final GridCoverage2D gc = getGC();
        final MapContext context = new DefaultMapContext(DefaultGeographicCRS.WGS84);
       
        // final Style style = new StyleBuilder().createStyle((Symbolizer) null);
        final Style style = RendererBaseTest.loadStyle(this, "empty.sld");
        context.addLayer(gc, style);

        final StreamingRenderer renderer = new StreamingRenderer();
        CountingRenderListener counter = new CountingRenderListener();
        renderer.addRenderListener(counter);
        renderer.setContext(context);
        BufferedImage image = new BufferedImage(300, 300, BufferedImage.TYPE_4BYTE_ABGR);
        Graphics2D g2d = (Graphics2D) image.getGraphics();
        renderer.paint(g2d, new Rectangle(0,0,300,300), context.getLayerBounds());
        g2d.dispose();
        // make sure no errors and no features
        assertEquals(0, counter.errors);
        assertEquals(0, counter.features);
    }
View Full Code Here

    // MAP CONTEXT
    // We want to show the context in a different CRS
    //
    //
    // /////////////////////////////////////////////////////////////////
    final MapContext context = new DefaultMapContext(DefaultGeographicCRS.WGS84);
    final Style style = getStyle();
    context.addLayer(coverage, style);

    // transform to a new crs
    final CoordinateReferenceSystem destCRS = getProjectedCRS(coverage);

    // ///////////////////////////////////////////////////////////////////
    //
    // Streaming renderer
    //
    // /////////////////////////////////////////////////////////////////
    final StreamingRenderer renderer = new StreamingRenderer();
    renderer.setContext(context);

    ReferencedEnvelope env = context.getLayerBounds();
    env = new ReferencedEnvelope(env.getMinX(), env.getMaxX(), env.getMinY(), env.getMaxY(), DefaultGeographicCRS.WGS84);
    final ReferencedEnvelope newbounds = env.transform(destCRS, true);

    RendererBaseTest.showRender("testGridCoverageReprojection", renderer, 1000, newbounds);
View Full Code Here

/* DEBUG:
        final ExampleDataGenerator exampleDataGenerator = new ExampleDataGenerator();
        final MapContext exampleMap = exampleDataGenerator.createExampleMap();
*/

        final MapContext exampleMap = createContextFromShapefile( new URL( "file:example_data/countries/countries.shp" ),
                                                                  new URL( "file:example_data/simple_style.sld" ) );

        // Create a 3D renderer
        final Renderer3D renderer3D = new Renderer3DImpl( exampleMap );
        final Component mapView3D = renderer3D.get3DView();

        // Create a 2D renderer with the same data for comparsion
        final StreamingRenderer streamingRenderer = new StreamingRenderer();
        final JMapPane mapView2D = new JMapPane( streamingRenderer, exampleMap );
        mapView2D.setMapArea( exampleMap.getLayerBounds() );
        mapView2D.setState( JMapPane.Pan );
        mapView2D.setCursor( new Cursor( Cursor.MOVE_CURSOR ) );

        // Build and show the rest of the UI
        final JLabel labelFor3DView = new JLabel( "3D map renderer" );
View Full Code Here

TOP

Related Classes of org.geotools.map.MapContext

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.