[josm-dev] LatLon.greatCircleDistance Bug?
Karl Newman
siliconfiend at gmail.com
Mon Jan 19 17:32:18 GMT 2009
On Mon, Jan 19, 2009 at 9:03 AM, Karl Newman <siliconfiend at gmail.com> wrote:
> On Mon, Jan 19, 2009 at 8:34 AM, Detlef Reichl <detlef.reichl at gmx.org>wrote:
>
>> Am Montag, den 19.01.2009, 17:15 +0100 schrieb Tobias Wendorff:
>> Hi Tobias,
>>
>> > The bug must be in the other parts.
>>
>> I'm a little step further. Form the MapScaller class i printed out the
>> ll1, ll2 and dist value to the console. It looks like this:
>>
>> ll1 64.5635383519239 : -19.701032734051942
>> ll2 64.5635383519239 : -9.890120706057816
>> dist 468619.7921204448
>>
>> ll1 65.91688367961092 : -22.856876103056717
>> ll2 65.91688367961092 : -11.955862738618798
>> dist 494557.8424123941
>>
>> ll1 67.34105605688401 : -26.363368735284247
>> ll2 67.34105605688401 : -14.251131663686559
>> dist 518612.50496088184
>>
>> ll1 68.82977522568474 : -30.259471659981504
>> ll2 68.82977522568474 : -16.801430469317406
>> dist 539957.2886111567
>>
>> ll1 70.3743573179418 : -34.58847490964512
>> ll2 70.3743573179418 : -19.635095808907234
>> dist 557687.3702770402
>>
>> ll1 71.963536631957 : -39.398478520382476
>> ll2 71.963536631957 : -22.783612852895935
>> dist 570850.2680160615
>>
>> ll1 73.58339022047235 : -44.74292697675731
>> ll2 73.58339022047235 : -26.281965123994485
>> dist 578490.4937988957
>>
>> ll1 75.21740411282117 : -50.681203039396024
>> ll2 75.21740411282117 : -30.169023202992882
>> dist 579708.5723878946
>>
>> ll1 76.84671859283488 : -57.27928755343901
>> ll2 76.84671859283488 : -34.487976624102195
>> dist 573732.9917813947
>>
>> ll1 78.45058287944866 : -64.61049256904235
>> ll2 78.45058287944866 : -39.28681375866812
>> dist 560001.2842969369
>>
>> ll1 80.00703564250523 : -72.75627591971273
>> ll2 80.00703564250523 : -44.61885501929692
>> dist 538243.7455625333
>>
>> ll1 81.49380667414835 : -81.80714630934649
>> ll2 81.49380667414835 : -50.54334530888447
>> dist 508560.6560124746
>>
>> ll1 82.88940754706157 : -91.86366896449512
>> ll2 82.88940754706157 : -57.12611229731509
>> dist 471481.77217010665
>>
>> ll1 84.17434746547553 : -103.03758302577135
>> ll2 84.17434746547553 : -64.44029784001577
>> dist 427995.86036005936
>>
>>
>> Up to a longitude difference of aprox 20 degrees it looks fine.
>>
>> The strange thing is, I copied the calculation to a small test program
>> and feed it with similar data and that worked like expected :-/
>>
>> I think that needs an expert ;-)
>>
>> > Sorry, I just started with JOSM ...
>> Me too (on the code side).
>>
>> > Tried to open a TRAC?
>> I don't like to open a bug with "there is a bug, but i don't know
>> where..."
>>
>> Cheers, detlef
>>
>
> I spot-checked a couple examples that you posted against an online great
> circle calculator and they appear to be correct (assuming your format is II1
> latitude : longitude). Remember that at higher latitudes, one degree of
> longitude is a shorter distance than it is at the equator. So, if the
> greatCircleDistance function is okay, maybe it's the arguments that are
> being passed to the function that need to be checked.
>
> Karl
>
I just had a quick look, and in both occurrences, it appears the distance is
calculated based on the coordinates of a 100 pixel long horizontal line with
its origin at the upper left corner. So, that would make sense why the
distance goes down as you zoom out because the latitude is increasing so the
line is becoming shorter. Probably it should be based on the diagonal
distance of the viewport, or at the least, the origin of the 100-pixel line
should be at the center of the viewport.
Karl
More information about the josm-dev
mailing list