private Envelope transformEnvelopeIntoQuerySrs( ICRS querySrs, Envelope env ) throws TransformationException, UnknownCRSException { GeometryTransformer transformer = new GeometryTransformer( querySrs ); return transformer.transform( env ); }
private MultiSolid transform( MultiSolid geom, Transformation trans ) throws TransformationException { List<Solid> transformedSolids = new LinkedList<Solid>(); for ( Solid s : geom ) { Solid ts = transform( s, trans ); transformedSolids.add( ts ); } return geomFactory.createMultiSolid( geom.getId(), getTargetCRS(), transformedSolids ); }
sourceEnv = createValidDomain( source ); return transform( geom, createCRSTransformation( source, toBeUsedTransformations ), sourceEnv );
private Geometry transform( Envelope envelope, Transformation trans ) throws TransformationException { return transform( envelope, trans, 20 ); }
GeometryHelper( Envelope bbox, int width, AffineTransform worldToScreen ) { this.worldToScreen = worldToScreen; try { if ( bbox.getCoordinateSystem() != null && ( !bbox.getCoordinateSystem().getAlias().equals( "CRS:1" ) ) ) { transformer = new GeometryTransformer( bbox.getCoordinateSystem() ); } } catch ( Throwable e ) { LOG.debug( "Stack trace:", e ); LOG.warn( "Setting up the renderer yielded an exception when setting up internal transformer. This may lead to problems." ); } }
if ( !insideValidDomain( domainOfValidity, geo ) ) { throw new OutsideCRSDomainException( "Geometry (gml:id=" + ( isSet( geo.getId() ) ? geo.getId() : "not set" ) case COMPOSITE_GEOMETRY: { @SuppressWarnings("unchecked") T transformedGeometry = (T) transform( (CompositeGeometry<?>) geo, trans ); return transformedGeometry; T transformedGeometry = (T) transform( (Envelope) geo, trans ); return transformedGeometry; T transformedGeometry = (T) transform( (MultiGeometry<?>) geo, trans, domainOfValidity ); return transformedGeometry; T transformedGeometry = (T) transform( (GeometricPrimitive) geo, trans ); return transformedGeometry; throw new TransformationException( Messages.getMessage( "CRS_TRANSFORMATION_ERROR", geo.getCoordinateSystem().getAlias(), getTargetCRS().getCodes(), ge.getMessage() ), ge );
/** * transforms the list of points * * @throws TransformationException */ private Points transform( Points points, Transformation trans ) throws TransformationException { List<Point> result = new ArrayList<Point>( points.size() ); for ( Point point : points ) { Point3d coord = new Point3d( point.get0(), point.get1(), point.get2() ); Point3d tmp = new Point3d( coord ); tmp = trans.doTransform( coord ); if ( Double.isNaN( point.get2() ) ) { result.add( geomFactory.createPoint( point.getId(), new double[] { tmp.x, tmp.y }, getTargetCRS() ) ); } else { // pass the 3rd coordinate if exist and dimension of source and target CRS is 2 if ( trans.getSourceCRS().getDimension() == 2 && trans.getTargetCRS().getDimension() == 2 ) { tmp.z = point.get2(); } result.add( geomFactory.createPoint( point.getId(), new double[] { tmp.x, tmp.y, tmp.z }, getTargetCRS() ) ); } } return new PointsList( result ); }
/** * transforms the coordinates of a deegree geometry to the target coordinate reference system. * * @param geo * to be transformed * @param sourceCRS * the source CRS for the geometry. overwrites the CRS of the geometry. * @return the same geometry in a different crs. * @throws TransformationException * if the transformation between the source and target crs cannot be created. * @throws IllegalArgumentException * if the coordinates system of the geometry is <code>null</code> */ public <T extends Geometry> T transform( T geo, ICRS sourceCRS ) throws TransformationException, IllegalArgumentException { return transform( geo, sourceCRS, false, null ); }
transformer = new GeometryTransformer( this.crs ); } catch ( IllegalArgumentException e ) { LOG.error( "The invalid crs '{}' was specified for the simple SQL data store.", crs );
/** * transforms the submitted point to the target coordinate reference system * * @throws TransformationException */ private Point transform( Point geo, Transformation trans ) throws TransformationException { Point3d coord = new Point3d( geo.get0(), geo.get1(), geo.get2() ); Point3d result = new Point3d( coord ); result = trans.doTransform( coord ); if ( Double.isNaN( geo.get2() ) ) { return geomFactory.createPoint( geo.getId(), new double[] { result.x, result.y }, getTargetCRS() ); } else if ( trans.getSourceCRS().getDimension() == 2 && trans.getTargetCRS().getDimension() == 2 ) { // pass the 3rd coordinate if exist and dimension of source and target CRS is 2 result.z = geo.get2(); } return geomFactory.createPoint( geo.getId(), new double[] { result.x, result.y, result.z }, getTargetCRS() ); }
private Envelope transform( Envelope bbox, ICRS targetCrs ) throws IllegalArgumentException, TransformationException, UnknownCRSException { if ( targetCrs.equals( bbox.getEnvelope().getCoordinateSystem() ) ) { return bbox; } GeometryTransformer transformer = new GeometryTransformer( targetCrs ); return transformer.transform( bbox ); } }
private CompositeGeometry<?> transform( CompositeGeometry<?> geom, Transformation trans ) throws TransformationException { List<GeometricPrimitive> transformed = new LinkedList<GeometricPrimitive>(); for ( GeometricPrimitive gp : geom ) { GeometricPrimitive tGp = transform( gp, trans ); transformed.add( tGp ); } return geomFactory.createCompositeGeometry( geom.getId(), getTargetCRS(), transformed ); }
/** * transforms the coordinates of a deegree geometry to the target coordinate reference system. * * @param <T> * * @param geo * to be transformed * @return the same geometry in a different crs. * @throws TransformationException * if the transformation between the source and target crs cannot be created. * @throws IllegalArgumentException * if the coordinates system of the geometry is <code>null</code> * @throws UnknownCRSException */ public <T extends Geometry> T transform( T geo ) throws TransformationException, IllegalArgumentException, UnknownCRSException { return transform( geo, null, false, null ); }
transformer = new GeometryTransformer( crs ); try { eastingAxis = crs.getEasting();
return geomFactory.createEnvelope( min, max, CRSManager.getCRSRef( this.getTargetCRS() ) );
private static Envelope getTransformedEnvelopeWithAuthoritativeAxisOrdering( final Envelope nativeBbox, final ICRS targetCrs, final ICRS latlon ) { ICRS targetCrsWithOfficialAxisOrder = targetCrs; try { targetCrsWithOfficialAxisOrder = getAxisAwareCrs( targetCrs ); } catch ( UnknownCRSException e ) { LOG.warn( "Cannot determine axis-aware CRS: {}", e.getLocalizedMessage() ); LOG.trace( "Stack trace:", e ); } try { GeometryTransformer transformer = new GeometryTransformer( targetCrsWithOfficialAxisOrder ); if ( nativeBbox.getCoordinateSystem() == null ) { return transformer.transform( nativeBbox, latlon ); } else { return transformer.transform( nativeBbox ); } } catch ( Throwable e ) { LOG.warn( "Cannot transform: {}", e.getLocalizedMessage() ); LOG.trace( "Stack trace:", e ); } return null; }
switch ( geometryType ) { case MULTI_CURVE: result = transform( (MultiCurve<Curve>) geom, trans ); break; case MULTI_GEOMETRY: List<Geometry> mg = new LinkedList<Geometry>(); for ( Geometry geo : geom ) { Geometry tG = transform( geo, trans, domainOfValidity ); mg.add( tG ); result = geomFactory.createMultiGeometry( geom.getId(), getTargetCRS(), mg ); break; case MULTI_LINE_STRING: result = transform( (MultiLineString) geom, trans ); break; case MULTI_POINT: result = transform( (MultiPoint) geom, trans ); break; case MULTI_POLYGON: result = transform( (MultiPolygon) geom, trans ); break; case MULTI_SOLID: result = transform( (MultiSolid) geom, trans ); break; case MULTI_SURFACE: result = transform( (MultiSurface<Surface>) geom, trans ); break;
/** * transforms the coordinates of a deegree geometry to the target coordinate reference system. Optionally tests * whether the given Geometry lies within the source crs' valid domain. * * @param geo * to be transformed * @param testValidDomain * true if the incoming geometry should be checked against the domain of validity of the CoordinateSystem * it is defined in. * @return the same geometry in a different crs. * @throws TransformationException * if the transformation between the source and target crs cannot be created. * @throws IllegalArgumentException * if the coordinates system of the geometry is <code>null</code> * @throws UnknownCRSException */ public Geometry transform( Geometry geo, boolean testValidDomain ) throws TransformationException, IllegalArgumentException, UnknownCRSException { return transform( geo, null, testValidDomain, null ); }
private FeatureCollection transformGeometries( FeatureCollection fc ) throws IllegalArgumentException, UnknownCRSException, TransformationException { FeatureCollection transformedFc = new GenericFeatureCollection(); GeometryTransformer transformer = new GeometryTransformer( fs.getStorageCRS() ); for ( Feature feature : fc ) { transformedFc.add( transformGeometries( feature, transformer ) ); } return transformedFc; }
private Geometry getCompatibleGeometry( Geometry literal ) throws SQLException { if ( crs == null ) { return literal; } Geometry transformedLiteral = literal; if ( literal != null ) { ICRS literalCRS = literal.getCoordinateSystem(); if ( literalCRS != null && !( crs.equals( literalCRS ) ) ) { LOG.debug( "Need transformed literal geometry for evaluation: " + literalCRS.getAlias() + " -> " + crs.getAlias() ); try { GeometryTransformer transformer = new GeometryTransformer( crs ); transformedLiteral = transformer.transform( literal ); } catch ( Throwable e ) { throw new SQLException( e.getMessage() ); } } } return transformedLiteral; }