Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'copyright:copyright_author:copyright_year:copyright_license',
mod_gpxfield.GPXField('copyright_author', attribute='author'),
mod_gpxfield.GPXField('copyright_year', tag='year'),
mod_gpxfield.GPXField('copyright_license', tag='license'),
'/copyright',
'link:@link',
mod_gpxfield.GPXField('link', attribute='href'),
mod_gpxfield.GPXField('link_text', tag='text'),
mod_gpxfield.GPXField('link_type', tag='type'),
'/link',
mod_gpxfield.GPXField('time', type=mod_gpxfield.TIME_TYPE),
mod_gpxfield.GPXField('keywords'),
mod_gpxfield.GPXComplexField('bounds', classs=GPXBounds),
mod_gpxfield.GPXExtensionsField('metadata_extensions', tag='extensions'),
'/metadata',
mod_gpxfield.GPXComplexField('waypoints', classs=GPXWaypoint, tag='wpt', is_list=True),
mod_gpxfield.GPXComplexField('routes', classs=GPXRoute, tag='rte', is_list=True),
mod_gpxfield.GPXComplexField('tracks', classs=GPXTrack, tag='trk', is_list=True),
mod_gpxfield.GPXExtensionsField('extensions', is_list=True),
]
__slots__ = ('version', 'creator', 'name', 'description', 'author_name',
'author_email', 'link', 'link_text', 'time', 'keywords',
'bounds', 'waypoints', 'routes', 'tracks', 'author_link',
'author_link_text', 'author_link_type', 'copyright_author',
'copyright_year', 'copyright_license', 'link_type',
'metadata_extensions', 'extensions', 'nsmap',
'schema_locations')
def __init__(self):
self.version = None
self.creator = None
def end_object(self, trek):
super(TrekGPXSerializer, self).end_object(trek)
for poi in trek.published_pois.all():
geom_3d = poi.geom_3d.transform(4326, clone=True) # GPX uses WGS84
wpt = gpxpy.gpx.GPXWaypoint(latitude=geom_3d.y,
longitude=geom_3d.x,
elevation=geom_3d.z)
wpt.name = u"%s: %s" % (poi.type, poi.name)
wpt.description = poi.description
self.gpx.waypoints.append(wpt)
def _point_to_GPX(self, point, klass=gpxpy.gpx.GPXWaypoint):
if isinstance(point, (tuple, list)):
point = Point(*point, srid=settings.SRID)
newpoint = point.transform(4326, clone=True) # transformation: gps uses 4326
# transform looses the Z parameter
return klass(latitude=newpoint.y, longitude=newpoint.x, elevation=point.z)
def _point_to_GPX(self, point, klass=gpxpy.gpx.GPXWaypoint):
if isinstance(point, (tuple, list)):
point = Point(*point, srid=settings.SRID)
newpoint = point.transform(4326, clone=True) # transformation: gps uses 4326
# transform looses the Z parameter
return klass(latitude=newpoint.y, longitude=newpoint.x, elevation=point.z)
def _point_to_GPX(self, point, klass=gpxpy.gpx.GPXWaypoint):
if isinstance(point, (tuple, list)):
point = Point(*point, srid=settings.SRID)
x, y = point.transform(4326, clone=True) # transformation: gps uses 4326
z = point.z # transform looses the Z parameter
return klass(latitude=y, longitude=x, elevation=z)