Skip to content

Isoline Routing API

IsolineRoutingApi

Bases: HEREApi

A python interface into the HERE Isoline Routing API

Source code in herepy/isoline_routing_api.py
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
class IsolineRoutingApi(HEREApi):
    """A python interface into the HERE Isoline Routing API"""

    def __init__(self, api_key: str = None, timeout: int = None):
        """Returns a IsolineRoutingApi instance.
        Args:
          api_key (str):
            API key taken from HERE Developer Portal.
          timeout (int):
            Timeout limit for requests.
        """

        super(IsolineRoutingApi, self).__init__(api_key, timeout)
        self._base_url = "https://isoline.router.hereapi.com/v8/isolines"

    def __get_error_from_response(self, json_data):
        if "error" in json_data:
            if json_data["error"] == "Unauthorized":
                return UnauthorizedError(json_data["error_description"])
        error_type = json_data.get("Type")
        error_message = json_data.get(
            "Message", "Error occurred on " + sys._getframe(1).f_code.co_name
        )
        if error_type == "Invalid Request":
            return InvalidRequestError(error_message)
        else:
            return HEREError(error_message)

    def __get_client_error_from_response(self, json_data):
        if "title" in json_data and "cause" in json_data:
            return HEREError(
                "Error on client: "
                + json_data["title"]
                + " cause: "
                + json_data["cause"]
            )
        else:
            return HEREError("herepy got a 400 from isoline router API")

    def __get(self, url, data, json_key):
        url = Utils.build_url(url, extra_params=data)
        response = requests.get(url, timeout=self._timeout)
        json_data = json.loads(response.content.decode("utf8"))
        if json_data.get(json_key) != None and json_data.get("isolines") != None:
            return IsolineRoutingResponse.new_from_jsondict(
                json_data, param_defaults={json_key: None, "isolines": None}
            )
        elif response.status_code == 400:
            error = self.__get_client_error_from_response(json_data=json_data)
            raise error
        else:
            error = self.__get_error_from_response(json_data)
            raise error

    def distance_based_isoline(
        self,
        transport_mode: IsolineRoutingTransportMode,
        origin: List[float],
        ranges: List[int],
        routing_mode: IsolineRoutingMode,
    ) -> Optional[IsolineRoutingResponse]:
        """A distance-based isoline, also called an Isodistance,
        can be requested using range[type]=distance and providing range[values] in meters.
        Args:
          transport_mode (IsolineRoutingTransportMode):
            Transport mode of routing.
          origin (List):
            List including latitude and longitude in order.
          ranges (List):
            List of range values for isoline (in meters).
          routing_mode (IsolineRoutingMode):
            Isoline routing mode.
        Returns:
          IsolineRoutingResponse
        Raises:
          HEREError"""

        string_ranges = [str(int) for int in ranges]
        data = {
            "transportMode": transport_mode.__str__(),
            "origin": str.format("{0},{1}", origin[0], origin[1]),
            "range[type]": IsolineRoutingRangeType.distance.__str__(),
            "range[values]": ",".join(string_ranges),
            "routingMode": routing_mode.__str__(),
            "apiKey": self._api_key,
        }
        return self.__get(self._base_url, data, "departure")

    def time_isoline(
        self,
        transport_mode: IsolineRoutingTransportMode,
        origin: List[float],
        ranges: List[int],
    ) -> Optional[IsolineRoutingResponse]:
        """A time-based isoline, also called an Isochrone,
        can be requested by using range[type]=time and providing range[values] in seconds.
        Args:
          transport_mode (IsolineRoutingTransportMode):
            Transport mode of routing.
          origin (List):
            List including latitude and longitude in order.
          ranges (List):
            List of range values for isoline (in meters).
        Returns:
          IsolineRoutingResponse
        Raises:
          HEREError"""

        string_ranges = [str(int) for int in ranges]
        data = {
            "transportMode": transport_mode.__str__(),
            "origin": str.format("{0},{1}", origin[0], origin[1]),
            "range[type]": IsolineRoutingRangeType.time.__str__(),
            "range[values]": ",".join(string_ranges),
            "apiKey": self._api_key,
        }
        return self.__get(self._base_url, data, "departure")

    def isoline_based_on_consumption(
        self,
        origin: List[float],
        ranges: List[int],
        transport_mode: IsolineRoutingTransportMode,
        free_flow_speed_table: List[float],
        traffic_speed_table: List[float],
        ascent: int,
        descent: float,
        auxiliary_consumption: float,
    ):
        """Electric vehicles have a limited reachable range based on their current battery
        charge and factors affecting the rate of energy consumed, such as road slope or auxiliary
        power usage. Therefore, it is useful to visualize the appropriate range to avoid running
        out of energy before reaching a charging point.
        Args:
          transport_mode (IsolineRoutingTransportMode):
            Transport mode of routing.
          origin (List):
            List including latitude and longitude in order.
          ranges (List):
            List of range values for isoline (in meters).
          transport_mode (IsolineRoutingTransportMode):
            Transport mode of routing.
          free_flow_speed_table (List[float]):
            Free flow speed table.
          traffic_speed_table (List[float]):
            Traffic speed table.
          ascent (int):
            Int value of ascent.
          descent (float):
            Value of descent.
          auxiliary_consumption (float):
            Auxiliary consumption.
        Returns:
          IsolineRoutingResponse
        Raises:
          HEREError"""

        string_ranges = [str(int) for int in ranges]

        free_speed_table = [0]
        free_speed_table.extend(free_flow_speed_table)
        free_speed_table_str = ",".join([str(n) for n in free_speed_table])

        speed_table = [0]
        speed_table.extend(traffic_speed_table)
        speed_table_str = ",".join([str(n) for n in speed_table])

        data = {
            "origin": str.format("{0},{1}", origin[0], origin[1]),
            "range[type]": IsolineRoutingRangeType.consumption.__str__(),
            "range[values]": ",".join(string_ranges),
            "transportMode": transport_mode.__str__(),
            "ev[freeFlowSpeedTable]": free_speed_table_str,
            "ev[trafficSpeedTable]": speed_table_str,
            "ev[ascent]": ascent,
            "ev[descent]": descent,
            "ev[auxiliaryConsumption]": auxiliary_consumption,
            "apiKey": self._api_key,
        }
        return self.__get(self._base_url, data, "departure")

    def isoline_routing_at_specific_time(
        self,
        transport_mode: IsolineRoutingTransportMode,
        ranges: List[int],
        origin: Optional[List[float]] = None,
        departure_time: Optional[str] = None,
        destination: Optional[List[float]] = None,
        arrival_time: Optional[str] = None,
    ):
        """To calculate an isoline around an origin with a specific time, use departureTime.
        For a reverse isoline, that is, when using destination, you can use arrivalTime.
        If departureTime or arrivalTime are specified as "any", the isoline calculation will
        not take traffic flow and other time-dependent effects into account. This can be useful
        when it is not certain for what time of the day the isoline needs to be computed.
        Args:
          transport_mode (IsolineRoutingTransportMode):
            Transport mode of routing.
          ranges (List):
            List of range values for isoline (in meters).
          origin (List):
            List including latitude and longitude in order.
          departure_time (str):
            Departure time of the routing in format yyyy-MM-ddThh:mm:ss.
          destination (List):
            List including latitude and longitude in order.
          arrival_time (str):
            Arrival time of the planned routing in format yyyy-MM-ddThh:mm:ss.
        Returns:
          IsolineRoutingResponse
        Raises:
          HEREError"""

        string_ranges = [str(int) for int in ranges]
        if origin and departure_time:
            data = {
                "transportMode": transport_mode.__str__(),
                "origin": str.format("{0},{1}", origin[0], origin[1]),
                "departureTime": departure_time,
                "range[type]": IsolineRoutingRangeType.time.__str__(),
                "range[values]": ",".join(string_ranges),
                "apiKey": self._api_key,
            }
            return self.__get(self._base_url, data, "departure")
        elif destination and arrival_time:
            data = {
                "transportMode": transport_mode.__str__(),
                "destination": str.format("{0},{1}", destination[0], destination[1]),
                "arrivalTime": arrival_time,
                "range[type]": IsolineRoutingRangeType.time.__str__(),
                "range[values]": ",".join(string_ranges),
                "apiKey": self._api_key,
            }
            return self.__get(self._base_url, data, "arrival")
        else:
            raise HEREError(
                "Please provide either origin & departure_time or destination & arrival_time."
            )

    def multi_range_routing(
        self,
        transport_mode: IsolineRoutingTransportMode,
        ranges: List[int],
        origin: Optional[List[float]] = None,
        destination: Optional[List[float]] = None,
    ):
        """Isoline routing can be requested with multiple ranges which allows for the calculation
        of many isolines with the same start or destination.
        Args:
          transport_mode (IsolineRoutingTransportMode):
            Transport mode of routing.
          ranges (List):
            Range values for isoline routing.
          origin (List):
            List including latitude and longitude in order.
          destination (List):
            List including latitude and longitude in order.
        Returns:
          IsolineRoutingResponse
        Raises:
          HEREError"""

        string_ranges = [str(int) for int in ranges]
        if origin:
            data = {
                "transportMode": transport_mode.__str__(),
                "origin": str.format("{0},{1}", origin[0], origin[1]),
                "range[type]": IsolineRoutingRangeType.distance.__str__(),
                "range[values]": ",".join(string_ranges),
                "apiKey": self._api_key,
            }
            return self.__get(self._base_url, data, "departure")
        elif destination:
            data = {
                "transportMode": transport_mode.__str__(),
                "destination": str.format("{0},{1}", destination[0], destination[1]),
                "range[type]": IsolineRoutingRangeType.distance.__str__(),
                "range[values]": ",".join(string_ranges),
                "apiKey": self._api_key,
            }
            return self.__get(self._base_url, data, "arrival")
        else:
            raise HEREError(
                "Please provide values for origin or destination parameter."
            )

    def reverse_direction_isoline(
        self,
        transport_mode: IsolineRoutingTransportMode,
        ranges: List[int],
        origin: Optional[List[float]] = None,
        destination: Optional[List[float]] = None,
    ):
        """Calculates an isoline in the reverse direction. To trigger calculation in reverse direction,
        use the destination parameter instead of origin.
        Args:
          transport_mode (IsolineRoutingTransportMode):
            Transport mode of routing.
          ranges (List):
            Range values for isoline routing.
          origin (List):
            List including latitude and longitude in order.
          destination (List):
            List including latitude and longitude in order.
        Returns:
          IsolineRoutingResponse
        Raises:
          HEREError"""

        string_ranges = [str(int) for int in ranges]
        if origin:
            data = {
                "transportMode": transport_mode.__str__(),
                "origin": str.format("{0},{1}", origin[0], origin[1]),
                "range[type]": IsolineRoutingRangeType.time.__str__(),
                "range[values]": ",".join(string_ranges),
                "apiKey": self._api_key,
            }
            return self.__get(self._base_url, data, "departure")
        elif destination:
            data = {
                "transportMode": transport_mode.__str__(),
                "destination": str.format("{0},{1}", destination[0], destination[1]),
                "range[type]": IsolineRoutingRangeType.time.__str__(),
                "range[values]": range,
                "apiKey": self._api_key,
            }
            return self.__get(self._base_url, data, "arrival")
        else:
            raise HEREError(
                "Please provide values for origin or destination parameter."
            )

__init__(api_key=None, timeout=None)

Returns a IsolineRoutingApi instance. Args: api_key (str): API key taken from HERE Developer Portal. timeout (int): Timeout limit for requests.

Source code in herepy/isoline_routing_api.py
20
21
22
23
24
25
26
27
28
29
30
def __init__(self, api_key: str = None, timeout: int = None):
    """Returns a IsolineRoutingApi instance.
    Args:
      api_key (str):
        API key taken from HERE Developer Portal.
      timeout (int):
        Timeout limit for requests.
    """

    super(IsolineRoutingApi, self).__init__(api_key, timeout)
    self._base_url = "https://isoline.router.hereapi.com/v8/isolines"

distance_based_isoline(transport_mode, origin, ranges, routing_mode)

A distance-based isoline, also called an Isodistance, can be requested using range[type]=distance and providing range[values] in meters. Args: transport_mode (IsolineRoutingTransportMode): Transport mode of routing. origin (List): List including latitude and longitude in order. ranges (List): List of range values for isoline (in meters). routing_mode (IsolineRoutingMode): Isoline routing mode. Returns: IsolineRoutingResponse Raises: HEREError

Source code in herepy/isoline_routing_api.py
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
def distance_based_isoline(
    self,
    transport_mode: IsolineRoutingTransportMode,
    origin: List[float],
    ranges: List[int],
    routing_mode: IsolineRoutingMode,
) -> Optional[IsolineRoutingResponse]:
    """A distance-based isoline, also called an Isodistance,
    can be requested using range[type]=distance and providing range[values] in meters.
    Args:
      transport_mode (IsolineRoutingTransportMode):
        Transport mode of routing.
      origin (List):
        List including latitude and longitude in order.
      ranges (List):
        List of range values for isoline (in meters).
      routing_mode (IsolineRoutingMode):
        Isoline routing mode.
    Returns:
      IsolineRoutingResponse
    Raises:
      HEREError"""

    string_ranges = [str(int) for int in ranges]
    data = {
        "transportMode": transport_mode.__str__(),
        "origin": str.format("{0},{1}", origin[0], origin[1]),
        "range[type]": IsolineRoutingRangeType.distance.__str__(),
        "range[values]": ",".join(string_ranges),
        "routingMode": routing_mode.__str__(),
        "apiKey": self._api_key,
    }
    return self.__get(self._base_url, data, "departure")

isoline_based_on_consumption(origin, ranges, transport_mode, free_flow_speed_table, traffic_speed_table, ascent, descent, auxiliary_consumption)

Electric vehicles have a limited reachable range based on their current battery charge and factors affecting the rate of energy consumed, such as road slope or auxiliary power usage. Therefore, it is useful to visualize the appropriate range to avoid running out of energy before reaching a charging point. Args: transport_mode (IsolineRoutingTransportMode): Transport mode of routing. origin (List): List including latitude and longitude in order. ranges (List): List of range values for isoline (in meters). transport_mode (IsolineRoutingTransportMode): Transport mode of routing. free_flow_speed_table (List[float]): Free flow speed table. traffic_speed_table (List[float]): Traffic speed table. ascent (int): Int value of ascent. descent (float): Value of descent. auxiliary_consumption (float): Auxiliary consumption. Returns: IsolineRoutingResponse Raises: HEREError

Source code in herepy/isoline_routing_api.py
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
def isoline_based_on_consumption(
    self,
    origin: List[float],
    ranges: List[int],
    transport_mode: IsolineRoutingTransportMode,
    free_flow_speed_table: List[float],
    traffic_speed_table: List[float],
    ascent: int,
    descent: float,
    auxiliary_consumption: float,
):
    """Electric vehicles have a limited reachable range based on their current battery
    charge and factors affecting the rate of energy consumed, such as road slope or auxiliary
    power usage. Therefore, it is useful to visualize the appropriate range to avoid running
    out of energy before reaching a charging point.
    Args:
      transport_mode (IsolineRoutingTransportMode):
        Transport mode of routing.
      origin (List):
        List including latitude and longitude in order.
      ranges (List):
        List of range values for isoline (in meters).
      transport_mode (IsolineRoutingTransportMode):
        Transport mode of routing.
      free_flow_speed_table (List[float]):
        Free flow speed table.
      traffic_speed_table (List[float]):
        Traffic speed table.
      ascent (int):
        Int value of ascent.
      descent (float):
        Value of descent.
      auxiliary_consumption (float):
        Auxiliary consumption.
    Returns:
      IsolineRoutingResponse
    Raises:
      HEREError"""

    string_ranges = [str(int) for int in ranges]

    free_speed_table = [0]
    free_speed_table.extend(free_flow_speed_table)
    free_speed_table_str = ",".join([str(n) for n in free_speed_table])

    speed_table = [0]
    speed_table.extend(traffic_speed_table)
    speed_table_str = ",".join([str(n) for n in speed_table])

    data = {
        "origin": str.format("{0},{1}", origin[0], origin[1]),
        "range[type]": IsolineRoutingRangeType.consumption.__str__(),
        "range[values]": ",".join(string_ranges),
        "transportMode": transport_mode.__str__(),
        "ev[freeFlowSpeedTable]": free_speed_table_str,
        "ev[trafficSpeedTable]": speed_table_str,
        "ev[ascent]": ascent,
        "ev[descent]": descent,
        "ev[auxiliaryConsumption]": auxiliary_consumption,
        "apiKey": self._api_key,
    }
    return self.__get(self._base_url, data, "departure")

isoline_routing_at_specific_time(transport_mode, ranges, origin=None, departure_time=None, destination=None, arrival_time=None)

To calculate an isoline around an origin with a specific time, use departureTime. For a reverse isoline, that is, when using destination, you can use arrivalTime. If departureTime or arrivalTime are specified as "any", the isoline calculation will not take traffic flow and other time-dependent effects into account. This can be useful when it is not certain for what time of the day the isoline needs to be computed. Args: transport_mode (IsolineRoutingTransportMode): Transport mode of routing. ranges (List): List of range values for isoline (in meters). origin (List): List including latitude and longitude in order. departure_time (str): Departure time of the routing in format yyyy-MM-ddThh:mm:ss. destination (List): List including latitude and longitude in order. arrival_time (str): Arrival time of the planned routing in format yyyy-MM-ddThh:mm:ss. Returns: IsolineRoutingResponse Raises: HEREError

Source code in herepy/isoline_routing_api.py
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
def isoline_routing_at_specific_time(
    self,
    transport_mode: IsolineRoutingTransportMode,
    ranges: List[int],
    origin: Optional[List[float]] = None,
    departure_time: Optional[str] = None,
    destination: Optional[List[float]] = None,
    arrival_time: Optional[str] = None,
):
    """To calculate an isoline around an origin with a specific time, use departureTime.
    For a reverse isoline, that is, when using destination, you can use arrivalTime.
    If departureTime or arrivalTime are specified as "any", the isoline calculation will
    not take traffic flow and other time-dependent effects into account. This can be useful
    when it is not certain for what time of the day the isoline needs to be computed.
    Args:
      transport_mode (IsolineRoutingTransportMode):
        Transport mode of routing.
      ranges (List):
        List of range values for isoline (in meters).
      origin (List):
        List including latitude and longitude in order.
      departure_time (str):
        Departure time of the routing in format yyyy-MM-ddThh:mm:ss.
      destination (List):
        List including latitude and longitude in order.
      arrival_time (str):
        Arrival time of the planned routing in format yyyy-MM-ddThh:mm:ss.
    Returns:
      IsolineRoutingResponse
    Raises:
      HEREError"""

    string_ranges = [str(int) for int in ranges]
    if origin and departure_time:
        data = {
            "transportMode": transport_mode.__str__(),
            "origin": str.format("{0},{1}", origin[0], origin[1]),
            "departureTime": departure_time,
            "range[type]": IsolineRoutingRangeType.time.__str__(),
            "range[values]": ",".join(string_ranges),
            "apiKey": self._api_key,
        }
        return self.__get(self._base_url, data, "departure")
    elif destination and arrival_time:
        data = {
            "transportMode": transport_mode.__str__(),
            "destination": str.format("{0},{1}", destination[0], destination[1]),
            "arrivalTime": arrival_time,
            "range[type]": IsolineRoutingRangeType.time.__str__(),
            "range[values]": ",".join(string_ranges),
            "apiKey": self._api_key,
        }
        return self.__get(self._base_url, data, "arrival")
    else:
        raise HEREError(
            "Please provide either origin & departure_time or destination & arrival_time."
        )

multi_range_routing(transport_mode, ranges, origin=None, destination=None)

Isoline routing can be requested with multiple ranges which allows for the calculation of many isolines with the same start or destination. Args: transport_mode (IsolineRoutingTransportMode): Transport mode of routing. ranges (List): Range values for isoline routing. origin (List): List including latitude and longitude in order. destination (List): List including latitude and longitude in order. Returns: IsolineRoutingResponse Raises: HEREError

Source code in herepy/isoline_routing_api.py
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
def multi_range_routing(
    self,
    transport_mode: IsolineRoutingTransportMode,
    ranges: List[int],
    origin: Optional[List[float]] = None,
    destination: Optional[List[float]] = None,
):
    """Isoline routing can be requested with multiple ranges which allows for the calculation
    of many isolines with the same start or destination.
    Args:
      transport_mode (IsolineRoutingTransportMode):
        Transport mode of routing.
      ranges (List):
        Range values for isoline routing.
      origin (List):
        List including latitude and longitude in order.
      destination (List):
        List including latitude and longitude in order.
    Returns:
      IsolineRoutingResponse
    Raises:
      HEREError"""

    string_ranges = [str(int) for int in ranges]
    if origin:
        data = {
            "transportMode": transport_mode.__str__(),
            "origin": str.format("{0},{1}", origin[0], origin[1]),
            "range[type]": IsolineRoutingRangeType.distance.__str__(),
            "range[values]": ",".join(string_ranges),
            "apiKey": self._api_key,
        }
        return self.__get(self._base_url, data, "departure")
    elif destination:
        data = {
            "transportMode": transport_mode.__str__(),
            "destination": str.format("{0},{1}", destination[0], destination[1]),
            "range[type]": IsolineRoutingRangeType.distance.__str__(),
            "range[values]": ",".join(string_ranges),
            "apiKey": self._api_key,
        }
        return self.__get(self._base_url, data, "arrival")
    else:
        raise HEREError(
            "Please provide values for origin or destination parameter."
        )

reverse_direction_isoline(transport_mode, ranges, origin=None, destination=None)

Calculates an isoline in the reverse direction. To trigger calculation in reverse direction, use the destination parameter instead of origin. Args: transport_mode (IsolineRoutingTransportMode): Transport mode of routing. ranges (List): Range values for isoline routing. origin (List): List including latitude and longitude in order. destination (List): List including latitude and longitude in order. Returns: IsolineRoutingResponse Raises: HEREError

Source code in herepy/isoline_routing_api.py
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
def reverse_direction_isoline(
    self,
    transport_mode: IsolineRoutingTransportMode,
    ranges: List[int],
    origin: Optional[List[float]] = None,
    destination: Optional[List[float]] = None,
):
    """Calculates an isoline in the reverse direction. To trigger calculation in reverse direction,
    use the destination parameter instead of origin.
    Args:
      transport_mode (IsolineRoutingTransportMode):
        Transport mode of routing.
      ranges (List):
        Range values for isoline routing.
      origin (List):
        List including latitude and longitude in order.
      destination (List):
        List including latitude and longitude in order.
    Returns:
      IsolineRoutingResponse
    Raises:
      HEREError"""

    string_ranges = [str(int) for int in ranges]
    if origin:
        data = {
            "transportMode": transport_mode.__str__(),
            "origin": str.format("{0},{1}", origin[0], origin[1]),
            "range[type]": IsolineRoutingRangeType.time.__str__(),
            "range[values]": ",".join(string_ranges),
            "apiKey": self._api_key,
        }
        return self.__get(self._base_url, data, "departure")
    elif destination:
        data = {
            "transportMode": transport_mode.__str__(),
            "destination": str.format("{0},{1}", destination[0], destination[1]),
            "range[type]": IsolineRoutingRangeType.time.__str__(),
            "range[values]": range,
            "apiKey": self._api_key,
        }
        return self.__get(self._base_url, data, "arrival")
    else:
        raise HEREError(
            "Please provide values for origin or destination parameter."
        )

time_isoline(transport_mode, origin, ranges)

A time-based isoline, also called an Isochrone, can be requested by using range[type]=time and providing range[values] in seconds. Args: transport_mode (IsolineRoutingTransportMode): Transport mode of routing. origin (List): List including latitude and longitude in order. ranges (List): List of range values for isoline (in meters). Returns: IsolineRoutingResponse Raises: HEREError

Source code in herepy/isoline_routing_api.py
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
def time_isoline(
    self,
    transport_mode: IsolineRoutingTransportMode,
    origin: List[float],
    ranges: List[int],
) -> Optional[IsolineRoutingResponse]:
    """A time-based isoline, also called an Isochrone,
    can be requested by using range[type]=time and providing range[values] in seconds.
    Args:
      transport_mode (IsolineRoutingTransportMode):
        Transport mode of routing.
      origin (List):
        List including latitude and longitude in order.
      ranges (List):
        List of range values for isoline (in meters).
    Returns:
      IsolineRoutingResponse
    Raises:
      HEREError"""

    string_ranges = [str(int) for int in ranges]
    data = {
        "transportMode": transport_mode.__str__(),
        "origin": str.format("{0},{1}", origin[0], origin[1]),
        "range[type]": IsolineRoutingRangeType.time.__str__(),
        "range[values]": ",".join(string_ranges),
        "apiKey": self._api_key,
    }
    return self.__get(self._base_url, data, "departure")