routingpy icon indicating copy to clipboard operation
routingpy copied to clipboard

HereMaps Isochrones returning faulty geometry

Open chrstnbwnkl opened this issue 4 years ago • 0 comments

Here's what I did

from shapely.geometry import Polygon
from routingpy import get_router_by_name

api = get_router_by_name("heremaps")(api_key)

location = [13.479801753996686, 52.55725875370285]

isochrones = api.isochrones(location, profile="car", intervals=[300,600])

geometries = []
for isochrone in isochrones:
    geometries.append(Polygon(isochrone.geometry))

Here's what I got

  • Shapely's Polygon instantiation causes an `AttributeError´: 'list' object has no attribute 'array_interface'

Here's what I was expecting

A list of Polygons


Here's what I think could be improved

Since HereMaps is the only router having that problem, the bug is likely to be caused by the response parsing. It seems like the geometry is wrapped one too many times into a list, because

geometries.append(Polygon(isochrone.geometry[0])) 

produces the desired result.

chrstnbwnkl avatar Jun 25 '21 08:06 chrstnbwnkl