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 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 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 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 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 ); }
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 ); }
/** * 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 ); }
try { crs = ( (Geometry) g ).getCoordinateSystem(); if ( transformer.getTargetCRS().equals( crs ) ) { return g;
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 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 Solid transform( Solid solid, Transformation trans ) throws TransformationException { SolidType type = solid.getSolidType(); Solid result = null; switch ( type ) { case CompositeSolid: result = transform( (CompositeSolid) solid, trans ); break; case Solid: Surface ext = solid.getExteriorSurface(); Surface tExt = transform( ext, trans ); List<Surface> inter = solid.getInteriorSurfaces(); List<Surface> tInter = new LinkedList<Surface>(); if ( inter != null && !inter.isEmpty() ) { for ( Surface in : inter ) { if ( in != null ) { Surface tIn = transform( in, trans ); tInter.add( tIn ); } } } result = geomFactory.createSolid( solid.getId(), getTargetCRS(), tExt, tInter ); break; } return result; }
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; }
/** * 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 ); }
mg.add( tG ); result = geomFactory.createMultiGeometry( geom.getId(), getTargetCRS(), mg ); break; case MULTI_LINE_STRING:
/** * 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() ); }
curveSegments[i++] = transform( segment, trans ); result = geomFactory.createCurve( curve.getId(), getTargetCRS(), curveSegments ); if ( type == CurveType.OrientableCurve ) { result = geomFactory.createOrientableCurve( curve.getId(), result.getCoordinateSystem(), result,