Пример #1
0
    def test_polyline6_3d_decoding_latlng(self):

        decoded = [(49.420577, 8.688641, 120.96),
                   (49.415776, 8.680916, 1491.39)]
        self.assertEqual(
            decoded,
            utils.decode_polyline6(self.coords3d_6prec, True, order="latlng"))
Пример #2
0
 def _parse_geometry(route_geometry):
     if geometry_format in (None, 'polyline'):
         geometry = utils.decode_polyline5(route_geometry, is3d=False)
     elif geometry_format == 'polyline6':
         geometry = utils.decode_polyline6(route_geometry, is3d=False)
     elif geometry_format == 'geojson':
         geometry = route_geometry['coordinates']
     else:
         raise ValueError(
             "OSRM: parameter geometries needs one of ['polyline', 'polyline6', 'geojson"
         )
     return geometry
Пример #3
0
    def _parse_direction_json(response, units):
        if response is None:  # pragma: no cover
            return Direction()

        geometry, duration, distance = [], 0, 0
        for leg in response['trip']['legs']:
            geometry.extend([list(reversed(coord)) for coord in utils.decode_polyline6(leg['shape'])])
            duration += leg['summary']['time']

            factor = 0.621371 if units == 'mi' else 1
            distance += int(leg['summary']['length'] * 1000 * factor)

        return Direction(geometry=geometry, duration=int(duration), distance=int(distance), raw=response)
Пример #4
0
    def test_polyline6_3d_decoding(self):

        decoded = [(8.688641, 49.420577, 120.96), (8.680916, 49.415776,
                                                   1491.39)]
        self.assertEqual(decoded,
                         utils.decode_polyline6(self.coords3d_6prec, True))
Пример #5
0
    def test_polyline6_2d_decoding(self):

        decoded = [(8.688641, 49.420577), (8.680916, 49.415776)]
        self.assertEqual(decoded, utils.decode_polyline6(self.coords2d_6prec))