Working with utility functions
Next, we have several utility functions that are used several times throughout the program. All of these, except the functions related to time, have been used in the previous chapters in some form. The ll2m()
function converts latitude and longitude to meters. The world2pixel()
function converts geospatial coordinates to pixel coordinates on our output map image. Then, we have two functions named get_utc_epoch()
and get_local_time()
that convert the UTC time stored in the GPX file to the local time along the route. Finally, we have a haversine distance function and our simple wms function to retrieve the map images:
def ll2m(lat, lon): """Lat/lon to meters""" x = lon * 20037508.34 / 180.0 y = math.log(math.tan((90.0 + lat) * math.pi / 360.0)) / (math.pi / 180.0) y = y * 20037508.34 / 180.0 return (x, y) def world2pixel(x, y, w, h, bbox): """Converts world coordinates ...