private Geometry transform( Envelope envelope, Transformation trans ) throws TransformationException { return transform( envelope, trans, 20 ); }
private Envelope getWgs84Envelope( Envelope env ) { try { env = transformer.transform( env ); } catch ( Exception e ) { LOG.error( "Cannot transform TileLayer envelope to WGS84." ); } return env; }
private Envelope transformEnvelopeIntoQuerySrs( ICRS querySrs, Envelope env ) throws TransformationException, UnknownCRSException { GeometryTransformer transformer = new GeometryTransformer( querySrs ); return transformer.transform( env ); }
/** * @param bbox * @return the bbox in the native srs */ private Envelope getTransformedEnvelope( Envelope bbox ) { if ( bbox != null && bbox.getCoordinateSystem() != null && transformer != null ) { try { bbox = transformer.transform( bbox ); } catch ( Exception e ) { LOG.error( "Transformation of bbox failed: " + e.getMessage(), e ); } } return bbox; }
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 ); }
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 ); }
private Polygon transform( Polygon polygon, Transformation trans ) throws TransformationException { Ring exterior = polygon.getExteriorRing(); LinearRing tExteriorRing = transform( exterior, trans ); List<Ring> interiorRings = polygon.getInteriorRings(); List<Ring> tInteriorRings = new ArrayList<Ring>( interiorRings == null ? 0 : interiorRings.size() ); if ( interiorRings != null && !interiorRings.isEmpty() ) { for ( Ring interior : interiorRings ) { if ( interior != null ) { tInteriorRings.add( transform( interior, trans ) ); } } } return geomFactory.createPolygon( polygon.getId(), getTargetCRS(), tExteriorRing, tInteriorRings ); }
private Envelope getTransformedEnvelope( Envelope env ) throws TransformationException, UnknownCRSException { ICRS inputCRS = env.getCoordinateSystem(); if ( inputCRS != null && outputCRS != null && !inputCRS.equals( outputCRS ) ) { if ( transformer == null ) { throw new UnknownCRSException( outputCRS.getAlias() ); } return geoTransformer.transform( env ); } return env; }
private CompositeSolid transform( CompositeSolid cSolid, Transformation trans ) throws TransformationException { List<Solid> tSolids = new ArrayList<Solid>( cSolid.size() ); for ( Solid s : cSolid ) { tSolids.add( transform( s, trans ) ); } return geomFactory.createCompositeSolid( cSolid.getId(), getTargetCRS(), tSolids ); }
private CompositeCurve transform( CompositeCurve cCurve, Transformation trans ) throws TransformationException { List<Curve> tCurves = new ArrayList<Curve>( cCurve.size() ); for ( Curve c : cCurve ) { tCurves.add( transform( c, trans ) ); } return geomFactory.createCompositeCurve( cCurve.getId(), getTargetCRS(), tCurves ); }
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 MultiLineString transform( MultiLineString geo, Transformation trans ) throws TransformationException { List<LineString> lines = new ArrayList<LineString>( geo.size() ); for ( LineString line : geo ) { lines.add( transform( line, trans ) ); } return geomFactory.createMultiLineString( geo.getId(), getTargetCRS(), lines ); }
private CompositeSurface transform( CompositeSurface compositeSurface, Transformation trans ) throws TransformationException { List<Surface> tSurfaces = new ArrayList<Surface>( compositeSurface.size() ); for ( Surface s : compositeSurface ) { Surface ts = transform( s, trans ); tSurfaces.add( ts ); } return geomFactory.createCompositeSurface( compositeSurface.getId(), getTargetCRS(), tSurfaces ); }
private MultiPolygon transform( MultiPolygon multiPolygon, Transformation trans ) throws TransformationException { ArrayList<Polygon> polys = new ArrayList<Polygon>( multiPolygon.size() ); for ( Polygon g : multiPolygon ) { polys.add( transform( g, trans ) ); } return geomFactory.createMultiPolygon( multiPolygon.getId(), getTargetCRS(), polys ); }
/** * transforms the submitted multi curve to the target coordinate reference system * * @throws TransformationException */ private MultiCurve<Curve> transform( MultiCurve<Curve> geo, Transformation trans ) throws TransformationException { List<Curve> curves = new ArrayList<Curve>( geo.size() ); for ( Curve curve : geo ) { curves.add( transform( curve, trans ) ); } return geomFactory.createMultiCurve( geo.getId(), getTargetCRS(), curves ); }
/** * transforms the submitted multi surface to the target coordinate reference system * * @throws TransformationException */ private MultiSurface<Surface> transform( MultiSurface<Surface> multiSurface, Transformation trans ) throws TransformationException { List<Surface> surfaces = new ArrayList<Surface>( multiSurface.size() ); for ( Surface surface : multiSurface ) { surfaces.add( transform( surface, trans ) ); } return geomFactory.createMultiSurface( multiSurface.getId(), getTargetCRS(), surfaces ); }
/** * transforms the submitted multi point to the target coordinate reference system * * @throws TransformationException */ private MultiPoint transform( MultiPoint geo, Transformation trans ) throws TransformationException { List<Point> points = new ArrayList<Point>( geo.size() ); for ( Point p : geo ) { points.add( transform( p, trans ) ); } return geomFactory.createMultiPoint( geo.getId(), getTargetCRS(), points ); }
private LineString transform( LineString geo, Transformation trans ) throws TransformationException { LineStringSegment segment = (LineStringSegment) geo.getCurveSegments().get( 0 ); // only one for a line string? Points pos = segment.getControlPoints(); pos = transform( pos, trans ); return geomFactory.createLineString( geo.getId(), getTargetCRS(), pos ); }
private LinearRing transform( Ring ring, Transformation trans ) throws TransformationException { if ( ring != null ) { // TODO DefaultRing.getAsLineString currently returns an UnsupportedOpertionException // interior.getAsLineString().getControlPoints(), Points cP = ring.getControlPoints(); Points tcP = transform( cP, trans ); return geomFactory.createLinearRing( ring.getId(), getTargetCRS(), tcP ); } return null; }
private Geometry transformGeometry( Geometry value, GeometryTransformer transformer ) throws IllegalArgumentException, TransformationException { Geometry transformed = value; if ( transformed.getCoordinateSystem() == null ) { transformed.setCoordinateSystem( transformer.getTargetCRS() ); } else { transformed = linearizer.linearize( value, crit ); if ( !( transformed instanceof Point && transformed.getCoordinateDimension() == 1 ) ) { transformed = transformer.transform( transformed, transformed.getCoordinateSystem() ); } } return transformed; }