osm_conversion csv
This commit is contained in:
parent
1ffc1968d5
commit
2008f23920
|
@ -0,0 +1,6 @@
|
|||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
</profile>
|
||||
</component>
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="EslintConfiguration">
|
||||
<option name="fix-on-save" value="true" />
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,13 @@
|
|||
# OSM Conversion
|
||||
|
||||
Convertir un résultat d'overpass vers un tableau CSV de base de données présentant les limites de vitesse de tronçons routiers.
|
||||
|
||||
file:///home/tykayn/Nextcloud/boulot/osm/bdd_vitesses/overpass_results
|
||||
|
||||
## Requête source Overpass turbo
|
||||
https://overpass-turbo.eu/s/1kGY
|
||||
|
||||
## CSV output
|
||||
|-----+--------+-------------+-------+---------+-----------+-----------+-------------+------------------+-----------+----------|
|
||||
| ref | way_id | speedlimit | tags | highway | start_lat | end_long | start_long | end_long | road_name | road_ref |
|
||||
|-----+--------+-------------+-------+---------+-----------+-----------+-------------+------------------+-----------+----------|
|
|
@ -0,0 +1,77 @@
|
|||
/**
|
||||
* converter of overpass results to CSV
|
||||
*/
|
||||
|
||||
const exportFileName = "bdd-vitesses-fr-osm_ways_zone-saint-mande_date-made-2022-08-03_full.csv"
|
||||
let header_csv = ["ref", "way_id", "speedlimit", "highway"]
|
||||
let lines_csv = []
|
||||
const sourceFilePath = "./overpass_results/export_saint_mande.json"
|
||||
const overpassDataJson = require(sourceFilePath)
|
||||
const reference_prefix = "75_";
|
||||
|
||||
let turn_ii = 0;
|
||||
let turn_ii_limit = 3;
|
||||
const fs = require('fs')
|
||||
console.log("overpassDataJson elements", overpassDataJson['elements'].length)
|
||||
|
||||
overpassDataJson['elements'].forEach((elem) => {
|
||||
|
||||
// limit turns for dev time
|
||||
turn_ii++
|
||||
if (turn_ii >= turn_ii_limit) {
|
||||
return
|
||||
}
|
||||
let line_properties = {
|
||||
"ref": reference_prefix,
|
||||
"way_id": elem.id,
|
||||
"speedlimit": null,
|
||||
"highway": null
|
||||
}
|
||||
console.log("elem.id", elem.id)
|
||||
if (elem.tags) {
|
||||
|
||||
|
||||
console.log("elem.tags.highway", elem.tags.highway)
|
||||
if (elem.tags.highway) {
|
||||
line_properties.highway = elem.tags.highway
|
||||
}
|
||||
|
||||
if (elem.tags.ref) {
|
||||
|
||||
// line_properties.ref += elem.tags.ref.replace(' ','-')
|
||||
line_properties.ref += elem.tags.ref
|
||||
}
|
||||
if (elem.tags.maxspeed) {
|
||||
console.log("elem.tags.maxspeed", elem.tags.maxspeed)
|
||||
line_properties['speedlimit'] = elem.tags.maxspeed
|
||||
}
|
||||
}
|
||||
lines_csv.push(line_properties)
|
||||
})
|
||||
|
||||
let lines_out = lines_csv.map(elem => {
|
||||
let keys = Object.keys(elem)
|
||||
let csv_line = '';
|
||||
keys.forEach(keyName=>{
|
||||
csv_line += elem[keyName]+', '
|
||||
})
|
||||
return csv_line + "\n"
|
||||
});
|
||||
console.log("lines_out", lines_out)
|
||||
// writeCSVOutput();
|
||||
|
||||
|
||||
|
||||
function writeCSVOutput() {
|
||||
|
||||
|
||||
|
||||
fs.writeFile('output/' + exportFileName, header_csv.join(',') + '\n' + lines_out, function (err, data) {
|
||||
if (err) {
|
||||
return console.log(err);
|
||||
}
|
||||
console.log('wrote output file', exportFileName);
|
||||
});
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue