Class WaySegmentParser

java.lang.Object
com.graphhopper.reader.osm.WaySegmentParser

public class WaySegmentParser extends Object
This class parses a given OSM file and splits OSM ways into 'segments' at all intersections (or 'junctions'). Intersections can be either crossings of different OSM ways or duplicate appearances of the same node within one way (when the way contains a loop). Furthermore, this class creates artificial segments at certain nodes. It also provides several hooks/callbacks to customize the processing of nodes, ways and relations.

The OSM file is read twice. The first time we ignore OSM nodes and only determine the OSM node IDs at which accepted ways are intersecting. During the second pass we split the OSM ways at intersections, introduce the artificial segments and pass the way information along with the corresponding nodes to a given callback.

We assume a strict order of the OSM file: nodes, ways, then relations.

The main difficulty is that the OSM ID range is very large (64bit integers) and to be able to provide the full node information for each segment we have to efficiently store the node data temporarily. This is addressed by OSMNodeData.

  • Method Details