Examples of ReferencedEnvelope


Examples of org.geotools.geometry.jts.ReferencedEnvelope

        // ReferencedEnvelope[-0.24291497975705742 : 0.24291497975711265, -0.5056179775280899 :
        // -0.0]
        // ReferencedEnvelope[-0.24291497975705742 : 0.24291497975711265, -0.5056179775280899 :
        // -0.0]
        CoordinateReferenceSystem EPSG4326 = CRS.decode("EPSG:4326"); //$NON-NLS-1$
        ReferencedEnvelope pixelBounds = new ReferencedEnvelope(-0.24291497975705742,
                0.24291497975711265, -0.5056179775280899, 0.0, EPSG4326);
        CoordinateReferenceSystem WGS84 = DefaultGeographicCRS.WGS84;

        ReferencedEnvelope latLong = pixelBounds.transform(WGS84, false);
        if (latLong == null) {
            String msg = "Unable to transform EPSG:4326 to DefaultGeographicCRS.WGS84"; //$NON-NLS-1$
            System.out.println(msg);
            // throw new FactoryException(msg);
        }
View Full Code Here

Examples of org.geotools.geometry.jts.ReferencedEnvelope

    public String getFileFormat() {
        return "png"; //$NON-NLS-1$
    }
   
    public ReferencedEnvelope getBounds() {
        return new ReferencedEnvelope(-180, 180, -85.051, 85.0511, DefaultGeographicCRS.WGS84);       
    }
View Full Code Here

Examples of org.geotools.geometry.jts.ReferencedEnvelope

        // only continue, if we have tiles that cover the requested extent
        if (!renderJob.getMapExtentTileCrs().intersects((Envelope) getBounds())) {
            return Collections.emptyMap();
        }
       
        ReferencedEnvelope extent = normalizeExtent(renderJob.getMapExtentTileCrs());
       
        WMTTileFactory tileFactory = getTileFactory();
               
        WMTZoomLevel zoomLevel = tileFactory.getZoomLevel(getZoomLevelToUse(renderJob.getZoomLevelMatcher(),
                scaleFactor, recommendedZoomLevel, layerProperties), this);
        long maxNumberOfTiles = zoomLevel.getMaxTileNumber();
               
        Map<String, Tile> tileList = new HashMap<String, Tile>();
       
        WMTPlugin.debug("[WMTSource.cutExtentIntoTiles] Zoom-Level: " + zoomLevel.getZoomLevel() //$NON-NLS-1$
                " Extent: " + extent, Trace.REQUEST); //$NON-NLS-1$
       
        // Let's get the first tile which covers the upper-left corner
        WMTTile firstTile = tileFactory.getTileFromCoordinate(
                extent.getMaxY(), extent.getMinX(), zoomLevel, this);
        tileList.put(firstTile.getId(), addTileToList(firstTile));
       
        WMTTile firstTileOfRow = null;
        WMTTile movingTile = firstTileOfRow = firstTile;
        // Loop column
        do {
            // Loop row
            do {
                // get the next tile right of this one
                WMTTile rightNeighbour = movingTile.getRightNeighbour();
               
                // Check if the new tile is still part of the extent and
                // that we don't have the first tile again
                if (extent.intersects((Envelope) rightNeighbour.getExtent())
                        && !firstTileOfRow.equals(rightNeighbour)) {
                    tileList.put(rightNeighbour.getId(), addTileToList(rightNeighbour));
                   
                    WMTPlugin.debug("[WMTSource.cutExtentIntoTiles] Adding right neighbour: " //$NON-NLS-1$
                            rightNeighbour.getId(), Trace.REQUEST);
                   
                    movingTile = rightNeighbour;
                } else {
                    break;
                }
                if (tileList.size()>tileLimitWarning) {
                    return Collections.emptyMap();
                }
            } while(tileList.size() < maxNumberOfTiles);

            // get the next tile under the first one of the row
            WMTTile lowerNeighbour = firstTileOfRow.getLowerNeighbour();
           
            // Check if the new tile is still part of the extent
            if (extent.intersects((Envelope) lowerNeighbour.getExtent())
                    && !firstTile.equals(lowerNeighbour)) {
                tileList.put(lowerNeighbour.getId(), addTileToList(lowerNeighbour));
               
                WMTPlugin.debug("[WMTSource.cutExtentIntoTiles] Adding lower neighbour: " //$NON-NLS-1$
                        lowerNeighbour.getId(), Trace.REQUEST);
View Full Code Here

Examples of org.geotools.geometry.jts.ReferencedEnvelope

     *
     * @param envelope
     * @return
     */
    private ReferencedEnvelope normalizeExtent(ReferencedEnvelope envelope) {
        ReferencedEnvelope bounds = getBounds();
       
        if (    envelope.getMaxY() > bounds.getMaxY() ||
                envelope.getMinY() < bounds.getMinY() ||
                envelope.getMaxX() > bounds.getMaxX() ||
                envelope.getMinX() < bounds.getMinX()   ) {
           
           
            double maxY = (envelope.getMaxY() > bounds.getMaxY()) ? bounds.getMaxY() : envelope.getMaxY();
            double minY = (envelope.getMinY() < bounds.getMinY()) ? bounds.getMinY() : envelope.getMinY();
            double maxX = (envelope.getMaxX() > bounds.getMaxX()) ? bounds.getMaxX() : envelope.getMaxX();
            double minX = (envelope.getMinX() < bounds.getMinX()) ? bounds.getMinX() : envelope.getMinX();
           
            ReferencedEnvelope newEnvelope = new ReferencedEnvelope(minX, maxX, minY, maxY,
                    envelope.getCoordinateReferenceSystem());
           
            return newEnvelope;
        }
       
View Full Code Here

Examples of org.geotools.geometry.jts.ReferencedEnvelope

public class ReferencedEnvelopeCache {
    private static Cache<Object, Object> crsCache = CacheBuilder.newBuilder().build();

    public static ReferencedEnvelope getReferencedEnvelope(final CoordinateReferenceSystem crs) {
        if (crs == null) {
            return new ReferencedEnvelope();
        }
        try {
            ReferencedEnvelope envelope = (ReferencedEnvelope) crsCache.get( crs.getName(), new Callable<Object>(){
                public Object call() {
                    return getCRSBounds(crs);
                }
            });
            return envelope;
        } catch (Throwable e) {
            return new ReferencedEnvelope();
        }
    }
View Full Code Here

Examples of org.geotools.geometry.jts.ReferencedEnvelope

        }
    }

    private static ReferencedEnvelope getCRSBounds(CoordinateReferenceSystem crs) {
        if (crs == null)
            return new ReferencedEnvelope();
        try {
            Extent extent = crs.getDomainOfValidity();
            Collection<? extends GeographicExtent> elem = extent.getGeographicElements();
            double xmin = Double.MAX_VALUE, ymin = Double.MAX_VALUE;
            double xmax = Double.MIN_VALUE, ymax = Double.MIN_VALUE;
            for (GeographicExtent ext : elem) {
                if (ext instanceof BoundingPolygon) {
                    BoundingPolygon bp = (BoundingPolygon) ext;
                    Collection<? extends org.opengis.geometry.Geometry> geoms = bp.getPolygons();
                    for (org.opengis.geometry.Geometry geom : geoms) {
                        Envelope env = geom.getEnvelope();
                        if (env.getMinimum(0) < xmin)
                            xmin = env.getMinimum(0);
                        if (env.getMaximum(0) > xmax)
                            xmax = env.getMaximum(0);
                        if (env.getMinimum(1) < ymin)
                            ymin = env.getMinimum(1);
                        if (env.getMaximum(1) > ymax)
                            ymax = env.getMaximum(1);
                    }
                } else if (ext instanceof GeographicBoundingBox) {
                    GeographicBoundingBox gbb = (GeographicBoundingBox) ext;
                    ReferencedEnvelope env = new ReferencedEnvelope(DefaultGeographicCRS.WGS84);
                    env.expandToInclude(gbb.getWestBoundLongitude(), gbb.getNorthBoundLatitude());
                    env.expandToInclude(gbb.getEastBoundLongitude(), gbb.getSouthBoundLatitude());
                    env = env.transform(crs, true);
                    if (env.getMinX() < xmin)
                        xmin = env.getMinX();
                    if (env.getMaxX() > xmax)
                        xmax = env.getMaxX();
                    if (env.getMinY() < ymin)
                        ymin = env.getMinY();
                    if (env.getMaxY() > ymax)
                        ymax = env.getMaxY();
                }
            }
            if (xmin == Double.MAX_VALUE || ymin == Double.MAX_VALUE || xmax == Double.MIN_VALUE
                    || ymax == Double.MAX_VALUE) {
                return new ReferencedEnvelope(crs);
            }
            return new ReferencedEnvelope(xmin, xmax, ymin, ymax, crs);
        } catch (Throwable ex) {
            return new ReferencedEnvelope(crs);
        }
    }
View Full Code Here

Examples of org.geotools.geometry.jts.ReferencedEnvelope

                        double xMin = Double.parseDouble(xMinText);
                        double yMin = Double.parseDouble(yMinText);
                        double xMax = Double.parseDouble(xMaxText);
                        double yMax = Double.parseDouble(yMaxText);
                       
                        boundsOfFirstTile = new ReferencedEnvelope(
                                xMin,
                                xMax,
                                yMin,
                                yMax,
                                DefaultGeographicCRS.WGS84
View Full Code Here

Examples of org.geotools.geometry.jts.ReferencedEnvelope

                    // We are building a envelope at (0/0) with the size of the first tile
                    // to calculate the scale
                    double halfWidth = boundsOfFirstTile.getWidth() / 2.0;
                    double halfHeight = boundsOfFirstTile.getHeight() / 2.0;
                   
                    ReferencedEnvelope boundsAtEquator = new ReferencedEnvelope(-halfWidth, halfWidth,
                            -halfHeight, halfHeight, DefaultGeographicCRS.WGS84);
                                       
                    int dpi = 96;
                    try{
                        dpi = Display.getDefault().getDPI().x;
View Full Code Here

Examples of org.geotools.geometry.jts.ReferencedEnvelope

     * @see org.locationtech.udig.project.ui.tool.AbstractTool#mouseReleased(MapMouseEvent)
     */
    public void mouseReleased( MapMouseEvent e ) {
        try {

            ReferencedEnvelope bbox = context.getBoundingBox(e.getPoint(), 5);

            // set up request
            final MosaicInfoView.InfoRequest request = new MosaicInfoView.InfoRequest();
            request.bbox = bbox;
            request.layers = context.getMapLayers();
View Full Code Here

Examples of org.geotools.geometry.jts.ReferencedEnvelope

    
     * @param tileName
     * @return BoundingBox for a tile
     */
    public static ReferencedEnvelope getExtentFromTileName(WWTileName tileName) {
        ReferencedEnvelope extent = new ReferencedEnvelope(
                tile2lon(tileName.getX(), tileName),
                tile2lon(tileName.getX() + 1, tileName),
                tile2lat(tileName.getY(), tileName),
                tile2lat(tileName.getY() + 1, tileName),
                DefaultGeographicCRS.WGS84);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.