Class DataIO
java.lang.Object
rgu.transport.util.DataIO
Methods for custom serialization code.
- Author:
- Lee A. Christie
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic TransitNetworkreadNetwork(File file) Reads a transit network from the specified file.static TransitNetworkreadNetwork(File file, BiConsumer<GeoLocation, GeoLocation> edgeConsumer, BiConsumer<GeoLocation, GeoLocation> edgeConsumerArtificial) Reads a transit network from the specified file, with optional consumers for edges.static TransitNetworkreadNetwork(File file, Predicate<GeoLocation> spatialFilter, BiConsumer<GeoLocation, GeoLocation> edgeConsumer, BiConsumer<GeoLocation, GeoLocation> edgeConsumerArtificial) Reads a transit network from the specified file, with optional consumers for edges and spatial filter.static Graph<GeoLocation, RoadEdge> Reads a road graph from the specified file.static Graph<GeoLocation, RoadEdge> readRoads(File file, BiConsumer<GeoLocation, GeoLocation> edgeConsumer) Reads a road graph from the specified file, with an optional consumer for edges.static Graph<GeoLocation, RoadEdge> readRoads(File file, Predicate<GeoLocation> spatialFilter, BiConsumer<GeoLocation, GeoLocation> edgeConsumer) Reads a road graph from the specified file, with an optional consumer for edges and spatial filter.splitCommas(String string) Splits a string on commas, removing quotation marks around entries.static voidwriteNetwork(File file, TransitNetwork network) Writes the given network to the specified file.static voidwriteRoads(File file, Graph<GeoLocation, RoadEdge> graph) Writes the given roads graph to the specified file.
-
Constructor Details
-
DataIO
public DataIO()
-
-
Method Details
-
splitCommas
-
writeRoads
Writes the given roads graph to the specified file.- Parameters:
file- the file to write to, not nullgraph- the graph to write, not null- Throws:
IOException- if an exception occurred writing
-
readRoads
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 nulledgeConsumer- 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 nullspatialFilter- a filter for which points to load, can be null if not usededgeConsumer- a callback for the edges, can be null if not used- Returns:
- the road graph
- Throws:
IOException- if an exception occurred reading
-
writeNetwork
Writes the given network to the specified file.- Parameters:
file- the file, not nullnetwork- the network, not null- Throws:
IOException- if an exception occurred writing
-
readNetwork
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 nulledgeConsumer- a callback for the edges, can be null if not usededgeConsumerArtificial- 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 nullspatialFilter- a filter for whether to include a location, can be null if not usededgeConsumer- a callback for the edges, can be null if not usededgeConsumerArtificial- a callback for the artificial edges, can be null if not used- Returns:
- the network
- Throws:
IOException- if an exception occurred reading
-