Opened 12 months ago

Last modified 11 months ago

#17972 new defect

Wrong row/col being calculated in due to incorrect conversion of decimal degrees to arc seconds.

Reported by: (wish to remain anonymous to the public!) <tfehlhab@…> Owned by: OliverW
Priority: major Milestone:
Component: Plugin elevationprofile Version:
Keywords: hgt srtm Cc:

Description (last modified by Don-vip)

Sorry if I'm mistaken and this is not really a bug, but it sure looks incorrect to me...

In, in the elevationprofile plugin, file: josm-plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/,
there appears to be an error.

Here are the suspected lines:

        // see
        double fLat = frac( * SECONDS_PER_MINUTE;
        double fLon = frac(coor.lon()) * SECONDS_PER_MINUTE;

        // compute offset within HGT file
        int row = (int) Math.round(fLat * SECONDS_PER_MINUTE / HGT_RES);
        int col = (int) Math.round(fLon * SECONDS_PER_MINUTE / HGT_RES);

Why are you using "SECONDS_PER_MINUTE"? lat/lons are in decimal degrees, right? So, you want to take the fractional part of the lat (or lon) and convert that to seconds. The link you referenced in the comment is converting to arc seconds. I believe you are using the wrong unit conversion. Instead of using "SECONDS_PER_MINUTE" you want to use "SECONDS_PER_DEGREE" (which is 3600).

Unless the lat/lons are in the format of "DD.mmmmmm", but that is not what your comments in would lead one to believe. "DD.mmmmmm" doesn't really make sense, anyway. If you meant to have lat/lons in "Degrees and Decimal Minutes", the format would be: DDD° MM.MMM'

Again, sorry if I'm mistaken.

Attachments (0)

Change History (1)

comment:1 Changed 11 months ago by Don-vip

Description: modified (diff)
Keywords: hgt srtm added; HgtReader removed

Modify Ticket

Change Properties
Set your email in Preferences
as new The owner will remain OliverW.
as The resolution will be set.
to The owner will be changed from OliverW to the specified user.
The owner will change to (wish to remain anonymous to the public!) <>
as duplicate The resolution will be set to duplicate.The specified ticket will be cross-referenced with this ticket
The owner will be changed from OliverW to anonymous.

Add Comment

E-mail address and name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.