1

Here is the GPX data I am giving to GraphHopper Map matching library:

private List<GPXEntry> getList()
{
    List<GPXEntry> sampleEntries = new ArrayList<GPXEntry>();
    GPXEntry point1 = new GPXEntry(13.0009316,77.5947316, 1431849367077L);
    GPXEntry point2 = new GPXEntry(12.9868999,77.6042,1431849683112L);
    GPXEntry point3 = new GPXEntry(12.9867766,77.6043633,1431849718336L);
    GPXEntry point4 = new GPXEntry(12.98658,77.6043283,1431849752169L);
    GPXEntry point5 = new GPXEntry(12.9846133,77.6052366,1431850069237L);
    sampleEntries.add(point1);
    sampleEntries.add(point2);
    sampleEntries.add(point3);
    sampleEntries.add(point4);
    sampleEntries.add(point5);
    return sampleEntries;
}

It is list of GPXEntry objects each containing lat, long and the timestamp of vehicle when the location was recorded.

Now, with map library, I am able to get edges and path using Dijkstra's algorithm. The QueryResults object has the following:

for (QueryResult item : queryResult) {
        System.out.println("Snapped position: "+ item.getSnappedPoint());
        edgesMap.put(item.getClosestEdge().getEdge(), item.getQueryDistance());
    }

I am getting edge ID and in the end the distance calculated is also correct when I compare with GoogleMaps distance. But, I want to use the timeStamp(epoch) data which I have given in the GPX data. I am assuming the library creates edges based on location points I have given and snaps it to actual route referred by OSM file.

I want to know for each edgeID, how do I get the time taken? For e.g., time between point1 and point2 should be (1431849683112L-1431849367077L). Does the library provide anything for this or I need to do it separately.

  • have you solved this question? – chenzhongpu Oct 10 '18 at 14:05
0

You can get the associated time indirectly for every edge via the EdgeMatch class using the distance and speed for every linked edgeState.

BTW: you are probably doing the map matching not correct. Although the QueryGraph does a similar thing and e.g. we are using this under the hood in the map matching component, this alone won't work that good for many points. Please have a look into the Java part of the map matching library

  • That code doesn't work at this particular line: LocationIndexMatch locationIndex = new LocationIndexMatch(graph, new RAMDirectory()); It says: The constructor LocationIndexMatch(GraphStorage, RAMDirectory) is undefined.<br> I also tried with LocationIndexMatch locationIndex = new LocationIndexMatch(graph, new LocationIndexTree(hopper.getGraph(), new RAMDirectory()));. It says IllegalThreadStateException. – Spiralarchitect May 27 '15 at 11:56
  • now fixed in the readme – Karussell May 28 '15 at 7:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.