Java program that parses OSM XML files into a json graph representation.
In output file you will have nodes and edges with weight (unit: centimetres
).
[
{
"la": 60.1570875,
"lo": 24.9563234,
"e": [
{
"i": 1,
"w": 514
},
{
"i": 17,
"w": 574
}
]
},
{
"la": 60.1570488,
"lo": 24.9562727,
"e": [
{
"i": 0,
"w": 514
},
{
"i": 2,
"w": 784
},
{
"i": 11302,
"w": 413
}
]
}
]
la = latitude
lo = longitude
e = edges
i = main array index, if the i is 0 it refers to the first element in the array
w = weight
-f, --files osm files to be parsed
-i, --includeWays way tags to include
-e, --excludeWays way tags to exclude (overrides includeWay)
-o, --output output file name
-q, --quiet suppress console output
- Download latest version under the releases tab.
- Download openstreetmap data. (click export, select area, and then export)
- Use -f flag to select osm files.
- Use -i flag to select ways. You can view osm map features here.
- Use -o flag to defining output file name.
- Run the jar file. (terminal
java -jar <jar-file-name>.jar -f files -i selected ways -o output file name
) - Now you have
json
in the same directory where the .jar file is. - If you use this data in your own service read openstreetmap licence.
- Parsing take much time or program crash.
- The program does not have enought memory. Use
-Xmx
flag with java. Example run commandjava -jar -Xmx4096m <jar-file-name>.jar
. That will increase java heap max size to 4gb. You will need 4gb ram for that.
- The program does not have enought memory. Use
You will need a Java Runtime Environment (JRE) to run java programs. You can download it here.
- Gradle - Dependency Management
This project is licensed under the GNU GENERAL PUBLIC LICENSE - see the LICENSE file for details