Last active
August 29, 2015 14:22
-
-
Save toutpt/4ae67703ceeecefaeac5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*global _:false */ | |
/** | |
* nom | |
* code | |
* type | |
* Site parent | |
* Service mainteneur | |
* long | |
* lat | |
*/ | |
var _ = require('lodash'); | |
var input = require('./highways.json'); | |
var elements = input.elements; | |
var names = []; | |
var name; | |
var data = {}; | |
_.forEach(elements, function (element) { | |
if (!element.tags){ | |
return; | |
} | |
if (!element.tags.name) { | |
return; | |
} | |
name = element.tags.name; | |
if (!_.contains(names, name)) { | |
names.push(name); | |
data[element.id] = { | |
name: element.tags.name, | |
type: element.tags.highway | |
}; | |
if (element.type === 'node') { | |
data[element.id].long = element.lon; | |
data[element.id].lat = element.lat; | |
} | |
if (element.type === 'way') { | |
var nodeid = element.nodes[0]; | |
_.forEach(elements, function (node) { | |
if (node.type === 'node' && node.id === nodeid) { | |
data[element.id].long = node.lon; | |
data[element.id].lat = node.lat; | |
} | |
}); | |
} | |
} else { | |
_.forOwn(data, function (value, key) { | |
if (value.name === name && element.type === 'node' && !value.lat) { | |
value.long = element.lon; | |
value.lat = element.lat; | |
} | |
}); | |
} | |
}); | |
var str; | |
_.forOwn(data, function (value, key) { | |
str = value.name + ';osm_highway_' + value.type + '_' + key + ';RTE;;'; | |
if (value.lat) { | |
str += value.long + ';' + value.lat; | |
} | |
console.log(str); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
This has been generated by the overpass-turbo wizard. | |
The original search was: | |
“highway=* in vern-sur-seiche” | |
*/ | |
[out:json][timeout:25]; | |
// fetch area “vern-sur-seiche” to search in | |
{{geocodeArea:vern-sur-seiche}}->.searchArea; | |
// gather results | |
( | |
// query part for: “highway=*” | |
node["highway"]["name"](area.searchArea); | |
way["highway"]["name"](area.searchArea); | |
relation["highway"]["name"](area.searchArea); | |
); | |
// print results | |
out body; | |
>; | |
out skel qt; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "osm", | |
"version": "1.0.0", | |
"description": "", | |
"main": "extract_sites.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "", | |
"license": "ISC", | |
"devDependencies": { | |
"lodash": "^3.9.3" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment