Routify Documentation
Loading...
Searching...
No Matches
ch.routify.osmparser.OsmParser Class Reference

Public Member Functions

JSONArray getNodes ()
 
JSONArray getWays ()
 
 OsmParser (String pathOfSourceFile) throws FileNotFoundException, ParseException
 
void initializeGraph (CustomGraph< CustomVertex, CustomEdge > graph)
 
void clear ()
 
void exportOsmIdToCoordinates (String path)
 

Static Public Member Functions

static void main (String[] args) throws FileNotFoundException, ParseException, IOException
 

Detailed Description

Parses OSM raw output from the Overpass Turbo API and initializes a graph representation of the data. It supports handling nodes and ways to construct vertices and edges in the graph.

Constructor & Destructor Documentation

◆ OsmParser()

ch.routify.osmparser.OsmParser.OsmParser ( String pathOfSourceFile) throws FileNotFoundException, ParseException
inline

Constructs an OsmParser and loads data from a specified source file.

Parameters
pathOfSourceFilePath to the GeoJSON file containing OSM data.
Exceptions
FileNotFoundExceptionIf the source file is not found.
ParseExceptionIf parsing the JSON data fails.

Member Function Documentation

◆ clear()

void ch.routify.osmparser.OsmParser.clear ( )
inline

Clears internal data structures to release memory.

◆ exportOsmIdToCoordinates()

void ch.routify.osmparser.OsmParser.exportOsmIdToCoordinates ( String path)
inline

Exports a mapping of OSM IDs to their corresponding latitude and longitude coordinates to a specified file. The method iterates over a collection of nodes, each represented as a JSONObject, extracting the OSM ID, latitude, and longitude. These details are then formatted and written to a file in a JSON structure.

Parameters
pathThe file system path where the exported JSON file will be saved. It specifies the location and name of the file. The method assumes that the path is valid and that it has the necessary permissions to write to it.
Exceptions
IOExceptionIf an I/O error occurs during writing to the file. This includes cases where the file cannot be opened for writing, if there is an error during writing to the file, or if the file cannot be closed.

◆ getNodes()

JSONArray ch.routify.osmparser.OsmParser.getNodes ( )
inline

◆ getWays()

JSONArray ch.routify.osmparser.OsmParser.getWays ( )
inline

◆ initializeGraph()

void ch.routify.osmparser.OsmParser.initializeGraph ( CustomGraph< CustomVertex, CustomEdge > graph)
inline

Initializes the graph with vertices and edges based on the parsed OSM data.

Parameters
graphThe graph to be initialized.

◆ main()

static void ch.routify.osmparser.OsmParser.main ( String[] args) throws FileNotFoundException, ParseException, IOException
inlinestatic

Main method to demonstrate the usage of OsmParser.

Parameters
argsCommand line arguments (not used).
Exceptions
FileNotFoundExceptionIf the source file is not found.
ParseExceptionIf parsing the JSON data fails.
IOExceptionIf an I/O error occurs.

The documentation for this class was generated from the following file: