Class OsmCoordinatesReader

java.lang.Object
org.jgrapht.osm.OsmCoordinatesReader

public final class OsmCoordinatesReader extends Object
Reads a headerless node_id,lat,lon CSV (the companion file produced by GpkgRoadGraphPreprocessor) into a Map<Integer, double[]> keyed by node id, with each value an array {lat, lon} in decimal degrees. Pair with HaversineHeuristic.ofMap(Map) for A* heuristics over the loaded graph.

Edge / node CSVs are intentionally separate files: the edge list goes through CSVImporter (which is graph-shaped), and the coordinate table is a flat key-value resource that does not fit the importer interface.

Author:
Shai Eilat
  • Method Details

    • readGzippedResource

      public static Map<Integer,double[]> readGzippedResource(Class<?> anchor, String resource) throws IOException
      Reads the gzipped coordinates resource into a map.
      Parameters:
      anchor - anchor class for Class.getResourceAsStream(java.lang.String)
      resource - resource path (must point at a gzipped CSV)
      Returns:
      a map from node id to {lat, lon}
      Throws:
      IOException - on missing resource or parse error
    • readGzippedFile

      public static Map<Integer,double[]> readGzippedFile(Path path) throws IOException
      Reads the gzipped coordinates file into a map.
      Parameters:
      path - file path (must point at a gzipped CSV)
      Returns:
      a map from node id to {lat, lon}
      Throws:
      IOException - on parse error
    • readGzipped

      public static Map<Integer,double[]> readGzipped(InputStream gzippedCsv) throws IOException
      Reads the gzipped coordinates stream into a map. The caller closes the stream.
      Parameters:
      gzippedCsv - gzipped CSV input stream
      Returns:
      a map from node id to {lat, lon}
      Throws:
      IOException - on parse error