After the GraphHopper readed a graph from a osm file, I created a new graph based on the GraphHopper’s basegraph with multiple edges removed(I kinda use it as an OSMreader). And I found a problem.

I found that the base graph I got from GraphHopper is some how simplified. the path that contains multiple edges without a fork will consider one single edge in a base graph. How can I disable this. How can I find a snap point on this simplified graph when it’s actually should snap to a non-simplified edge?

Is it possible to read a graph from a OSM file using a OSMreader, if it’s unable to read the unmodified basegraph from a GraphHopper? should I use a xmlreader instead?

There is a configuration called `routing.way_point_max_distance`

that handles this for the import. I.e. how the OSM data ends up in the graph.

And then there is `way_point_max_distance`

that handles this at query time. I.e. how the graph data ends up in the response.

Both are by default 1 (meter), i.e. if there are three points A, B and C and point B has a perpendicular distance to the segment A-C which is smaller than 1 meter, then point B will be removed (i.e. simplified, aka “ramer douglas peucker”).

After I using ghConfig.putObject(Parameters.Routing.INIT_WAY_POINT_MAX_DISTANCE, 0); it will still give me imaginary edges while I’m getting all edges in basegraph of the temphopper through iterator and I can’t see why.

I found that the base graph I got from GraphHopper is some how simplified. the path that contains multiple edges without a fork will consider one single edge in a base graph.

It’s very hard to understand what you are trying to say. How is the graph ‘simplified’? Which path that contains multiple edges are you talking about? What is a path without a fork? What does “the path considers one single edge” mean?

How can I find a snap point on this simplified graph when it’s actually should snap to a non-simplified edge?

I do not understand this question either.

Is it possible to read a graph from a OSM file using a OSMreader,

Yes, building a graph from an OSM file is exactly what OSMReader does.

if it’s unable to read the unmodified basegraph from a GraphHopper

OSMReader does not read a base graph at all. It reads an OSM file.

I just trying to use a graphhopper as a OSMReader just to get its basegraph. Some edges like a->b->c->d->e is in the OSM file will somehow replaced by an edge a->e which is a line segment. I just want to know how to disable that.

But how are we supposed to understand what you are doing? When you import an OSM file using GraphHopper it won’t replace OSM ways with line segments. The only thing it might do is remove intermediate nodes in case they do not contribute to the way geometry, because they just lie on a straight line. karussell already explained how to disable this.

What am I doing is reading all the edges from a basegraph that I get from a graphhopper, then I choose part of those edges to build a new basegraph. And I will using some lower api to get a new shortest path in the new graph.

And I don’t know how, the basegraph I get from the hopper removed some intermediate node on a pretty curvy path, so to me it did replace those edges with a line segment.

I actually want to use the OSMReader, but I don’t know how, is there any docs or example of it?

then I choose part of those edges to build a new basegraph

how?

Using a iterator, reading all its edges, get its edge’s start and end node. put those node and edge in a new basegraph if I want to keep this edge.

something like this

```
...
Basegraph newgraph...
NodeAccess newna = newgraph.getNodeAccess ()...
Basegraph oldgraph = graphhopper.getBaseGraph();// graphhopper is a hopper which is already loaded.
EdgeIterator edgeIterator = oldgraph.getAllEdges();
while(has next edge)
if filter(edge) == false then continue
int nodeA = edgeIterator.getBaseNode();
int nodeB = edgeIterator.getAdjNode();
if nodeA not in newna then newna.add(nodeA)
if nodeB not in newna then newna.add(nodeB)
newgraph.edge(nodeA,nodeB).setDistance(get old distance).set(.......
```

I’m only guessing because you are not showing your entire code, but you probably do not copy the way geometry.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.