import os
from django.contrib.gis.utils import LayerMapping
class GPXMapping(LayerMapping):
def __init__(self, *args, **kwargs):
# Setting this environment variable tells OGR to use the elevation
# attribute as the Z coordinate value on the geometries. See:
# http://www.gdal.org/ogr/drv_gpx.html
os.environ['GPX_ELE_AS_25D'] = 'YES'
super(GPXMapping, self).__init__(*args, **kwargs)
# Unset the environment variable, so it doesn't affect other
# GPX DataSource objects.
os.environ.pop('GPX_ELE_AS_25D')
Comments
Great, thanks for this great recipe. Is there any way to plot it on a GoogleMap widget which seems to only accept LineStrings, or I'm overlooking something ?
Keep up the good work.
#