2023-02-07 16:09:53 +01:00
|
|
|
var axios = require('axios');
|
|
|
|
var qs = require('qs');
|
|
|
|
var data = qs.stringify({
|
2023-02-07 21:00:00 +01:00
|
|
|
'data': '[bbox:51.990800124058914,10.045623779296875,52.552976197007524,11.01104736328125][out:json];(node["shop"="second_hand"];way["shop"="second_hand"];relation["shop"="second_hand"];);out center;'
|
2023-02-07 16:09:53 +01:00
|
|
|
});
|
|
|
|
var config = {
|
2023-02-07 21:00:00 +01:00
|
|
|
method: 'post',
|
|
|
|
maxBodyLength: Infinity,
|
|
|
|
url: 'https://overpass-api.de/api/interpreter',
|
|
|
|
headers: {
|
|
|
|
'Content-Type': 'application/x-www-form-urlencoded'
|
|
|
|
},
|
|
|
|
data : data
|
2023-02-07 16:09:53 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
function myFunction(value,key) {
|
2023-02-07 21:00:00 +01:00
|
|
|
//console.log("key: "+key+",type: "+value.type);
|
|
|
|
if(value.tags.name===undefined){
|
|
|
|
console.log('ERROR: OSM element does NOT include name tag');
|
|
|
|
}else if(value.type==='node'){
|
|
|
|
console.log('node');
|
|
|
|
console.log('name: '+value.tags.name);
|
|
|
|
console.log('lat: '+value.lat);
|
|
|
|
console.log('lon: '+value.lon);
|
|
|
|
}else if(value.type==='way'){
|
|
|
|
console.log('way');
|
|
|
|
console.log('name: '+value.tags.name);
|
|
|
|
console.log('lat: '+value.center.lat);
|
|
|
|
console.log('lon: '+value.center.lon);
|
|
|
|
}else{
|
|
|
|
console.log('ERROR: OSM element NOT supported');
|
|
|
|
}
|
2023-02-07 16:09:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
axios(config)
|
|
|
|
.then(function (response) {
|
|
|
|
//log JSON
|
2023-02-07 21:00:00 +01:00
|
|
|
const dataObj=response.data;
|
|
|
|
//console.log("dataObj: "+dataObj);
|
|
|
|
const elemAry=dataObj.elements;
|
|
|
|
const elemAryLength=elemAry.length;
|
|
|
|
console.log("no: "+elemAryLength)
|
|
|
|
elemAry.forEach(myFunction);
|
2023-02-07 16:09:53 +01:00
|
|
|
})
|
|
|
|
.catch(function (error) {
|
|
|
|
console.log(error);
|
|
|
|
});
|