Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Latitude & Longitude order confusing #113

Open
ketourneau opened this issue Mar 24, 2023 · 1 comment
Open

Latitude & Longitude order confusing #113

ketourneau opened this issue Mar 24, 2023 · 1 comment

Comments

@ketourneau
Copy link

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
Copy link

Related to #93.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants