here-apiheremapshere-traffic

How to retrieve data from a layer with a pipeline


I'm trying to get the average speed from the "HERE Real Time Traffic" catalog in the "Flow" layer. I could see that there was an example in the documentation:

https://developer.here.com/documentation/java-scala-dev/dev_guide/here-realtime-traffic/index.html

Thanks to the segmentID, in the example, it manages to retrieve the desired data, but in my case I don't have a segmentID and I would like to retrieve this data thanks to the gps coordinate (lat,long).

I want to know if there is a way to get the segmentID using the coordinates ? or to use the exemple but with a lat,long values.

I tried to convert the coordinates to segmentid but i didn't find an appropriete fonction to do.

I also think about using API REST to get the segmentid but i don't think it will be an good idea.


Solution

  • You can do this by using the below route matching API and passing the trace points in the CSV file format to get the segmentId.

    https://routematching.hereapi.com/v8/match/routelinks?apiKey={your_api_key}&mode=fastest;car;traffic:disabled&routeMatch=1

    sample tracepoint

    LATITUDE, LONGITUDE

    53.3737131,-1.4704939

    53.3742428,-1.4677477

    In the response you will see like

    segmentRef: "$0:23605339:$1:80475176#-0..1"

    segmentId is $1 parameter i.e 80475176