﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
17972	Wrong row/col being calculated in HgtReader.java due to incorrect conversion of decimal degrees to arc seconds.	(wish to remain anonymous to the public!) <tfehlhab@…>	OliverW	"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:

{{{
#!java
        // 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.

"	defect	new	major		Plugin elevationprofile			hgt srtm	
