osm_conversion csv
This commit is contained in:
parent
2008f23920
commit
7bc952b614
@ -7,7 +7,7 @@ let header_csv = ["ref", "way_id", "speedlimit", "highway"]
|
|||||||
let lines_csv = []
|
let lines_csv = []
|
||||||
const sourceFilePath = "./overpass_results/export_saint_mande.json"
|
const sourceFilePath = "./overpass_results/export_saint_mande.json"
|
||||||
const overpassDataJson = require(sourceFilePath)
|
const overpassDataJson = require(sourceFilePath)
|
||||||
const reference_prefix = "75_";
|
let reference_prefix = "94160_";
|
||||||
|
|
||||||
let turn_ii = 0;
|
let turn_ii = 0;
|
||||||
let turn_ii_limit = 3;
|
let turn_ii_limit = 3;
|
||||||
@ -21,11 +21,14 @@ overpassDataJson['elements'].forEach((elem) => {
|
|||||||
if (turn_ii >= turn_ii_limit) {
|
if (turn_ii >= turn_ii_limit) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
let line_properties = {
|
let line_properties = {
|
||||||
"ref": reference_prefix,
|
"ref": reference_prefix + turn_ii,
|
||||||
"way_id": elem.id,
|
"way_id": elem.id,
|
||||||
|
"osm_link": "https://www.openstreetmap.org/way/" + elem.id,
|
||||||
"speedlimit": null,
|
"speedlimit": null,
|
||||||
"highway": null
|
"highway": null,
|
||||||
|
"name": null,
|
||||||
}
|
}
|
||||||
console.log("elem.id", elem.id)
|
console.log("elem.id", elem.id)
|
||||||
if (elem.tags) {
|
if (elem.tags) {
|
||||||
@ -38,11 +41,12 @@ overpassDataJson['elements'].forEach((elem) => {
|
|||||||
|
|
||||||
if (elem.tags.ref) {
|
if (elem.tags.ref) {
|
||||||
|
|
||||||
// line_properties.ref += elem.tags.ref.replace(' ','-')
|
line_properties.ref += '_' + elem.tags.ref.replace(' ', '-')
|
||||||
line_properties.ref += elem.tags.ref
|
}
|
||||||
|
if (elem.tags.name) {
|
||||||
|
line_properties['name'] = elem.tags.name
|
||||||
}
|
}
|
||||||
if (elem.tags.maxspeed) {
|
if (elem.tags.maxspeed) {
|
||||||
console.log("elem.tags.maxspeed", elem.tags.maxspeed)
|
|
||||||
line_properties['speedlimit'] = elem.tags.maxspeed
|
line_properties['speedlimit'] = elem.tags.maxspeed
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -50,23 +54,30 @@ overpassDataJson['elements'].forEach((elem) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
let lines_out = lines_csv.map(elem => {
|
let lines_out = lines_csv.map(elem => {
|
||||||
|
|
||||||
let keys = Object.keys(elem)
|
let keys = Object.keys(elem)
|
||||||
let csv_line = '';
|
let csv_line = '';
|
||||||
|
let ii = 0;
|
||||||
keys.forEach(keyName => {
|
keys.forEach(keyName => {
|
||||||
csv_line += elem[keyName]+', '
|
csv_line += elem[keyName]
|
||||||
|
if(ii < 1? '': ', '){
|
||||||
|
csv_line += ','
|
||||||
|
}
|
||||||
|
ii++
|
||||||
|
console.log("ii, elem[keyName]", ii, elem[keyName])
|
||||||
|
|
||||||
})
|
})
|
||||||
return csv_line + "\n"
|
return csv_line + "\n"
|
||||||
});
|
});
|
||||||
console.log("lines_out", lines_out)
|
writeCSVOutput();
|
||||||
// writeCSVOutput();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function writeCSVOutput() {
|
function writeCSVOutput() {
|
||||||
|
|
||||||
|
|
||||||
|
let content = header_csv.join(',') + '\n' + lines_out;
|
||||||
fs.writeFile('output/' + exportFileName, header_csv.join(',') + '\n' + lines_out, function (err, data) {
|
console.log("content", content)
|
||||||
|
fs.writeFile('output/' + exportFileName, content, function (err, data) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return console.log(err);
|
return console.log(err);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,3 @@
|
|||||||
|
ref,way_id,speedlimit,highway
|
||||||
|
94160_113859326https://www.openstreetmap.org/way/13859326,50,primary,Avenue de la Porte de Vincennes,
|
||||||
|
,94160_217075650https://www.openstreetmap.org/way/17075650,30,secondary,Avenue Courteline,
|
|
Loading…
Reference in New Issue
Block a user