NetTopologySuite / ProjNet4GeoAPI

.NET Spatial Reference and Projection Engine
GNU Lesser General Public License v2.1
273 stars 83 forks source link

Latitude & Longitude order confusing #113

Open ketourneau opened 1 year ago

ketourneau commented 1 year ago

Hi,

We try to convert WGS84 coordinate in WGS84 EPSG:3395 but we got wrong result.

double latitude = 47.27064771;
double longitude = -1.6129427;
string wktWGS84_3395 = "PROJCS[\"WGS84 / WorldMercator\",GEOGCS[\"WGS84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4326\"]],PROJECTION[\"Mercator_1SP\"],PARAMETER[\"central_meridian\",0],PARAMETER[\"scale_factor\",1],PARAMETER[\"false_easting\",0],PARAMETER[\"false_northing\",0],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],AXIS[\"Easting\",EAST],AXIS[\"Northing\",NORTH],AUTHORITY[\"EPSG\",\"3395\"]]";

ProjNet.CoordinateSystems.CoordinateSystem wgs84_4326 = ProjNet.CoordinateSystems.GeographicCoordinateSystem.WGS84;
ProjNet.CoordinateSystems.CoordinateSystem wgs84_33385 = ProjNet.IO.CoordinateSystems.CoordinateSystemWktReader.Parse (wktWGS84_3395) as ProjNet.CoordinateSystems.CoordinateSystem;
ICoordinateTransformation trans = new CoordinateTransformationFactory ().CreateFromCoordinateSystems (wgs84_4326, wgs84_33385);
double[] result = trans.MathTransform.Transform (new double[] {latitude, longitude});

Debug.Log (result[0]); // Longitude: -178373.847780952
Debug.Log (result[1]); // Latitude: 5262144.43254542

Expected result : Longitude: -179551.96870091045 Latitude: 5954960.960474437

Like documentation say : All transformations are done on double arrays, where the first value is primary axis (X/East/Latitude) and the second the secondary (Y/North/Longitude). You can provide an optional third value (Z/Height), which can change if a datum transformation occurs* during the transform.

If we invert latitude and longitude it's work.

jjanuszkiewicz commented 1 year ago

Related to #93.