public void TestMathTransformBug() { var coordinateTransformFactory = new CoordinateTransformationFactory(); var coordinateSystemFactory = new CoordinateSystemFactory(); var itmParameters = new List <ProjectionParameter> { new ProjectionParameter("latitude_of_origin", 31.734393611111109123611111111111), new ProjectionParameter("central_meridian", 35.204516944444442572222222222222), new ProjectionParameter("false_northing", 626907.390), new ProjectionParameter("false_easting", 219529.584), new ProjectionParameter("scale_factor", 1.0000067) }; var itmDatum = coordinateSystemFactory.CreateHorizontalDatum("Isreal 1993", DatumType.HD_Geocentric, Ellipsoid.GRS80, new Wgs84ConversionInfo(-24.0024, -17.1032, -17.8444, -0.33077, -1.85269, 1.66969, 5.4248)); var itmGeo = coordinateSystemFactory.CreateGeographicCoordinateSystem("ITM", AngularUnit.Degrees, itmDatum, PrimeMeridian.Greenwich, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum.North)); var itmProjection = coordinateSystemFactory.CreateProjection("Transverse_Mercator", "Transverse_Mercator", itmParameters); var itm = coordinateSystemFactory.CreateProjectedCoordinateSystem("ITM", itmGeo, itmProjection, LinearUnit.Metre, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum.North)); var wgs84 = ProjectedCoordinateSystem.WGS84_UTM(36, true).GeographicCoordinateSystem; var ctFwd = _css.CreateTransformation(itm, wgs84).MathTransform; var pt1a = (x : 200000.0, y : 600000.0); var pt2a = ctFwd.Transform(pt1a.x, pt1a.y); var pt1b = ctFwd.Inverse().Transform(pt2a.x, pt2a.y); var pt2b = ctFwd.Transform(pt1a.x, pt1a.y); Assert.That(pt1a.x, Is.EqualTo(pt1b.x).Within(0.01)); Assert.That(pt1a.y, Is.EqualTo(pt1b.y).Within(0.01)); Assert.That(pt2a, Is.EqualTo(pt2b)); }
/// <summary> /// Creates a coordinats transfomation from ITM to WGS84. /// </summary> /// <returns></returns> public static IMathTransform Create() { var coordinateTransformFactory = new CoordinateTransformationFactory(); var coordinateSystemFactory = new CoordinateSystemFactory(); var itmParameters = new List <ProjectionParameter> { new ProjectionParameter("latitude_of_origin", 31.734393611111109123611111111111), new ProjectionParameter("central_meridian", 35.204516944444442572222222222222), new ProjectionParameter("false_northing", 626907.390), new ProjectionParameter("false_easting", 219529.584), new ProjectionParameter("scale_factor", 1.0000067) }; var itmDatum = coordinateSystemFactory.CreateHorizontalDatum("Isreal 1993", DatumType.HD_Geocentric, Ellipsoid.GRS80, new Wgs84ConversionInfo(-24.0024, -17.1032, -17.8444, -0.33077, -1.85269, 1.66969, 5.4248)); var itmGeo = coordinateSystemFactory.CreateGeographicCoordinateSystem("ITM", AngularUnit.Degrees, itmDatum, PrimeMeridian.Greenwich, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum.North)); var itmProjection = coordinateSystemFactory.CreateProjection("Transverse_Mercator", "Transverse_Mercator", itmParameters); var itm = coordinateSystemFactory.CreateProjectedCoordinateSystem("ITM", itmGeo, itmProjection, LinearUnit.Metre, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum.North)); var wgs84 = ProjectedCoordinateSystem.WGS84_UTM(36, true).GeographicCoordinateSystem; return(coordinateTransformFactory.CreateFromCoordinateSystems(itm, wgs84).MathTransform); }
private void TestGeocentric() { CoordinateSystemFactory cFac = new CoordinateSystemFactory(); IGeographicCoordinateSystem gcs = cFac.CreateGeographicCoordinateSystem("WGS84", AngularUnit.Degrees, HorizontalDatum.WGS84, PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientationEnum.East), new AxisInfo("Lat", AxisOrientationEnum.North)); IGeocentricCoordinateSystem geoccs = cFac.CreateGeocentricCoordinateSystem("WGS84 geocentric", gcs.HorizontalDatum, LinearUnit.Metre, PrimeMeridian.Greenwich); ICoordinateTransformation trans = new CoordinateTransformationFactory().CreateFromCoordinateSystems(gcs, geoccs); var pGeo = new Coordinate(2.12955, 53.80939444, 73); var pGc = Transform(trans.MathTransform, pGeo); trans.MathTransform.Invert(); var pGeo2 = Transform(trans.MathTransform, pGc); trans.MathTransform.Invert(); result.Text += PrintResultTable(gcs, geoccs, pGeo, pGc, new Coordinate(3771793.97, 140253.34, 5124304.35), pGeo2, "Geocentric test"); return; }
public void TestMercator_2SP_Projection() { var ellipsoid = CoordinateSystemFactory.CreateFlattenedSphere("Krassowski 1940", 6378245.0, 298.3, LinearUnit.Metre); var datum = CoordinateSystemFactory.CreateHorizontalDatum("Krassowski 1940", DatumType.HD_Geocentric, ellipsoid, null); var gcs = CoordinateSystemFactory.CreateGeographicCoordinateSystem("Krassowski 1940", AngularUnit.Degrees, datum, PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientationEnum.East), new AxisInfo("Lat", AxisOrientationEnum.North)); var parameters = new List <ProjectionParameter>(5) { new ProjectionParameter("latitude_of_origin", 42), new ProjectionParameter("central_meridian", 51), new ProjectionParameter("false_easting", 0), new ProjectionParameter("false_northing", 0) }; var projection = CoordinateSystemFactory.CreateProjection("Mercator_2SP", "Mercator_2SP", parameters); var coordsys = CoordinateSystemFactory.CreateProjectedCoordinateSystem("Pulkovo 1942 / Mercator Caspian Sea", gcs, projection, LinearUnit.Metre, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum.North)); var trans = CoordinateTransformationFactory.CreateFromCoordinateSystems(gcs, coordsys); var pGeo = new[] { 53d, 53d }; var pUtm = trans.MathTransform.Transform(pGeo); var pGeo2 = trans.MathTransform.Inverse().Transform(pUtm); var expected = new[] { 165704.29, 5171848.07 }; Assert.IsTrue(ToleranceLessThan(pUtm, expected, 0.02), TransformationError("Mercator_2SP", expected, pUtm, false)); Assert.IsTrue(ToleranceLessThan(pGeo, pGeo2, 0.0000001), TransformationError("Mercator_2SP", pGeo, pGeo2, true)); }
public void TestLambertConicConformal2SP_Projection() { var ellipsoid = /*Ellipsoid.Clarke1866;*/ CoordinateSystemFactory.CreateFlattenedSphere("Clarke 1866", 20925832.16, 294.97470, LinearUnit.USSurveyFoot); var datum = CoordinateSystemFactory.CreateHorizontalDatum("Clarke 1866", DatumType.HD_Geocentric, ellipsoid, null); var gcs = CoordinateSystemFactory.CreateGeographicCoordinateSystem("Clarke 1866", AngularUnit.Degrees, datum, PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientationEnum.East), new AxisInfo("Lat", AxisOrientationEnum.North)); var parameters = new List <ProjectionParameter>(5) { new ProjectionParameter("latitude_of_origin", 27.833333333), new ProjectionParameter("central_meridian", -99), new ProjectionParameter("standard_parallel_1", 28.3833333333), new ProjectionParameter("standard_parallel_2", 30.2833333333), new ProjectionParameter("false_easting", 2000000 / LinearUnit.USSurveyFoot.MetersPerUnit), new ProjectionParameter("false_northing", 0) }; var projection = CoordinateSystemFactory.CreateProjection("Lambert Conic Conformal (2SP)", "lambert_conformal_conic_2sp", parameters); var coordsys = CoordinateSystemFactory.CreateProjectedCoordinateSystem("NAD27 / Texas South Central", gcs, projection, LinearUnit.USSurveyFoot, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum.North)); var trans = CoordinateTransformationFactory.CreateFromCoordinateSystems(gcs, coordsys); var pGeo = new[] { -96, 28.5 }; var pUtm = trans.MathTransform.Transform(pGeo); var pGeo2 = trans.MathTransform.Inverse().Transform(pUtm); var expected = new[] { 2963503.91 / LinearUnit.USSurveyFoot.MetersPerUnit, 254759.80 / LinearUnit.USSurveyFoot.MetersPerUnit }; Assert.IsTrue(ToleranceLessThan(pUtm, expected, 0.05), TransformationError("LambertConicConformal2SP", expected, pUtm)); Assert.IsTrue(ToleranceLessThan(pGeo, pGeo2, 0.0000001), TransformationError("LambertConicConformal2SP", pGeo, pGeo2, true)); }
public void TestTransverseMercator_Projection() { var ellipsoid = CoordinateSystemFactory.CreateFlattenedSphere("Airy 1830", 6377563.396, 299.32496, LinearUnit.Metre); var datum = CoordinateSystemFactory.CreateHorizontalDatum("Airy 1830", DatumType.HD_Geocentric, ellipsoid, null); var gcs = CoordinateSystemFactory.CreateGeographicCoordinateSystem("Airy 1830", AngularUnit.Degrees, datum, PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientationEnum.East), new AxisInfo("Lat", AxisOrientationEnum.North)); var parameters = new List <ProjectionParameter>(5) { new ProjectionParameter("latitude_of_origin", 49), new ProjectionParameter("central_meridian", -2), new ProjectionParameter("scale_factor", 0.9996012717 /* 0.9996*/), new ProjectionParameter("false_easting", 400000), new ProjectionParameter("false_northing", -100000) }; var projection = CoordinateSystemFactory.CreateProjection("Transverse Mercator", "Transverse_Mercator", parameters); var coordsys = CoordinateSystemFactory.CreateProjectedCoordinateSystem("OSGB 1936 / British National Grid", gcs, projection, LinearUnit.Metre, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum.North)); var trans = CoordinateTransformationFactory.CreateFromCoordinateSystems(gcs, coordsys); var pGeo = new[] { 0.5, 50.5 }; var pUtm = trans.MathTransform.Transform(pGeo); var pGeo2 = trans.MathTransform.Inverse().Transform(pUtm); //"POINT(577393.372775651 69673.621953601)" var expected = new[] { 577274.98, 69740.49 }; Assert.IsTrue(ToleranceLessThan(pUtm, expected, 0.01), TransformationError("TransverseMercator", expected, pUtm)); Assert.IsTrue(ToleranceLessThan(pGeo, pGeo2, 1E-6), TransformationError("TransverseMercator", pGeo, pGeo2, true)); }
public void TestTransverseMercator_Projection() { CoordinateSystemFactory cFac = new CoordinateSystemFactory(); IEllipsoid ellipsoid = cFac.CreateFlattenedSphere("Airy 1830", 6377563.396, 299.32496, LinearUnit.Metre); IHorizontalDatum datum = cFac.CreateHorizontalDatum("Airy 1830", DatumType.HD_Geocentric, ellipsoid, null); IGeographicCoordinateSystem gcs = cFac.CreateGeographicCoordinateSystem("Airy 1830", AngularUnit.Degrees, datum, PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientationEnum.East), new AxisInfo("Lat", AxisOrientationEnum.North)); List <ProjectionParameter> parameters = new List <ProjectionParameter>(5); parameters.Add(new ProjectionParameter("latitude_of_origin", 49)); parameters.Add(new ProjectionParameter("central_meridian", -2)); parameters.Add(new ProjectionParameter("scale_factor", 0.9996012717)); parameters.Add(new ProjectionParameter("false_easting", 400000)); parameters.Add(new ProjectionParameter("false_northing", -100000)); IProjection projection = cFac.CreateProjection("Transverse Mercator", "Transverse_Mercator", parameters); IProjectedCoordinateSystem coordsys = cFac.CreateProjectedCoordinateSystem("OSGB 1936 / British National Grid", gcs, projection, LinearUnit.Metre, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum.North)); ICoordinateTransformation trans = new CoordinateTransformationFactory().CreateFromCoordinateSystems(gcs, coordsys); double[] pGeo = new double[] { 0.5, 50.5 }; double[] pUtm = trans.MathTransform.Transform(pGeo); double[] pGeo2 = trans.MathTransform.Inverse().Transform(pUtm); double[] expected = new double[] { 577274.99, 69740.50 }; Assert.IsTrue(ToleranceLessThan(pUtm, expected, 0.02), String.Format("TransverseMercator forward transformation outside tolerance, Expected {0}, got {1}", expected.ToString(), pUtm.ToString())); Assert.IsTrue(ToleranceLessThan(pGeo, pGeo2, 0.0000001), String.Format("TransverseMercator reverse transformation outside tolerance, Expected {0}, got {1}", pGeo.ToString(), pGeo2.ToString())); }
private static CoordinateSystemFactory CreateNad83ToLambertFactory(out IGeographicCoordinateSystem gcs, out IProjectedCoordinateSystem coordsys) { CoordinateSystemFactory cfac = new CoordinateSystemFactory(); // Define ellipsoid GRS 1980 used by NAD83 IEllipsoid ellipsoid = cfac.CreateFlattenedSphere("GRS 1980", 6378137, 298.257222101, LinearUnit.Metre); // Define NAD83 system IHorizontalDatum datum = cfac.CreateHorizontalDatum("NAD83 (CSRS)", DatumType.HD_Other, ellipsoid, null); gcs = cfac.CreateGeographicCoordinateSystem("NAD83 (CSRS)", AngularUnit.Degrees, datum, PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientationEnum.East), new AxisInfo("Lat", AxisOrientationEnum.North)); // Define Lambert parameters List <ProjectionParameter> parameters = new List <ProjectionParameter>(5); parameters.Add(new ProjectionParameter("latitude_of_origin", 44)); parameters.Add(new ProjectionParameter("central_meridian", -70)); parameters.Add(new ProjectionParameter("standard_parallel_1", 50)); parameters.Add(new ProjectionParameter("standard_parallel_2", 46)); parameters.Add(new ProjectionParameter("false_easting", 800000)); parameters.Add(new ProjectionParameter("false_northing", 0)); IProjection projection = cfac.CreateProjection("Lambert Conic Conformal (2SP)", "lambert_conformal_conic_2sp", parameters); coordsys = cfac.CreateProjectedCoordinateSystem("NAD83/Lambert", gcs, projection, LinearUnit.Metre, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum.North)); return(cfac); }
public static ICoordinateTransformation LatLonToGoogle() { CoordinateSystemFactory csFac = new CoordinateSystemFactory(); CoordinateTransformationFactory ctFac = new CoordinateTransformationFactory(); IGeographicCoordinateSystem sourceCs = csFac.CreateGeographicCoordinateSystem( "WGS 84", AngularUnit.Degrees, HorizontalDatum.WGS84, PrimeMeridian.Greenwich, new AxisInfo("north", AxisOrientationEnum.North), new AxisInfo("east", AxisOrientationEnum.East)); List <ProjectionParameter> parameters = new List <ProjectionParameter>(); parameters.Add(new ProjectionParameter("semi_major", 6378137.0)); parameters.Add(new ProjectionParameter("semi_minor", 6378137.0)); parameters.Add(new ProjectionParameter("latitude_of_origin", 0.0)); parameters.Add(new ProjectionParameter("central_meridian", 0.0)); parameters.Add(new ProjectionParameter("scale_factor", 1.0)); parameters.Add(new ProjectionParameter("false_easting", 0.0)); parameters.Add(new ProjectionParameter("false_northing", 0.0)); IProjection projection = csFac.CreateProjection("Google Mercator", "mercator_1sp", parameters); IProjectedCoordinateSystem targetCs = csFac.CreateProjectedCoordinateSystem( "Google Mercator", sourceCs, projection, LinearUnit.Metre, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum.North)); return(ctFac.CreateFromCoordinateSystems(sourceCs, targetCs)); }
//Creates a Mercator projection private static ICoordinateSystem GetMercatorProjection() { var factory = new CoordinateSystemFactory(); var wgs84 = factory.CreateGeographicCoordinateSystem("WGS 84", AngularUnit.Degrees, HorizontalDatum.WGS84, PrimeMeridian.Greenwich, new AxisInfo("north", AxisOrientationEnum.North), new AxisInfo("east", AxisOrientationEnum.East)); var parameters = new List <ProjectionParameter> { new ProjectionParameter("semi_major", 6371000), // 6378137 new ProjectionParameter("semi_minor", 6371000), // 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) }; var projection = factory.CreateProjection("Mercator", "mercator_1sp", parameters); var mercator = factory.CreateProjectedCoordinateSystem("Mercator", wgs84, projection, LinearUnit.Metre, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum.North)); return(mercator); }
public void TestLambertConicConformal2SP_Projection() { CoordinateSystemFactory cFac = new CoordinateSystemFactory(); IEllipsoid ellipsoid = cFac.CreateFlattenedSphere("Clarke 1866", 20925832.16, 294.97470, LinearUnit.USSurveyFoot); IHorizontalDatum datum = cFac.CreateHorizontalDatum("Clarke 1866", DatumType.HD_Geocentric, ellipsoid, null); IGeographicCoordinateSystem gcs = cFac.CreateGeographicCoordinateSystem("Clarke 1866", AngularUnit.Degrees, datum, PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientationEnum.East), new AxisInfo("Lat", AxisOrientationEnum.North)); List <ProjectionParameter> parameters = new List <ProjectionParameter>(5); parameters.Add(new ProjectionParameter("latitude_of_origin", 27.833333333)); parameters.Add(new ProjectionParameter("central_meridian", -99)); parameters.Add(new ProjectionParameter("standard_parallel_1", 28.3833333333)); parameters.Add(new ProjectionParameter("standard_parallel_2", 30.2833333333)); parameters.Add(new ProjectionParameter("false_easting", 2000000 / LinearUnit.USSurveyFoot.MetersPerUnit)); parameters.Add(new ProjectionParameter("false_northing", 0)); IProjection projection = cFac.CreateProjection("Lambert Conic Conformal (2SP)", "lambert_conformal_conic_2sp", parameters); IProjectedCoordinateSystem coordsys = cFac.CreateProjectedCoordinateSystem("NAD27 / Texas South Central", gcs, projection, LinearUnit.USSurveyFoot, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum.North)); ICoordinateTransformation trans = new CoordinateTransformationFactory().CreateFromCoordinateSystems(gcs, coordsys); double[] pGeo = new double[] { -96, 28.5 }; double[] pUtm = trans.MathTransform.Transform(pGeo); double[] pGeo2 = trans.MathTransform.Inverse().Transform(pUtm); double[] expected = new double[] { 2963503.91 / LinearUnit.USSurveyFoot.MetersPerUnit, 254759.80 / LinearUnit.USSurveyFoot.MetersPerUnit }; Assert.IsTrue(ToleranceLessThan(pUtm, expected, 0.05), String.Format("LambertConicConformal2SP forward transformation outside tolerance, Expected [{0},{1}], got [{2},{3}]", expected[0], expected[1], pUtm[0], pUtm[1])); Assert.IsTrue(ToleranceLessThan(pGeo, pGeo2, 0.0000001), String.Format("LambertConicConformal2SP reverse transformation outside tolerance, Expected [{0},{1}], got [{2},{3}]", pGeo[0], pGeo[1], pGeo2[0], pGeo2[1])); }
public void TestAlbersProjectionFeet() { CoordinateSystemFactory cFac = new CoordinateSystemFactory(); IEllipsoid ellipsoid = cFac.CreateFlattenedSphere("Clarke 1866", 6378206.4, 294.9786982138982, LinearUnit.USSurveyFoot); IHorizontalDatum datum = cFac.CreateHorizontalDatum("Clarke 1866", DatumType.HD_Geocentric, ellipsoid, null); IGeographicCoordinateSystem gcs = cFac.CreateGeographicCoordinateSystem("Clarke 1866", AngularUnit.Degrees, datum, PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientationEnum.East), new AxisInfo("Lat", AxisOrientationEnum.North)); List <ProjectionParameter> parameters = new List <ProjectionParameter>(5); parameters.Add(new ProjectionParameter("central_meridian", -96)); parameters.Add(new ProjectionParameter("latitude_of_center", 23)); parameters.Add(new ProjectionParameter("standard_parallel_1", 29.5)); parameters.Add(new ProjectionParameter("standard_parallel_2", 45.5)); parameters.Add(new ProjectionParameter("false_easting", 0)); parameters.Add(new ProjectionParameter("false_northing", 0)); IProjection projection = cFac.CreateProjection("Albers Conical Equal Area", "albers", parameters); IProjectedCoordinateSystem coordsys = cFac.CreateProjectedCoordinateSystem("Albers Conical Equal Area", gcs, projection, LinearUnit.Foot, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum.North)); ICoordinateTransformation trans = new CoordinateTransformationFactory().CreateFromCoordinateSystems(gcs, coordsys); double[] pGeo = new double[] { -75, 35 }; double[] pUtm = trans.MathTransform.Transform(pGeo); double[] pGeo2 = trans.MathTransform.Inverse().Transform(pUtm); double[] expected = new double[] { 1885472.7 / LinearUnit.Foot.MetersPerUnit, 1535925 / LinearUnit.Foot.MetersPerUnit }; Assert.IsTrue(ToleranceLessThan(pUtm, expected, 0.1), String.Format("Albers forward transformation outside tolerance, Expected [{0},{1}], got [{2},{3}]", expected[0], expected[1], pUtm[0], pUtm[1])); Assert.IsTrue(ToleranceLessThan(pGeo, pGeo2, 0.0000001), String.Format("Albers reverse transformation outside tolerance, Expected [{0},{1}], got [{2},{3}]", pGeo[0], pGeo[1], pGeo2[0], pGeo2[1])); }
public void TestMercator_1SP_Projection() { CoordinateSystemFactory cFac = new CoordinateSystemFactory(); IEllipsoid ellipsoid = cFac.CreateFlattenedSphere("Bessel 1840", 6377397.155, 299.15281, LinearUnit.Metre); IHorizontalDatum datum = cFac.CreateHorizontalDatum("Bessel 1840", DatumType.HD_Geocentric, ellipsoid, null); IGeographicCoordinateSystem gcs = cFac.CreateGeographicCoordinateSystem("Bessel 1840", AngularUnit.Degrees, datum, PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientationEnum.East), new AxisInfo("Lat", AxisOrientationEnum.North)); List <ProjectionParameter> parameters = new List <ProjectionParameter>(5); parameters.Add(new ProjectionParameter("latitude_of_origin", 0)); parameters.Add(new ProjectionParameter("central_meridian", 110)); parameters.Add(new ProjectionParameter("scale_factor", 0.997)); parameters.Add(new ProjectionParameter("false_easting", 3900000)); parameters.Add(new ProjectionParameter("false_northing", 900000)); IProjection projection = cFac.CreateProjection("Mercator_1SP", "Mercator_1SP", parameters); IProjectedCoordinateSystem coordsys = cFac.CreateProjectedCoordinateSystem("Makassar / NEIEZ", gcs, projection, LinearUnit.Metre, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum.North)); ICoordinateTransformation trans = new CoordinateTransformationFactory().CreateFromCoordinateSystems(gcs, coordsys); double[] pGeo = new double[] { 120, -3 }; double[] pUtm = trans.MathTransform.Transform(pGeo); double[] pGeo2 = trans.MathTransform.Inverse().Transform(pUtm); double[] expected = new double[] { 5009726.58, 569150.82 }; Assert.IsTrue(ToleranceLessThan(pUtm, expected, 0.02), String.Format("Mercator_1SP forward transformation outside tolerance, Expected [{0},{1}], got [{2},{3}]", expected[0], expected[1], pUtm[0], pUtm[1])); Assert.IsTrue(ToleranceLessThan(pGeo, pGeo2, 0.0000001), String.Format("Mercator_1SP reverse transformation outside tolerance, Expected [{0},{1}], got [{2},{3}]", pGeo[0], pGeo[1], pGeo2[0], pGeo2[1])); }
public void TestMercator_1SP_Projection_Feet() { var ellipsoid = CoordinateSystemFactory.CreateFlattenedSphere("Bessel 1840", 6377397.155, 299.15281, LinearUnit.Metre); var datum = CoordinateSystemFactory.CreateHorizontalDatum("Bessel 1840", DatumType.HD_Geocentric, ellipsoid, null); var gcs = CoordinateSystemFactory.CreateGeographicCoordinateSystem("Bessel 1840", AngularUnit.Degrees, datum, PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientationEnum.East), new AxisInfo("Lat", AxisOrientationEnum.North)); var parameters = new List <ProjectionParameter>(5) { new ProjectionParameter("latitude_of_origin", 0), new ProjectionParameter("central_meridian", 110), new ProjectionParameter("scale_factor", 0.997), new ProjectionParameter("false_easting", 3900000 / LinearUnit.Foot.MetersPerUnit), new ProjectionParameter("false_northing", 900000 / LinearUnit.Foot.MetersPerUnit) }; var projection = CoordinateSystemFactory.CreateProjection("Mercator_1SP", "Mercator_1SP", parameters); var coordsys = CoordinateSystemFactory.CreateProjectedCoordinateSystem("Makassar / NEIEZ", gcs, projection, LinearUnit.Foot, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum.North)); var trans = CoordinateTransformationFactory.CreateFromCoordinateSystems(gcs, coordsys); var pGeo = new[] { 120d, -3d }; var pUtm = trans.MathTransform.Transform(pGeo); var pGeo2 = trans.MathTransform.Inverse().Transform(pUtm); var expected = new[] { 5009726.58 / LinearUnit.Foot.MetersPerUnit, 569150.82 / LinearUnit.Foot.MetersPerUnit }; Assert.IsTrue(ToleranceLessThan(pUtm, expected, 0.02), TransformationError("Mercator_1SP", expected, pUtm, false)); Assert.IsTrue(ToleranceLessThan(pGeo, pGeo2, 0.0000001), TransformationError("Mercator_1SP", pGeo, pGeo2, true)); }
public void TestMercator_2SP_Projection() { CoordinateSystemFactory cFac = new CoordinateSystemFactory(); IEllipsoid ellipsoid = cFac.CreateFlattenedSphere("Krassowski 1940", 6378245.0, 298.3, LinearUnit.Metre); IHorizontalDatum datum = cFac.CreateHorizontalDatum("Krassowski 1940", DatumType.HD_Geocentric, ellipsoid, null); IGeographicCoordinateSystem gcs = cFac.CreateGeographicCoordinateSystem("Krassowski 1940", AngularUnit.Degrees, datum, PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientationEnum.East), new AxisInfo("Lat", AxisOrientationEnum.North)); List <ProjectionParameter> parameters = new List <ProjectionParameter>(5); parameters.Add(new ProjectionParameter("latitude_of_origin", 42)); parameters.Add(new ProjectionParameter("central_meridian", 51)); parameters.Add(new ProjectionParameter("false_easting", 0)); parameters.Add(new ProjectionParameter("false_northing", 0)); IProjection projection = cFac.CreateProjection("Mercator_2SP", "Mercator_2SP", parameters); IProjectedCoordinateSystem coordsys = cFac.CreateProjectedCoordinateSystem("Pulkovo 1942 / Mercator Caspian Sea", gcs, projection, LinearUnit.Metre, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum.North)); ICoordinateTransformation trans = new CoordinateTransformationFactory().CreateFromCoordinateSystems(gcs, coordsys); double[] pGeo = new double[] { 53, 53 }; double[] pUtm = trans.MathTransform.Transform(pGeo); double[] pGeo2 = trans.MathTransform.Inverse().Transform(pUtm); double[] expected = new double[] { 165704.29, 5171848.07 }; Assert.IsTrue(ToleranceLessThan(pUtm, expected, 0.02), String.Format("Mercator_2SP forward transformation outside tolerance, Expected {0}, got {1}", expected.ToString(), pUtm.ToString())); Assert.IsTrue(ToleranceLessThan(pGeo, pGeo2, 0.0000001), String.Format("Mercator_2SP reverse transformation outside tolerance, Expected {0}, got {1}", pGeo.ToString(), pGeo2.ToString())); }
public void TestAlbersProjectionFeet() { var ellipsoid = CoordinateSystemFactory.CreateFlattenedSphere("Clarke 1866", 6378206.4, 294.9786982138982, LinearUnit.Metre); var datum = CoordinateSystemFactory.CreateHorizontalDatum("Clarke 1866", DatumType.HD_Geocentric, ellipsoid, null); var gcs = CoordinateSystemFactory.CreateGeographicCoordinateSystem("Clarke 1866", AngularUnit.Degrees, datum, PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientationEnum.East), new AxisInfo("Lat", AxisOrientationEnum.North)); var parameters = new List <ProjectionParameter>(5) { new ProjectionParameter("central_meridian", -96), new ProjectionParameter("latitude_of_center", 23), new ProjectionParameter("standard_parallel_1", 29.5), new ProjectionParameter("standard_parallel_2", 45.5), new ProjectionParameter("false_easting", 0), new ProjectionParameter("false_northing", 0) }; var projection = CoordinateSystemFactory.CreateProjection("Albers Conical Equal Area", "albers", parameters); var coordsys = CoordinateSystemFactory.CreateProjectedCoordinateSystem("Albers Conical Equal Area", gcs, projection, LinearUnit.Foot, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum.North)); var trans = CoordinateTransformationFactory.CreateFromCoordinateSystems(gcs, coordsys); var pGeo = new double[] { -75, 35 }; var pUtm = trans.MathTransform.Transform(pGeo); var pGeo2 = trans.MathTransform.Inverse().Transform(pUtm); var expected = new[] { 1885472.7 / LinearUnit.Foot.MetersPerUnit, 1535925 / LinearUnit.Foot.MetersPerUnit }; Assert.IsTrue(ToleranceLessThan(pUtm, expected, 0.1), TransformationError("Albers", expected, pUtm, false)); Assert.IsTrue(ToleranceLessThan(pGeo, pGeo2, 0.0000001), TransformationError("Albers", pGeo, pGeo2, true)); }
// GIS RV09 - Slide 4 private IProjectedCoordinateSystem CreateUtmProjection(int utmZone) { CoordinateSystemFactory cFac = new CoordinateSystemFactory(); // Create geographic coordinate system based on the WGS84 datum IEllipsoid ellipsoid = cFac.CreateFlattenedSphere("WGS 84", 6378137, 298.257223563, LinearUnit.Metre); IHorizontalDatum datum = cFac.CreateHorizontalDatum("WGS 84", DatumType.HD_Geocentric, ellipsoid, null); IGeographicCoordinateSystem gcs = cFac.CreateGeographicCoordinateSystem("WGS 84", AngularUnit.Degrees, datum, PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientationEnum.East), new AxisInfo("Lat", AxisOrientationEnum.North)); // Create UTM projection List <ProjectionParameter> parameters = new List <ProjectionParameter>(); parameters.Add(new ProjectionParameter("latitude_of_origin", 0)); parameters.Add(new ProjectionParameter("central_meridian", -183 + 6 * utmZone)); parameters.Add(new ProjectionParameter("scale_factor", 0.9996)); parameters.Add(new ProjectionParameter("false_easting", 500000)); parameters.Add(new ProjectionParameter("false_northing", 0.0)); IProjection projection = cFac.CreateProjection("Transverse Mercator", "Transverse_Mercator", parameters); return(cFac.CreateProjectedCoordinateSystem("WGS 84 / UTM zone " + utmZone.ToString() + "N", gcs, projection, LinearUnit.Metre, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("Norh", AxisOrientationEnum.North))); }
public void TestAlbersProjection() { var cFac = new CoordinateSystemFactory(); var ellipsoid = cFac.CreateFlattenedSphere( "Clarke 1866", 6378206.4, 294.9786982138982, LinearUnit.USSurveyFoot); var datum = cFac.CreateHorizontalDatum( "Clarke 1866", DatumType.HD_Geocentric, ellipsoid, null); var gcs = cFac.CreateGeographicCoordinateSystem( "Clarke 1866", AngularUnit.Degrees, datum, PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientationEnum.East), new AxisInfo("Lat", AxisOrientationEnum.North)); var parameters = new List <ProjectionParameter>(5); parameters.Add(new ProjectionParameter("central_meridian", -96)); parameters.Add(new ProjectionParameter("latitude_of_center", 23)); parameters.Add(new ProjectionParameter("standard_parallel_1", 29.5)); parameters.Add(new ProjectionParameter("standard_parallel_2", 45.5)); parameters.Add(new ProjectionParameter("false_easting", 0)); parameters.Add(new ProjectionParameter("false_northing", 0)); var projection = cFac.CreateProjection( "Albers Conical Equal Area", "albers", parameters); var coordsys = cFac.CreateProjectedCoordinateSystem( "Albers Conical Equal Area", gcs, projection, LinearUnit.Metre, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum.North)); var trans = new CoordinateTransformationFactory().CreateFromCoordinateSystems(gcs, coordsys); var f = GeometryFactory.Default; var pGeo = f.CreatePoint(new Coordinate(-75, 35)); var pUtm = GeometryTransform.TransformPoint(f, pGeo, trans.MathTransform); var pGeo2 = GeometryTransform.TransformPoint(f, pUtm, trans.MathTransform.Inverse()); var expected = f.CreatePoint(new Coordinate(1885472.7, 1535925)); Assert.IsTrue(ToleranceLessThan(pUtm, expected, 0.05), string.Format("Albers forward transformation outside tolerance, Expected [{0},{1}], got [{2},{3}]", expected.X, expected.Y, pUtm.X, pUtm.Y)); Assert.IsTrue(ToleranceLessThan(pGeo, pGeo2, 0.0000001), string.Format("Albers reverse transformation outside tolerance, Expected [{0},{1}], got [{2},{3}]", pGeo.X, pGeo.Y, pGeo2.X, pGeo2.Y)); }
public void TestAlbersProjection() { ICoordinateSystemFactory cFac = new CoordinateSystemFactory(); ILinearUnit usSurveyFoot = cFac.CreateLinearUnit(); IEllipsoid ellipsoid = cFac.CreateFlattenedSphere( 6378206.4, 294.9786982138982, LinearUnit.USSurveyFoot, "Clarke 1866"); IHorizontalDatum datum = cFac.CreateHorizontalDatum( DatumType.HorizontalGeocentric, ellipsoid, null, "Clarke 1866"); IGeographicCoordinateSystem gcs = cFac.CreateGeographicCoordinateSystem( "Clarke 1866", AngularUnit.Degrees, datum, PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientation.East), new AxisInfo("Lat", AxisOrientation.North)); //Collection<ProjectionParameter> parameters = new Collection<ProjectionParameter>(5); Collection <ProjectionParameter> parameters = new Collection <ProjectionParameter>(); parameters.Add(new ProjectionParameter("central_meridian", -96)); parameters.Add(new ProjectionParameter("latitude_of_origin", 23)); parameters.Add(new ProjectionParameter("standard_parallel_1", 29.5)); parameters.Add(new ProjectionParameter("standard_parallel_2", 45.5)); parameters.Add(new ProjectionParameter("false_easting", 0)); parameters.Add(new ProjectionParameter("false_northing", 0)); IProjection projection = cFac.CreateProjection("Albers Conical Equal Area", "albers", parameters); IProjectedCoordinateSystem coordsys = cFac.CreateProjectedCoordinateSystem( gcs, projection, LinearUnit.Metre, new AxisInfo("East", AxisOrientation.East), new AxisInfo("North", AxisOrientation.North)); ICoordinateTransformation trans = new CoordinateTransformationFactory() .CreateFromCoordinateSystems(gcs, coordsys); IPoint pGeo = new Point(-75, 35); IPoint pUtm = trans.MathTransform.Transform(pGeo); IPoint pGeo2 = trans.MathTransform.Inverse().Transform(pUtm); IPoint expected = new IPoint(1885472.7, 1535925); Assert.IsTrue(toleranceLessThan(pUtm, expected, 0.05), String.Format("Albers forward transformation outside tolerance, Expected {0}, got {1}", expected, pUtm)); Assert.IsTrue(toleranceLessThan(pGeo, pGeo2, 0.0000001), String.Format("Albers reverse transformation outside tolerance, Expected {0}, got {1}", pGeo.ToString(), pGeo2.ToString())); }
public void TestAlbersProjection() { ICoordinateSystemFactory cFac = new CoordinateSystemFactory(); ILinearUnit usSurveyFoot = cFac.CreateLinearUnit(); IEllipsoid ellipsoid = cFac.CreateFlattenedSphere( 6378206.4, 294.9786982138982, LinearUnit.USSurveyFoot, "Clarke 1866"); IHorizontalDatum datum = cFac.CreateHorizontalDatum( DatumType.HorizontalGeocentric, ellipsoid, null, "Clarke 1866"); IGeographicCoordinateSystem gcs = cFac.CreateGeographicCoordinateSystem( "Clarke 1866", AngularUnit.Degrees, datum, PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientation.East), new AxisInfo("Lat", AxisOrientation.North)); //Collection<ProjectionParameter> parameters = new Collection<ProjectionParameter>(5); Collection<ProjectionParameter> parameters = new Collection<ProjectionParameter>(); parameters.Add(new ProjectionParameter("central_meridian", -96)); parameters.Add(new ProjectionParameter("latitude_of_origin", 23)); parameters.Add(new ProjectionParameter("standard_parallel_1", 29.5)); parameters.Add(new ProjectionParameter("standard_parallel_2", 45.5)); parameters.Add(new ProjectionParameter("false_easting", 0)); parameters.Add(new ProjectionParameter("false_northing", 0)); IProjection projection = cFac.CreateProjection("Albers Conical Equal Area", "albers", parameters); IProjectedCoordinateSystem coordsys = cFac.CreateProjectedCoordinateSystem( gcs, projection, LinearUnit.Metre, new AxisInfo("East", AxisOrientation.East), new AxisInfo("North", AxisOrientation.North)); ICoordinateTransformation trans = new CoordinateTransformationFactory() .CreateFromCoordinateSystems(gcs, coordsys); IPoint pGeo = new Point(-75, 35); IPoint pUtm = trans.MathTransform.Transform(pGeo); IPoint pGeo2 = trans.MathTransform.Inverse().Transform(pUtm); IPoint expected = new IPoint(1885472.7, 1535925); Assert.IsTrue(toleranceLessThan(pUtm, expected, 0.05), String.Format("Albers forward transformation outside tolerance, Expected {0}, got {1}", expected, pUtm)); Assert.IsTrue(toleranceLessThan(pGeo, pGeo2, 0.0000001), String.Format("Albers reverse transformation outside tolerance, Expected {0}, got {1}", pGeo.ToString(), pGeo2.ToString())); }
public void TestGeocentric() { var gcs = CoordinateSystemFactory.CreateGeographicCoordinateSystem("ETRF89 Geographic", AngularUnit.Degrees, HorizontalDatum.ETRF89, PrimeMeridian.Greenwich, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum.North)); var gcenCs = CoordinateSystemFactory.CreateGeocentricCoordinateSystem("ETRF89 Geocentric", HorizontalDatum.ETRF89, LinearUnit.Metre, PrimeMeridian.Greenwich); var ct = CoordinateTransformationFactory.CreateFromCoordinateSystems(gcs, gcenCs); var pExpected = new[] { 2 + 7.0 / 60 + 46.38 / 3600, 53 + 48.0 / 60 + 33.82 / 3600 }; // Point.FromDMS(2, 7, 46.38, 53, 48, 33.82); var pExpected3D = new[] { pExpected[0], pExpected[1], 73.0 }; var p0 = new[] { 3771793.97, 140253.34, 5124304.35 }; var p1 = ct.MathTransform.Transform(pExpected3D); var p2 = ct.MathTransform.Inverse().Transform(p1); Assert.IsTrue(ToleranceLessThan(p1, p0, 0.01)); Assert.IsTrue(ToleranceLessThan(p2, pExpected, 0.00001)); }
private void TestLambertConicConformal_2SP() { CoordinateSystemFactory cFac = new CoordinateSystemFactory(); IEllipsoid ellipsoid = cFac.CreateFlattenedSphere("Clarke 1866", 20925832.16, 294.97470, LinearUnit.USSurveyFoot); IHorizontalDatum datum = cFac.CreateHorizontalDatum("Clarke 1866", DatumType.HD_Geocentric, ellipsoid, null); IGeographicCoordinateSystem gcs = cFac.CreateGeographicCoordinateSystem("Clarke 1866", AngularUnit.Degrees, datum, PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientationEnum.East), new AxisInfo("Lat", AxisOrientationEnum.North)); List <ProjectionParameter> parameters = new List <ProjectionParameter>(); parameters.Add(new ProjectionParameter("latitude_of_origin", 27.833333333)); parameters.Add(new ProjectionParameter("central_meridian", -99)); parameters.Add(new ProjectionParameter("standard_parallel_1", 28.3833333333)); parameters.Add(new ProjectionParameter("standard_parallel_2", 30.2833333333)); parameters.Add(new ProjectionParameter("false_easting", 2000000)); parameters.Add(new ProjectionParameter("false_northing", 0)); IProjection projection = cFac.CreateProjection("Lambert Conic Conformal (2SP)", "lambert_conformal_conic_2sp", parameters); IProjectedCoordinateSystem coordsys = cFac.CreateProjectedCoordinateSystem("NAD27 / Texas South Central", gcs, projection, LinearUnit.USSurveyFoot, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum. North)); ICoordinateTransformation trans = new CoordinateTransformationFactory().CreateFromCoordinateSystems(gcs, coordsys); var pGeo = new Coordinate(-96, 28.5); var pUtm = Transform(trans.MathTransform, pGeo); trans.MathTransform.Invert(); var pGeo2 = Transform(trans.MathTransform, pUtm); trans.MathTransform.Invert(); result.Text += PrintResultTable(gcs, coordsys, pGeo, pUtm, new Coordinate(2963503.91, 254759.80), pGeo2, "Lambert Conic Conformal 2SP test"); }
private void TestAlbers() { CoordinateSystemFactory cFac = new CoordinateSystemFactory(); IEllipsoid ellipsoid = cFac.CreateFlattenedSphere("Clarke 1866", 6378206.4, 294.9786982138982, LinearUnit.USSurveyFoot); IHorizontalDatum datum = cFac.CreateHorizontalDatum("Clarke 1866", DatumType.HD_Geocentric, ellipsoid, null); IGeographicCoordinateSystem gcs = cFac.CreateGeographicCoordinateSystem("Clarke 1866", AngularUnit.Degrees, datum, PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientationEnum.East), new AxisInfo("Lat", AxisOrientationEnum.North)); List <ProjectionParameter> parameters = new List <ProjectionParameter>(); parameters.Add(new ProjectionParameter("central_meridian", -96)); parameters.Add(new ProjectionParameter("latitude_of_origin", 23)); parameters.Add(new ProjectionParameter("standard_parallel_1", 29.5)); parameters.Add(new ProjectionParameter("standard_parallel_2", 45.5)); parameters.Add(new ProjectionParameter("false_easting", 0)); parameters.Add(new ProjectionParameter("false_northing", 0)); IProjection projection = cFac.CreateProjection("Albers Conical Equal Area", "albers", parameters); IProjectedCoordinateSystem coordsys = cFac.CreateProjectedCoordinateSystem("Albers Conical Equal Area", gcs, projection, LinearUnit.Metre, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum. North)); ICoordinateTransformation trans = new CoordinateTransformationFactory().CreateFromCoordinateSystems(gcs, coordsys); var pGeo = new Coordinate(-75, 35); var pUtm = Transform(trans.MathTransform, pGeo); trans.MathTransform.Invert(); var pGeo2 = Transform(trans.MathTransform, pUtm); trans.MathTransform.Invert(); result.Text += PrintResultTable(gcs, coordsys, pGeo, pUtm, new Coordinate(1885472.7, 1535925), pGeo2, "Albers Conical Equal Area test"); }
public void TestKrovak_Projection() { CoordinateSystemFactory cFac = new CoordinateSystemFactory(); IEllipsoid ellipsoid = cFac.CreateFlattenedSphere("Bessel 1840", 6377397.155, 299.15281, LinearUnit.Metre); IHorizontalDatum datum = cFac.CreateHorizontalDatum("Bessel 1840", DatumType.HD_Geocentric, ellipsoid, null); IGeographicCoordinateSystem gcs = cFac.CreateGeographicCoordinateSystem("Bessel 1840", AngularUnit.Degrees, datum, PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientationEnum.East), new AxisInfo("Lat", AxisOrientationEnum.North)); List <ProjectionParameter> parameters = new List <ProjectionParameter>(5); parameters.Add(new ProjectionParameter("latitude_of_center", 49.5)); parameters.Add(new ProjectionParameter("longitude_of_center", 42.5)); parameters.Add(new ProjectionParameter("azimuth", 30.28813972222222)); parameters.Add(new ProjectionParameter("pseudo_standard_parallel_1", 78.5)); parameters.Add(new ProjectionParameter("scale_factor", 0.9999)); parameters.Add(new ProjectionParameter("false_easting", 0)); parameters.Add(new ProjectionParameter("false_northing", 0)); IProjection projection = cFac.CreateProjection("Krovak", "Krovak", parameters); IProjectedCoordinateSystem coordsys = cFac.CreateProjectedCoordinateSystem("WGS 84", gcs, projection, LinearUnit.Metre, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum.North)); ICoordinateTransformation trans = new CoordinateTransformationFactory().CreateFromCoordinateSystems(gcs, coordsys); // test case 1 double[] pGeo = new double[] { 12, 48 }; double[] expected = new double[] { -953172.26, -1245573.32 }; double[] pUtm = trans.MathTransform.Transform(pGeo); double[] pGeo2 = trans.MathTransform.Inverse().Transform(pUtm); Assert.IsTrue(ToleranceLessThan(pUtm, expected, 0.02), String.Format("Krovak forward transformation outside tolerance, Expected [{0},{1}], got [{2},{3}]", expected[0], expected[1], pUtm[0], pUtm[1])); Assert.IsTrue(ToleranceLessThan(pGeo, pGeo2, 0.0000001), String.Format("Krovak reverse transformation outside tolerance, Expected [{0},{1}], got [{2},{3}]", pGeo[0], pGeo[1], pGeo2[0], pGeo2[1])); // test case 2 pGeo = new double[] { 18, 49 }; expected = new double[] { -499258.06, -1192389.16 }; pUtm = trans.MathTransform.Transform(pGeo); pGeo2 = trans.MathTransform.Inverse().Transform(pUtm); Assert.IsTrue(ToleranceLessThan(pUtm, expected, 0.02), String.Format("Krovak forward transformation outside tolerance, Expected [{0},{1}], got [{2},{3}]", expected[0], expected[1], pUtm[0], pUtm[1])); Assert.IsTrue(ToleranceLessThan(pGeo, pGeo2, 0.0000001), String.Format("Krovak reverse transformation outside tolerance, Expected [{0},{1}], got [{2},{3}]", pGeo[0], pGeo[1], pGeo2[0], pGeo2[1])); }
private void TestMercator_1SP() { CoordinateSystemFactory cFac = new CoordinateSystemFactory(); IEllipsoid ellipsoid = cFac.CreateFlattenedSphere("Bessel 1840", 6377397.155, 299.15281, LinearUnit.Metre); IHorizontalDatum datum = cFac.CreateHorizontalDatum("Bessel 1840", DatumType.HD_Geocentric, ellipsoid, null); IGeographicCoordinateSystem gcs = cFac.CreateGeographicCoordinateSystem("Bessel 1840", AngularUnit.Degrees, datum, PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientationEnum.East), new AxisInfo("Lat", AxisOrientationEnum.North)); List <ProjectionParameter> parameters = new List <ProjectionParameter>(); parameters.Add(new ProjectionParameter("latitude_of_origin", 0)); parameters.Add(new ProjectionParameter("central_meridian", 110)); parameters.Add(new ProjectionParameter("scale_factor", 0.997)); parameters.Add(new ProjectionParameter("false_easting", 3900000)); parameters.Add(new ProjectionParameter("false_northing", 900000)); IProjection projection = cFac.CreateProjection("Mercator_1SP", "Mercator_1SP", parameters); IProjectedCoordinateSystem coordsys = cFac.CreateProjectedCoordinateSystem("Makassar / NEIEZ", gcs, projection, LinearUnit.Metre, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum. North)); ICoordinateTransformation trans = new CoordinateTransformationFactory().CreateFromCoordinateSystems(gcs, coordsys); var pGeo = new Coordinate(120, -3); var pUtm = Transform(trans.MathTransform, pGeo); trans.MathTransform.Invert(); var pGeo2 = Transform(trans.MathTransform, pUtm); trans.MathTransform.Invert(); result.Text += PrintResultTable(gcs, coordsys, pGeo, pUtm, new Coordinate(5009726.58, 569150.82), pGeo2, "Mercator_1SP test"); }
public void TestKrovak_Projection() { var ellipsoid = CoordinateSystemFactory.CreateFlattenedSphere("Bessel 1840", 6377397.155, 299.15281, LinearUnit.Metre); var datum = CoordinateSystemFactory.CreateHorizontalDatum("Bessel 1840", DatumType.HD_Geocentric, ellipsoid, null); var gcs = CoordinateSystemFactory.CreateGeographicCoordinateSystem("Bessel 1840", AngularUnit.Degrees, datum, PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientationEnum.East), new AxisInfo("Lat", AxisOrientationEnum.North)); var parameters = new List <ProjectionParameter>(5) { new ProjectionParameter("latitude_of_center", 49.5), new ProjectionParameter("longitude_of_center", 42.5), new ProjectionParameter("azimuth", 30.28813972222222), new ProjectionParameter("pseudo_standard_parallel_1", 78.5), new ProjectionParameter("scale_factor", 0.9999), new ProjectionParameter("false_easting", 0), new ProjectionParameter("false_northing", 0) }; var projection = CoordinateSystemFactory.CreateProjection("Krovak", "Krovak", parameters); var coordsys = CoordinateSystemFactory.CreateProjectedCoordinateSystem("WGS 84", gcs, projection, LinearUnit.Metre, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum.North)); var trans = new CoordinateTransformationFactory().CreateFromCoordinateSystems(gcs, coordsys); // test case 1 var pGeo = new[] { 12d, 48d }; var expected = new[] { -953172.26, -1245573.32 }; var pUtm = trans.MathTransform.Transform(pGeo); var pGeo2 = trans.MathTransform.Inverse().Transform(pUtm); Assert.IsTrue(ToleranceLessThan(pUtm, expected, 0.02), TransformationError("Krovak", expected, pUtm)); Assert.IsTrue(ToleranceLessThan(pGeo, pGeo2, 0.0000001), TransformationError("Krovak", pGeo, pGeo2, true)); // test case 2 pGeo = new double[] { 18, 49 }; expected = new double[] { -499258.06, -1192389.16 }; pUtm = trans.MathTransform.Transform(pGeo); pGeo2 = trans.MathTransform.Inverse().Transform(pUtm); Assert.IsTrue(ToleranceLessThan(pUtm, expected, 0.02), TransformationError("Krovak", expected, pUtm)); Assert.IsTrue(ToleranceLessThan(pGeo, pGeo2, 0.0000001), TransformationError("Krovak", pGeo, pGeo2)); }
private void TestAlbers() { CoordinateSystemFactory cFac = new CoordinateSystemFactory(); IEllipsoid ellipsoid = cFac.CreateFlattenedSphere("Clarke 1866", 6378206.4, 294.9786982138982, LinearUnit.USSurveyFoot); IHorizontalDatum datum = cFac.CreateHorizontalDatum("Clarke 1866", DatumType.HD_Geocentric, ellipsoid, null); IGeographicCoordinateSystem gcs = cFac.CreateGeographicCoordinateSystem("Clarke 1866", AngularUnit.Degrees, datum, PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientationEnum.East), new AxisInfo("Lat", AxisOrientationEnum.North)); List<ProjectionParameter> parameters = new List<ProjectionParameter>(); parameters.Add(new ProjectionParameter("central_meridian", -96)); parameters.Add(new ProjectionParameter("latitude_of_origin", 23)); parameters.Add(new ProjectionParameter("standard_parallel_1", 29.5)); parameters.Add(new ProjectionParameter("standard_parallel_2", 45.5)); parameters.Add(new ProjectionParameter("false_easting", 0)); parameters.Add(new ProjectionParameter("false_northing", 0)); IProjection projection = cFac.CreateProjection("Albers Conical Equal Area", "albers", parameters); IProjectedCoordinateSystem coordsys = cFac.CreateProjectedCoordinateSystem("Albers Conical Equal Area", gcs, projection, LinearUnit.Metre, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum. North)); ICoordinateTransformation trans = new CoordinateTransformationFactory().CreateFromCoordinateSystems(gcs, coordsys); var pGeo = new Coordinate(-75, 35); var pUtm = Transform(trans.MathTransform, pGeo); trans.MathTransform.Invert(); var pGeo2 = Transform(trans.MathTransform, pUtm); trans.MathTransform.Invert(); result.Text += PrintResultTable(gcs, coordsys, pGeo, pUtm, new Coordinate(1885472.7, 1535925), pGeo2, "Albers Conical Equal Area test"); }
private void TestTransverseMercator() { CoordinateSystemFactory cFac = new CoordinateSystemFactory(); IEllipsoid ellipsoid = cFac.CreateFlattenedSphere("Airy 1830", 6377563.396, 299.32496, LinearUnit.Metre); IHorizontalDatum datum = cFac.CreateHorizontalDatum("Airy 1830", DatumType.HD_Geocentric, ellipsoid, null); IGeographicCoordinateSystem gcs = cFac.CreateGeographicCoordinateSystem("Airy 1830", AngularUnit.Degrees, datum, PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientationEnum.East), new AxisInfo("Lat", AxisOrientationEnum.North)); List <ProjectionParameter> parameters = new List <ProjectionParameter>(); parameters.Add(new ProjectionParameter("latitude_of_origin", 49)); parameters.Add(new ProjectionParameter("central_meridian", -2)); parameters.Add(new ProjectionParameter("scale_factor", 0.9996012717)); parameters.Add(new ProjectionParameter("false_easting", 400000)); parameters.Add(new ProjectionParameter("false_northing", -100000)); IProjection projection = cFac.CreateProjection("Transverse Mercator", "Transverse_Mercator", parameters); IProjectedCoordinateSystem coordsys = cFac.CreateProjectedCoordinateSystem("OSGB 1936 / British National Grid", gcs, projection, LinearUnit.Metre, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum. North)); ICoordinateTransformation trans = new CoordinateTransformationFactory().CreateFromCoordinateSystems(gcs, coordsys); var pGeo = new Coordinate(0.5, 50.5); var pUtm = Transform(trans.MathTransform, pGeo); trans.MathTransform.Invert(); var pGeo2 = Transform(trans.MathTransform, pUtm); trans.MathTransform.Invert(); result.Text += PrintResultTable(gcs, coordsys, pGeo, pUtm, new Coordinate(577274.99, 69740.50), pGeo2, "Transverse Mercator test"); }
public void Test_Constructor() { ICoordinateSystemFactory csFactory = new CoordinateSystemFactory(); IAngularUnit angularUnit = new AngularUnit(1); ILinearUnit linearUnit = new LinearUnit(1); IEllipsoid ellipsoid = csFactory.CreateFlattenedSphere("test", 1, 2, linearUnit); IAxisInfo axis0 = new AxisInfo("axis0name", AxisOrientation.Up); IAxisInfo axis1 = new AxisInfo("axis1name", AxisOrientation.Up); WGS84ConversionInfo wgs = new WGS84ConversionInfo(); IPrimeMeridian primeMeridian = csFactory.CreatePrimeMeridian("name", angularUnit, 2.0); IHorizontalDatum horizontalDatum = csFactory.CreateHorizontalDatum("datum", DatumType.IHD_Geocentric, ellipsoid, wgs); IGeographicCoordinateSystem gcs = csFactory.CreateGeographicCoordinateSystem("name", angularUnit, horizontalDatum, primeMeridian, axis0, axis1); //PrimeMeridian primeMeridian = new PrimeMeridian("name", angularUnit, 0.5); IAxisInfo[] axisArray = new IAxisInfo[2]; axisArray[0] = axis0; axisArray[1] = axis1; ProjectionParameter[] paramList = new ProjectionParameter[1]; paramList[0].Name = "test"; paramList[0].Value = 2.2; Projection projection = new Projection("mercator", paramList, "class", "remarks", "authority", "authoritycode"); ProjectedCoordinateSystem pjc = new ProjectedCoordinateSystem(horizontalDatum, axisArray, gcs, linearUnit, projection, "remarks", "authority", "authorityCode", "name", "alias", "abbreviation"); Assertion.AssertEquals("Test 1", linearUnit, pjc.LinearUnit); Assertion.AssertEquals("Test 2", horizontalDatum, pjc.HorizontalDatum); Assertion.AssertEquals("Test 3", axis0, pjc.GetAxis(0)); Assertion.AssertEquals("Test 4", axis1, pjc.GetAxis(1)); Assertion.AssertEquals("Test 5", gcs, pjc.GeographicCoordinateSystem); Assertion.AssertEquals("Test 6", "abbreviation", pjc.Abbreviation); Assertion.AssertEquals("Test 7", "alias", pjc.Alias); Assertion.AssertEquals("Test 8", "authority", pjc.Authority); Assertion.AssertEquals("Test 9", "authorityCode", pjc.AuthorityCode); Assertion.AssertEquals("Test 10", "name", pjc.Name); Assertion.AssertEquals("Test 11", "remarks", pjc.Remarks); }
public void TestMercator_1SP_Projection() { CoordinateSystemFactory cFac = new CoordinateSystemFactory(); IEllipsoid ellipsoid = cFac.CreateFlattenedSphere("Bessel 1840", 6377397.155, 299.15281, LinearUnit.Metre); IHorizontalDatum datum = cFac.CreateHorizontalDatum("Bessel 1840", DatumType.HD_Geocentric, ellipsoid, null); IGeographicCoordinateSystem gcs = cFac.CreateGeographicCoordinateSystem("Bessel 1840", AngularUnit.Degrees, datum, PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientation.East), new AxisInfo("Lat", AxisOrientation.North)); //Collection<ProjectionParameter> parameters = new Collection<ProjectionParameter>(5); Collection<ProjectionParameter> parameters = new Collection<ProjectionParameter>(); parameters.Add(new ProjectionParameter("latitude_of_origin", 0)); parameters.Add(new ProjectionParameter("central_meridian", 110)); parameters.Add(new ProjectionParameter("scale_factor", 0.997)); parameters.Add(new ProjectionParameter("false_easting", 3900000)); parameters.Add(new ProjectionParameter("false_northing", 900000)); IProjection projection = cFac.CreateProjection("Mercator_1SP", "Mercator_1SP", parameters); IProjectedCoordinateSystem coordsys = cFac.CreateProjectedCoordinateSystem("Makassar / NEIEZ", gcs, projection, LinearUnit.Metre, new AxisInfo("East", AxisOrientation.East), new AxisInfo("North", AxisOrientation.North)); ICoordinateTransformation trans = new CoordinateTransformationFactory().CreateFromCoordinateSystems(gcs, coordsys); Point pGeo = new Point(120, -3); Point pUtm = trans.MathTransform.Transform(pGeo); Point pGeo2 = trans.MathTransform.Inverse().Transform(pUtm); Point expected = new Point(5009726.58, 569150.82); Assert.IsTrue(toleranceLessThan(pUtm, expected, 0.02), String.Format("Mercator_1SP forward transformation outside tolerance, Expected {0}, got {1}", expected.ToString(), pUtm.ToString())); Assert.IsTrue(toleranceLessThan(pGeo, pGeo2, 0.0000001), String.Format("Mercator_1SP reverse transformation outside tolerance, Expected {0}, got {1}", pGeo.ToString(), pGeo2.ToString())); }
public void Test_Constructor() { ICoordinateSystemFactory csFactory = new CoordinateSystemFactory(); IAngularUnit angularUnit = new AngularUnit(1); ILinearUnit linearUnit = new LinearUnit(1); IEllipsoid ellipsoid = csFactory.CreateFlattenedSphere("test", 1, 2, linearUnit); IAxisInfo axis0 = new AxisInfo("axis0name", AxisOrientation.Up); IAxisInfo axis1 = new AxisInfo("axis1name", AxisOrientation.Up); WGS84ConversionInfo wgs = new WGS84ConversionInfo(); IPrimeMeridian primeMeridian = csFactory.CreatePrimeMeridian("name", angularUnit, 2.0); IHorizontalDatum horizontalDatum = csFactory.CreateHorizontalDatum("datum", DatumType.IHD_Geocentric, ellipsoid, wgs); IGeographicCoordinateSystem gcs = csFactory.CreateGeographicCoordinateSystem("name", angularUnit, horizontalDatum, primeMeridian, axis0, axis1); Assertion.AssertEquals("ctor 1", "name", gcs.Name); Assertion.AssertEquals("ctor 2", angularUnit, gcs.AngularUnit); Assertion.AssertEquals("ctor 3", horizontalDatum, gcs.HorizontalDatum); Assertion.AssertEquals("ctor 4", primeMeridian, gcs.PrimeMeridian); Assertion.AssertEquals("ctor 5", axis0, gcs.GetAxis(0)); Assertion.AssertEquals("ctor 5", axis1, gcs.GetAxis(1)); }
private IProjectedCoordinateSystem createExpectedCoordinateSystem() { ICoordinateSystemFactory factory = new CoordinateSystemFactory <BufferedCoordinate2D>( _geoFactory.CoordinateFactory, _geoFactory); IEllipsoid grs80 = Ellipsoid.Grs80; IHorizontalDatum harn = factory.CreateHorizontalDatum( DatumType.HorizontalGeocentric, grs80, null, "D_North_American_1983_HARN"); IPrimeMeridian greenwich = PrimeMeridian.Greenwich; IAxisInfo axis0 = new AxisInfo(AxisOrientation.East, "Lon"); IAxisInfo axis1 = new AxisInfo(AxisOrientation.North, "Lat"); // Made the first parameter - the IExtents - null, which should be improved IGeographicCoordinateSystem gcs = factory.CreateGeographicCoordinateSystem(null, AngularUnit.Degrees, harn, greenwich, axis0, axis1, "GCS_North_American_1983_HARN"); IProjection prj = factory.CreateProjection( "Lambert_Conformal_Conic", new ProjectionParameter[] { new ProjectionParameter("False_Easting", 8202099.737532808), new ProjectionParameter("False_Northing", 0), new ProjectionParameter("Central_Meridian", -120.5), new ProjectionParameter("Standard_Parallel_1", 44.33333333333334), new ProjectionParameter("Standard_Parallel_2", 46.0), new ProjectionParameter("Latitude_Of_Origin", 43.66666666666666) }, "Lambert_Conformal_Conic"); IProjectedCoordinateSystem expected = factory.CreateProjectedCoordinateSystem( gcs, prj, LinearUnit.Foot, axis0, axis1, "NAD_1983_HARN_StatePlane_Oregon_North_FIPS_3601"); // TODO: Check if this is correct, since on line 184 of CoorindateSystemFactory.cs, // HorizontalDatum is passed in as null return(expected); }
private void TestMercator_2SP() { CoordinateSystemFactory cFac = new CoordinateSystemFactory(); IEllipsoid ellipsoid = cFac.CreateFlattenedSphere("Krassowski 1940", 6378245.0, 298.3, LinearUnit.Metre); IHorizontalDatum datum = cFac.CreateHorizontalDatum("Krassowski 1940", DatumType.HD_Geocentric, ellipsoid, null); IGeographicCoordinateSystem gcs = cFac.CreateGeographicCoordinateSystem("Krassowski 1940", AngularUnit.Degrees, datum, PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientationEnum.East), new AxisInfo("Lat", AxisOrientationEnum.North)); List <ProjectionParameter> parameters = new List <ProjectionParameter>(); parameters.Add(new ProjectionParameter("latitude_of_origin", 42)); parameters.Add(new ProjectionParameter("central_meridian", 51)); parameters.Add(new ProjectionParameter("false_easting", 0)); parameters.Add(new ProjectionParameter("false_northing", 0)); IProjection projection = cFac.CreateProjection("Mercator_2SP", "Mercator_2SP", parameters); IProjectedCoordinateSystem coordsys = cFac.CreateProjectedCoordinateSystem( "Pulkovo 1942 / Mercator Caspian Sea", gcs, projection, LinearUnit.Metre, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum.North)); ICoordinateTransformation trans = new CoordinateTransformationFactory().CreateFromCoordinateSystems(gcs, coordsys); var pGeo = new Coordinate(53, 53); var pUtm = Transform(trans.MathTransform, pGeo); trans.MathTransform.Invert(); var pGeo2 = Transform(trans.MathTransform, pUtm); trans.MathTransform.Invert(); result.Text += PrintResultTable(gcs, coordsys, pGeo, pUtm, new Coordinate(165704.29, 5171848.07), pGeo2, "Mercator_2SP test"); }
private void TestMercator_1SP() { CoordinateSystemFactory cFac = new CoordinateSystemFactory(); IEllipsoid ellipsoid = cFac.CreateFlattenedSphere("Bessel 1840", 6377397.155, 299.15281, LinearUnit.Metre); IHorizontalDatum datum = cFac.CreateHorizontalDatum("Bessel 1840", DatumType.HD_Geocentric, ellipsoid, null); IGeographicCoordinateSystem gcs = cFac.CreateGeographicCoordinateSystem("Bessel 1840", AngularUnit.Degrees, datum, PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientationEnum.East), new AxisInfo("Lat", AxisOrientationEnum.North)); List<ProjectionParameter> parameters = new List<ProjectionParameter>(); parameters.Add(new ProjectionParameter("latitude_of_origin", 0)); parameters.Add(new ProjectionParameter("central_meridian", 110)); parameters.Add(new ProjectionParameter("scale_factor", 0.997)); parameters.Add(new ProjectionParameter("false_easting", 3900000)); parameters.Add(new ProjectionParameter("false_northing", 900000)); IProjection projection = cFac.CreateProjection("Mercator_1SP", "Mercator_1SP", parameters); IProjectedCoordinateSystem coordsys = cFac.CreateProjectedCoordinateSystem("Makassar / NEIEZ", gcs, projection, LinearUnit.Metre, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum. North)); ICoordinateTransformation trans = new CoordinateTransformationFactory().CreateFromCoordinateSystems(gcs, coordsys); var pGeo = new Coordinate(120, -3); var pUtm = Transform(trans.MathTransform, pGeo); trans.MathTransform.Invert(); var pGeo2 = Transform(trans.MathTransform, pUtm); trans.MathTransform.Invert(); result.Text += PrintResultTable(gcs, coordsys, pGeo, pUtm, new Coordinate(5009726.58, 569150.82), pGeo2, "Mercator_1SP test"); }
public void TestTransverseMercator_Projection() { CoordinateSystemFactory cFac = new CoordinateSystemFactory(); IEllipsoid ellipsoid = cFac.CreateFlattenedSphere("Airy 1830", 6377563.396, 299.32496, LinearUnit.Metre); IHorizontalDatum datum = cFac.CreateHorizontalDatum("Airy 1830", DatumType.HD_Geocentric, ellipsoid, null); IGeographicCoordinateSystem gcs = cFac.CreateGeographicCoordinateSystem("Airy 1830", AngularUnit.Degrees, datum, PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientation.East), new AxisInfo("Lat", AxisOrientation.North)); //Collection<ProjectionParameter> parameters = new Collection<ProjectionParameter>(5); Collection<ProjectionParameter> parameters = new Collection<ProjectionParameter>(); parameters.Add(new ProjectionParameter("latitude_of_origin", 49)); parameters.Add(new ProjectionParameter("central_meridian", -2)); parameters.Add(new ProjectionParameter("scale_factor", 0.9996012717)); parameters.Add(new ProjectionParameter("false_easting", 400000)); parameters.Add(new ProjectionParameter("false_northing", -100000)); IProjection projection = cFac.CreateProjection("Transverse Mercator", "Transverse_Mercator", parameters); IProjectedCoordinateSystem coordsys = cFac.CreateProjectedCoordinateSystem("OSGB 1936 / British National Grid", gcs, projection, LinearUnit.Metre, new AxisInfo("East", AxisOrientation.East), new AxisInfo("North", AxisOrientation.North)); ICoordinateTransformation trans = new CoordinateTransformationFactory().CreateFromCoordinateSystems(gcs, coordsys); Point pGeo = new Point(0.5, 50.5); Point pUtm = trans.MathTransform.Transform(pGeo); Point pGeo2 = trans.MathTransform.Inverse().Transform(pUtm); Point expected = new Point(577274.99, 69740.50); Assert.IsTrue(toleranceLessThan(pUtm, expected, 0.02), String.Format( "TransverseMercator forward transformation outside tolerance, Expected {0}, got {1}", expected.ToString(), pUtm.ToString())); Assert.IsTrue(toleranceLessThan(pGeo, pGeo2, 0.0000001), String.Format( "TransverseMercator reverse transformation outside tolerance, Expected {0}, got {1}", pGeo.ToString(), pGeo2.ToString())); }
private void TestMercator_2SP() { CoordinateSystemFactory cFac = new CoordinateSystemFactory(); IEllipsoid ellipsoid = cFac.CreateFlattenedSphere("Krassowski 1940", 6378245.0, 298.3, LinearUnit.Metre); IHorizontalDatum datum = cFac.CreateHorizontalDatum("Krassowski 1940", DatumType.HD_Geocentric, ellipsoid, null); IGeographicCoordinateSystem gcs = cFac.CreateGeographicCoordinateSystem("Krassowski 1940", AngularUnit.Degrees, datum, PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientationEnum.East), new AxisInfo("Lat", AxisOrientationEnum.North)); List<ProjectionParameter> parameters = new List<ProjectionParameter>(); parameters.Add(new ProjectionParameter("latitude_of_origin", 42)); parameters.Add(new ProjectionParameter("central_meridian", 51)); parameters.Add(new ProjectionParameter("false_easting", 0)); parameters.Add(new ProjectionParameter("false_northing", 0)); IProjection projection = cFac.CreateProjection("Mercator_2SP", "Mercator_2SP", parameters); IProjectedCoordinateSystem coordsys = cFac.CreateProjectedCoordinateSystem( "Pulkovo 1942 / Mercator Caspian Sea", gcs, projection, LinearUnit.Metre, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum.North)); ICoordinateTransformation trans = new CoordinateTransformationFactory().CreateFromCoordinateSystems(gcs, coordsys); var pGeo = new Coordinate(53, 53); var pUtm = Transform(trans.MathTransform, pGeo); trans.MathTransform.Invert(); var pGeo2 = Transform(trans.MathTransform, pUtm); trans.MathTransform.Invert(); result.Text += PrintResultTable(gcs, coordsys, pGeo, pUtm, new Coordinate(165704.29, 5171848.07), pGeo2, "Mercator_2SP test"); }
private void TestTransverseMercator() { CoordinateSystemFactory cFac = new CoordinateSystemFactory(); IEllipsoid ellipsoid = cFac.CreateFlattenedSphere("Airy 1830", 6377563.396, 299.32496, LinearUnit.Metre); IHorizontalDatum datum = cFac.CreateHorizontalDatum("Airy 1830", DatumType.HD_Geocentric, ellipsoid, null); IGeographicCoordinateSystem gcs = cFac.CreateGeographicCoordinateSystem("Airy 1830", AngularUnit.Degrees, datum, PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientationEnum.East), new AxisInfo("Lat", AxisOrientationEnum.North)); List<ProjectionParameter> parameters = new List<ProjectionParameter>(); parameters.Add(new ProjectionParameter("latitude_of_origin", 49)); parameters.Add(new ProjectionParameter("central_meridian", -2)); parameters.Add(new ProjectionParameter("scale_factor", 0.9996012717)); parameters.Add(new ProjectionParameter("false_easting", 400000)); parameters.Add(new ProjectionParameter("false_northing", -100000)); IProjection projection = cFac.CreateProjection("Transverse Mercator", "Transverse_Mercator", parameters); IProjectedCoordinateSystem coordsys = cFac.CreateProjectedCoordinateSystem("OSGB 1936 / British National Grid", gcs, projection, LinearUnit.Metre, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum. North)); ICoordinateTransformation trans = new CoordinateTransformationFactory().CreateFromCoordinateSystems(gcs, coordsys); var pGeo = new Coordinate(0.5, 50.5); var pUtm = Transform(trans.MathTransform, pGeo); trans.MathTransform.Invert(); var pGeo2 = Transform(trans.MathTransform, pUtm); trans.MathTransform.Invert(); result.Text += PrintResultTable(gcs, coordsys, pGeo, pUtm, new Coordinate(577274.99, 69740.50), pGeo2, "Transverse Mercator test"); }
private void TestGeocentric() { CoordinateSystemFactory cFac = new CoordinateSystemFactory(); IGeographicCoordinateSystem gcs = cFac.CreateGeographicCoordinateSystem("WGS84", AngularUnit.Degrees, HorizontalDatum.WGS84, PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientationEnum.East), new AxisInfo("Lat", AxisOrientationEnum.North)); IGeocentricCoordinateSystem geoccs = cFac.CreateGeocentricCoordinateSystem("WGS84 geocentric", gcs.HorizontalDatum, LinearUnit.Metre, PrimeMeridian.Greenwich); ICoordinateTransformation trans = new CoordinateTransformationFactory().CreateFromCoordinateSystems(gcs, geoccs); var pGeo = new Coordinate(2.12955, 53.80939444, 73); var pGc = Transform(trans.MathTransform, pGeo); trans.MathTransform.Invert(); var pGeo2 = Transform(trans.MathTransform, pGc); trans.MathTransform.Invert(); result.Text += PrintResultTable(gcs, geoccs, pGeo, pGc, new Coordinate(3771793.97, 140253.34, 5124304.35), pGeo2, "Geocentric test"); return; }
public void TestMercator_2SP_Projection() { CoordinateSystemFactory cFac = new CoordinateSystemFactory(); IEllipsoid ellipsoid = cFac.CreateFlattenedSphere("Krassowski 1940", 6378245.0, 298.3, LinearUnit.Metre); IHorizontalDatum datum = cFac.CreateHorizontalDatum("Krassowski 1940", DatumType.HD_Geocentric, ellipsoid, null); IGeographicCoordinateSystem gcs = cFac.CreateGeographicCoordinateSystem("Krassowski 1940", AngularUnit.Degrees, datum, PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientation.East), new AxisInfo("Lat", AxisOrientation.North)); //Collection<ProjectionParameter> parameters = new Collection<ProjectionParameter>(5); Collection<ProjectionParameter> parameters = new Collection<ProjectionParameter>(); parameters.Add(new ProjectionParameter("latitude_of_origin", 42)); parameters.Add(new ProjectionParameter("central_meridian", 51)); parameters.Add(new ProjectionParameter("false_easting", 0)); parameters.Add(new ProjectionParameter("false_northing", 0)); IProjection projection = cFac.CreateProjection("Mercator_2SP", "Mercator_2SP", parameters); IProjectedCoordinateSystem coordsys = cFac.CreateProjectedCoordinateSystem("Pulkovo 1942 / Mercator Caspian Sea", gcs, projection, LinearUnit.Metre, new AxisInfo("East", AxisOrientation.East), new AxisInfo("North", AxisOrientation.North)); ICoordinateTransformation trans = new CoordinateTransformationFactory().CreateFromCoordinateSystems(gcs, coordsys); Point pGeo = new Point(53, 53); Point pUtm = trans.MathTransform.Transform(pGeo); Point pGeo2 = trans.MathTransform.Inverse().Transform(pUtm); Point expected = new Point(165704.29, 5171848.07); Assert.IsTrue(toleranceLessThan(pUtm, expected, 0.02), String.Format("Mercator_2SP forward transformation outside tolerance, Expected {0}, got {1}", expected.ToString(), pUtm.ToString())); Assert.IsTrue(toleranceLessThan(pGeo, pGeo2, 0.0000001), String.Format("Mercator_2SP reverse transformation outside tolerance, Expected {0}, got {1}", pGeo.ToString(), pGeo2.ToString())); }
public void TestGeocentric() { CoordinateSystemFactory cFac = new CoordinateSystemFactory(); IGeographicCoordinateSystem gcs = cFac.CreateGeographicCoordinateSystem("ETRF89 Geographic", AngularUnit.Degrees, HorizontalDatum.ETRF89, PrimeMeridian.Greenwich, new AxisInfo("East", AxisOrientation.East), new AxisInfo("North", AxisOrientation.North)); IGeocentricCoordinateSystem gcenCs = cFac.CreateGeocentricCoordinateSystem("ETRF89 Geocentric", HorizontalDatum.ETRF89, LinearUnit.Metre, PrimeMeridian.Greenwich); CoordinateTransformationFactory gtFac = new CoordinateTransformationFactory(); ICoordinateTransformation ct = gtFac.CreateFromCoordinateSystems(gcs, gcenCs); Point pExpected = Point.FromDMS(2, 7, 46.38, 53, 48, 33.82); Point3D pExpected3D = new Point3D(pExpected.X, pExpected.Y, 73.0); Point3D p0 = new Point3D(3771793.97, 140253.34, 5124304.35); Point3D p1 = ct.MathTransform.Transform(pExpected3D) as Point3D; Point3D p2 = ct.MathTransform.Inverse().Transform(p1) as Point3D; Assert.IsTrue(toleranceLessThan(p1, p0, 0.01)); Assert.IsTrue(toleranceLessThan(p2, pExpected, 0.00001)); }
private void TestLambertConicConformal_2SP() { CoordinateSystemFactory cFac = new CoordinateSystemFactory(); IEllipsoid ellipsoid = cFac.CreateFlattenedSphere("Clarke 1866", 20925832.16, 294.97470, LinearUnit.USSurveyFoot); IHorizontalDatum datum = cFac.CreateHorizontalDatum("Clarke 1866", DatumType.HD_Geocentric, ellipsoid, null); IGeographicCoordinateSystem gcs = cFac.CreateGeographicCoordinateSystem("Clarke 1866", AngularUnit.Degrees, datum, PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientationEnum.East), new AxisInfo("Lat", AxisOrientationEnum.North)); List<ProjectionParameter> parameters = new List<ProjectionParameter>(); parameters.Add(new ProjectionParameter("latitude_of_origin", 27.833333333)); parameters.Add(new ProjectionParameter("central_meridian", -99)); parameters.Add(new ProjectionParameter("standard_parallel_1", 28.3833333333)); parameters.Add(new ProjectionParameter("standard_parallel_2", 30.2833333333)); parameters.Add(new ProjectionParameter("false_easting", 2000000)); parameters.Add(new ProjectionParameter("false_northing", 0)); IProjection projection = cFac.CreateProjection("Lambert Conic Conformal (2SP)", "lambert_conformal_conic_2sp", parameters); IProjectedCoordinateSystem coordsys = cFac.CreateProjectedCoordinateSystem("NAD27 / Texas South Central", gcs, projection, LinearUnit.USSurveyFoot, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum. North)); ICoordinateTransformation trans = new CoordinateTransformationFactory().CreateFromCoordinateSystems(gcs, coordsys); var pGeo = new Coordinate(-96, 28.5); var pUtm = Transform(trans.MathTransform, pGeo); trans.MathTransform.Invert(); var pGeo2 = Transform(trans.MathTransform, pUtm); trans.MathTransform.Invert(); result.Text += PrintResultTable(gcs, coordsys, pGeo, pUtm, new Coordinate(2963503.91, 254759.80), pGeo2, "Lambert Conic Conformal 2SP test"); }
public void TestLambertConicConformal2SP_Projection() { CoordinateSystemFactory cFac = new CoordinateSystemFactory(); IEllipsoid ellipsoid = cFac.CreateFlattenedSphere("Clarke 1866", 20925832.16, 294.97470, LinearUnit.USSurveyFoot); IHorizontalDatum datum = cFac.CreateHorizontalDatum("Clarke 1866", DatumType.HD_Geocentric, ellipsoid, null); IGeographicCoordinateSystem gcs = cFac.CreateGeographicCoordinateSystem("Clarke 1866", AngularUnit.Degrees, datum, PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientation.East), new AxisInfo("Lat", AxisOrientation.North)); //Collection<ProjectionParameter> parameters = new Collection<ProjectionParameter>(5); Collection<ProjectionParameter> parameters = new Collection<ProjectionParameter>(); parameters.Add(new ProjectionParameter("latitude_of_origin", 27.833333333)); parameters.Add(new ProjectionParameter("central_meridian", -99)); parameters.Add(new ProjectionParameter("standard_parallel_1", 28.3833333333)); parameters.Add(new ProjectionParameter("standard_parallel_2", 30.2833333333)); parameters.Add(new ProjectionParameter("false_easting", 2000000)); parameters.Add(new ProjectionParameter("false_northing", 0)); IProjection projection = cFac.CreateProjection("Lambert Conic Conformal (2SP)", "lambert_conformal_conic_2sp", parameters); IProjectedCoordinateSystem coordsys = cFac.CreateProjectedCoordinateSystem("NAD27 / Texas South Central", gcs, projection, LinearUnit.USSurveyFoot, new AxisInfo("East", AxisOrientation.East), new AxisInfo("North", AxisOrientation.North)); ICoordinateTransformation trans = new CoordinateTransformationFactory().CreateFromCoordinateSystems(gcs, coordsys); Point pGeo = new Point(-96, 28.5); Point pUtm = trans.MathTransform.Transform(pGeo); Point pGeo2 = trans.MathTransform.Inverse().Transform(pUtm); Point expected = new Point(2963503.91, 254759.80); Assert.IsTrue(toleranceLessThan(pUtm, expected, 0.02), String.Format( "LambertConicConformal2SP forward transformation outside tolerance, Expected {0}, got {1}", expected.ToString(), pUtm.ToString())); Assert.IsTrue(toleranceLessThan(pGeo, pGeo2, 0.0000001), String.Format( "LambertConicConformal2SP reverse transformation outside tolerance, Expected {0}, got {1}", pGeo.ToString(), pGeo2.ToString())); }