private ProjNet.CoordinateSystems.ICoordinateSystem getMercatorProjection() { CoordinateSystemFactory factory = new CoordinateSystemFactory(); ProjNet.CoordinateSystems.IGeographicCoordinateSystem wgs84 = factory.CreateGeographicCoordinateSystem("WGS 84", AngularUnit.Degrees, HorizontalDatum.WGS84, PrimeMeridian.Greenwich, new ProjNet.CoordinateSystems.AxisInfo("north", ProjNet.CoordinateSystems.AxisOrientationEnum.North), new AxisInfo("east", AxisOrientationEnum.East)); List <ProjectionParameter> parameters = new List <ProjectionParameter> { new ProjectionParameter("semi_major", 6378137), new ProjectionParameter("semi_minor", 6378137), new ProjectionParameter("latitude_of_origin", 0.0), new ProjectionParameter("central_meridian", 0.0), new ProjectionParameter("scale_factor", 1.0), new ProjectionParameter("false_easting", 0.0), new ProjectionParameter("false_northing", 0.0) }; IProjection projection = factory.CreateProjection("Mercator", "mercator_1sp", parameters); IProjectedCoordinateSystem mercator = factory.CreateProjectedCoordinateSystem("Mercator", wgs84, projection, LinearUnit.Metre, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum.North)); return(mercator); }
public void Filter(GeoAPI.Geometries.Coordinate coord) { ProjNet.CoordinateSystems.ICoordinateSystem mercator = getMercatorProjection(); ProjNet.CoordinateSystems.IGeographicCoordinateSystem latlon = (ProjNet.CoordinateSystems.IGeographicCoordinateSystem)CoordinateSystemWktReader.Parse(SRID_4236); ProjNet.CoordinateSystems.Transformations.ICoordinateTransformationFactory ctfac = new CoordinateTransformationFactory(); ProjNet.CoordinateSystems.Transformations.ICoordinateTransformation transformation = ctfac.CreateFromCoordinateSystems(latlon, mercator); double[] newCoords = transformation.MathTransform.Transform(new double[] { coord.X, coord.Y }); coord.X = newCoords[0]; coord.Y = newCoords[1]; }