1

Is there a way to retrieve the segmentID from a specific position (lat/lng)? I need the segmentID for the routing API in avoid[segments]

I tried reverse geocoding, but I could not find any information to obtain the segmentID.

this.service.reverseGeocode(
  {
    at: '37.56042131221306,139.9987190961508',
    spans: 'segmentId',
    locationattributes: 'segmentId'
  },
  (result) => {
    console.log(result.items[0])
  },
  this.onError
)

Result:

  {
  title: "..."
  access: [..]
  address: {..}
  distance: 31
  houseNumberType: "PA"
  id: "here:xs1:pointaddress:10039667:CgcIESDz4uQEEAEaATI"
  position: {lat: 37.56069, lng: 139.99863}
  resultType: "houseNumber"
  title: "..."
}

But using spans or locationattributes does not return the segmentID. The call returns an ID like here:xs1:streetsection:1000002351972, but I cannot use that for routing in avoid[segments]

Thank you in advance

gerald
  • 11
  • 1

1 Answers1

0

You have to make below calls for your usecase.

1>Rest call to get segmentId For the route.

https://router.hereapi.com/v8/routes? apikey={your_app_id}& origin=32.834496,74.81515& destination=32.811632,75.816037& return=polyline,summary,actions,instructions& spans=segmentId& transportMode=car&

2>Rest Call to get the get Route with avoid[segments]

https://router.hereapi.com/v8/routes? apikey={your_app_id}& origin=32.834496,74.81515& destination=32.811632,74.816037& return=polyline,summary,actions,instructions& spans=segmentId& transportMode=car& avoid[segments]=here:cm:segment:808368834,here:cm:segment:808095972