How to use the gpxpy.geo 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
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
def simplify(self, max_distance=None):
        """
        Simplify using the Ramer-Douglas-Peucker algorithm: http://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm
        """
        if not max_distance:
            max_distance = 10

        self.points = mod_geo.simplify_polyline(self.points, max_distance)
github tkrajina / gpxpy / gpxpy / gpx.py View on Github external
segment. If elevation for some points is not found those are simply
        ignored.

        Returns
        -------
        uphill_downhill: UphillDownhill named tuple
            uphill: float
                Uphill elevation climbs in meters
            downhill: float
                Downhill elevation descent in meters
        """
        if not self.points:
            return UphillDownhill(0, 0)

        elevations = list(map(lambda point: point.elevation, self.points))
        uphill, downhill = mod_geo.calculate_uphill_downhill(elevations)

        return UphillDownhill(uphill, downhill)
github tkrajina / gpxpy / gpxpy / gpx.py View on Github external
def _find_next_simplified_point(self, pos, max_distance):
        for candidate in range(pos + 1, len(self.points) - 1):
            for i in range(pos + 1, candidate):
                d = mod_geo.distance_from_line(self.points[i],
                                               self.points[pos],
                                               self.points[candidate])
                if d > max_distance:
                    return candidate - 1
        return None
github tkrajina / gpxpy / gpxpy / gpx.py View on Github external
def length(self):
        """
        Computes length (2-dimensional) of route.

        Returns:
        -----------
        length: float
            Length returned in meters
        """
        return mod_geo.length_2d(self.points)
github rubenvereecken / pokemongo-api / pogo / location.py View on Github external
def getDistance(*coords):
        return gpxpy.geo.haversine_distance(*coords)
github tkrajina / gpxpy / gpxpy / gpx.py View on Github external
speed_kmh = (distance / 1000.) / (mod_utils.total_seconds(timedelta) / 60. ** 2)

                #print speed, stopped_speed_threshold
                if speed_kmh <= stopped_speed_threshold:
                    stopped_time += mod_utils.total_seconds(timedelta)
                    stopped_distance += distance
                else:
                    moving_time += mod_utils.total_seconds(timedelta)
                    moving_distance += distance

                    if distance and moving_time:
                        speeds_and_distances.append((distance / mod_utils.total_seconds(timedelta), distance, ))

        max_speed = None
        if speeds_and_distances:
            max_speed = mod_geo.calculate_max_speed(speeds_and_distances)

        return MovingData(moving_time, stopped_time, moving_distance, stopped_distance, max_speed)
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.link_type = None
        self.symbol = symbol
        self.type = type
github tkrajina / gpxpy / gpxpy / gpx.py View on Github external
def length_3d(self):
        """
        Computes 3-dimensional length of segment (latitude, longitude, and
        elevation).

        Returns
        ----------
        length : float
            Length returned in meters
        """
        return mod_geo.length_3d(self.points)