0

I am using the Osm2po.router in Java, trying to find the clazz of roads from this Get road type (clazz) in osm2po.

When I am using the router without any supports, I am able to find the vertex Ids. That is, the following code returns a path:

Graph graph = new Graph(graphFile);
Properties params = new Properties();
params.setProperty("findShortestPath", "false");
params.setProperty("ignoreRestrictions", "true");
params.setProperty("ignoreOneWays", "true");
params.setProperty("heuristicFactor", "0.0"); // 0.0 Dijkstra, 1.0 good A*

int sourceId = graph.findClosestVertexId(-37.820088f, 144.970264f); 
int targetId = graph.findClosestVertexId(-35.281537f, 149.129242f); 

Returns a non-negative "sourceId" and "targetId" int.

However, if I change the code to follow the above link, the same target and source nodes return null.

Graph graph = new Graph(graphFile, new Log(), Graph.SUPPORT_EDGEFLAGS, false, null);
Properties params = new Properties();
params.setProperty("findShortestPath", "false");
params.setProperty("ignoreRestrictions", "true");
params.setProperty("ignoreOneWays", "true");
params.setProperty("heuristicFactor", "0.0"); // 0.0 Dijkstra, 1.0 good A*

int sourceId = graph.findClosestVertexId(-37.820088f, 144.970264f); 
int targetId = graph.findClosestVertexId(-35.281537f,   149.129242f);   

Why? My understanding is that the route should be the same, the only change I've made is about what details about the roads to retain.

I've tried changing the Boolean which is the fourth parameter in the Graph constructor, but that doesn't change the result.

  • I realise that if change the flag to -1, that is the graph is: Graph graph = new Graph(graphFile, new Log(), Graph.SUPPORT_EDGEFLAGS, false, null); then the code runs fine. It has a non-zero clazz variable. I'm not sure why it doesn't work when I include SUPPORT_EDGEFLAGS, but it works. – ClownsENT Jun 23 '16 at 1:35
0
SUPPORT_LATLON | SUPPORT_EDGEFLAGS

the default constructor sets SUPPORT_LATLON only. Other constructors must set the combination explicitly. The code above is a binary operation with Or-Op "|"

| improve this answer | |

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.