Package org.geotools.geometry.jts

Examples of org.geotools.geometry.jts.ReferencedEnvelope.transform()


            // make sure we use the declared CRS, not the native one, the may differ
            if ( !CRS.equalsIgnoreMetadata( DefaultGeographicCRS.WGS84, declaredCRS) ) {
                //transform
                try {
                    ReferencedEnvelope bounds = new ReferencedEnvelope(nativeBounds, declaredCRS);
                    return bounds.transform( DefaultGeographicCRS.WGS84, true );
                } catch( Exception e ) {
                    throw (IOException) new IOException("transform error").initCause( e );
                }
            } else {
                return new ReferencedEnvelope(nativeBounds, DefaultGeographicCRS.WGS84);
View Full Code Here


        }
       
        // apply the bounds, taking into account the reprojection policy if need be
        if (rinfo.getProjectionPolicy() == ProjectionPolicy.REPROJECT_TO_DECLARED && bounds != null) {
            try {
                bounds = bounds.transform(rinfo.getCRS(), true);
                GridGeometry grid = ((CoverageInfo) rinfo).getGrid();
                ((CoverageInfo) rinfo).setGrid(new GridGeometry2D(grid.getGridRange(),grid.getGridToCRS(), rinfo.getCRS()));
            } catch(Exception e) {
                throw (IOException) new IOException("transform error").initCause(e);
            }
View Full Code Here

            // native available but geographic to be computed
            setupBounds(featureType);
        } else if(featureType.getNativeBoundingBox() == null && crs != null) {
            // we know the geographic and we can reproject back to native
            ReferencedEnvelope boundsLatLon = featureType.getLatLonBoundingBox();
            featureType.setNativeBoundingBox(boundsLatLon.transform(crs, true));
        }
    }
   
    /**
     * Builds the default coverage contained in the current store
View Full Code Here

          }
      }
     
      if ( !CRS.equalsIgnoreMetadata(declaredCRS, nativeCRS) &&
          php == ProjectionPolicy.REPROJECT_TO_DECLARED ) {
          return nativeBox.transform(declaredCRS,true);
      } else if(php == ProjectionPolicy.FORCE_DECLARED) {
          return new ReferencedEnvelope(nativeBox, declaredCRS);
      }
     
      return nativeBox;
View Full Code Here

    }

    private double calculateExpandFactor(Envelope bboxOfImage, String srs) throws Exception {
      CoordinateReferenceSystem crs = Region.decodeCRS(srs);
      ReferencedEnvelope env = new ReferencedEnvelope(bboxOfImage, crs);
      env = env.transform(Region.WGS84, true);
     
      double diag = sqrt( pow(env.getWidth(), 2) + pow(env.getHeight(), 2));
     
      double scale = diag/WGS_DIAG;
     
View Full Code Here

                env = layer.getLayer().getResource().getLatLonBoundingBox();
            }

            if (env != null) {
                try {
                    env = env.transform(webMercator, true);
                    boundsAsQueryParam = String.format(Locale.ENGLISH, "&bbox=%f,%f,%f,%f",
                        env.getMinX(), env.getMinY(), env.getMaxX(), env.getMaxY());
                } catch (Exception e) {
                    LOGGER.log(Level.WARNING, "Unable to reproject layer " + layer.getName()
                        + "to spherical mercator");
View Full Code Here

                    envelopes = projectionHandler.getQueryEnvelopes();
                }
            }
            if(envelopes == null) {
                if (mapCRS != null && featCrs != null && !CRS.equalsIgnoreMetadata(featCrs, mapCRS)) {
                    envelopes = Collections.singletonList(envelope.transform(featCrs, true, 10));
                } else {
                    envelopes = Collections.singletonList(envelope);
                }
            }
View Full Code Here

                    if(readGG != null) {
                        // Crop will fail if we try to crop outside of the coverage area
                        ReferencedEnvelope renderingEnvelope = new ReferencedEnvelope(readGG.getEnvelope());
                        CoordinateReferenceSystem coverageCRS = coverage.getCoordinateReferenceSystem2D();
                        if(!CRS.equalsIgnoreMetadata(renderingEnvelope.getCoordinateReferenceSystem(), coverageCRS)) {
                            renderingEnvelope = renderingEnvelope.transform(coverageCRS, true);
                        }
                        if(coverage.getEnvelope2D().intersects(renderingEnvelope)) {
                            // the resulting coverage might be larger than the readGG envelope, shall we crop it?
                            final ParameterValueGroup param = CROP.getParameters();
                            param.parameter("Source").setValue(coverage);
View Full Code Here

            } else {
                try {
                    CoordinateReferenceSystem dataCrs = dataBounds.getCoordinateReferenceSystem();
                    if ((dataCrs != null) && mapCRS != null
                            && !CRS.equalsIgnoreMetadata(dataCrs, mapCRS)) {
                        dataBounds = dataBounds.transform(mapCRS, true);
                    }
                    if (dataCrs == null && mapCRS != null) {
                        LOGGER.log(Level.SEVERE,
                                "It was not possible to get a projected bounds estimate");
                    }
View Full Code Here

        if (!CRS.equalsIgnoreMetadata(nativeCRS, reqEnv.getCoordinateReferenceSystem())) {
            // we're being reprojected. We'll need to reproject reqEnv into
            // our native coordsys
            try {
                // ReferencedEnvelope origReqEnv = reqEnv;
                reqEnv = reqEnv.transform(nativeCRS, true);
            } catch (FactoryException fe) {
                // unable to reproject?
                throw new IllegalArgumentException("Unable to find a reprojection from requested "
                        + "coordsys to native coordsys for this request", fe);
            } catch (TransformException te) {
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.