Geometry Transformation factory

Topics: Algorithms, SharpMap v0.9 / v1.x
Editor
Feb 5, 2014 at 11:00 AM
Hi,

Is there a way to convert whole geometries between coordinate systems?

I have my transforms defined, but the only way I can see of doing the transform is using the MathTransform.Transform method that takes a coordinate.

Like this:

public IGeometry TransformGeometry(IGeometry geom)
   {
       if (SRID == 0 || CoordinateTransformation == null)
       {
           return geom;
       }

       if (geom.OgcGeometryType == OgcGeometryType.Polygon)
       {
           var tList = new List<Coordinate>();

           geom.Coordinates.ToList().ForEach(x => tList.Add(CoordinateTransformation.MathTransform.Transform(x)));

          return new Polygon(new LinearRing(tList.ToArray()));
       }

       return null;
   }
This is fine as I can just pad it out with the other geometry types, but I can't help but think someone must have written something like this already!

Thanks

Rob
Coordinator
Feb 5, 2014 at 11:58 AM
yes you can find it here:
https://sharpmap.codeplex.com/SourceControl/latest#Branches/1.0/SharpMap/CoordinateSystems/Transformations/GeometryTransform.cs

It should be in the GeoAPI.CoordinateSystems.Transformations namespace
Editor
Feb 5, 2014 at 1:55 PM
OK, got it thanks.

Rob