Java Code Examples for org.geotools.geometry.jts.ReferencedEnvelope#expandToInclude()

The following examples show how to use org.geotools.geometry.jts.ReferencedEnvelope#expandToInclude() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ImageGenerator.java    From hortonmachine with GNU General Public License v3.0 6 votes vote down vote up
private void expandToIncludeEnvelope( ReferencedEnvelope maxExtent, org.opengis.geometry.Envelope envelope ) {
    ReferencedEnvelope tmpExtent = new ReferencedEnvelope(envelope.getCoordinateReferenceSystem());
    DirectPosition ll = envelope.getLowerCorner();
    double[] coordinate = ll.getCoordinate();
    tmpExtent.expandToInclude(new Coordinate(coordinate[0], coordinate[1]));
    DirectPosition ur = envelope.getUpperCorner();
    coordinate = ur.getCoordinate();
    tmpExtent.expandToInclude(new Coordinate(coordinate[0], coordinate[1]));

    try {
        ReferencedEnvelope transformed = tmpExtent.transform(maxExtent.getCoordinateReferenceSystem(), true);
        maxExtent.expandToInclude(transformed);
    } catch (TransformException | FactoryException e) {
        e.printStackTrace();
    }
}
 
Example 2
Source File: DatabaseLasDataManager.java    From hortonmachine with GNU General Public License v3.0 6 votes vote down vote up
@Override
public synchronized ReferencedEnvelope getOverallEnvelope() throws Exception {
    if (referencedEnvelope2D == null) {
        checkOpen();

        List<LasSource> lasSources = LasSourcesTable.getLasSources(spatialDb);
        ReferencedEnvelope total = new ReferencedEnvelope(crs);
        for( LasSource lasSource : lasSources ) {
            Envelope envelopeInternal = lasSource.polygon.getEnvelopeInternal();
            total.expandToInclude(envelopeInternal);
        }
        referencedEnvelope2D = total;
        referencedEnvelope2DList.add(referencedEnvelope2D);
    }
    return referencedEnvelope2D;
}
 
Example 3
Source File: DatabaseLasDataManager.java    From hortonmachine with GNU General Public License v3.0 6 votes vote down vote up
@Override
public synchronized ReferencedEnvelope3D getEnvelope3D() throws Exception {
    if (referencedEnvelope3D == null) {
        checkOpen();

        List<LasSource> lasSources = LasSourcesTable.getLasSources(spatialDb);
        ReferencedEnvelope total = new ReferencedEnvelope(crs);
        double minZ = Double.POSITIVE_INFINITY;
        double maxZ = Double.NEGATIVE_INFINITY;
        for( LasSource lasSource : lasSources ) {
            Envelope envelopeInternal = lasSource.polygon.getEnvelopeInternal();
            total.expandToInclude(envelopeInternal);
            minZ = Math.min(minZ, lasSource.minElev);
            maxZ = Math.max(maxZ, lasSource.maxElev);
        }
        referencedEnvelope3D = new ReferencedEnvelope3D(total.getMinX(), total.getMaxX(), total.getMinY(), total.getMaxY(),
                minZ, maxZ, crs);
    }
    return referencedEnvelope3D;
}
 
Example 4
Source File: Mapsforge2MbtilesConverter.java    From hortonmachine with GNU General Public License v3.0 5 votes vote down vote up
private OsmTilegenerator getGenerator( ReferencedEnvelope llBounds ) {
//        MapWorkerPool.NUMBER_OF_THREADS = 4;
//        // Map buffer size
//        ReadBuffer.setMaximumBufferSize(6500000);
//        // Square frame buffer
//        FrameBufferController.setUseSquareFrameBuffer(false);

        DisplayModel model = new DisplayModel();
        model.setUserScaleFactor(pScaleFactor);
        model.setFixedTileSize(pTilesize);

        DataPolicy dataPolicy = DataPolicy.RETURN_ALL;
        MultiMapDataStore mapDatabase = new MultiMapDataStore(dataPolicy);
        for( int i = 0; i < inMapFiles.length; i++ )
            mapDatabase.addMapDataStore(new MapFile(inMapFiles[i]), false, false);

        if (llBounds != null) {
            BoundingBox bb = mapDatabase.boundingBox();
            llBounds.expandToInclude(new Envelope(bb.minLongitude, bb.maxLongitude, bb.minLatitude, bb.maxLatitude));
        }

        InMemoryTileCache tileCache = new InMemoryTileCache(200);
        DatabaseRenderer renderer = new DatabaseRenderer(mapDatabase, AwtGraphicFactory.INSTANCE, tileCache,
                new TileBasedLabelStore(tileCache.getCapacityFirstLevel()), true, true, null);
        InternalRenderTheme xmlRenderTheme = InternalRenderTheme.DEFAULT;
        RenderThemeFuture theme = new RenderThemeFuture(AwtGraphicFactory.INSTANCE, xmlRenderTheme, model);
        // super important!! without the following line, all rendering
        // activities will block until the theme is created.
        new Thread(theme).start();
        OsmTilegenerator osmTilegenerator = new OsmTilegenerator(mapDatabase, renderer, theme, model, pTilesize);
        return osmTilegenerator;
    }
 
Example 5
Source File: DatabaseController.java    From hortonmachine with GNU General Public License v3.0 5 votes vote down vote up
protected void showInMapFrame( boolean withLayers, SimpleFeatureCollection[] fcs, Style[] styles ) {
    if (mapFrame == null || !mapFrame.isVisible()) {
        Class<DatabaseController> class1 = DatabaseController.class;
        ImageIcon icon = new ImageIcon(class1.getResource("/org/hortonmachine/images/hm150.png"));
        mapFrame = new HMMapframe("Geometries Viewer");
        mapFrame.setIconImage(icon.getImage());
        mapFrame.enableToolBar(true);
        mapFrame.enableStatusBar(false);
        mapFrame.enableLayerTable(withLayers);
        mapFrame.enableTool(Tool.PAN, Tool.ZOOM, Tool.RESET);
        mapFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        if (withLayers) {
            mapFrame.setSize(900, 600);
        } else {
            mapFrame.setSize(600, 600);
        }
        mapFrame.setVisible(true);

    }
    ReferencedEnvelope renv = null;
    for( int i = 0; i < fcs.length; i++ ) {
        SimpleFeatureCollection fc = fcs[i];
        if (styles != null) {
            mapFrame.addLayer(fc, styles[i]);
        } else {
            mapFrame.addLayer(fc);
        }
        ReferencedEnvelope bounds = fc.getBounds();
        if (renv == null) {
            renv = bounds;
        } else {
            renv.expandToInclude(bounds);
        }
    }

    mapFrame.getMapPane().setDisplayArea(renv);
}