Opened 6 years ago
Last modified 6 years ago
#17972 new defect
Wrong row/col being calculated in HgtReader.java due to incorrect conversion of decimal degrees to arc seconds.
Reported by: | Owned by: | OliverW | |
---|---|---|---|
Priority: | major | Milestone: | |
Component: | Plugin elevationprofile | Version: | |
Keywords: | hgt srtm | Cc: |
Description (last modified by )
Sorry if I'm mistaken and this is not really a bug, but it sure looks incorrect to me...
In Hgtreader.java, in the elevationprofile plugin, file: josm-plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/HgtReader.java,
there appears to be an error.
Here are the suspected lines:
// see http://gis.stackexchange.com/questions/43743/how-to-extract-elevation-from-hgt-file double fLat = frac(coor.lat()) * 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 LatLon.java 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 by , 6 years ago
Description: | modified (diff) |
---|---|
Keywords: | hgt srtm added; HgtReader removed |