How to use the routingpy.Google.WayPoint function in routingpy

To help you get started, we’ve selected a few routingpy 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 gis-ops / routing-py / tests / test_google.py View on Github external
)

        directions = self.client.directions(**query)

        self.assertEqual(1, len(responses.calls))
        self.assertURLEqual(
            'https://maps.googleapis.com/maps/api/directions/json?alternatives=true&arrival_time=1567512000&'
            'avoid=tolls%7Cferries&destination=49.420577%2C8.688641&key=sample_key&language=de&'
            'origin=49.415776%2C8.680916&profile=driving&region=de&traffic_model=optimistic&transit_mode=bus%7Crail&t'
            'ransit_routing_preference=less_walking&units=metrics&waypoints=optimize%3Atrue%7Cvia%3Aenc%3Aosazgqo%40%2F%40%3A%7C49.415776%2C8.680916%7C'
            'via%3Aplace_id%3AEiNNYXJrdHBsLiwgNjkxMTcgSGVpZGVsYmVyZywgR2VybWFueSIuKiwKFAoSCdubgq0HwZdHEdclR2bm32EmEhQKEgmTG6mCBsGXRxF38ZZ8m5j3VQ',
            responses.calls[0].request.url
        )

        # Test if 'bla' triggers a ValueError
        query['locations'].insert(1, Google.WayPoint(PARAM_LINE_MULTI[0], 'bla', True))

        with self.assertRaises(ValueError):
            matrix = self.client.directions(**query)

        # Test if origin=WayPoint triggers a TypeError
        query['coordinates'] = [
            Google.WayPoint('osazgqo@/@', 'enc', False),
            Google.WayPoint(PARAM_LINE_MULTI[1], 'coords', True),
        ]

        with self.assertRaises(TypeError):
            self.client.directions(**query)
github gis-ops / routing-py / tests / test_google.py View on Github external
def test_waypoint_generator_matrix(self):
        query = ENDPOINTS_QUERIES[self.name]['matrix']
        query['locations'] = [
            PARAM_LINE_MULTI[1],
            Google.WayPoint('osazgqo@/@', 'enc', False),
            Google.WayPoint(PARAM_LINE_MULTI[1], 'coords', True),
            Google.WayPoint(
                'EiNNYXJrdHBsLiwgNjkxMTcgSGVpZGVsYmVyZywgR2VybWFueSIuKiwKFAoSCdubgq0HwZdHEdclR2bm32EmEhQKEgmTG6mCBsGXRxF38ZZ8m5j3VQ',
                'place_id', False
            ),
            PARAM_LINE_MULTI[0],
        ]

        responses.add(
            responses.GET,
            'https://maps.googleapis.com/maps/api/distancematrix/json',
            status=200,
            json=ENDPOINTS_RESPONSES[self.name]['matrix'],
            content_type='application/json'
        )

        matrix = self.client.matrix(**query)
github gis-ops / routing-py / tests / test_google.py View on Github external
def test_waypoint_generator_matrix(self):
        query = ENDPOINTS_QUERIES[self.name]['matrix']
        query['locations'] = [
            PARAM_LINE_MULTI[1],
            Google.WayPoint('osazgqo@/@', 'enc', False),
            Google.WayPoint(PARAM_LINE_MULTI[1], 'coords', True),
            Google.WayPoint(
                'EiNNYXJrdHBsLiwgNjkxMTcgSGVpZGVsYmVyZywgR2VybWFueSIuKiwKFAoSCdubgq0HwZdHEdclR2bm32EmEhQKEgmTG6mCBsGXRxF38ZZ8m5j3VQ',
                'place_id', False
            ),
            PARAM_LINE_MULTI[0],
        ]

        responses.add(
            responses.GET,
            'https://maps.googleapis.com/maps/api/distancematrix/json',
            status=200,
            json=ENDPOINTS_RESPONSES[self.name]['matrix'],
            content_type='application/json'
        )

        matrix = self.client.matrix(**query)
github gis-ops / routing-py / tests / test_google.py View on Github external
'avoid=tolls%7Cferries&destination=49.420577%2C8.688641&key=sample_key&language=de&'
            'origin=49.415776%2C8.680916&profile=driving&region=de&traffic_model=optimistic&transit_mode=bus%7Crail&t'
            'ransit_routing_preference=less_walking&units=metrics&waypoints=optimize%3Atrue%7Cvia%3Aenc%3Aosazgqo%40%2F%40%3A%7C49.415776%2C8.680916%7C'
            'via%3Aplace_id%3AEiNNYXJrdHBsLiwgNjkxMTcgSGVpZGVsYmVyZywgR2VybWFueSIuKiwKFAoSCdubgq0HwZdHEdclR2bm32EmEhQKEgmTG6mCBsGXRxF38ZZ8m5j3VQ',
            responses.calls[0].request.url
        )

        # Test if 'bla' triggers a ValueError
        query['locations'].insert(1, Google.WayPoint(PARAM_LINE_MULTI[0], 'bla', True))

        with self.assertRaises(ValueError):
            matrix = self.client.directions(**query)

        # Test if origin=WayPoint triggers a TypeError
        query['coordinates'] = [
            Google.WayPoint('osazgqo@/@', 'enc', False),
            Google.WayPoint(PARAM_LINE_MULTI[1], 'coords', True),
        ]

        with self.assertRaises(TypeError):
            self.client.directions(**query)
github gis-ops / routing-py / tests / test_google.py View on Github external
def test_waypoint_generator_directions(self):
        query = deepcopy(ENDPOINTS_QUERIES[self.name]['directions'])
        query['locations'] = [
            PARAM_LINE_MULTI[1],
            Google.WayPoint('osazgqo@/@', 'enc', False),
            Google.WayPoint(PARAM_LINE_MULTI[1], 'coords', True),
            Google.WayPoint(
                'EiNNYXJrdHBsLiwgNjkxMTcgSGVpZGVsYmVyZywgR2VybWFueSIuKiwKFAoSCdubgq0HwZdHEdclR2bm32EmEhQKEgmTG6mCBsGXRxF38ZZ8m5j3VQ',
                'place_id', False
            ),
            PARAM_LINE_MULTI[0],
        ]
        query['optimize'] = True

        responses.add(
            responses.GET,
            'https://maps.googleapis.com/maps/api/directions/json',
            status=200,
            json=ENDPOINTS_RESPONSES[self.name]['directions'],
            content_type='application/json'
        )

        directions = self.client.directions(**query)
github gis-ops / routing-py / tests / test_google.py View on Github external
'origin=49.415776%2C8.680916&profile=driving&region=de&traffic_model=optimistic&transit_mode=bus%7Crail&t'
            'ransit_routing_preference=less_walking&units=metrics&waypoints=optimize%3Atrue%7Cvia%3Aenc%3Aosazgqo%40%2F%40%3A%7C49.415776%2C8.680916%7C'
            'via%3Aplace_id%3AEiNNYXJrdHBsLiwgNjkxMTcgSGVpZGVsYmVyZywgR2VybWFueSIuKiwKFAoSCdubgq0HwZdHEdclR2bm32EmEhQKEgmTG6mCBsGXRxF38ZZ8m5j3VQ',
            responses.calls[0].request.url
        )

        # Test if 'bla' triggers a ValueError
        query['locations'].insert(1, Google.WayPoint(PARAM_LINE_MULTI[0], 'bla', True))

        with self.assertRaises(ValueError):
            matrix = self.client.directions(**query)

        # Test if origin=WayPoint triggers a TypeError
        query['coordinates'] = [
            Google.WayPoint('osazgqo@/@', 'enc', False),
            Google.WayPoint(PARAM_LINE_MULTI[1], 'coords', True),
        ]

        with self.assertRaises(TypeError):
            self.client.directions(**query)
github gis-ops / routing-py / tests / test_google.py View on Github external
def test_waypoint_generator_matrix(self):
        query = ENDPOINTS_QUERIES[self.name]['matrix']
        query['locations'] = [
            PARAM_LINE_MULTI[1],
            Google.WayPoint('osazgqo@/@', 'enc', False),
            Google.WayPoint(PARAM_LINE_MULTI[1], 'coords', True),
            Google.WayPoint(
                'EiNNYXJrdHBsLiwgNjkxMTcgSGVpZGVsYmVyZywgR2VybWFueSIuKiwKFAoSCdubgq0HwZdHEdclR2bm32EmEhQKEgmTG6mCBsGXRxF38ZZ8m5j3VQ',
                'place_id', False
            ),
            PARAM_LINE_MULTI[0],
        ]

        responses.add(
            responses.GET,
            'https://maps.googleapis.com/maps/api/distancematrix/json',
            status=200,
            json=ENDPOINTS_RESPONSES[self.name]['matrix'],
            content_type='application/json'
        )