How to use the routingpy.isochrone.Isochrones 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_heremaps.py View on Github external
'https://isoline.route.api.here.com/routing/7.2/calculateisoline.json',
            status=200,
            json=ENDPOINTS_RESPONSES[self.name]['isochrones'],
            content_type='application/json'
        )

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

        self.assertEqual(1, len(responses.calls))
        self.assertURLEqual(
            'https://isoline.route.api.here.com/routing/7.2/calculateisoline.json?app_code=sample_app_code&'
            'app_id=sample_app_id&mode=fastest%3Bcar&quality=1&range=1000%2C2000%2C3000&rangeType=distance&'
            'singleComponent=false&start=geo%2148.23424%2C8.34234', responses.calls[0].request.url
        )

        self.assertIsInstance(isochrones, Isochrones)
        self.assertEqual(3, len(isochrones))
        for iso in isochrones:
            self.assertIsInstance(iso, Isochrone)
            self.assertIsInstance(iso.geometry, list)
            self.assertIsInstance(iso.center, list)
            self.assertIsInstance(iso.interval, int)
github gis-ops / routing-py / tests / test_mapbox_osrm.py View on Github external
convert._delimit_list(query["locations"]),
            ),
            status=200,
            json=ENDPOINTS_RESPONSES[self.name]['isochrones'],
            content_type='application/json'
        )

        iso = self.client.isochrones(**query)

        self.assertEqual(1, len(responses.calls))
        self.assertURLEqual(
            'https://api.mapbox.com/isochrone/v1/mapbox/driving/8.34234,48.23424?costing=mapbox/driving&access_token=sample_key&'
            'contours_colors=ff0000%2C00FF00&contours_minutes=10%2C20&denoise=0.1&generalize=0.5&polygons=True',
            responses.calls[0].request.url
        )
        self.assertIsInstance(iso, Isochrones)
        self.assertEqual(2, len(iso))
        for ischrone in iso:
            self.assertIsInstance(ischrone, Isochrone)
            self.assertIsInstance(ischrone.geometry, list)
            self.assertIsInstance(ischrone.interval, int)
            self.assertIsInstance(ischrone.center, list)
github gis-ops / routing-py / routingpy / routers / heremaps.py View on Github external
def _parse_isochrone_json(response, intervals):
        if response is None:  # pragma: no cover
            return Isochrones()

        geometries = []
        for idx, isochrones in enumerate(response['response']['isoline']):
            range_polygons = []
            if 'component' in isochrones:
                for component in isochrones['component']:
                    if 'shape' in component:
                        coordinates_list = []
                        for coordinates in component['shape']:
                            coordinates_list.append([float(f) for f in coordinates.split(",")])
                        range_polygons.append(coordinates_list)

            geometries.append(
                Isochrone(
                    geometry=range_polygons,
                    interval=intervals[idx],
github gis-ops / routing-py / routingpy / routers / valhalla.py View on Github external
def _parse_isochrone_json(response, intervals, center):
        if response is None:  # pragma: no cover
            return Isochrones()

        return Isochrones(
            [
                Isochrone(
                    geometry=isochrone['geometry']['coordinates'],
                    interval=intervals[idx],
                    center=center
                ) for idx, isochrone in enumerate(list(reversed(response['features'])))
            ], response
        )
github gis-ops / routing-py / routingpy / routers / graphhopper.py View on Github external
if response is None:  # pragma: no cover
            return Isochrones()

        isochrones = []
        accessor = 'polygons' if type == 'json' else 'features'
        for index, polygon in enumerate(response[accessor]):
            isochrones.append(
                Isochrone(
                    geometry=[l[:2] for l in polygon['geometry']['coordinates'][0]
                              ],  # takes in elevation for some reason
                    interval=int(max_range * ((polygon['properties']['bucket'] + 1) / buckets)),
                    center=center,
                )
            )

        return Isochrones(isochrones, response)
github gis-ops / routing-py / routingpy / routers / graphhopper.py View on Github external
def _parse_isochrone_json(response, type, max_range, buckets, center):
        if response is None:  # pragma: no cover
            return Isochrones()

        isochrones = []
        accessor = 'polygons' if type == 'json' else 'features'
        for index, polygon in enumerate(response[accessor]):
            isochrones.append(
                Isochrone(
                    geometry=[l[:2] for l in polygon['geometry']['coordinates'][0]
                              ],  # takes in elevation for some reason
                    interval=int(max_range * ((polygon['properties']['bucket'] + 1) / buckets)),
                    center=center,
                )
            )

        return Isochrones(isochrones, response)
github gis-ops / routing-py / routingpy / routers / openrouteservice.py View on Github external
def _parse_isochrone_json(response):
        if response is None:  # pragma: no cover
            return Isochrones()

        isochrones = []
        for idx, isochrone in enumerate(response['features']):
            isochrones.append(
                Isochrone(
                    geometry=isochrone['geometry']['coordinates'][0],
                    interval=isochrone['properties']['value'],
                    center=isochrone['properties']['center']
                )
            )

        return Isochrones(isochrones=isochrones, raw=response)
github gis-ops / routing-py / routingpy / routers / valhalla.py View on Github external
def _parse_isochrone_json(response, intervals, center):
        if response is None:  # pragma: no cover
            return Isochrones()

        return Isochrones(
            [
                Isochrone(
                    geometry=isochrone['geometry']['coordinates'],
                    interval=intervals[idx],
                    center=center
                ) for idx, isochrone in enumerate(list(reversed(response['features'])))
            ], response
        )