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

Reproject.ReprojectPoints not working for more than 1 point #781

Closed
mogikanin opened this issue May 6, 2016 · 1 comment
Closed

Reproject.ReprojectPoints not working for more than 1 point #781

mogikanin opened this issue May 6, 2016 · 1 comment

Comments

@mogikanin
Copy link
Contributor

This issue was imported from CodePlex

sindizzy wrote 2016-05-05 at 00:34
It took me some time to debug this but I dont think Reproject.ReprojectPoints is working like it should. I take two points on my map (NorthPoleStereographic) and want to reproject them to WGS84. I setup the calculation and only the first point comes out
correct. When I do them individually then both come out correct. Can someone maybe point out my shortcoming.

'set projection of the map
mapMain.Projection = KnownCoordinateSystems.Projected.Polar.NorthPoleStereographic
mapMain.Projection.CentralMeridian = -165
mapMain.Projection.FalseEasting = 0
mapMain.Projection.FalseNorthing = 0
mapMain.Projection.ScaleFactor = 1
mapMain.Projection.LatitudeOfOrigin = 90

Now in that projection here are my coordinates:

CoordinateA x=4485207.83013716 y=2805066.943671
CoordinateB x=2656525.17410077 y=3950495.93338145

So my first attempt is to send all points at once:

Dim firstCoord As New Coordinate(4485207.83013716, 2805066.943671)
Dim lastCoord As New Coordinate(2656525.17410077, 3950495.93338145) 
Debug.Print("    firstCoord Vertex in MapProj x={0} y={1}", firstCoord.X, firstCoord.Y)
Debug.Print("    lastCoord  Vertex in MapProj x={0} y={1}", lastCoord.X, lastCoord.Y)

'create an array of coordinates in the map's projection
Dim mapXY() As Double = {firstCoord.X, firstCoord.Y, lastCoord.X, lastCoord.Y}
Dim mapZ() As Double = {firstCoord.Z, lastCoord.Z}

'now we reproject the coordinates to geographic coordinates
Reproject.ReprojectPoints(mapXY, mapZ, mapMain.Projection, KnownCoordinateSystems.Geographic.World.WGS1984, 0, 2)

 'create reprojected coordinates for ease of use
Dim firstCoordWgs84 As New Coordinate(mapXY(0), mapXY(1), mapZ(0))
Dim lastCoordWgs84 As New Coordinate(mapXY(2), mapXY(3), mapZ(1))

Debug.Print("    firstCoord Vertex in WGS84   x={0} y={1}", firstCoordWgs84.X, firstCoordWgs84.Y)
Debug.Print("    lastCoord  Vertex in WGS84   x={0} y={1}", lastCoordWgs84.X, lastCoordWgs84.Y)

and here is the debug (not sure how the last coordinate was calculated)

firstCoord Vertex in MapProj x=4485207.83013716 y=2805066.943671
lastCoord  Vertex in MapProj x=2656525.17410077 y=3950495.93338145
firstCoord Vertex in WGS84   x=-42.9779741870071 y=45.0079085872576
lastCoord  Vertex in WGS84   x=-165 y=0

My second attempt reprojects the points one at a time

 'create an array for first coordinate in the map's projection
Dim mapXY() As Double = {firstCoord.X, firstCoord.Y}
Dim mapZ() As Double = {firstCoord.Z}

'now we reproject the coordinates to geographic coordinates
Reproject.ReprojectPoints(mapXY, mapZ, mapMain.Projection, KnownCoordinateSystems.Geographic.World.WGS1984, 0, 1)
Dim firstCoordWgs84 As New Coordinate(mapXY(0), mapXY(1), mapZ(0))

'create an array for the second coordinate in the map's projection
mapXY = {lastCoord.X, lastCoord.Y}
mapZ = {lastCoord.Z}

'now we reproject the coordinates to geographic coordinates
Reproject.ReprojectPoints(mapXY, mapZ, mapMain.Projection, KnownCoordinateSystems.Geographic.World.WGS1984, 0, 1)
Dim lastCoordWgs84 As New Coordinate(mapXY(0), mapXY(1), mapZ(0))

Debug.Print("    firstCoord Vertex in WGS84   x={0} y={1}", firstCoordWgs84.X, firstCoordWgs84.Y)
Debug.Print("    lastCoord  Vertex in WGS84   x={0} y={1}", lastCoordWgs84.X, lastCoordWgs84.Y)

and here is that debug (with the last point being entirely different from the first attempt but this second attempt is the correct result)

firstCoord Vertex in MapProj x=4485207.83013716 y=2805066.943671
lastCoord  Vertex in MapProj x=2656525.17410077 y=3950495.93338145
firstCoord Vertex in WGS84   x=-42.9779741870071 y=45.0079085872576
lastCoord  Vertex in WGS84   x=-18.9190007521499 y=49.133436167914

~AGP

@mogikanin mogikanin added this to the 2.0 milestone May 26, 2016
@mogikanin mogikanin added the bug label May 26, 2016
@mogikanin mogikanin self-assigned this May 26, 2016
@mogikanin
Copy link
Contributor Author

Reproduced. It is an issue in Stereographic transform. But for other projections ReprojectPoints() works fine for more than 1 point at once.

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

No branches or pull requests

2 participants