1- # EVMap OSM Data Updater (PoC)
1+ # EVMap OSM Loader
22
3- This is a proof-of-concept for a charging station data fetcher for
4- OpenStreetMap. The script fetches all charging stations worldwide through the
5- Overpass API, preprocesses the data and writes it to a gzip-compressed JSON
6- file.
7-
8- ## Requirements
9-
10- - [ curl] ( https://curl.se/ )
11- - [ jq] ( https://stedolan.github.io/jq/ )
12- - [ gzip] ( https://www.gnu.org/software/gzip/ )
3+ A Rust implementation of the Overpass API data loader for charging stations.
4+ This tool downloads worldwide charging station data from OpenStreetMap via the
5+ Overpass API, preprocesses it, and saves the result as a compressed JSON file
6+ (for consumption by EVMap).
137
148## Data Format
159
1610The resulting gzipped JSON file contains data in the following format:
1711
1812``` json5
1913{
20- " timestamp" : 1633282807.294814 , // UNIX timestamp in seconds
14+ " timestamp" : 1633282807 , // UNIX timestamp in seconds
15+ " count" : 4376 , // Number of elements below
2116 " elements" : [
2217 {
2318 // Unique numeric ID
2419 " id" : 9079237567 ,
2520 // Latitude, longitude (WGS84 coordinates, I assume)
2621 " lat" : 47.0701573 ,
2722 " lon" : 7.5664432 ,
23+ // Type of element (node, way, relation)
24+ " type" : " node" ,
2825 // Timestamp of last update
2926 " timestamp" : " 2021-09-10T11:47:56Z" ,
3027 // Numeric, monotonically increasing version number
@@ -34,29 +31,108 @@ The resulting gzipped JSON file contains data in the following format:
3431 // Raw key-value OSM tags
3532 " tags" : {
3633 " amenity" : " charging_station" ,
37- ...
34+ ... // More OSM tags
3835 }
3936 },
40- ...
37+ ... // More elements
4138 ]
4239}
4340```
4441
4542For the tagging schema, see < https://wiki.openstreetmap.org/wiki/DE:Tag:amenity%3Dcharging_station >
4643
44+ ## Building
45+
46+ Make sure you have Rust and Cargo installed.
47+
48+ Build the project:
49+
50+ cargo build --release
51+
52+ The binary will be available at ` target/release/evmap-osm-loader ` .
53+
4754## Usage
4855
49- Simply invoke the script:
56+ ### Basic Usage
57+
58+ Download charging station data with default settings:
5059
51- ./load-overpass.sh
60+ evmap-osm-loader
5261
53- Note: The API query may take multiple minutes. The default timeout is set to 15
54- minutes, but depending on the load on the API endpoint, this may not be
62+ ** Note 1: ** The API query may take multiple minutes. The default timeout is set
63+ to 15 minutes, but depending on the load on the API endpoint, this may not be
5564sufficient.
5665
57- The script can be adjusted by editing the configuration variables. Possible
58- configuration variables include the Overpass API endpoint or the download
59- timeout.
66+ ** Note 2:** By default, the script uses the Overpass API interpreter at
67+ < https://overpass.osm.ch/api/interpreter > , which returns only data within
68+ Switzerland. This is great for testing with a reduced data set. For a worldwide
69+ result set, you can specify the URL ` https://overpass-api.de/api/interpreter `
70+ using the ` --overpass-url ` option.
71+
72+ Show usage:
73+
74+ evmap-osm-loader --help
75+
76+ ### Command-Line Options
77+
78+ ```
79+ evmap-osm-loader [OPTIONS]
80+
81+ Options:
82+ --keep-intermediate <BOOL>
83+ Keep intermediate raw response file
84+ [default: false]
85+
86+ --overpass-url <OVERPASS_URL>
87+ Overpass API interpreter URL
88+ [default: https://overpass.osm.ch/api/interpreter]
89+
90+ --timeout-seconds <TIMEOUT_SECONDS>
91+ Timeout in seconds for the Overpass query
92+ [default: 900]
93+
94+ --outfile-raw <OUTFILE_RAW>
95+ Output file for raw response (only written if --keep-intermediate=true)
96+ [default: overpass-result.json]
97+
98+ --outfile-compressed <OUTFILE_COMPRESSED>
99+ Output file for compressed result
100+ [default: charging-stations-osm.json.gz]
101+
102+ -h, --help
103+ Print help
104+
105+ -V, --version
106+ Print version
107+ ```
108+
109+ ## Query Details
110+
111+ The tool executes the following Overpass QL query:
112+
113+ ```
114+ [out:json][timeout:900];
115+ (
116+ node[amenity=charging_station];
117+ area[amenity=charging_station];
118+ relation[amenity=charging_station];
119+ );
120+ out meta qt;
121+ ```
122+
123+ This query retrieves:
124+
125+ - All nodes tagged as charging stations
126+ - All areas (ways) tagged as charging stations
127+ - All relations tagged as charging stations
128+
129+ ## Future Enhancements
130+
131+ The async architecture allows for future parallelization opportunities, such as:
132+
133+ - Parallel processing of large datasets
134+ - Concurrent API requests for different regions
135+ - Streamed parsing and processing of HTTP response
60136
61137## License
62138
0 commit comments