User talk:Travelling salesman/gpx reduce

From OpenStreetMap Wiki
Jump to: navigation, search


thanks for the script. Very useful I am currently working through half a gb of tracks from my bike journey. I used your code and adapted it for kml-files, since those work better with google earth. I stumbled across something I don't get (wether in the new nor the old version)

def latlonele_to_xyz(lat, lon, ele):
     s = sin(radians(lat))
     c = cos(radians(lat))
     r = ele + a * b / norm([s*a, c*b])
     lon = radians(lon)
     return r * c * sin(lon), r * c * (-cos(lon)), r * s

shouldn't that be like the following?

lat = radians(lat)
lon = radians(lon)
r = "seem right"
return r*sin(lat)*cos(lon), r*sin(lat)*sin(lon), r*cos(lat)

compared to yours written out:

return r*cos(lat)*sin(lon), r*cos(lat)*(-cos(lon)), r*sin(lat)

I took reference in in which case lat would be omega and lon would be phi.

Although this may be outdated...: The formula you quoted is correct for standard spherical coordinates where theta starts from the north pole. However in geographic coordinates, which I applied, the latitude is measured from the equator. --Travelling salesman (talk) 17:02, 24 May 2016 (UTC)