Class DataIO

java.lang.Object
rgu.transport.util.DataIO

public final class DataIO extends Object
Methods for custom serialization code.
Author:
Lee A. Christie
  • Constructor Details

    • DataIO

      public DataIO()
  • Method Details

    • splitCommas

      public static List<String> splitCommas(String string)
      Splits a string on commas, removing quotation marks around entries.
      Parameters:
      string - a comma-seperated string, not null
      Returns:
      the entries
    • writeRoads

      public static void writeRoads(File file, Graph<GeoLocation, RoadEdge> graph) throws IOException
      Writes the given roads graph to the specified file.
      Parameters:
      file - the file to write to, not null
      graph - the graph to write, not null
      Throws:
      IOException - if an exception occurred writing
    • readRoads

      public static Graph<GeoLocation, RoadEdge> readRoads(File file) throws IOException
      Reads a road graph from the specified file.
      Parameters:
      file - the file, not null
      Returns:
      the road graph
      Throws:
      IOException - if an exception occurred reading
    • readRoads

      public static Graph<GeoLocation, RoadEdge> readRoads(File file, BiConsumer<GeoLocation, GeoLocation> edgeConsumer) throws IOException
      Reads a road graph from the specified file, with an optional consumer for edges.
      Parameters:
      file - the file, not null
      edgeConsumer - a callback for the edges, can be null if not used
      Returns:
      the road graph
      Throws:
      IOException - if an exception occurred reading
    • readRoads

      public static Graph<GeoLocation, RoadEdge> readRoads(File file, Predicate<GeoLocation> spatialFilter, BiConsumer<GeoLocation, GeoLocation> edgeConsumer) throws IOException
      Reads a road graph from the specified file, with an optional consumer for edges and spatial filter.
      Parameters:
      file - the file, not null
      spatialFilter - a filter for which points to load, can be null if not used
      edgeConsumer - a callback for the edges, can be null if not used
      Returns:
      the road graph
      Throws:
      IOException - if an exception occurred reading
    • writeNetwork

      public static void writeNetwork(File file, TransitNetwork network) throws IOException
      Writes the given network to the specified file.
      Parameters:
      file - the file, not null
      network - the network, not null
      Throws:
      IOException - if an exception occurred writing
    • readNetwork

      public static TransitNetwork readNetwork(File file) throws IOException
      Reads a transit network from the specified file.
      Parameters:
      file - the file, not null
      Returns:
      the network
      Throws:
      IOException - if an exception occurred reading
    • readNetwork

      public static TransitNetwork readNetwork(File file, BiConsumer<GeoLocation, GeoLocation> edgeConsumer, BiConsumer<GeoLocation, GeoLocation> edgeConsumerArtificial) throws IOException
      Reads a transit network from the specified file, with optional consumers for edges.
      Parameters:
      file - the file, not null
      edgeConsumer - a callback for the edges, can be null if not used
      edgeConsumerArtificial - a callback for the artificial edges, can be null if not used
      Returns:
      the network
      Throws:
      IOException - if an exception occurred reading
    • readNetwork

      public static TransitNetwork readNetwork(File file, Predicate<GeoLocation> spatialFilter, BiConsumer<GeoLocation, GeoLocation> edgeConsumer, BiConsumer<GeoLocation, GeoLocation> edgeConsumerArtificial) throws IOException
      Reads a transit network from the specified file, with optional consumers for edges and spatial filter.
      Parameters:
      file - the file, not null
      spatialFilter - a filter for whether to include a location, can be null if not used
      edgeConsumer - a callback for the edges, can be null if not used
      edgeConsumerArtificial - a callback for the artificial edges, can be null if not used
      Returns:
      the network
      Throws:
      IOException - if an exception occurred reading