How to use the gpxpy.geo.Location function in gpxpy

To help you get started, we’ve selected a few gpxpy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tkrajina / gpxpy / gpxpy / gpx.py View on Github external
def __init__(self, latitude=None, longitude=None, elevation=None, time=None, name=None,
                 description=None, symbol=None, type=None, comment=None,
                 horizontal_dilution=None, vertical_dilution=None,
                 position_dilution=None):

        mod_geo.Location.__init__(self, latitude, longitude, elevation)
        self.latitude = latitude
        self.longitude = longitude
        self.elevation = elevation
        self.time = time
        self.magnetic_variation = None
        self.geoid_height = None
        self.name = name
        self.comment = comment
        self.description = description
        self.source = None
        self.link = None
        self.link_text = None
        self.symbol = symbol
        self.type = type
        self.type_of_gpx_fix = None
        self.satellites = None
github tkrajina / gpxpy / gpxpy / gpx.py View on Github external
"""
        if not self.segments:
            return None
        sum_lat = 0
        sum_lon = 0
        n = 0
        for track_segment in self.segments:
            for point in track_segment.points:
                n += 1.
                sum_lat += point.latitude
                sum_lon += point.longitude

        if not n:
            return mod_geo.Location(float(0), float(0))

        return mod_geo.Location(latitude=sum_lat / n, longitude=sum_lon / n)
github tkrajina / gpxpy / gpxpy / geo.py View on Github external
def __add__(self, location_delta):
        latitude, longitude = location_delta.move(self)
        return Location(latitude, longitude)
github tkrajina / gpxpy / gpxpy / gpx.py View on Github external
return None

        if not self.points:
            return None

        sum_lat = 0.
        sum_lon = 0.
        n = 0.

        for point in self.points:
            n += 1.
            sum_lat += point.latitude
            sum_lon += point.longitude

        if not n:
            return mod_geo.Location(float(0), float(0))

        return mod_geo.Location(latitude=sum_lat / n, longitude=sum_lon / n)
github tkrajina / gpxpy / gpxpy / gpx.py View on Github external
LocationDelta to move each point
        """
        for route_point in self.points:
            route_point.move(location_delta)

    def __repr__(self):
        representation = ''
        for attribute in 'name', 'description', 'number':
            value = getattr(self, attribute)
            if value is not None:
                representation += '%s%s=%s' % (', ' if representation else '', attribute, repr(value))
        representation += '%spoints=[%s])' % (', ' if representation else '', '...' if self.points else '')
        return 'GPXRoute(%s)' % representation


class GPXTrackPoint(mod_geo.Location):
    gpx_10_fields = GPX_TRACK_POINT_FIELDS
    gpx_11_fields = GPX_11_POINT_FIELDS

    __slots__ = ('latitude', 'longitude', 'elevation', 'time', 'course',
                 'speed', 'magnetic_variation', 'geoid_height', 'name',
                 'comment', 'description', 'source', 'link', 'link_text',
                 'symbol', 'type', 'type_of_gpx_fix', 'satellites',
                 'horizontal_dilution', 'vertical_dilution',
                 'position_dilution', 'age_of_dgps_data', 'dgps_id',
                 'link_type', 'extensions')

    def __init__(self, latitude=None, longitude=None, elevation=None, time=None, symbol=None, comment=None,
                 horizontal_dilution=None, vertical_dilution=None, position_dilution=None, speed=None,
                 name=None):
        mod_geo.Location.__init__(self, latitude, longitude, elevation)
        self.latitude = latitude
github tkrajina / gpxpy / gpxpy / gpx.py View on Github external
def __iter__(self):
        return (self.min_latitude, self.max_latitude, self.min_longitude, self.max_longitude,).__iter__()


class GPXXMLSyntaxException(GPXException):
    """
    Exception used when the XML syntax is invalid.

    The __cause__ can be a minidom or lxml exception (See http://www.python.org/dev/peps/pep-3134/).
    """
    def __init__(self, message, original_exception):
        GPXException.__init__(self, message)
        self.__cause__ = original_exception


class GPXWaypoint(mod_geo.Location):
    gpx_10_fields = GPX_10_POINT_FIELDS
    gpx_11_fields = GPX_11_POINT_FIELDS

    __slots__ = ('latitude', 'longitude', 'elevation', 'time',
                 'magnetic_variation', 'geoid_height', 'name', 'comment',
                 'description', 'source', 'link', 'link_text', 'symbol',
                 'type', 'type_of_gpx_fix', 'satellites',
                 'horizontal_dilution', 'vertical_dilution',
                 'position_dilution', 'age_of_dgps_data', 'dgps_id',
                 'link_type', 'extensions')

    def __init__(self, latitude=None, longitude=None, elevation=None, time=None,
                 name=None, description=None, symbol=None, type=None,
                 comment=None, horizontal_dilution=None, vertical_dilution=None,
                 position_dilution=None):
        mod_geo.Location.__init__(self, latitude, longitude, elevation)
github tkrajina / gpxpy / gpxpy / gpx.py View on Github external
"""
        if self.time:
            self.time += delta

    def remove_time(self):
        """ Will remove time metadata. """
        self.time = None

    def get_max_dilution_of_precision(self):
        """
        Only care about the max dop for filtering, no need to go into too much detail
        """
        return max(self.horizontal_dilution, self.vertical_dilution, self.position_dilution)


class GPXRoutePoint(mod_geo.Location):
    gpx_10_fields = GPX_10_POINT_FIELDS
    gpx_11_fields = GPX_11_POINT_FIELDS

    __slots__ = ('latitude', 'longitude', 'elevation', 'time',
                 'magnetic_variation', 'geoid_height', 'name', 'comment',
                 'description', 'source', 'link', 'link_text', 'symbol',
                 'type', 'type_of_gpx_fix', 'satellites',
                 'horizontal_dilution', 'vertical_dilution',
                 'position_dilution', 'age_of_dgps_data', 'dgps_id',
                 'link_type', 'extensions')

    def __init__(self, latitude=None, longitude=None, elevation=None, time=None, name=None,
                 description=None, symbol=None, type=None, comment=None,
                 horizontal_dilution=None, vertical_dilution=None,
                 position_dilution=None):