openstreetmap / iD

🆔 The easy-to-use OpenStreetMap editor in JavaScript.
https://www.openstreetmap.org/edit?editor=id
ISC License
3.35k stars 1.2k forks source link

Wrong offset values in meters #9792

Open Dron007 opened 1 year ago

Dron007 commented 1 year ago

URL

https://www.openstreetmap.org/edit#map=18/46.43038/30.71566

How to reproduce the issue?

During imagery alignment the offset in meters shows incorrect values comparing to the real imagery offset.

Here is how to reproduce it:

  1. Select any imagery (I used Bing), reset offset. Objects layer could be switched off for clarity.
  2. Move map to some contrast object and measure its width with the ruler and any other program (see results from Google Earth). 1 2

As you can see, the width of this ice rink is correctly shown as 40 meters so ruler is correct.

  1. Set offset to "-40, 0". We expect moving of the object left and its right edge should be aligned with the left edge of the ruler. But here is what we see: 4

  2. Try offset "40, 0" expecting the opposite: right edge of the object should be aligned with the left edge of the ruler. The result: 3

As you can see, it is not 40 m but about 27 m, 1.45 size smaller. I suspect that latitude and longitude are mixed up in the parameters of the functions which convert degrees delta to meters. Why I think so? There is the same problem in JOSM which I noticed after I applied offset from offset database. iD don't use offset database but there is conversion of degrees to meters. Here is the example of possible error:

Point 1 (lat, lon): (46.429716, 30.714416) Point 2 (lat, lon): (46.429716, 30.714942) dLon = 30.714942 - 30.714416 = 0.000526 Let's calculate distance using geoLonToMeters()

0.000526 * (TAU * EQUATORIAL_RADIUS / 360) * Math.abs(Math.cos(46.4297 * (Math.PI / 180))) = 40.2

which is correct. Now let's use geoLatToMeters

0.000526 * (TAU * POLAR_RADIUS / 360)/40 = 58.5

which is exactly the same offset we need to enter to get correct imagery offset.

So I suspect that geoLatToMeters() was used internally for map longitude offset and `geoLonToMeters() was used for map latitude offset.

This bug makes it hard to set the same offset to work with different editors.

Screenshot(s) or anything else?

See above.

Which deployed environments do you see the issue in?

Released version at openstreetmap.org/edit

What version numbers does this issue effect?

2.26.2

Which browsers are you seeing this problem on?

Chrome

k-yle commented 1 year ago

this issue is not present at the equator, so I'm guessing geoMetersToOffset & geoOffsetToMeters needs to consider the current lattitude