Commit bcea13bb authored by Patrick's avatar Patrick
Browse files

Big update

parent 5457d923
...@@ -1549,6 +1549,11 @@ ...@@ -1549,6 +1549,11 @@
} }
} }
}, },
"assert-options": {
"version": "0.7.0",
"resolved": "https://registry.npmjs.org/assert-options/-/assert-options-0.7.0.tgz",
"integrity": "sha512-7q9uNH/Dh8gFgpIIb9ja8PJEWA5AQy3xnBC8jtKs8K/gNVCr1K6kIvlm59HUyYgvM7oEDoLzGgPcGd9FqhtXEQ=="
},
"assert-plus": { "assert-plus": {
"version": "0.2.0", "version": "0.2.0",
"resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.2.0.tgz", "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.2.0.tgz",
...@@ -2173,6 +2178,11 @@ ...@@ -2173,6 +2178,11 @@
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz",
"integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==" "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A=="
}, },
"buffer-writer": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/buffer-writer/-/buffer-writer-2.0.0.tgz",
"integrity": "sha512-a7ZpuTZU1TRtnwyCNW3I5dc0wWNC3VR9S++Ewyk2HHZdrO3CQJqSpd+95Us590V6AL7JqUAH2IwZ/398PmNFgw=="
},
"buffer-xor": { "buffer-xor": {
"version": "1.0.3", "version": "1.0.3",
"resolved": "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz", "resolved": "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz",
...@@ -10967,6 +10977,11 @@ ...@@ -10967,6 +10977,11 @@
"integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=", "integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=",
"dev": true "dev": true
}, },
"packet-reader": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/packet-reader/-/packet-reader-1.0.0.tgz",
"integrity": "sha512-HAKu/fG3HpHFO0AA8WE8q2g+gBJaZ9MG7fcKk+IJPLTGAD6Psw4443l+9DGRbOIh3/aXr7Phy0TjilYivJo5XQ=="
},
"pako": { "pako": {
"version": "1.0.10", "version": "1.0.10",
"resolved": "https://registry.npmjs.org/pako/-/pako-1.0.10.tgz", "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.10.tgz",
...@@ -11176,6 +11191,76 @@ ...@@ -11176,6 +11191,76 @@
"resolved": "https://registry.npmjs.org/performance-now/-/performance-now-0.2.0.tgz", "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-0.2.0.tgz",
"integrity": "sha1-M+8wxcd9TqIcWlOGnZG1bY8lVeU=" "integrity": "sha1-M+8wxcd9TqIcWlOGnZG1bY8lVeU="
}, },
"pg": {
"version": "8.5.1",
"resolved": "https://registry.npmjs.org/pg/-/pg-8.5.1.tgz",
"integrity": "sha512-9wm3yX9lCfjvA98ybCyw2pADUivyNWT/yIP4ZcDVpMN0og70BUWYEGXPCTAQdGTAqnytfRADb7NERrY1qxhIqw==",
"requires": {
"buffer-writer": "2.0.0",
"packet-reader": "1.0.0",
"pg-connection-string": "2.4.0",
"pg-pool": "3.2.2",
"pg-protocol": "1.4.0",
"pg-types": "2.2.0",
"pgpass": "1.0.4"
}
},
"pg-connection-string": {
"version": "2.4.0",
"resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-2.4.0.tgz",
"integrity": "sha512-3iBXuv7XKvxeMrIgym7njT+HlZkwZqqGX4Bu9cci8xHZNT+Um1gWKqCsAzcC0d95rcKMU5WBg6YRUcHyV0HZKQ=="
},
"pg-int8": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/pg-int8/-/pg-int8-1.0.1.tgz",
"integrity": "sha512-WCtabS6t3c8SkpDBUlb1kjOs7l66xsGdKpIPZsg4wR+B3+u9UAum2odSsF9tnvxg80h4ZxLWMy4pRjOsFIqQpw=="
},
"pg-minify": {
"version": "1.6.2",
"resolved": "https://registry.npmjs.org/pg-minify/-/pg-minify-1.6.2.tgz",
"integrity": "sha512-1KdmFGGTP6jplJoI8MfvRlfvMiyBivMRP7/ffh4a11RUFJ7kC2J0ZHlipoKiH/1hz+DVgceon9U2qbaHpPeyPg=="
},
"pg-pool": {
"version": "3.2.2",
"resolved": "https://registry.npmjs.org/pg-pool/-/pg-pool-3.2.2.tgz",
"integrity": "sha512-ORJoFxAlmmros8igi608iVEbQNNZlp89diFVx6yV5v+ehmpMY9sK6QgpmgoXbmkNaBAx8cOOZh9g80kJv1ooyA=="
},
"pg-promise": {
"version": "10.9.2",
"resolved": "https://registry.npmjs.org/pg-promise/-/pg-promise-10.9.2.tgz",
"integrity": "sha512-ewelfzZeSPe5sbgd5ylB6edVXqoD8AH/fqZj4wPLL0242vXtkFY3JuUqt3mfvTruOqZHhoINpoXTfmC9UXbZ7A==",
"requires": {
"assert-options": "0.7.0",
"pg": "8.5.1",
"pg-minify": "1.6.2",
"spex": "3.2.0"
}
},
"pg-protocol": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/pg-protocol/-/pg-protocol-1.4.0.tgz",
"integrity": "sha512-El+aXWcwG/8wuFICMQjM5ZSAm6OWiJicFdNYo+VY3QP+8vI4SvLIWVe51PppTzMhikUJR+PsyIFKqfdXPz/yxA=="
},
"pg-types": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/pg-types/-/pg-types-2.2.0.tgz",
"integrity": "sha512-qTAAlrEsl8s4OiEQY69wDvcMIdQN6wdz5ojQiOy6YRMuynxenON0O5oCpJI6lshc6scgAY8qvJ2On/p+CXY0GA==",
"requires": {
"pg-int8": "1.0.1",
"postgres-array": "2.0.0",
"postgres-bytea": "1.0.0",
"postgres-date": "1.0.7",
"postgres-interval": "1.2.0"
}
},
"pgpass": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/pgpass/-/pgpass-1.0.4.tgz",
"integrity": "sha512-YmuA56alyBq7M59vxVBfPJrGSozru8QAdoNlWuW3cz8l+UX3cWge0vTvjKhsSHSJpo3Bom8/Mm6hf0TR5GY0+w==",
"requires": {
"split2": "3.2.2"
}
},
"pify": { "pify": {
"version": "4.0.1", "version": "4.0.1",
"resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz", "resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz",
...@@ -11784,6 +11869,29 @@ ...@@ -11784,6 +11869,29 @@
"uniqs": "2.0.0" "uniqs": "2.0.0"
} }
}, },
"postgres-array": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/postgres-array/-/postgres-array-2.0.0.tgz",
"integrity": "sha512-VpZrUqU5A69eQyW2c5CA1jtLecCsN2U/bD6VilrFDWq5+5UIEVO7nazS3TEcHf1zuPYO/sqGvUvW62g86RXZuA=="
},
"postgres-bytea": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/postgres-bytea/-/postgres-bytea-1.0.0.tgz",
"integrity": "sha1-AntTPAqokOJtFy1Hz5zOzFIazTU="
},
"postgres-date": {
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/postgres-date/-/postgres-date-1.0.7.tgz",
"integrity": "sha512-suDmjLVQg78nMK2UZ454hAG+OAW+HQPZ6n++TNDUX+L0+uUlLywnoxJKDou51Zm+zTCjrCl0Nq6J9C5hP9vK/Q=="
},
"postgres-interval": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/postgres-interval/-/postgres-interval-1.2.0.tgz",
"integrity": "sha512-9ZhXKM/rw350N1ovuWHbGxnGh/SNJ4cnxHiM0rxE4VN41wsg8P8zWn9hv/buK00RP4WvlOyr/RBDiptyxVbkZQ==",
"requires": {
"xtend": "4.0.2"
}
},
"prepend-http": { "prepend-http": {
"version": "1.0.4", "version": "1.0.4",
"resolved": "https://registry.npmjs.org/prepend-http/-/prepend-http-1.0.4.tgz", "resolved": "https://registry.npmjs.org/prepend-http/-/prepend-http-1.0.4.tgz",
...@@ -13284,6 +13392,11 @@ ...@@ -13284,6 +13392,11 @@
"integrity": "sha512-J+FWzZoynJEXGphVIS+XEh3kFSjZX/1i9gFBaWQcB+/tmpe2qUsSBABpcxqxnAxFdiUFEgAX1bjYGQvIZmoz9Q==", "integrity": "sha512-J+FWzZoynJEXGphVIS+XEh3kFSjZX/1i9gFBaWQcB+/tmpe2qUsSBABpcxqxnAxFdiUFEgAX1bjYGQvIZmoz9Q==",
"dev": true "dev": true
}, },
"spex": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/spex/-/spex-3.2.0.tgz",
"integrity": "sha512-9srjJM7NaymrpwMHvSmpDeIK5GoRMX/Tq0E8aOlDPS54dDnDUIp30DrP9SphMPEETDLzEM9+4qo+KipmbtPecg=="
},
"split-string": { "split-string": {
"version": "3.1.0", "version": "3.1.0",
"resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz", "resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz",
...@@ -13293,6 +13406,39 @@ ...@@ -13293,6 +13406,39 @@
"extend-shallow": "3.0.2" "extend-shallow": "3.0.2"
} }
}, },
"split2": {
"version": "3.2.2",
"resolved": "https://registry.npmjs.org/split2/-/split2-3.2.2.tgz",
"integrity": "sha512-9NThjpgZnifTkJpzTZ7Eue85S49QwpNhZTq6GRJwObb6jnLFNGB7Qm73V5HewTROPyxD0C29xqmaI68bQtV+hg==",
"requires": {
"readable-stream": "3.6.0"
},
"dependencies": {
"readable-stream": {
"version": "3.6.0",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz",
"integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==",
"requires": {
"inherits": "2.0.4",
"string_decoder": "1.3.0",
"util-deprecate": "1.0.2"
}
},
"safe-buffer": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
"integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ=="
},
"string_decoder": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz",
"integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==",
"requires": {
"safe-buffer": "5.2.1"
}
}
}
},
"sprintf-js": { "sprintf-js": {
"version": "1.0.3", "version": "1.0.3",
"resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz",
...@@ -14819,8 +14965,7 @@ ...@@ -14819,8 +14965,7 @@
"xtend": { "xtend": {
"version": "4.0.2", "version": "4.0.2",
"resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz",
"integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==", "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ=="
"dev": true
}, },
"y18n": { "y18n": {
"version": "3.2.1", "version": "3.2.1",
......
...@@ -57,6 +57,7 @@ ...@@ -57,6 +57,7 @@
"http-auth": "^4.1.2", "http-auth": "^4.1.2",
"jquery": "^3.4.1", "jquery": "^3.4.1",
"npm": "^6.13.6", "npm": "^6.13.6",
"pg-promise": "^10.9.2",
"request": "^2.81.0", "request": "^2.81.0",
"soap": "^0.30.0" "soap": "^0.30.0"
}, },
......
...@@ -36,3 +36,810 @@ httpsServer.listen(8081, () => { ...@@ -36,3 +36,810 @@ httpsServer.listen(8081, () => {
console.log('HTTPS Server running on port 443'); console.log('HTTPS Server running on port 443');
}); });
var minutesDifference
var hoursDifference
var secondsDifference
var daysDifference
function timeDifference(date11,date22) {
var date2 = new Date(date11);
var date1 = new Date(date22);
var difference = date1 - date2
daysDifference = Math.floor(difference/1000/60/60/24);
difference -= daysDifference*1000*60*60*24
hoursDifference = Math.floor(difference/1000/60/60);
difference -= hoursDifference*1000*60*60
minutesDifference = Math.floor(difference/1000/60);
difference -= minutesDifference*1000*60
secondsDifference = Math.floor(difference/1000);
console.log('difference = ' +
daysDifference + ' day/s ' +
hoursDifference + ' hour/s ' +
minutesDifference + ' minute/s ' +
secondsDifference + ' second/s ');
}
function timeDifference1(date11,date22) {
var date2 = new Date(date11);
var date1 = new Date(date22);
var difference = date1 - date2
var minutesDifference1
var hoursDifference1
var secondsDifference1
var daysDifference1
daysDifference1 = Math.floor(difference/1000/60/60/24);
difference -= daysDifference1*1000*60*60*24
hoursDifference1 = Math.floor(difference/1000/60/60);
difference -= hoursDifference1*1000*60*60
minutesDifference1 = Math.floor(difference/1000/60);
difference -= minutesDifference1*1000*60
secondsDifference1 = Math.floor(difference/1000);
console.log('difference = ' +
daysDifference1 + ' day/s ' +
hoursDifference1 + ' hour/s ' +
minutesDifference1 + ' minute/s ' +
secondsDifference1 + ' second/s ');
var result = {"daysDifference":daysDifference1,
"hoursDifference":hoursDifference1,
"minutesDifference":minutesDifference1,
"secondsDifference":secondsDifference1}
return(result);
}
//===========================================================================================================================
//Final Version
//===========================================================================================================================
// ---- Traffic Flow ----
// - 3Parts -
// - get request from the html page
app.get('/TrafficFlow', async (req, res) => {
console.log('command angekommen!')
try{
let APIout = await flow_getApiResponse('https://traffic.ls.hereapi.com/traffic/6.2/flow.json?prox=48.7823,9.1807,919&responseattributes=sh%2Cfc&apiKey=9Grm-6B7VRvxAnbf2eKw29gR-9uuJP8VaXXYR8LK93Y');
let json_tf = await flow_buildTFLOWJson(APIout);
var json_tfs = {
"name":"flow" + "01",
"type":"FeatureCollection",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
"features": json_tf
};
res.json(json_tfs)
}catch (error) {
console.log(error)
}
});
// - request from the here API
function flow_getApiResponse(url) {
return new Promise(function (resolve, reject) {
request(url, function (error, res, body) {
if (!error && res.statusCode == 200) {
resolve(body);
} else {
reject(error);
}
});
});
}
// - build geojson from response
function flow_buildTFLOWJson(inputData){
return new Promise(function (resolve, reject) {
try {
var json_tflow = JSON.parse(inputData)
var JsonFeature = [];
console.log(json_tflow.RWS[0].RW.length + "---- in flow func")
var length = json_tflow.RWS[0].RW.length;
// console.log(length);
for (var i = 0; i<= length -1; i++){
var shplength = json_tflow.RWS[0].RW[i].FIS[0].FI[0].SHP.length;
// var type = accident.body.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].TRAFFIC_ITEM_TYPE_DESC;
var mid = json_tflow.RWS[0].RW[i].mid;
var LI = json_tflow.RWS[0].RW[i].LI;
var DE = json_tflow.RWS[0].RW[i].DE;
var PBT = json_tflow.RWS[0].RW[i].PBT;
var TMC = json_tflow.RWS[0].RW[i].FIS[0].FI[0].TMC;
var CF = json_tflow.RWS[0].RW[i].FIS[0].FI[0].CF[0];
var locationshp = [];
for (var j = 0; j <= shplength - 1; j++ ){
var value = json_tflow.RWS[0].RW[i].FIS[0].FI[0].SHP[j].value[0];
// console.log(value[0])
var splitvalue = [];
splitvalue = value.split(" ");
// console.log(splitvalue.length)
var coord = [];
for (var k = 0; k <= splitvalue.length -2; k++){
var latlon = [];
latlon = splitvalue[k].split(",");
var lat = latlon[0];
var lon = latlon[1];
coord.push([parseFloat(lon),parseFloat(lat)])
}
// var FC = accident.body.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].LOCATION.GEOLOC.ORIGIN.LONGITUDE;
locationshp.push(coord)
// console.log(value)
}
if (CF.JF){
// console.log("CF.JF -- " + CF.JF)
}
if ((CF.JF >= 3) ){
JsonFeature.push({
"type":"Feature",
"properties": { "id": mid, "name": "linestring" , "LI": LI, "DE": DE, "PBT":PBT, "TMC":TMC, "CF":CF},
"geometry":{
"type":"MultiLineString",
"coordinates": locationshp
},
"vcsMeta": {
"style": {
"type": "vector",
"stroke": {
"color": [
153,
0,
0,
1
],
"width": 2,
"lineDash": null
}
}
}
})
} else if ((CF.JF <3 && CF.JF >= 2) ){
JsonFeature.push({
"type":"Feature",
"properties": { "id": mid, "name": "linestring" , "LI": LI, "DE": DE, "PBT":PBT, "TMC":TMC, "CF":CF},
"geometry":{
"type":"MultiLineString",
"coordinates": locationshp
},
"vcsMeta": {
"style": {
"type": "vector",
"stroke": {
"color": [
255,
153,
51,
1
],
"width": 2,
"lineDash": null
}
}
}
})
} else if ((CF.JF <2 && CF.JF >= 1)){
JsonFeature.push({
"type":"Feature",
"properties": { "id": mid, "name": "linestring" , "LI": LI, "DE": DE, "PBT":PBT, "TMC":TMC, "CF":CF},
"geometry":{
"type":"MultiLineString",
"coordinates": locationshp
},
"vcsMeta": {
"style": {
"type": "vector",
"stroke": {
"color": [
230,
230,
0,
1
],
"width": 2,
"lineDash": null
}
}
}
})
} else if ((CF.JF < 1)){
JsonFeature.push({
"type":"Feature",
"properties": { "id": mid, "name": "linestring" , "LI": LI, "DE": DE, "PBT":PBT, "TMC":TMC, "CF":CF},
"geometry":{
"type":"MultiLineString",
"coordinates": locationshp
},
"vcsMeta": {
"style": {
"type": "vector",
"stroke": {
"color": [
0,
153,
0,
1
],
"width": 2,
"lineDash": null
}
}
}
})
}
};
resolve(JsonFeature)
}catch(error){ reject(error)}
});
};
// ---- Accidents ----
// - 3Parts -
// - get request from the html page
app.get('/CONSTRUCTION', async (req, res) => {
console.log('Construction angekommen!')
try{
let APIout = await CON_getApiResponse('https://traffic.ls.hereapi.com/traffic/6.3/incidents.json?apiKey=9Grm-6B7VRvxAnbf2eKw29gR-9uuJP8VaXXYR8LK93Y&bbox=48.790,9.139;48.771,9.239');
let json_con = await CON_buildTFLOWJson(APIout,"CONSTRUCTION");
console.log(json_con)
var json_cons = {
"name":"incident" + "01",
"type":"FeatureCollection",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
"features": json_con
};
res.json(json_cons)
}catch (error) {
console.log(error)
}
});
app.get('/ROAD_CLOSURE', async (req, res) => {
console.log('Construction angekommen!')
try{
let APIout = await CON_getApiResponse('https://traffic.ls.hereapi.com/traffic/6.3/incidents.json?apiKey=9Grm-6B7VRvxAnbf2eKw29gR-9uuJP8VaXXYR8LK93Y&bbox=48.790,9.139;48.771,9.239');
let json_con = await CON_buildTFLOWJson(APIout,"ROAD_CLOSURE");
console.log(json_con)
var json_cons = {
"name":"incident" + "01",
"type":"FeatureCollection",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
"features": json_con
};
res.json(json_cons)
}catch (error) {
console.log(error)
}
});
// - request from the here API
function CON_getApiResponse(url) {
return new Promise(function (resolve, reject) {
request(url, function (error, res, body) {
if (!error && res.statusCode == 200) {
resolve(body);
} else {
reject(error);
}
});
});
}
// - build geojson from response
function CON_buildTFLOWJson(inputData,type){
return new Promise(function (resolve, reject) {
try {
var JsonFeature = [];
var json_acc = JSON.parse(inputData)
var length = json_acc.TRAFFIC_ITEMS.TRAFFIC_ITEM.length;
// console.log(length)
for (var i = 0; i <= length - 1; i++){
// console.log(json_acc.TRAFFIC_ITEMS.TRAFFIC_ITEM[i])
var lat = json_acc.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].LOCATION.GEOLOC.ORIGIN.LATITUDE;
var lon = json_acc.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].LOCATION.GEOLOC.ORIGIN.LONGITUDE;
// var type = json_acc.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].TRAFFIC_ITEM_TYPE_DESC;
var id = json_acc.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].TRAFFIC_ITEM_ID;
var origid = json_acc.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].ORIGINAL_TRAFFIC_ITEM_ID;
var TRAFFIC_ITEM_DESCRIPTION = json_acc.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].TRAFFIC_ITEM_DESCRIPTION;
var COMMENTS = json_acc.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].COMMENTS;
var CRITICALITY = json_acc.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].CRITICALITY;
var VERIFIED = json_acc.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].VERIFIED;
var TRAFFIC_ITEM_TYPE_DESC = json_acc.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].TRAFFIC_ITEM_TYPE_DESC;
var TRAFFIC_ITEM_STATUS_SHORT_DESC = json_acc.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].TRAFFIC_ITEM_STATUS_SHORT_DESC;
var TRAFFIC_ITEM_DETAIL = json_acc.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].TRAFFIC_ITEM_DETAIL;
var START_TIME = json_acc.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].START_TIME;
var LOCATION = json_acc.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].LOCATION;
var ENTRY_TIME = json_acc.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].ENTRY_TIME;
var END_TIME = json_acc.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].END_TIME;
var ABBREVIATION = json_acc.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].ABBREVIATION;
if (type == 'CONSTRUCTION'){
// console.log(i)
if (TRAFFIC_ITEM_TYPE_DESC == "CONSTRUCTION"){
JsonFeature.push({
"type":"Feature",
"properties": { "id": id, "name": "datapoint" , "original_traffic_id": origid, "TRAFFIC_ITEM_DESCRIPTION": TRAFFIC_ITEM_DESCRIPTION, "COMMENTS":COMMENTS, "CRITICALITY":CRITICALITY,
"VERIFIED":VERIFIED,"TRAFFIC_ITEM_TYPE_DESC":TRAFFIC_ITEM_TYPE_DESC, "TRAFFIC_ITEM_STATUS_SHORT_DESC":TRAFFIC_ITEM_STATUS_SHORT_DESC, "TRAFFIC_ITEM_DETAIL":TRAFFIC_ITEM_DETAIL,
"START_TIME":START_TIME, "LOCATION":LOCATION, "ENTRY_TIME":ENTRY_TIME, "END_TIME":END_TIME, "ABBREVIATION":ABBREVIATION},
"geometry":{
"type":"MultiPoint",
"coordinates": [ [lon, lat]]
}
})
}
} else if (type == "ROAD_CLOSURE"){
if (TRAFFIC_ITEM_TYPE_DESC == "ROAD_CLOSURE"){
JsonFeature.push({
"type":"Feature",
"properties": { "id": id, "name": "datapoint" , "original_traffic_id": origid, "TRAFFIC_ITEM_DESCRIPTION": TRAFFIC_ITEM_DESCRIPTION, "COMMENTS":COMMENTS, "CRITICALITY":CRITICALITY,
"VERIFIED":VERIFIED,"TRAFFIC_ITEM_TYPE_DESC":TRAFFIC_ITEM_TYPE_DESC, "TRAFFIC_ITEM_STATUS_SHORT_DESC":TRAFFIC_ITEM_STATUS_SHORT_DESC, "TRAFFIC_ITEM_DETAIL":TRAFFIC_ITEM_DETAIL,
"START_TIME":START_TIME, "LOCATION":LOCATION, "ENTRY_TIME":ENTRY_TIME, "END_TIME":END_TIME, "ABBREVIATION":ABBREVIATION},
"geometry":{
"type":"MultiPoint",
"coordinates": [ [lon, lat]]
}
})
}
}
}
resolve(JsonFeature)
}catch(error){ reject(error)}
});
};
// ---- Navpoint ----
// - receive coordinates and return a geojson
app.get('/addPoint', async (req, res) => {
try {
var data = req.query;
var Punktadd = {
"type":"FeatureCollection",
"name":"data_point",
"crs":{
"type":"name",
"properties":{
"name":"urn:ogc:def:crs:OGC:1.3:CRS84"
}
},
"features":[
{
"type":"Feature",
"properties":{
"id":null,
"name":"datapoint",
"loc": data.sloc
},
"geometry":{
"type":"Point",
"coordinates":[
parseFloat(parseFloat(data.slon).toFixed(7)),
parseFloat(parseFloat(data.slat).toFixed(7))
]
}
}
]
}
res.json(Punktadd);
} catch (error) {
console.log(error)
}
});
// http://localhost:8083/Routecalc2?slat=48.68997020356071&slon=9.202611390575258&sloc=Start&elat=48.726559406813294&elon=9.113775973868089&eloc=End
// ---- Route Berechnen Test ----
app.get('/Routecalc2', async (req, res) => {
console.log('command angekommen ////// Route/////!')
const pointData = req.query;
console.log(pointData);
try {
let APIout = await CON_getApiResponse('https://router.hereapi.com/v8/routes?transportMode=car&origin='+ pointData.slat + ',' + pointData.slon + '&destination=' + pointData.elat + ',' + pointData.elon + '&return=polyline&apiKey=9Grm-6B7VRvxAnbf2eKw29gR-9uuJP8VaXXYR8LK93Y');
console.log(APIout)
let json_route = await Route_buildJson(APIout);
console.log(json_route)
var json_routes = {
"name":"navcar" + "01",
"type":"FeatureCollection",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
"features": json_route
};
console.log(json_routes);
console.log('.../route calc successful!');
res.json(json_routes);
}
catch (err) {
console.log('.../loadSetP failed!\n' + err);
}
});
// - build geojson for Car Routing
function Route_buildJson(inputData){
return new Promise(function (resolve, reject) {
try {
var JsonFeature = [];
var json_route = JSON.parse(inputData)
var pol = polycalc.decode(json_route.routes[0].sections[0].polyline)
var length = pol.polyline.length;
// console.log(length);
var id = json_route.routes[0].id;
var mid = json_route.routes[0].sections[0].id;
var transport = json_route.routes[0].sections[0].transport.mode;
var departureTime = json_route.routes[0].sections[0].departure.time;
var departureOriglat = json_route.routes[0].sections[0].departure.place.originalLocation.lat;
// console.log(departureOriglat)
var departureOriglon = json_route.routes[0].sections[0].departure.place.originalLocation.lng;
// console.log(departureOriglon)
var departurelat = json_route.routes[0].sections[0].departure.place.location.lat;
var departurelon = json_route.routes[0].sections[0].departure.place.location.lng;
var arrivalTime = json_route.routes[0].sections[0].arrival.time;
var arrivalOriglat = json_route.routes[0].sections[0].arrival.place.originalLocation.lat;
var arrivalOriglon = json_route.routes[0].sections[0].arrival.place.originalLocation.lng;
var arrivallat = json_route.routes[0].sections[0].arrival.place.location.lat;
var arrivallon = json_route.routes[0].sections[0].arrival.place.location.lng;
var departure = [];
departure.push([parseFloat(parseFloat(departureOriglon).toFixed(5)),parseFloat(parseFloat(departureOriglat).toFixed(5))]);
departure.push([parseFloat(parseFloat(departurelon).toFixed(5)),parseFloat(parseFloat(departurelat).toFixed(5))])
timeDifference(departureTime,arrivalTime);
JsonFeature.push({
"type":"Feature",
"properties": { "id": id, "name": "linestring" ,"transport": transport,"departureTime": departureTime, "daysDifference": daysDifference, "hoursDifference": hoursDifference, "minutesDifference" : minutesDifference, "secondsDifference": secondsDifference},
"geometry":{
"type":"LineString",
"coordinates": departure
},
"vcsMeta": {
"style": {
"type": "vector",
"stroke": {
"color": [
30,144,255,
1
],
"width": 3,
"lineDash": null
}
}
}
})
var arrival = [];
arrival.push([parseFloat(parseFloat(arrivalOriglon).toFixed(5)),parseFloat(parseFloat(arrivalOriglat).toFixed(5))]);
arrival.push([parseFloat(parseFloat(arrivallon).toFixed(5)),parseFloat(parseFloat(arrivallat).toFixed(5))])
// console.log(arrival)
JsonFeature.push({
"type":"Feature",
"properties": { "id": id, "name": "linestring" ,"transport": transport,"arrivalTime": arrivalTime,"departureTime": departureTime, "daysDifference": daysDifference, "hoursDifference": hoursDifference, "minutesDifference" : minutesDifference, "secondsDifference": secondsDifference},
"geometry":{
"type":"LineString",
"coordinates": arrival
},
"vcsMeta": {
"style": {
"type": "vector",
"stroke": {
"color": [
30,144,255,
1
],
"width": 3,
"lineDash": null
}
}
}
})
var pline = [];
var length = pol.polyline.length;
for (var i = 0; i<= length -1; i++){
pline.push([parseFloat(parseFloat(pol.polyline[i][1]).toFixed(5)),parseFloat(parseFloat(pol.polyline[i][0]).toFixed(5))])
}
JsonFeature.push({
"type":"Feature",
"properties": { "id": id, "name": "linestring" ,"transport": transport,"departureTime": departureTime, "daysDifference": daysDifference, "hoursDifference": hoursDifference, "minutesDifference" : minutesDifference, "secondsDifference": secondsDifference},
"geometry":{
"type":"LineString",
"coordinates": pline
},
"vcsMeta": {
"style": {
"type": "vector",
"stroke": {
"color": [
199,21,133,
1
],
"width": 4,
"lineDash": null
}
}
}
})
// console.log(JsonFeature)
resolve(JsonFeature)
}catch(error){ reject(error)}
});
};
// ---- Route Offis Berechnen Test ----
app.get('/navPublicT2', async (req, res) => {
console.log('command angekommen ////// Route/////!')
const pointData = req.query;
console.log(pointData);
try {
let APIout = await CON_getApiResponse('https://transit.router.hereapi.com/v8/routes?origin='+ parseFloat(parseFloat(pointData.slat).toFixed(5)) + ',' + parseFloat(parseFloat(pointData.slon).toFixed(5)) + '&destination=' + parseFloat(parseFloat(pointData.elat).toFixed(5)) + ',' + parseFloat(parseFloat(pointData.elon).toFixed(5)) + '&return=polyline&apiKey=9Grm-6B7VRvxAnbf2eKw29gR-9uuJP8VaXXYR8LK93Y');
console.log(APIout)
let json_pub = await Route_PublicbuildJson(APIout);
console.log(json_pub)
// navPublicjson = {
// "name":"navPublic" + "01",
// "type":"FeatureCollection",
// "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
// "features": buildNavPublic()
// };
var json_public = {
"name":"navPublic" + "01",
"type":"FeatureCollection",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
"features": json_pub
};
console.log(json_public);
console.log('.../route calc successful!');
res.json(json_public);
}
catch (err) {
console.log('.../loadSetP failed!\n' + err);
}
});
// - build geojson for Public Routing
function Route_PublicbuildJson(inputData){
return new Promise(function (resolve, reject) {
try {
var JsonFeature = [];
// var pol = polycalc.decode(navcar.body.routes[0].sections[0].polyline)
// var length = pol.polyline.length;
// console.log(length);
var json_public = JSON.parse(inputData)
var id = json_public.routes[0].id;
var length = json_public.routes[0].sections.length;
console.log("length of Sections: " + length)
for (var i = 0; i<= length -1; i++){
console.log(i)
if (json_public.routes[0].sections[i].type == "pedestrian"){
console.log("pedestrian")
var section = json_public.routes[0].sections[i]
var agencyid = section.id;
var agencyname = section.name;
var arrivaltime = section.arrival.time;
var arrivalplace = section.arrival.place;
var departuretime = section.departure.time;
var departureplace = section.departure.place;
var transportInfo = section.transport;
var pol = polycalc.decode(section.polyline)
var pollength = pol.polyline.length;
var timedifference = timeDifference1(departuretime,arrivaltime);
var pline = [];
for (var j = 0; j<= pollength -1; j++){
pline.push([parseFloat(parseFloat(pol.polyline[j][1]).toFixed(5)),parseFloat(parseFloat(pol.polyline[j][0]).toFixed(5))])
}
JsonFeature.push({
"type":"Feature",
"properties": { "id": agencyid,"agencyName":agencyname, "name": "linestring" ,"type": "pedestrian","transportInfo":transportInfo,"arrivalTime": arrivaltime,"arrivalPlace": arrivalplace,"departureTime": departuretime,"departurePlace": departureplace, "daysDifference": timedifference.daysDifference, "hoursDifference": timedifference.hoursDifference, "minutesDifference" : timedifference.minutesDifference, "secondsDifference": timedifference.secondsDifference},
"geometry":{
"type":"LineString",
"coordinates": pline
},
"vcsMeta": {
"style": {
"type": "vector",
"stroke": {
"color": [
30,144,255,
1
],
"width": 3,
"lineDash": null
}
}
}
})
console.log(JsonFeature)
} else if (json_public.routes[0].sections[i].type == "transit"){
console.log("transit")
var section = json_public.routes[0].sections[i]
var agencyid = section.id;
var agencyname = section.name;
var arrivaltime = section.arrival.time;
var arrivalplace = section.arrival.place;
var departuretime = section.departure.time;
var departureplace = section.departure.place;
var transportInfo = section.transport;
var pol = polycalc.decode(section.polyline)
var pollength = pol.polyline.length;
var timedifference = timeDifference1(departuretime,arrivaltime);
var pline = [];
for (var j = 0; j<= pollength -1; j++){
pline.push([parseFloat(parseFloat(pol.polyline[j][1]).toFixed(5)),parseFloat(parseFloat(pol.polyline[j][0]).toFixed(5))])
}
JsonFeature.push({
"type":"Feature",
"properties": { "id": agencyid,"agencyName":agencyname, "name": "linestring" ,"type": "transit","transportInfo":transportInfo,"arrivalTime": arrivaltime,"arrivalPlace": arrivalplace,"departureTime": departuretime,"departurePlace": departureplace, "daysDifference": timedifference.daysDifference, "hoursDifference": timedifference.hoursDifference, "minutesDifference" : timedifference.minutesDifference, "secondsDifference": timedifference.secondsDifference},
"geometry":{
"type":"LineString",
"coordinates": pline
},
"vcsMeta": {
"style": {
"type": "vector",
"stroke": {
"color": [
255,140,0,
1
],
"width": 4,
"lineDash": null
}
}
}
})
console.log(JsonFeature)
}
}
resolve(JsonFeature)
}catch(error){ reject(error)}
});
};
// ---- Noise Real Time ----
// - 3Parts -
// - get request from the html page
app.get('/NoiseRealTime', async (req, res) => {
console.log('command angekommen!')
try{
let APIout = await flow_getApiResponse('https://data.sensor.community/airrohr/v1/sensor/49368/');
console.log(APIout);
res.json(JSON.parse(APIout));
}catch (error) {
console.log(error)
}
});
// ---- Historic Noise Data ----
// ---- Trial Version from PostgreSQL ----
const pgp = require('pg-promise')({
// Initialization Options
});
const connection = {
user: 'postgres', // name of the user account
database: 'NoiseSensorData', // name of the database
password: 'ahpk94meteor', // env var: PGPASSWORD
host: '193.196.38.112', // Server hosting the postgres database (host: '35.187.21.114')
port: 5432, // env var: PGPORT
max: 10, // max number of clients in the pool
idleTimeoutMillis: 30000 // how long a client is allowed to remain idle before being closed
}
const db = pgp(connection);
console.log('successful connected to DB: NoiseSensorData!')
app.post('/getNoiseHist', function (req, res) {
try {
const data = req.body;
// = "select sensor_id from public.noisesensor;"
let query_string = " SELECT * FROM noisesensors ORDER BY timestamp ASC;"
// query_string += "from noisesensor;";
console.log(query_string)
// request the data rsr
db.result(query_string)
.then(result => {
res.json(result.rows);
})
.catch(error => {
console.log('ERROR:', error);
});
console.log('.../getNoiseHist successful!');
}
catch (err) {
console.log('.../getNoiseHist failed!\n' + err);
}
});
\ No newline at end of file
...@@ -16,189 +16,1243 @@ app.use(express.static('vcm')); ...@@ -16,189 +16,1243 @@ app.use(express.static('vcm'));
app.listen(process.env.PORT || 8083); app.listen(process.env.PORT || 8083);
console.log("on 8083"); console.log("on 8083");
//Public Transport https://transit.router.hereapi.com/v8/routes?origin=48.803175,9.226140&destination=48.780264,9.172469&return=polyline&apiKey=9Grm-6B7VRvxAnbf2eKw29gR-9uuJP8VaXXYR8LK93Y // //Public Transport https://transit.router.hereapi.com/v8/routes?origin=48.803175,9.226140&destination=48.780264,9.172469&return=polyline&apiKey=9Grm-6B7VRvxAnbf2eKw29gR-9uuJP8VaXXYR8LK93Y
//https://traffic.ls.hereapi.com/traffic/6.1/flow.json?bbox=48.8575,8.9757;48.6747,9.3712&responseattributes=sh%2Cfc&apiKey=9Grm-6B7VRvxAnbf2eKw29gR-9uuJP8VaXXYR8LK93Y // //https://traffic.ls.hereapi.com/traffic/6.1/flow.json?bbox=48.8575,8.9757;48.6747,9.3712&responseattributes=sh%2Cfc&apiKey=9Grm-6B7VRvxAnbf2eKw29gR-9uuJP8VaXXYR8LK93Y
var flow // var flow
request('https://traffic.ls.hereapi.com/traffic/6.2/flow.json?prox=48.7823,9.1807,919&responseattributes=sh%2Cfc&apiKey=9Grm-6B7VRvxAnbf2eKw29gR-9uuJP8VaXXYR8LK93Y', {json:true},(err, res, body) => { // request('https://traffic.ls.hereapi.com/traffic/6.2/flow.json?prox=48.7823,9.1807,919&responseattributes=sh%2Cfc&apiKey=9Grm-6B7VRvxAnbf2eKw29gR-9uuJP8VaXXYR8LK93Y', {json:true},(err, res, body) => {
if (err) {return console.log(err); }
console.log(body.url);
console.log(body.explanation);
flow = res
})
var accident
request('https://traffic.ls.hereapi.com/traffic/6.3/incidents.json?apiKey=9Grm-6B7VRvxAnbf2eKw29gR-9uuJP8VaXXYR8LK93Y&bbox=48.790,9.139;48.771,9.239', { json: true }, (err, res, body) => {
if (err) { return console.log(err); }
console.log(body.url);
console.log(body.explanation);
accident = res
console.log(accident[1]);
});
var navcar
// request('https://router.hereapi.com/v8/routes?transportMode=car&origin=48.803175,9.226140&destination=48.780264,9.172469&return=polyline&apiKey=9Grm-6B7VRvxAnbf2eKw29gR-9uuJP8VaXXYR8LK93Y', {json:true},(err, res, body) => {
// if (err) {return console.log(err); } // if (err) {return console.log(err); }
// console.log(body.url); // console.log(body.url);
// console.log(body.explanation); // console.log(body.explanation);
// navcar = res // flow = res
// })
// var accident
// request('https://traffic.ls.hereapi.com/traffic/6.3/incidents.json?apiKey=9Grm-6B7VRvxAnbf2eKw29gR-9uuJP8VaXXYR8LK93Y&bbox=48.790,9.139;48.771,9.239', { json: true }, (err, res, body) => {
// if (err) { return console.log(err); }
// console.log(body.url);
// console.log(body.explanation);
// accident = res
// console.log(accident[1]);
// });
// var navcar
// // request('https://router.hereapi.com/v8/routes?transportMode=car&origin=48.803175,9.226140&destination=48.780264,9.172469&return=polyline&apiKey=9Grm-6B7VRvxAnbf2eKw29gR-9uuJP8VaXXYR8LK93Y', {json:true},(err, res, body) => {
// // if (err) {return console.log(err); }
// // console.log(body.url);
// // console.log(body.explanation);
// // navcar = res
// // })
// var testjsonsflow = {
// "type": "FeatureCollection",
// "features": [
// {
// "type": "Feature",
// "properties": {},
// "geometry": {
// "type": "LineString",
// "coordinates": [
// [
// 9.211758404732821,
// 48.79928779052079,
// -0.003812428450083977
// ],
// [
// 9.21372550369925,
// 48.79757037042029,
// -0.004464600820639255
// ],
// [
// 9.217416766673484,
// 48.79386716715126,
// -0.0037284616307613283
// ],
// [
// 9.217370353016513,
// 48.79390319685058,
// -0.0038132023499026415
// ]
// ]
// },
// "vcsMeta": {
// "style": {
// "type": "vector",
// "stroke": {
// "color": [
// 51,
// 153,
// 204,
// 1
// ],
// "width": 39,
// "lineDash": null
// }
// }
// }
// }
// ],
// "vcsMeta": {
// "version": "1.0",
// "altitudeMode": "clampToGround",
// "embeddedIcons": []
// }
// }
// var flowjson;
// app.get('/FLOW', function (req, res) {
// console.log('command angekommen!')
// try {
// // res.json(testjsonsflow);
// res.json(flowjson);
// console.log('.../loadSetP successful!');
// }
// catch (err) {
// console.log('.../loadSetP failed!\n' + err);
// }
// });
// // var navcartest;
// var navcarjson;
// app.get('/NAVCAR', function (req, res) {
// console.log('command angekommen!')
// try {
// // console.log(navcar.body.routes[0].sections[0].polyline)
// // var pol = polycalc.decode(navcar.body.routes[0].sections[0].polyline)
// // console.log(pol)
// // res.json(testjsonsflow);
// res.json(navcarjson);
// // console.log(navcarjson)
// console.log('.../loadSetP successful!');
// }
// catch (err) {
// console.log('.../loadSetP failed!\n' + err);
// }
// });
// app.get('/CONSTRUCTION2', function (req, res) {
// console.log('command angekommen!')
// try {
// var testjson = {
// "name":"incident" + "01",
// "type":"FeatureCollection",
// "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
// "features": buildJSON('CONSTRUCTION')
// };
// res.json(testjson);
// console.log('.../loadSetP successful!');
// }
// catch (err) {
// console.log('.../loadSetP failed!\n' + err);
// }
// });
// app.get('/ROAD_CLOSURE2', function (req, res) {
// console.log('command angekommen!')
// try {
// var testjson = {
// "name":"incident" + "01",
// "type":"FeatureCollection",
// "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
// "features": buildJSON('ROAD_CLOSURE')
// };
// res.json(testjson);
// console.log('.../loadSetP successful!');
// }
// catch (err) {
// console.log('.../loadSetP failed!\n' + err);
// }
// });
// function buildFLOW(){
// var JsonFeature = [];
// var length = flow.body.RWS[0].RW.length;
// // console.log(length);
// for (var i = 0; i<= length -1; i++){
// var shplength = flow.body.RWS[0].RW[i].FIS[0].FI[0].SHP.length;
// // var type = accident.body.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].TRAFFIC_ITEM_TYPE_DESC;
// var mid = flow.body.RWS[0].RW[i].mid;
// var LI = flow.body.RWS[0].RW[i].LI;
// var DE = flow.body.RWS[0].RW[i].DE;
// var PBT = flow.body.RWS[0].RW[i].PBT;
// var TMC = flow.body.RWS[0].RW[i].FIS[0].FI[0].TMC;
// var CF = flow.body.RWS[0].RW[i].FIS[0].FI[0].CF[0];
// var locationshp = [];
// for (var j = 0; j <= shplength - 1; j++ ){
// var value = flow.body.RWS[0].RW[i].FIS[0].FI[0].SHP[j].value[0];
// // console.log(value[0])
// var splitvalue = [];
// splitvalue = value.split(" ");
// // console.log(splitvalue.length)
// var coord = [];
// for (var k = 0; k <= splitvalue.length -2; k++){
// var latlon = [];
// latlon = splitvalue[k].split(",");
// var lat = latlon[0];
// var lon = latlon[1];
// coord.push([parseFloat(lon),parseFloat(lat)])
// }
// // var FC = accident.body.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].LOCATION.GEOLOC.ORIGIN.LONGITUDE;
// locationshp.push(coord)
// // console.log(value)
// }
// if (CF.JF){
// // console.log("CF.JF -- " + CF.JF)
// }
// if ((CF.JF >= 3) ){
// JsonFeature.push({
// "type":"Feature",
// "properties": { "id": mid, "name": "linestring" , "LI": LI, "DE": DE, "PBT":PBT, "TMC":TMC, "CF":CF},
// "geometry":{
// "type":"MultiLineString",
// "coordinates": locationshp
// },
// "vcsMeta": {
// "style": {
// "type": "vector",
// "stroke": {
// "color": [
// 153,
// 0,
// 0,
// 1
// ],
// "width": 2,
// "lineDash": null
// }
// }
// }
// })
// } else if ((CF.JF <3 && CF.JF >= 2) ){
// JsonFeature.push({
// "type":"Feature",
// "properties": { "id": mid, "name": "linestring" , "LI": LI, "DE": DE, "PBT":PBT, "TMC":TMC, "CF":CF},
// "geometry":{
// "type":"MultiLineString",
// "coordinates": locationshp
// },
// "vcsMeta": {
// "style": {
// "type": "vector",
// "stroke": {
// "color": [
// 255,
// 153,
// 51,
// 1
// ],
// "width": 2,
// "lineDash": null
// }
// }
// }
// })
// } else if ((CF.JF <2 && CF.JF >= 1)){
// JsonFeature.push({
// "type":"Feature",
// "properties": { "id": mid, "name": "linestring" , "LI": LI, "DE": DE, "PBT":PBT, "TMC":TMC, "CF":CF},
// "geometry":{
// "type":"MultiLineString",
// "coordinates": locationshp
// },
// "vcsMeta": {
// "style": {
// "type": "vector",
// "stroke": {
// "color": [
// 230,
// 230,
// 0,
// 1
// ],
// "width": 2,
// "lineDash": null
// }
// }
// }
// })
// } else if ((CF.JF < 1)){
// JsonFeature.push({
// "type":"Feature",
// "properties": { "id": mid, "name": "linestring" , "LI": LI, "DE": DE, "PBT":PBT, "TMC":TMC, "CF":CF},
// "geometry":{
// "type":"MultiLineString",
// "coordinates": locationshp
// },
// "vcsMeta": {
// "style": {
// "type": "vector",
// "stroke": {
// "color": [
// 0,
// 153,
// 0,
// 1
// ],
// "width": 2,
// "lineDash": null
// }
// }
// }
// })
// }
// // JsonFeature.push({
// // "type":"Feature",
// // "properties": { "id": mid, "name": "linestring" , "LI": LI, "DE": DE, "PBT":PBT, "TMC":TMC, "CF":CF},
// // "geometry":{
// // "type":"MultiLineString",
// // "coordinates": locationshp
// // },
// // "vcsMeta": {
// // "style": {
// // "type": "vector",
// // "stroke": {
// // "color": [
// // 51,
// // 153,
// // 204,
// // 1
// // ],
// // "width": 39,
// // "lineDash": null
// // }
// // }
// // }
// // })
// // console.log(JsonFeature)
// }
// return JsonFeature
// }
// function buildNavCar(){
// var JsonFeature = [];
// var pol = polycalc.decode(navcar.body.routes[0].sections[0].polyline)
// var length = pol.polyline.length;
// // console.log(length);
// var id = navcar.body.routes[0].id;
// var mid = navcar.body.routes[0].sections[0].id;
// var transport = navcar.body.routes[0].sections[0].transport.mode;
// var departureTime = navcar.body.routes[0].sections[0].departure.time;
// var departureOriglat = navcar.body.routes[0].sections[0].departure.place.originalLocation.lat;
// // console.log(departureOriglat)
// var departureOriglon = navcar.body.routes[0].sections[0].departure.place.originalLocation.lng;
// // console.log(departureOriglon)
// var departurelat = navcar.body.routes[0].sections[0].departure.place.location.lat;
// var departurelon = navcar.body.routes[0].sections[0].departure.place.location.lng;
// var arrivalTime = navcar.body.routes[0].sections[0].arrival.time;
// var arrivalOriglat = navcar.body.routes[0].sections[0].arrival.place.originalLocation.lat;
// var arrivalOriglon = navcar.body.routes[0].sections[0].arrival.place.originalLocation.lng;
// var arrivallat = navcar.body.routes[0].sections[0].arrival.place.location.lat;
// var arrivallon = navcar.body.routes[0].sections[0].arrival.place.location.lng;
// var departure = [];
// departure.push([parseFloat(parseFloat(departureOriglon).toFixed(5)),parseFloat(parseFloat(departureOriglat).toFixed(5))]);
// departure.push([parseFloat(parseFloat(departurelon).toFixed(5)),parseFloat(parseFloat(departurelat).toFixed(5))])
// timeDifference(departureTime,arrivalTime);
// JsonFeature.push({
// "type":"Feature",
// "properties": { "id": id, "name": "linestring" ,"transport": transport,"departureTime": departureTime, "daysDifference": daysDifference, "hoursDifference": hoursDifference, "minutesDifference" : minutesDifference, "secondsDifference": secondsDifference},
// "geometry":{
// "type":"LineString",
// "coordinates": departure
// },
// "vcsMeta": {
// "style": {
// "type": "vector",
// "stroke": {
// "color": [
// 30,144,255,
// 1
// ],
// "width": 3,
// "lineDash": null
// }
// }
// }
// }) // })
var testjsonsflow = { // var arrival = [];
"type": "FeatureCollection", // arrival.push([parseFloat(parseFloat(arrivalOriglon).toFixed(5)),parseFloat(parseFloat(arrivalOriglat).toFixed(5))]);
"features": [ // arrival.push([parseFloat(parseFloat(arrivallon).toFixed(5)),parseFloat(parseFloat(arrivallat).toFixed(5))])
{ // // console.log(arrival)
"type": "Feature", // JsonFeature.push({
"properties": {},
"geometry": { // "type":"Feature",
"type": "LineString", // "properties": { "id": id, "name": "linestring" ,"transport": transport,"arrivalTime": arrivalTime,"departureTime": departureTime, "daysDifference": daysDifference, "hoursDifference": hoursDifference, "minutesDifference" : minutesDifference, "secondsDifference": secondsDifference},
"coordinates": [ // "geometry":{
[ // "type":"LineString",
9.211758404732821, // "coordinates": arrival
48.79928779052079, // },
-0.003812428450083977 // "vcsMeta": {
], // "style": {
[ // "type": "vector",
9.21372550369925, // "stroke": {
48.79757037042029, // "color": [
-0.004464600820639255 // 30,144,255,
], // 1
[ // ],
9.217416766673484, // "width": 3,
48.79386716715126, // "lineDash": null
-0.0037284616307613283 // }
], // }
[ // }
9.217370353016513, // })
48.79390319685058,
-0.0038132023499026415
] // var pline = [];
] // var length = pol.polyline.length;
},
"vcsMeta": { // for (var i = 0; i<= length -1; i++){
"style": { // pline.push([parseFloat(parseFloat(pol.polyline[i][1]).toFixed(5)),parseFloat(parseFloat(pol.polyline[i][0]).toFixed(5))])
"type": "vector", // }
"stroke": { // JsonFeature.push({
"color": [
51, // "type":"Feature",
153, // "properties": { "id": id, "name": "linestring" ,"transport": transport,"departureTime": departureTime, "daysDifference": daysDifference, "hoursDifference": hoursDifference, "minutesDifference" : minutesDifference, "secondsDifference": secondsDifference},
204, // "geometry":{
1 // "type":"LineString",
], // "coordinates": pline
"width": 39, // },
"lineDash": null // "vcsMeta": {
} // "style": {
} // "type": "vector",
} // "stroke": {
} // "color": [
], // 199,21,133,
"vcsMeta": { // 1
"version": "1.0", // ],
"altitudeMode": "clampToGround", // "width": 4,
"embeddedIcons": [] // "lineDash": null
} // }
// }
// }
// })
// // console.log(JsonFeature)
// return JsonFeature
// }
// function buildJSON(type){
// var JsonFeature = [];
// var length = accident.body.TRAFFIC_ITEMS.TRAFFIC_ITEM.length;
// // console.log(length)
// for (var i = 0; i <= length - 1; i++){
// // console.log(accident.body.TRAFFIC_ITEMS.TRAFFIC_ITEM[i])
// var lat = accident.body.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].LOCATION.GEOLOC.ORIGIN.LATITUDE;
// var lon = accident.body.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].LOCATION.GEOLOC.ORIGIN.LONGITUDE;
// // var type = accident.body.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].TRAFFIC_ITEM_TYPE_DESC;
// var id = accident.body.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].TRAFFIC_ITEM_ID;
// var origid = accident.body.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].ORIGINAL_TRAFFIC_ITEM_ID;
// var TRAFFIC_ITEM_DESCRIPTION = accident.body.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].TRAFFIC_ITEM_DESCRIPTION;
// var COMMENTS = accident.body.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].COMMENTS;
// var CRITICALITY = accident.body.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].CRITICALITY;
// var VERIFIED = accident.body.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].VERIFIED;
// var TRAFFIC_ITEM_TYPE_DESC = accident.body.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].TRAFFIC_ITEM_TYPE_DESC;
// var TRAFFIC_ITEM_STATUS_SHORT_DESC = accident.body.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].TRAFFIC_ITEM_STATUS_SHORT_DESC;
// var TRAFFIC_ITEM_DETAIL = accident.body.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].TRAFFIC_ITEM_DETAIL;
// var START_TIME = accident.body.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].START_TIME;
// var LOCATION = accident.body.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].LOCATION;
// var ENTRY_TIME = accident.body.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].ENTRY_TIME;
// var END_TIME = accident.body.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].END_TIME;
// var ABBREVIATION = accident.body.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].ABBREVIATION;
// if (type == 'CONSTRUCTION'){
// // console.log(i)
// if (TRAFFIC_ITEM_TYPE_DESC == "CONSTRUCTION"){
// JsonFeature.push({
// "type":"Feature",
// "properties": { "id": id, "name": "datapoint" , "original_traffic_id": origid, "TRAFFIC_ITEM_DESCRIPTION": TRAFFIC_ITEM_DESCRIPTION, "COMMENTS":COMMENTS, "CRITICALITY":CRITICALITY,
// "VERIFIED":VERIFIED,"TRAFFIC_ITEM_TYPE_DESC":TRAFFIC_ITEM_TYPE_DESC, "TRAFFIC_ITEM_STATUS_SHORT_DESC":TRAFFIC_ITEM_STATUS_SHORT_DESC, "TRAFFIC_ITEM_DETAIL":TRAFFIC_ITEM_DETAIL,
// "START_TIME":START_TIME, "LOCATION":LOCATION, "ENTRY_TIME":ENTRY_TIME, "END_TIME":END_TIME, "ABBREVIATION":ABBREVIATION},
// "geometry":{
// "type":"MultiPoint",
// "coordinates": [ [lon, lat]]
// }
// })
// }
// } else if (type == "ROAD_CLOSURE"){
// if (TRAFFIC_ITEM_TYPE_DESC == "ROAD_CLOSURE"){
// JsonFeature.push({
// "type":"Feature",
// "properties": { "id": id, "name": "datapoint" , "original_traffic_id": origid, "TRAFFIC_ITEM_DESCRIPTION": TRAFFIC_ITEM_DESCRIPTION, "COMMENTS":COMMENTS, "CRITICALITY":CRITICALITY,
// "VERIFIED":VERIFIED,"TRAFFIC_ITEM_TYPE_DESC":TRAFFIC_ITEM_TYPE_DESC, "TRAFFIC_ITEM_STATUS_SHORT_DESC":TRAFFIC_ITEM_STATUS_SHORT_DESC, "TRAFFIC_ITEM_DETAIL":TRAFFIC_ITEM_DETAIL,
// "START_TIME":START_TIME, "LOCATION":LOCATION, "ENTRY_TIME":ENTRY_TIME, "END_TIME":END_TIME, "ABBREVIATION":ABBREVIATION},
// "geometry":{
// "type":"MultiPoint",
// "coordinates": [ [lon, lat]]
// }
// })
// }
// }
// }
// return JsonFeature;
// }
// app.post('/getTrafficIncidents', function (req, res) {
// console.log('command angekommen!')
// try {
// res.json(accident);
// console.log('.../loadSetP successful!');
// }
// catch (err) {
// console.log('.../loadSetP failed!\n' + err);
// }
// });
// app.post('/FLOWdata', function (req, res) {
// console.log('command angekommen!')
// try {
// flowjson = {
// "name":"flow" + "01",
// "type":"FeatureCollection",
// "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
// "features": buildFLOW()
// };
// res.json(flowjson);
// console.log('.../loadSetP successful!');
// }
// catch (err) {
// console.log('.../loadSetP failed!\n' + err);
// }
// });
// app.post('/FLOWtest', function (req, res) {
// console.log('command angekommen!')
// try {
// res.json(testjsonsflow);
// console.log('.../loadSetP successful!');
// }
// catch (err) {
// console.log('.../loadSetP failed!\n' + err);
// }
// });
// app.post('/NavCARdata', function (req, res) {
// console.log('command angekommen!')
// try {
// navcarjson = {
// "name":"navcar" + "01",
// "type":"FeatureCollection",
// "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
// "features": buildNavCar()
// };
// res.json(navcarjson);
// console.log('.../loadSetP successful!');
// }
// catch (err) {
// console.log('.../loadSetP failed!\n' + err);
// }
// });
// var IDGeojson = 100000
// var ballonContent = {
// header: "Test",
// Content: "This is a test",
// lat: "",
// lon: "",
// categorie: "locationSM.png"
// }
// app.post('/', function(req,res){
// try {
// const data = req.body;
// console.log("data ==============")
// // console.log(data.header);
// // console.log(data.Content);
// // console.log(data.lat);
// // console.log(data.lon);
// // console.log(data.categorie);
// ballonContent.header = data.header;
// ballonContent.Content = data.Content;
// ballonContent.lat = data.lat;
// ballonContent.lon = data.lon;
// ballonContent.categorie = data.categorie;
// console.log("args ==============")
// // console.log(args);
// //asdf
// // const returnedTarget = Object.assign(args.ui,data);
// // args.ui = data;
// // args.gmlid = data.id;
// // console.log("returned ==============")
// // console.log(returnedTarget)
// // console.log("args ==============")
// // console.log(args);
// getCurrentFilenames();
// writeGeojsonFile();
// writeConfigFile();
// res.end('It worked!');
// }
// catch (err) {
// console.log('.../getSimS failed!\n' + err);
// }
// });
// var Startpoint;
// var Startpointlat;
// var Startpointlon;
// var Endpoint;
// var Endpointlat;
// var Endpointlon;
// List all the filenames before renaming
// app.post('/navPoint', function(req,res){
// try {
// console.log("navPoint arrived ////////")
// const data = req.body;
// console.log("data ==============")
// console.log(data.lat);
// console.log(data.lon);
// console.log(data.loc);
// if (data.loc == "Start"){
// Startpointlat = parseFloat(parseFloat(data.lat).toFixed(7))
// Startpointlon = parseFloat(parseFloat(data.lon).toFixed(7))
// Startpoint = {
// "type":"FeatureCollection",
// "name":"data_point",
// "crs":{
// "type":"name",
// "properties":{
// "name":"urn:ogc:def:crs:OGC:1.3:CRS84"
// }
// },
// "features":[
// {
// "type":"Feature",
// "properties":{
// "id":null,
// "name":"datapoint"
// },
// "geometry":{
// "type":"Point",
// "coordinates":[
// parseFloat(parseFloat(data.lon).toFixed(7)),
// parseFloat(parseFloat(data.lat).toFixed(7))
// ]
// }
// }
// ]
// }
// // Startpoint.push({
// // "type":"Feature",
// // "properties": { "id": data.loc, "name": "datapoint"},
// // "geometry":{
// // "type":"MultiPoint",
// // "coordinates": [ [data.lon, data.lat]]
// // }
// // })
// console.log(Startpoint)
// res.json(Startpoint);
// } else if (data.loc == "End"){
// Endpointlat = parseFloat(parseFloat(data.lat).toFixed(7))
// Endpointlon = parseFloat(parseFloat(data.lon).toFixed(7))
// Endpoint = {
// "type":"FeatureCollection",
// "name":"data_point",
// "crs":{
// "type":"name",
// "properties":{
// "name":"urn:ogc:def:crs:OGC:1.3:CRS84"
// }
// },
// "features":[
// {
// "type":"Feature",
// "properties":{
// "id":null,
// "name":"datapoint"
// },
// "geometry":{
// "type":"Point",
// "coordinates":[
// parseFloat(parseFloat(data.lon).toFixed(7)),
// parseFloat(parseFloat(data.lat).toFixed(7))
// ]
// }
// }
// ]
// }
// res.json(Endpoint);
// }
// }
// catch (err) {
// console.log('.../getSimS failed!\n' + err);
// }
// });
// app.get('/Startpoint', function (req, res) {
// console.log('command angekommen ////// Startpoint!')
// try {
// // res.json(testjsonsflow);
// res.json(Startpoint);
// console.log('.../loadSetP successful!');
// }
// catch (err) {
// console.log('.../loadSetP failed!\n' + err);
// }
// });
// app.get('/Endpoint', function (req, res) {
// console.log('command angekommen!')
// try {
// // res.json(testjsonsflow);
// res.json(Endpoint);
// console.log('.../loadSetP successful!');
// }
// catch (err) {
// console.log('.../loadSetP failed!\n' + err);
// }
// });
// function getCurrentFilenames() {
// console.log("Current filenames:");
// fs.readdirSync(__dirname + '/vcm/templates').forEach(file => {
// if (file.includes('.geojson')){
// var tempid = file.replace('.geojson','')
// // console.log(tempid)
// if (isNaN(tempid) == false){
// var tempid = parseInt(tempid, 10);
// if (tempid >= IDGeojson){
// IDGeojson = tempid
// console.log("this one - " + IDGeojson)
// }
// } else {
// console.log("not this one - " + tempid)
// }
// }
// // console.log(file);
// });
// IDGeojson += 1
// }
// function writeGeojsonFile() {
// var geojsontemplate = ' {' +
// ' "type": "FeatureCollection",' +
// ' "name": "data_point",' +
// '"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },' +
// ' "features": [' +
// ' { "type": "Feature", "properties": { "id": null, "name": "datapoint" }, "geometry": { "type": "Point", "coordinates": [ ' + ballonContent.lon + ', ' + ballonContent.lat + ' ] } }' +
// ' ]' +
// ' }'
// console.log(geojsontemplate);
// try {
// console.log(geojsontemplate);
// fs.writeFile(__dirname + "/vcm/templates/" + IDGeojson + '.geojson', geojsontemplate, function (err) {
// if (err) throw err;
// console.log('Saved!');
// });
// } catch (err) {
// console.error(err);
// }
// }
// function writeConfigFile(){
// // name of the file
// var filename = 'vcm/config.json';
// var contentSync = fs.readFileSync(filename);
// console.log('Content of the file : ' + contentSync);
// console.log(contentSync.includes('"balloonTypes":'));
// var newtext = contentSync.toString().replace('"layers": [','"layers": [' +
// '{' +
// '"name": "'+ IDGeojson +'",' +
// '"url": "./templates/'+IDGeojson+'.geojson",' +
// '"type": "vcs.vcm.layer.GeoJSON",' +
// '"datasourceId": "...",'+
// '"activeOnStartup": true,'+
// '"exclusive": false,' +
// '"projection": {' +
// ' "epsg": "4326",' +
// ' "proj4": ""' +
// '},' +
// '"altitudeMode": "relativeToGround",' +
// '"style": {' +
// ' "image": {' +
// ' "icon": {' +
// ' "src": "./templates/' + ballonContent.categorie + '",' +
// ' "scale": 0.5' +
// ' }' +
// ' }' +
// '},' +
// '"heightAboveGround": 0' +
// '},')
// var ballonText = "\"balloonTypes\": [" +
// "{" +
// "\"template\": [" +
// "\"<div class='balloon' onclick='' id='myBalloon'>\"," +
// "\" <h1 class='balloon-title'>" + ballonContent.header + "</h1>\"," +
// "\" <div class='balloon-content' style='height:290px; margin-right: 0px;'\"," +
// "\" </div>\"," +
// "\"<p class='balloon-text'><span>" + ballonContent.Content + "</span><br></p>\"," +
// // "\"<img style='padding-top:10px' src='images/content/contentboeckingerstrasse/station3_outdoorkiosk1.jpg' alt='Simply Easy Learning' width='375'>\"," +
// "\"</div>\"," +
// "\"<% %>\"" +
// // "\"<% openquestionaire() %>\"" +
// "]," +
// "\"minTop\": \"balloonHeight + 10\"," +
// "\"minLeft\": \"70\"," +
// "\"layerTypes\": [" +
// "\"\""+
// "],"+
// "\"layerNames\": [" +
// "\""+ IDGeojson +"\"" +
// "]" +
// "},"
// var newtext = newtext.toString().replace("\"balloonTypes\": [", ballonText)
// console.log(newtext);
// fs.writeFile(filename, newtext, 'utf8', function (err) {
// if (err) return console.log(err);
// });
// }
// function writeBallon() {
// var ballonText = "{" +
// "\"template\": [" +
// "\"<div class='balloon' onclick='showtourSpecific()' id='myBalloon'>\"," +
// "\" <h1 class='balloon-title'>Station 3</h1>\"," +
// "\" <div class='balloon-content' style='height:290px; margin-right: 0px;'\"," +
// "\" </div>\"," +
// "\"<p class='balloon-text'><span>hier wurde eine Outdoorkiosk errichtet.</span><br></p>\"," +
// "\"<img style='padding-top:10px' src='images/content/contentboeckingerstrasse/station3_outdoorkiosk1.jpg' alt='Simply Easy Learning' width='375'>\"," +
// "\"</div>\"," +
// "\"<% %>\"," +
// "\"<% openquestionaire() %>\"" +
// "]," +
// "\"minTop\": \"balloonHeight + 10\"," +
// "\"minLeft\": \"70\"," +
// "\"layerTypes\": [" +
// "\"\""+
// "],"+
// "\"layerNames\": [" +
// "\"LocationThree\"" +
// "]" +
// "},"
// }
var minutesDifference
var hoursDifference
var secondsDifference
var daysDifference
function timeDifference(date11,date22) {
var date2 = new Date(date11);
var date1 = new Date(date22);
var difference = date1 - date2
daysDifference = Math.floor(difference/1000/60/60/24);
difference -= daysDifference*1000*60*60*24
hoursDifference = Math.floor(difference/1000/60/60);
difference -= hoursDifference*1000*60*60
minutesDifference = Math.floor(difference/1000/60);
difference -= minutesDifference*1000*60
secondsDifference = Math.floor(difference/1000);
console.log('difference = ' +
daysDifference + ' day/s ' +
hoursDifference + ' hour/s ' +
minutesDifference + ' minute/s ' +
secondsDifference + ' second/s ');
} }
var flowjson;
app.get('/FLOW', function (req, res) {
console.log('command angekommen!')
try {
function timeDifference1(date11,date22) {
var date2 = new Date(date11);
var date1 = new Date(date22);
var difference = date1 - date2
// res.json(testjsonsflow); var minutesDifference1
res.json(flowjson); var hoursDifference1
var secondsDifference1
var daysDifference1
console.log('.../loadSetP successful!'); daysDifference1 = Math.floor(difference/1000/60/60/24);
difference -= daysDifference1*1000*60*60*24
} hoursDifference1 = Math.floor(difference/1000/60/60);
catch (err) { difference -= hoursDifference1*1000*60*60
console.log('.../loadSetP failed!\n' + err);
}
}); minutesDifference1 = Math.floor(difference/1000/60);
// var navcartest; difference -= minutesDifference1*1000*60
var navcarjson;
app.get('/NAVCAR', function (req, res) {
console.log('command angekommen!')
try {
// console.log(navcar.body.routes[0].sections[0].polyline)
// var pol = polycalc.decode(navcar.body.routes[0].sections[0].polyline)
// console.log(pol)
// res.json(testjsonsflow); secondsDifference1 = Math.floor(difference/1000);
res.json(navcarjson);
// console.log(navcarjson)
console.log('.../loadSetP successful!'); console.log('difference = ' +
daysDifference1 + ' day/s ' +
hoursDifference1 + ' hour/s ' +
minutesDifference1 + ' minute/s ' +
secondsDifference1 + ' second/s ');
var result = {"daysDifference":daysDifference1,
"hoursDifference":hoursDifference1,
"minutesDifference":minutesDifference1,
"secondsDifference":secondsDifference1}
return(result);
}
}
catch (err) {
console.log('.../loadSetP failed!\n' + err);
}
}); // app.post('/Routecalc', function (req, res) {
// console.log('command angekommen ////// Route/////!')
// const pointData = req.body;
// try {
// console.log('https://router.hereapi.com/v8/routes?transportMode=car&origin='+ pointData.slat + ',' + pointData.slon + '&destination=' + pointData.elat + ',' + pointData.elon + '&return=polyline&apiKey=9Grm-6B7VRvxAnbf2eKw29gR-9uuJP8VaXXYR8LK93Y')
// request('https://router.hereapi.com/v8/routes?transportMode=car&origin='+ pointData.slat + ',' + pointData.slon + '&destination=' + pointData.elat + ',' + pointData.elon + '&return=polyline&apiKey=9Grm-6B7VRvxAnbf2eKw29gR-9uuJP8VaXXYR8LK93Y', {json:true},(err, res, body) => {
// if (err) {return console.log(err); }
// console.log(body.url);
// console.log(body.explanation);
// navcar = res
// })
// navcarjson = {
// "name":"navcar" + "01",
// "type":"FeatureCollection",
// "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
// "features": buildNavCar()
app.get('/CONSTRUCTION', function (req, res) { // };
console.log('command angekommen!') // // res.json(testjsonsflow);
try {
var testjson = { // console.log(navcarjson);
"name":"incident" + "01", // console.log('.../route calc successful!');
"type":"FeatureCollection", // res.json(navcarjson);
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } }, // }
"features": buildJSON('CONSTRUCTION') // catch (err) {
// console.log('.../loadSetP failed!\n' + err);
// }
}; // });
res.json(testjson); // var responseStuff
// var navPublicjson
console.log('.../loadSetP successful!'); // app.post('/navPublicT', function (req, res) {
// console.log('command angekommen ////// Route/////!')
// const pointData = req.body;
// console.log(pointData.slat);
} // try {
catch (err) {
console.log('.../loadSetP failed!\n' + err);
}
}); // console.log('https://transit.router.hereapi.com/v8/routes?origin='+ parseFloat(parseFloat(pointData.slat).toFixed(5)) + ',' + parseFloat(parseFloat(pointData.slon).toFixed(5)) + '&destination=' + parseFloat(parseFloat(pointData.elat).toFixed(5)) + ',' + parseFloat(parseFloat(pointData.elon).toFixed(5)) + '&return=polyline&apiKey=9Grm-6B7VRvxAnbf2eKw29gR-9uuJP8VaXXYR8LK93Y')
app.get('/ROAD_CLOSURE', function (req, res) { // request('https://transit.router.hereapi.com/v8/routes?origin='+ parseFloat(parseFloat(pointData.slat).toFixed(5)) + ',' + parseFloat(parseFloat(pointData.slon).toFixed(5)) + '&destination=' + parseFloat(parseFloat(pointData.elat).toFixed(5)) + ',' + parseFloat(parseFloat(pointData.elon).toFixed(5)) + '&return=polyline&apiKey=9Grm-6B7VRvxAnbf2eKw29gR-9uuJP8VaXXYR8LK93Y', {json:true},(err, res, body) => {
// if (err) {return console.log(err); }
// // console.log(body.url);
// // console.log(body.explanation);
// responseStuff = res
// // console.log(responseStuff);
// console.log('.../route calc successful!');
// })
// for (i = 1; i<= 1000; ++i){
// if (responseStuff){
// console.log("responseStuff");
// navPublicjson = {
// "name":"navPublic" + "01",
// "type":"FeatureCollection",
// "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
// "features": buildNavPublic()
// };
// res.json(navPublicjson);
// break;
// }
// }
// }
// catch (err) {
// console.log('.../loadSetP failed!\n' + err);
// }
// });
// function buildNavPublic(){
// var JsonFeature = [];
// // var pol = polycalc.decode(navcar.body.routes[0].sections[0].polyline)
// // var length = pol.polyline.length;
// // console.log(length);
// var id = responseStuff.body.routes[0].id;
// var length = responseStuff.body.routes[0].sections.length;
// console.log("length of Sections: " + length)
// for (var i = 0; i<= length -1; i++){
// console.log(i)
// if (responseStuff.body.routes[0].sections[i].type == "pedestrian"){
// console.log("pedestrian")
// var section = responseStuff.body.routes[0].sections[i]
// var agencyid = section.id;
// var agencyname = section.name;
// var arrivaltime = section.arrival.time;
// var arrivalplace = section.arrival.place;
// var departuretime = section.departure.time;
// var departureplace = section.departure.place;
// var transportInfo = section.transport;
// var pol = polycalc.decode(section.polyline)
// var pollength = pol.polyline.length;
// var timedifference = timeDifference1(departuretime,arrivaltime);
// var pline = [];
// for (var j = 0; j<= pollength -1; j++){
// pline.push([parseFloat(parseFloat(pol.polyline[j][1]).toFixed(5)),parseFloat(parseFloat(pol.polyline[j][0]).toFixed(5))])
// }
// JsonFeature.push({
// "type":"Feature",
// "properties": { "id": agencyid,"agencyName":agencyname, "name": "linestring" ,"type": "pedestrian","transportInfo":transportInfo,"arrivalTime": arrivaltime,"arrivalPlace": arrivalplace,"departureTime": departuretime,"departurePlace": departureplace, "daysDifference": timedifference.daysDifference, "hoursDifference": timedifference.hoursDifference, "minutesDifference" : timedifference.minutesDifference, "secondsDifference": timedifference.secondsDifference},
// "geometry":{
// "type":"LineString",
// "coordinates": pline
// },
// "vcsMeta": {
// "style": {
// "type": "vector",
// "stroke": {
// "color": [
// 30,144,255,
// 1
// ],
// "width": 3,
// "lineDash": null
// }
// }
// }
// })
// console.log(JsonFeature)
// } else if (responseStuff.body.routes[0].sections[i].type == "transit"){
// console.log("transit")
// var section = responseStuff.body.routes[0].sections[i]
// var agencyid = section.id;
// var agencyname = section.name;
// var arrivaltime = section.arrival.time;
// var arrivalplace = section.arrival.place;
// var departuretime = section.departure.time;
// var departureplace = section.departure.place;
// var transportInfo = section.transport;
// var pol = polycalc.decode(section.polyline)
// var pollength = pol.polyline.length;
// var timedifference = timeDifference1(departuretime,arrivaltime);
// var pline = [];
// for (var j = 0; j<= pollength -1; j++){
// pline.push([parseFloat(parseFloat(pol.polyline[j][1]).toFixed(5)),parseFloat(parseFloat(pol.polyline[j][0]).toFixed(5))])
// }
// JsonFeature.push({
// "type":"Feature",
// "properties": { "id": agencyid,"agencyName":agencyname, "name": "linestring" ,"type": "transit","transportInfo":transportInfo,"arrivalTime": arrivaltime,"arrivalPlace": arrivalplace,"departureTime": departuretime,"departurePlace": departureplace, "daysDifference": timedifference.daysDifference, "hoursDifference": timedifference.hoursDifference, "minutesDifference" : timedifference.minutesDifference, "secondsDifference": timedifference.secondsDifference},
// "geometry":{
// "type":"LineString",
// "coordinates": pline
// },
// "vcsMeta": {
// "style": {
// "type": "vector",
// "stroke": {
// "color": [
// 255,140,0,
// 1
// ],
// "width": 4,
// "lineDash": null
// }
// }
// }
// })
// console.log(JsonFeature)
// }
// }
// return JsonFeature
// }
// app.get('/NAVPUB', function (req, res) {
// console.log('command angekommen!')
// try {
// // console.log(navcar.body.routes[0].sections[0].polyline)
// // var pol = polycalc.decode(navcar.body.routes[0].sections[0].polyline)
// // console.log(pol)
// // res.json(testjsonsflow);
// res.json(navPublicjson);
// // console.log(navcarjson)
// console.log('.../loadSetP successful!');
// }
// catch (err) {
// console.log('.../loadSetP failed!\n' + err);
// }
// });
//===========================================================================================================================
//Final Version
//===========================================================================================================================
// ---- Traffic Flow ----
// - 3Parts -
// - get request from the html page
app.get('/TrafficFlow', async (req, res) => {
console.log('command angekommen!') console.log('command angekommen!')
try { try{
let APIout = await flow_getApiResponse('https://traffic.ls.hereapi.com/traffic/6.2/flow.json?prox=48.7823,9.1807,919&responseattributes=sh%2Cfc&apiKey=9Grm-6B7VRvxAnbf2eKw29gR-9uuJP8VaXXYR8LK93Y');
var testjson = { let json_tf = await flow_buildTFLOWJson(APIout);
"name":"incident" + "01", var json_tfs = {
"name":"flow" + "01",
"type":"FeatureCollection", "type":"FeatureCollection",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } }, "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
"features": buildJSON('ROAD_CLOSURE') "features": json_tf
};
res.json(testjson); };
console.log('.../loadSetP successful!'); res.json(json_tfs)
}
catch (err) {
console.log('.../loadSetP failed!\n' + err);
}
}catch (error) {
console.log(error)
}
}); });
// - request from the here API
function buildFLOW(){ function flow_getApiResponse(url) {
return new Promise(function (resolve, reject) {
request(url, function (error, res, body) {
if (!error && res.statusCode == 200) {
resolve(body);
} else {
reject(error);
}
});
});
}
// - build geojson from response
function flow_buildTFLOWJson(inputData){
return new Promise(function (resolve, reject) {
try {
var json_tflow = JSON.parse(inputData)
var JsonFeature = []; var JsonFeature = [];
var length = flow.body.RWS[0].RW.length; console.log(json_tflow.RWS[0].RW.length + "---- in flow func")
var length = json_tflow.RWS[0].RW.length;
// console.log(length); // console.log(length);
for (var i = 0; i<= length -1; i++){ for (var i = 0; i<= length -1; i++){
var shplength = flow.body.RWS[0].RW[i].FIS[0].FI[0].SHP.length; var shplength = json_tflow.RWS[0].RW[i].FIS[0].FI[0].SHP.length;
// var type = accident.body.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].TRAFFIC_ITEM_TYPE_DESC; // var type = accident.body.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].TRAFFIC_ITEM_TYPE_DESC;
var mid = flow.body.RWS[0].RW[i].mid; var mid = json_tflow.RWS[0].RW[i].mid;
var LI = flow.body.RWS[0].RW[i].LI; var LI = json_tflow.RWS[0].RW[i].LI;
var DE = flow.body.RWS[0].RW[i].DE; var DE = json_tflow.RWS[0].RW[i].DE;
var PBT = flow.body.RWS[0].RW[i].PBT; var PBT = json_tflow.RWS[0].RW[i].PBT;
var TMC = flow.body.RWS[0].RW[i].FIS[0].FI[0].TMC; var TMC = json_tflow.RWS[0].RW[i].FIS[0].FI[0].TMC;
var CF = flow.body.RWS[0].RW[i].FIS[0].FI[0].CF[0]; var CF = json_tflow.RWS[0].RW[i].FIS[0].FI[0].CF[0];
var locationshp = []; var locationshp = [];
for (var j = 0; j <= shplength - 1; j++ ){ for (var j = 0; j <= shplength - 1; j++ ){
var value = flow.body.RWS[0].RW[i].FIS[0].FI[0].SHP[j].value[0]; var value = json_tflow.RWS[0].RW[i].FIS[0].FI[0].SHP[j].value[0];
// console.log(value[0]) // console.log(value[0])
...@@ -324,179 +1378,100 @@ function buildFLOW(){ ...@@ -324,179 +1378,100 @@ function buildFLOW(){
} }
}) })
} }
// JsonFeature.push({ };
resolve(JsonFeature)
// "type":"Feature", }catch(error){ reject(error)}
// "properties": { "id": mid, "name": "linestring" , "LI": LI, "DE": DE, "PBT":PBT, "TMC":TMC, "CF":CF},
// "geometry":{
// "type":"MultiLineString",
// "coordinates": locationshp
// },
// "vcsMeta": {
// "style": {
// "type": "vector",
// "stroke": {
// "color": [
// 51,
// 153,
// 204,
// 1
// ],
// "width": 39,
// "lineDash": null
// }
// }
// }
// })
// console.log(JsonFeature)
}
return JsonFeature
}
function buildNavCar(){
var JsonFeature = [];
var pol = polycalc.decode(navcar.body.routes[0].sections[0].polyline)
var length = pol.polyline.length;
// console.log(length);
var id = navcar.body.routes[0].id;
var mid = navcar.body.routes[0].sections[0].id;
var transport = navcar.body.routes[0].sections[0].transport.mode;
var departureTime = navcar.body.routes[0].sections[0].departure.time;
var departureOriglat = navcar.body.routes[0].sections[0].departure.place.originalLocation.lat;
// console.log(departureOriglat)
var departureOriglon = navcar.body.routes[0].sections[0].departure.place.originalLocation.lng;
// console.log(departureOriglon)
var departurelat = navcar.body.routes[0].sections[0].departure.place.location.lat;
var departurelon = navcar.body.routes[0].sections[0].departure.place.location.lng;
var arrivalTime = navcar.body.routes[0].sections[0].arrival.time;
var arrivalOriglat = navcar.body.routes[0].sections[0].arrival.place.originalLocation.lat;
var arrivalOriglon = navcar.body.routes[0].sections[0].arrival.place.originalLocation.lng;
var arrivallat = navcar.body.routes[0].sections[0].arrival.place.location.lat;
var arrivallon = navcar.body.routes[0].sections[0].arrival.place.location.lng;
var departure = [];
departure.push([parseFloat(parseFloat(departureOriglon).toFixed(5)),parseFloat(parseFloat(departureOriglat).toFixed(5))]);
departure.push([parseFloat(parseFloat(departurelon).toFixed(5)),parseFloat(parseFloat(departurelat).toFixed(5))])
timeDifference(departureTime,arrivalTime);
});
JsonFeature.push({ };
"type":"Feature",
"properties": { "id": id, "name": "linestring" ,"transport": transport,"departureTime": departureTime, "daysDifference": daysDifference, "hoursDifference": hoursDifference, "minutesDifference" : minutesDifference, "secondsDifference": secondsDifference},
"geometry":{
"type":"LineString",
"coordinates": departure
},
"vcsMeta": {
"style": {
"type": "vector",
"stroke": {
"color": [
30,144,255,
1
],
"width": 3,
"lineDash": null
}
}
}
})
var arrival = []; // ---- Accidents ----
arrival.push([parseFloat(parseFloat(arrivalOriglon).toFixed(5)),parseFloat(parseFloat(arrivalOriglat).toFixed(5))]); // - 3Parts -
arrival.push([parseFloat(parseFloat(arrivallon).toFixed(5)),parseFloat(parseFloat(arrivallat).toFixed(5))]) // - get request from the html page
// console.log(arrival) app.get('/CONSTRUCTION', async (req, res) => {
JsonFeature.push({ console.log('Construction angekommen!')
try{
let APIout = await CON_getApiResponse('https://traffic.ls.hereapi.com/traffic/6.3/incidents.json?apiKey=9Grm-6B7VRvxAnbf2eKw29gR-9uuJP8VaXXYR8LK93Y&bbox=48.790,9.139;48.771,9.239');
"type":"Feature", let json_con = await CON_buildTFLOWJson(APIout,"CONSTRUCTION");
"properties": { "id": id, "name": "linestring" ,"transport": transport,"arrivalTime": arrivalTime,"departureTime": departureTime, "daysDifference": daysDifference, "hoursDifference": hoursDifference, "minutesDifference" : minutesDifference, "secondsDifference": secondsDifference}, console.log(json_con)
"geometry":{ var json_cons = {
"type":"LineString", "name":"incident" + "01",
"coordinates": arrival "type":"FeatureCollection",
}, "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
"vcsMeta": { "features": json_con
"style": {
"type": "vector",
"stroke": {
"color": [
30,144,255,
1
],
"width": 3,
"lineDash": null
}
}
}
})
};
res.json(json_cons)
}catch (error) {
console.log(error)
}
var pline = []; });
var length = pol.polyline.length; app.get('/ROAD_CLOSURE', async (req, res) => {
console.log('Construction angekommen!')
try{
let APIout = await CON_getApiResponse('https://traffic.ls.hereapi.com/traffic/6.3/incidents.json?apiKey=9Grm-6B7VRvxAnbf2eKw29gR-9uuJP8VaXXYR8LK93Y&bbox=48.790,9.139;48.771,9.239');
let json_con = await CON_buildTFLOWJson(APIout,"ROAD_CLOSURE");
console.log(json_con)
var json_cons = {
"name":"incident" + "01",
"type":"FeatureCollection",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
"features": json_con
for (var i = 0; i<= length -1; i++){ };
pline.push([parseFloat(parseFloat(pol.polyline[i][1]).toFixed(5)),parseFloat(parseFloat(pol.polyline[i][0]).toFixed(5))]) res.json(json_cons)
} }catch (error) {
JsonFeature.push({ console.log(error)
}
"type":"Feature", });
"properties": { "id": id, "name": "linestring" ,"transport": transport,"departureTime": departureTime, "daysDifference": daysDifference, "hoursDifference": hoursDifference, "minutesDifference" : minutesDifference, "secondsDifference": secondsDifference}, // - request from the here API
"geometry":{ function CON_getApiResponse(url) {
"type":"LineString", return new Promise(function (resolve, reject) {
"coordinates": pline request(url, function (error, res, body) {
}, if (!error && res.statusCode == 200) {
"vcsMeta": { resolve(body);
"style": { } else {
"type": "vector", reject(error);
"stroke": {
"color": [
199,21,133,
1
],
"width": 4,
"lineDash": null
}
}
} }
}) });
});
// console.log(JsonFeature)
return JsonFeature
} }
// - build geojson from response
function buildJSON(type){ function CON_buildTFLOWJson(inputData,type){
return new Promise(function (resolve, reject) {
try {
var JsonFeature = []; var JsonFeature = [];
var length = accident.body.TRAFFIC_ITEMS.TRAFFIC_ITEM.length; var json_acc = JSON.parse(inputData)
var length = json_acc.TRAFFIC_ITEMS.TRAFFIC_ITEM.length;
// console.log(length) // console.log(length)
for (var i = 0; i <= length - 1; i++){ for (var i = 0; i <= length - 1; i++){
// console.log(accident.body.TRAFFIC_ITEMS.TRAFFIC_ITEM[i]) // console.log(json_acc.TRAFFIC_ITEMS.TRAFFIC_ITEM[i])
var lat = accident.body.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].LOCATION.GEOLOC.ORIGIN.LATITUDE; var lat = json_acc.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].LOCATION.GEOLOC.ORIGIN.LATITUDE;
var lon = accident.body.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].LOCATION.GEOLOC.ORIGIN.LONGITUDE; var lon = json_acc.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].LOCATION.GEOLOC.ORIGIN.LONGITUDE;
// var type = accident.body.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].TRAFFIC_ITEM_TYPE_DESC; // var type = json_acc.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].TRAFFIC_ITEM_TYPE_DESC;
var id = accident.body.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].TRAFFIC_ITEM_ID; var id = json_acc.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].TRAFFIC_ITEM_ID;
var origid = accident.body.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].ORIGINAL_TRAFFIC_ITEM_ID; var origid = json_acc.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].ORIGINAL_TRAFFIC_ITEM_ID;
var TRAFFIC_ITEM_DESCRIPTION = accident.body.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].TRAFFIC_ITEM_DESCRIPTION; var TRAFFIC_ITEM_DESCRIPTION = json_acc.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].TRAFFIC_ITEM_DESCRIPTION;
var COMMENTS = accident.body.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].COMMENTS; var COMMENTS = json_acc.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].COMMENTS;
var CRITICALITY = accident.body.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].CRITICALITY; var CRITICALITY = json_acc.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].CRITICALITY;
var VERIFIED = accident.body.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].VERIFIED; var VERIFIED = json_acc.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].VERIFIED;
var TRAFFIC_ITEM_TYPE_DESC = accident.body.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].TRAFFIC_ITEM_TYPE_DESC; var TRAFFIC_ITEM_TYPE_DESC = json_acc.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].TRAFFIC_ITEM_TYPE_DESC;
var TRAFFIC_ITEM_STATUS_SHORT_DESC = accident.body.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].TRAFFIC_ITEM_STATUS_SHORT_DESC; var TRAFFIC_ITEM_STATUS_SHORT_DESC = json_acc.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].TRAFFIC_ITEM_STATUS_SHORT_DESC;
var TRAFFIC_ITEM_DETAIL = accident.body.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].TRAFFIC_ITEM_DETAIL; var TRAFFIC_ITEM_DETAIL = json_acc.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].TRAFFIC_ITEM_DETAIL;
var START_TIME = accident.body.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].START_TIME; var START_TIME = json_acc.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].START_TIME;
var LOCATION = accident.body.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].LOCATION; var LOCATION = json_acc.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].LOCATION;
var ENTRY_TIME = accident.body.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].ENTRY_TIME; var ENTRY_TIME = json_acc.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].ENTRY_TIME;
var END_TIME = accident.body.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].END_TIME; var END_TIME = json_acc.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].END_TIME;
var ABBREVIATION = accident.body.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].ABBREVIATION; var ABBREVIATION = json_acc.TRAFFIC_ITEMS.TRAFFIC_ITEM[i].ABBREVIATION;
if (type == 'CONSTRUCTION'){ if (type == 'CONSTRUCTION'){
...@@ -531,200 +1506,25 @@ function buildJSON(type){ ...@@ -531,200 +1506,25 @@ function buildJSON(type){
} }
}) })
} }
} }
}
return JsonFeature;
}
app.post('/getTrafficIncidents', function (req, res) {
console.log('command angekommen!')
try {
res.json(accident);
console.log('.../loadSetP successful!');
}
catch (err) {
console.log('.../loadSetP failed!\n' + err);
}
});
app.post('/FLOWdata', function (req, res) {
console.log('command angekommen!')
try {
flowjson = {
"name":"flow" + "01",
"type":"FeatureCollection",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
"features": buildFLOW()
};
res.json(flowjson);
console.log('.../loadSetP successful!');
}
catch (err) {
console.log('.../loadSetP failed!\n' + err);
}
});
app.post('/FLOWtest', function (req, res) {
console.log('command angekommen!')
try {
res.json(testjsonsflow);
console.log('.../loadSetP successful!');
}
catch (err) {
console.log('.../loadSetP failed!\n' + err);
}
});
app.post('/NavCARdata', function (req, res) {
console.log('command angekommen!')
try {
navcarjson = {
"name":"navcar" + "01",
"type":"FeatureCollection",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
"features": buildNavCar()
};
res.json(navcarjson);
console.log('.../loadSetP successful!');
}
catch (err) {
console.log('.../loadSetP failed!\n' + err);
}
}); }
var IDGeojson = 100000 resolve(JsonFeature)
var ballonContent = { }catch(error){ reject(error)}
header: "Test",
Content: "This is a test",
lat: "",
lon: "",
categorie: "locationSM.png"
}
app.post('/', function(req,res){
try {
const data = req.body; });
console.log("data ==============")
// console.log(data.header);
// console.log(data.Content);
// console.log(data.lat);
// console.log(data.lon);
// console.log(data.categorie);
ballonContent.header = data.header;
ballonContent.Content = data.Content;
ballonContent.lat = data.lat;
ballonContent.lon = data.lon;
ballonContent.categorie = data.categorie;
console.log("args ==============")
// console.log(args);
//asdf
// const returnedTarget = Object.assign(args.ui,data);
// args.ui = data;
// args.gmlid = data.id;
// console.log("returned ==============")
// console.log(returnedTarget)
// console.log("args ==============")
// console.log(args);
getCurrentFilenames();
writeGeojsonFile();
writeConfigFile();
res.end('It worked!');
} };
catch (err) {
console.log('.../getSimS failed!\n' + err);
}
});
var Startpoint;
var Startpointlat;
var Startpointlon;
var Endpoint;
var Endpointlat;
var Endpointlon;
// List all the filenames before renaming
app.post('/navPoint', function(req,res){
// ---- Navpoint ----
// - receive coordinates and return a geojson
app.get('/addPoint', async (req, res) => {
try { try {
console.log("navPoint arrived ////////") var data = req.query;
const data = req.body; var Punktadd = {
console.log("data ==============")
console.log(data.lat);
console.log(data.lon);
console.log(data.loc);
if (data.loc == "Start"){
Startpointlat = parseFloat(parseFloat(data.lat).toFixed(7))
Startpointlon = parseFloat(parseFloat(data.lon).toFixed(7))
Startpoint = {
"type":"FeatureCollection",
"name":"data_point",
"crs":{
"type":"name",
"properties":{
"name":"urn:ogc:def:crs:OGC:1.3:CRS84"
}
},
"features":[
{
"type":"Feature",
"properties":{
"id":null,
"name":"datapoint"
},
"geometry":{
"type":"Point",
"coordinates":[
parseFloat(parseFloat(data.lon).toFixed(7)),
parseFloat(parseFloat(data.lat).toFixed(7))
]
}
}
]
}
// Startpoint.push({
// "type":"Feature",
// "properties": { "id": data.loc, "name": "datapoint"},
// "geometry":{
// "type":"MultiPoint",
// "coordinates": [ [data.lon, data.lat]]
// }
// })
console.log(Startpoint)
res.json(Startpoint);
} else if (data.loc == "End"){
Endpointlat = parseFloat(parseFloat(data.lat).toFixed(7))
Endpointlon = parseFloat(parseFloat(data.lon).toFixed(7))
Endpoint = {
"type":"FeatureCollection", "type":"FeatureCollection",
"name":"data_point", "name":"data_point",
"crs":{ "crs":{
...@@ -738,277 +1538,210 @@ app.post('/navPoint', function(req,res){ ...@@ -738,277 +1538,210 @@ app.post('/navPoint', function(req,res){
"type":"Feature", "type":"Feature",
"properties":{ "properties":{
"id":null, "id":null,
"name":"datapoint" "name":"datapoint",
"loc": data.sloc
}, },
"geometry":{ "geometry":{
"type":"Point", "type":"Point",
"coordinates":[ "coordinates":[
parseFloat(parseFloat(data.lon).toFixed(7)), parseFloat(parseFloat(data.slon).toFixed(7)),
parseFloat(parseFloat(data.lat).toFixed(7)) parseFloat(parseFloat(data.slat).toFixed(7))
] ]
} }
} }
] ]
} }
res.json(Endpoint); res.json(Punktadd);
}
} catch (error) {
} console.log(error)
catch (err) {
console.log('.../getSimS failed!\n' + err);
} }
}); });
app.get('/Startpoint', function (req, res) {
console.log('command angekommen ////// Startpoint!')
try {
// http://localhost:8083/Routecalc2?slat=48.68997020356071&slon=9.202611390575258&sloc=Start&elat=48.726559406813294&elon=9.113775973868089&eloc=End
// ---- Route Berechnen Test ----
app.get('/Routecalc2', async (req, res) => {
console.log('command angekommen ////// Route/////!')
const pointData = req.query;
console.log(pointData);
try {
let APIout = await CON_getApiResponse('https://router.hereapi.com/v8/routes?transportMode=car&origin='+ pointData.slat + ',' + pointData.slon + '&destination=' + pointData.elat + ',' + pointData.elon + '&return=polyline&apiKey=9Grm-6B7VRvxAnbf2eKw29gR-9uuJP8VaXXYR8LK93Y');
// res.json(testjsonsflow); console.log(APIout)
res.json(Startpoint); let json_route = await Route_buildJson(APIout);
console.log(json_route)
console.log('.../loadSetP successful!'); var json_routes = {
"name":"navcar" + "01",
"type":"FeatureCollection",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
"features": json_route
};
console.log(json_routes);
console.log('.../route calc successful!');
res.json(json_routes);
} }
catch (err) { catch (err) {
console.log('.../loadSetP failed!\n' + err); console.log('.../loadSetP failed!\n' + err);
} }
}); });
app.get('/Endpoint', function (req, res) { // - build geojson for Car Routing
console.log('command angekommen!') function Route_buildJson(inputData){
return new Promise(function (resolve, reject) {
try { try {
var JsonFeature = [];
var json_route = JSON.parse(inputData)
var pol = polycalc.decode(json_route.routes[0].sections[0].polyline)
var length = pol.polyline.length;
// console.log(length);
var id = json_route.routes[0].id;
var mid = json_route.routes[0].sections[0].id;
var transport = json_route.routes[0].sections[0].transport.mode;
var departureTime = json_route.routes[0].sections[0].departure.time;
var departureOriglat = json_route.routes[0].sections[0].departure.place.originalLocation.lat;
// console.log(departureOriglat)
var departureOriglon = json_route.routes[0].sections[0].departure.place.originalLocation.lng;
// console.log(departureOriglon)
var departurelat = json_route.routes[0].sections[0].departure.place.location.lat;
var departurelon = json_route.routes[0].sections[0].departure.place.location.lng;
var arrivalTime = json_route.routes[0].sections[0].arrival.time;
var arrivalOriglat = json_route.routes[0].sections[0].arrival.place.originalLocation.lat;
var arrivalOriglon = json_route.routes[0].sections[0].arrival.place.originalLocation.lng;
var arrivallat = json_route.routes[0].sections[0].arrival.place.location.lat;
var arrivallon = json_route.routes[0].sections[0].arrival.place.location.lng;
var departure = [];
departure.push([parseFloat(parseFloat(departureOriglon).toFixed(5)),parseFloat(parseFloat(departureOriglat).toFixed(5))]);
departure.push([parseFloat(parseFloat(departurelon).toFixed(5)),parseFloat(parseFloat(departurelat).toFixed(5))])
timeDifference(departureTime,arrivalTime);
// res.json(testjsonsflow);
res.json(Endpoint);
console.log('.../loadSetP successful!'); JsonFeature.push({
"type":"Feature",
"properties": { "id": id, "name": "linestring" ,"transport": transport,"departureTime": departureTime, "daysDifference": daysDifference, "hoursDifference": hoursDifference, "minutesDifference" : minutesDifference, "secondsDifference": secondsDifference},
"geometry":{
"type":"LineString",
"coordinates": departure
},
"vcsMeta": {
"style": {
"type": "vector",
"stroke": {
"color": [
30,144,255,
1
],
"width": 3,
"lineDash": null
} }
catch (err) {
console.log('.../loadSetP failed!\n' + err);
} }
}
})
}); var arrival = [];
arrival.push([parseFloat(parseFloat(arrivalOriglon).toFixed(5)),parseFloat(parseFloat(arrivalOriglat).toFixed(5))]);
arrival.push([parseFloat(parseFloat(arrivallon).toFixed(5)),parseFloat(parseFloat(arrivallat).toFixed(5))])
function getCurrentFilenames() { // console.log(arrival)
console.log("Current filenames:"); JsonFeature.push({
fs.readdirSync(__dirname + '/vcm/templates').forEach(file => {
if (file.includes('.geojson')){
var tempid = file.replace('.geojson','')
// console.log(tempid) "type":"Feature",
if (isNaN(tempid) == false){ "properties": { "id": id, "name": "linestring" ,"transport": transport,"arrivalTime": arrivalTime,"departureTime": departureTime, "daysDifference": daysDifference, "hoursDifference": hoursDifference, "minutesDifference" : minutesDifference, "secondsDifference": secondsDifference},
var tempid = parseInt(tempid, 10); "geometry":{
if (tempid >= IDGeojson){ "type":"LineString",
IDGeojson = tempid "coordinates": arrival
console.log("this one - " + IDGeojson) },
"vcsMeta": {
"style": {
"type": "vector",
"stroke": {
"color": [
30,144,255,
1
],
"width": 3,
"lineDash": null
} }
} else {
console.log("not this one - " + tempid)
} }
} }
// console.log(file); })
});
IDGeojson += 1
}
function writeGeojsonFile() {
var geojsontemplate = ' {' +
' "type": "FeatureCollection",' +
' "name": "data_point",' +
'"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },' +
' "features": [' +
' { "type": "Feature", "properties": { "id": null, "name": "datapoint" }, "geometry": { "type": "Point", "coordinates": [ ' + ballonContent.lon + ', ' + ballonContent.lat + ' ] } }' +
' ]' +
' }'
console.log(geojsontemplate);
try {
console.log(geojsontemplate);
fs.writeFile(__dirname + "/vcm/templates/" + IDGeojson + '.geojson', geojsontemplate, function (err) {
if (err) throw err;
console.log('Saved!');
});
} catch (err) {
console.error(err);
}
}
function writeConfigFile(){
// name of the file
var filename = 'vcm/config.json';
var contentSync = fs.readFileSync(filename);
console.log('Content of the file : ' + contentSync);
console.log(contentSync.includes('"balloonTypes":'));
var newtext = contentSync.toString().replace('"layers": [','"layers": [' +
'{' +
'"name": "'+ IDGeojson +'",' +
'"url": "./templates/'+IDGeojson+'.geojson",' +
'"type": "vcs.vcm.layer.GeoJSON",' +
'"datasourceId": "...",'+
'"activeOnStartup": true,'+
'"exclusive": false,' +
'"projection": {' +
' "epsg": "4326",' +
' "proj4": ""' +
'},' +
'"altitudeMode": "relativeToGround",' +
'"style": {' +
' "image": {' +
' "icon": {' +
' "src": "./templates/' + ballonContent.categorie + '",' +
' "scale": 0.5' +
' }' +
' }' +
'},' +
'"heightAboveGround": 0' +
'},')
var ballonText = "\"balloonTypes\": [" +
"{" +
"\"template\": [" +
"\"<div class='balloon' onclick='' id='myBalloon'>\"," +
"\" <h1 class='balloon-title'>" + ballonContent.header + "</h1>\"," +
"\" <div class='balloon-content' style='height:290px; margin-right: 0px;'\"," +
"\" </div>\"," +
"\"<p class='balloon-text'><span>" + ballonContent.Content + "</span><br></p>\"," +
// "\"<img style='padding-top:10px' src='images/content/contentboeckingerstrasse/station3_outdoorkiosk1.jpg' alt='Simply Easy Learning' width='375'>\"," +
"\"</div>\"," +
"\"<% %>\"" +
// "\"<% openquestionaire() %>\"" +
"]," +
"\"minTop\": \"balloonHeight + 10\"," +
"\"minLeft\": \"70\"," +
"\"layerTypes\": [" +
"\"\""+
"],"+
"\"layerNames\": [" +
"\""+ IDGeojson +"\"" +
"]" +
"},"
var newtext = newtext.toString().replace("\"balloonTypes\": [", ballonText)
console.log(newtext);
fs.writeFile(filename, newtext, 'utf8', function (err) {
if (err) return console.log(err);
});
}
function writeBallon() {
var ballonText = "{" +
"\"template\": [" +
"\"<div class='balloon' onclick='showtourSpecific()' id='myBalloon'>\"," +
"\" <h1 class='balloon-title'>Station 3</h1>\"," +
"\" <div class='balloon-content' style='height:290px; margin-right: 0px;'\"," +
"\" </div>\"," +
"\"<p class='balloon-text'><span>hier wurde eine Outdoorkiosk errichtet.</span><br></p>\"," +
"\"<img style='padding-top:10px' src='images/content/contentboeckingerstrasse/station3_outdoorkiosk1.jpg' alt='Simply Easy Learning' width='375'>\"," +
"\"</div>\"," +
"\"<% %>\"," +
"\"<% openquestionaire() %>\"" +
"]," +
"\"minTop\": \"balloonHeight + 10\"," +
"\"minLeft\": \"70\"," +
"\"layerTypes\": [" +
"\"\""+
"],"+
"\"layerNames\": [" +
"\"LocationThree\"" +
"]" +
"},"
}
var minutesDifference
var hoursDifference
var secondsDifference
var daysDifference
function timeDifference(date11,date22) {
var date2 = new Date(date11);
var date1 = new Date(date22);
var difference = date1 - date2
daysDifference = Math.floor(difference/1000/60/60/24);
difference -= daysDifference*1000*60*60*24
hoursDifference = Math.floor(difference/1000/60/60);
difference -= hoursDifference*1000*60*60
minutesDifference = Math.floor(difference/1000/60);
difference -= minutesDifference*1000*60
secondsDifference = Math.floor(difference/1000); var pline = [];
var length = pol.polyline.length;
console.log('difference = ' + for (var i = 0; i<= length -1; i++){
daysDifference + ' day/s ' + pline.push([parseFloat(parseFloat(pol.polyline[i][1]).toFixed(5)),parseFloat(parseFloat(pol.polyline[i][0]).toFixed(5))])
hoursDifference + ' hour/s ' + }
minutesDifference + ' minute/s ' + JsonFeature.push({
secondsDifference + ' second/s ');
}
"type":"Feature",
"properties": { "id": id, "name": "linestring" ,"transport": transport,"departureTime": departureTime, "daysDifference": daysDifference, "hoursDifference": hoursDifference, "minutesDifference" : minutesDifference, "secondsDifference": secondsDifference},
"geometry":{
"type":"LineString",
"coordinates": pline
},
"vcsMeta": {
"style": {
"type": "vector",
"stroke": {
"color": [
199,21,133,
1
],
"width": 4,
"lineDash": null
}
}
}
})
function timeDifference1(date11,date22) { // console.log(JsonFeature)
var date2 = new Date(date11);
var date1 = new Date(date22);
var difference = date1 - date2
var minutesDifference1
var hoursDifference1
var secondsDifference1
var daysDifference1
daysDifference1 = Math.floor(difference/1000/60/60/24);
difference -= daysDifference1*1000*60*60*24
hoursDifference1 = Math.floor(difference/1000/60/60);
difference -= hoursDifference1*1000*60*60
minutesDifference1 = Math.floor(difference/1000/60); resolve(JsonFeature)
difference -= minutesDifference1*1000*60 }catch(error){ reject(error)}
secondsDifference1 = Math.floor(difference/1000);
console.log('difference = ' +
daysDifference1 + ' day/s ' +
hoursDifference1 + ' hour/s ' +
minutesDifference1 + ' minute/s ' +
secondsDifference1 + ' second/s ');
var result = {"daysDifference":daysDifference1,
"hoursDifference":hoursDifference1,
"minutesDifference":minutesDifference1,
"secondsDifference":secondsDifference1}
return(result);
}
});
app.post('/Routecalc', function (req, res) { };
// ---- Route Offis Berechnen Test ----
app.get('/navPublicT2', async (req, res) => {
console.log('command angekommen ////// Route/////!') console.log('command angekommen ////// Route/////!')
const pointData = req.body; const pointData = req.query;
console.log(pointData);
try { try {
console.log('https://router.hereapi.com/v8/routes?transportMode=car&origin='+ pointData.slat + ',' + pointData.slon + '&destination=' + pointData.elat + ',' + pointData.elon + '&return=polyline&apiKey=9Grm-6B7VRvxAnbf2eKw29gR-9uuJP8VaXXYR8LK93Y') let APIout = await CON_getApiResponse('https://transit.router.hereapi.com/v8/routes?origin='+ parseFloat(parseFloat(pointData.slat).toFixed(5)) + ',' + parseFloat(parseFloat(pointData.slon).toFixed(5)) + '&destination=' + parseFloat(parseFloat(pointData.elat).toFixed(5)) + ',' + parseFloat(parseFloat(pointData.elon).toFixed(5)) + '&return=polyline&apiKey=9Grm-6B7VRvxAnbf2eKw29gR-9uuJP8VaXXYR8LK93Y');
request('https://router.hereapi.com/v8/routes?transportMode=car&origin='+ pointData.slat + ',' + pointData.slon + '&destination=' + pointData.elat + ',' + pointData.elon + '&return=polyline&apiKey=9Grm-6B7VRvxAnbf2eKw29gR-9uuJP8VaXXYR8LK93Y', {json:true},(err, res, body) => {
if (err) {return console.log(err); } console.log(APIout)
console.log(body.url); let json_pub = await Route_PublicbuildJson(APIout);
console.log(body.explanation); console.log(json_pub)
navcar = res // navPublicjson = {
}) // "name":"navPublic" + "01",
navcarjson = { // "type":"FeatureCollection",
"name":"navcar" + "01", // "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
// "features": buildNavPublic()
// };
var json_public = {
"name":"navPublic" + "01",
"type":"FeatureCollection", "type":"FeatureCollection",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } }, "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
"features": buildNavCar() "features": json_pub
}; };
// res.json(testjsonsflow);
console.log(navcarjson); console.log(json_public);
console.log('.../route calc successful!'); console.log('.../route calc successful!');
res.json(navcarjson); res.json(json_public);
} }
catch (err) { catch (err) {
console.log('.../loadSetP failed!\n' + err); console.log('.../loadSetP failed!\n' + err);
...@@ -1016,68 +1749,25 @@ app.post('/Routecalc', function (req, res) { ...@@ -1016,68 +1749,25 @@ app.post('/Routecalc', function (req, res) {
}); });
var responseStuff // - build geojson for Public Routing
var navPublicjson function Route_PublicbuildJson(inputData){
return new Promise(function (resolve, reject) {
app.post('/navPublicT', function (req, res) {
console.log('command angekommen ////// Route/////!')
const pointData = req.body;
console.log(pointData.slat);
try { try {
console.log('https://transit.router.hereapi.com/v8/routes?origin='+ parseFloat(parseFloat(pointData.slat).toFixed(5)) + ',' + parseFloat(parseFloat(pointData.slon).toFixed(5)) + '&destination=' + parseFloat(parseFloat(pointData.elat).toFixed(5)) + ',' + parseFloat(parseFloat(pointData.elon).toFixed(5)) + '&return=polyline&apiKey=9Grm-6B7VRvxAnbf2eKw29gR-9uuJP8VaXXYR8LK93Y')
request('https://transit.router.hereapi.com/v8/routes?origin='+ parseFloat(parseFloat(pointData.slat).toFixed(5)) + ',' + parseFloat(parseFloat(pointData.slon).toFixed(5)) + '&destination=' + parseFloat(parseFloat(pointData.elat).toFixed(5)) + ',' + parseFloat(parseFloat(pointData.elon).toFixed(5)) + '&return=polyline&apiKey=9Grm-6B7VRvxAnbf2eKw29gR-9uuJP8VaXXYR8LK93Y', {json:true},(err, res, body) => {
if (err) {return console.log(err); }
// console.log(body.url);
// console.log(body.explanation);
responseStuff = res
// console.log(responseStuff);
console.log('.../route calc successful!');
})
for (i = 1; i<= 1000; ++i){
if (responseStuff){
console.log("responseStuff");
navPublicjson = {
"name":"navPublic" + "01",
"type":"FeatureCollection",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
"features": buildNavPublic()
};
res.json(navPublicjson);
break;
}
}
}
catch (err) {
console.log('.../loadSetP failed!\n' + err);
}
});
function buildNavPublic(){
var JsonFeature = []; var JsonFeature = [];
// var pol = polycalc.decode(navcar.body.routes[0].sections[0].polyline) // var pol = polycalc.decode(navcar.body.routes[0].sections[0].polyline)
// var length = pol.polyline.length; // var length = pol.polyline.length;
// console.log(length); // console.log(length);
var id = responseStuff.body.routes[0].id; var json_public = JSON.parse(inputData)
var id = json_public.routes[0].id;
var length = responseStuff.body.routes[0].sections.length; var length = json_public.routes[0].sections.length;
console.log("length of Sections: " + length) console.log("length of Sections: " + length)
for (var i = 0; i<= length -1; i++){ for (var i = 0; i<= length -1; i++){
console.log(i) console.log(i)
if (responseStuff.body.routes[0].sections[i].type == "pedestrian"){ if (json_public.routes[0].sections[i].type == "pedestrian"){
console.log("pedestrian") console.log("pedestrian")
var section = responseStuff.body.routes[0].sections[i] var section = json_public.routes[0].sections[i]
var agencyid = section.id; var agencyid = section.id;
var agencyname = section.name; var agencyname = section.name;
var arrivaltime = section.arrival.time; var arrivaltime = section.arrival.time;
...@@ -1118,9 +1808,9 @@ function buildNavPublic(){ ...@@ -1118,9 +1808,9 @@ function buildNavPublic(){
} }
}) })
console.log(JsonFeature) console.log(JsonFeature)
} else if (responseStuff.body.routes[0].sections[i].type == "transit"){ } else if (json_public.routes[0].sections[i].type == "transit"){
console.log("transit") console.log("transit")
var section = responseStuff.body.routes[0].sections[i] var section = json_public.routes[0].sections[i]
var agencyid = section.id; var agencyid = section.id;
var agencyname = section.name; var agencyname = section.name;
var arrivaltime = section.arrival.time; var arrivaltime = section.arrival.time;
...@@ -1166,25 +1856,79 @@ function buildNavPublic(){ ...@@ -1166,25 +1856,79 @@ function buildNavPublic(){
} }
return JsonFeature
}
app.get('/NAVPUB', function (req, res) {
resolve(JsonFeature)
}catch(error){ reject(error)}
});
};
// ---- Noise Real Time ----
// - 3Parts -
// - get request from the html page
app.get('/NoiseRealTime', async (req, res) => {
console.log('command angekommen!') console.log('command angekommen!')
try{
let APIout = await flow_getApiResponse('https://data.sensor.community/airrohr/v1/sensor/49368/');
console.log(APIout);
res.json(JSON.parse(APIout));
}catch (error) {
console.log(error)
}
});
// ---- Historic Noise Data ----
// ---- Trial Version from PostgreSQL ----
const pgp = require('pg-promise')({
// Initialization Options
});
const connection = {
user: 'postgres', // name of the user account
database: 'NoiseSensorData', // name of the database
password: 'ahpk94meteor', // env var: PGPASSWORD
host: '193.196.38.112', // Server hosting the postgres database (host: '35.187.21.114')
port: 5432, // env var: PGPORT
max: 10, // max number of clients in the pool
idleTimeoutMillis: 30000 // how long a client is allowed to remain idle before being closed
}
const db = pgp(connection);
console.log('successful connected to DB: NoiseSensorData!')
app.post('/getNoiseHist', function (req, res) {
try { try {
// console.log(navcar.body.routes[0].sections[0].polyline)
// var pol = polycalc.decode(navcar.body.routes[0].sections[0].polyline)
// console.log(pol)
// res.json(testjsonsflow); const data = req.body;
res.json(navPublicjson); // = "select sensor_id from public.noisesensor;"
// console.log(navcarjson)
console.log('.../loadSetP successful!'); let query_string = " SELECT * FROM noisesensors ORDER BY timestamp ASC;"
// query_string += "from noisesensor;";
console.log(query_string)
// request the data rsr
db.result(query_string)
.then(result => {
res.json(result.rows);
})
.catch(error => {
console.log('ERROR:', error);
});
console.log('.../getNoiseHist successful!');
} }
catch (err) { catch (err) {
console.log('.../loadSetP failed!\n' + err); console.log('.../getNoiseHist failed!\n' + err);
} }
}); });
...@@ -305,7 +305,7 @@ ...@@ -305,7 +305,7 @@
null null
], ],
"layerNames": [ "layerNames": [
"NAVCAR" "CarRoute"
], ],
"minTop": "balloonHeight + 30", "minTop": "balloonHeight + 30",
"minLeft": "70", "minLeft": "70",
...@@ -340,7 +340,7 @@ ...@@ -340,7 +340,7 @@
null null
], ],
"layerNames": [ "layerNames": [
"NAVPUB" "PublicRoute"
], ],
"minTop": "balloonHeight + 30", "minTop": "balloonHeight + 30",
"minLeft": "70", "minLeft": "70",
...@@ -598,7 +598,7 @@ ...@@ -598,7 +598,7 @@
"balloonHeader": "Balloon header" "balloonHeader": "Balloon header"
},{ },{
"template": [ "template": [
"<div class='balloon' onclick='Questionnaire()' id='myBalloonP1'>", "<div class='balloon' onclick='Questionnaire()' id='myBalloon'>",
" <h1 class='balloon-title'>Umfrage (Böckinger Straße)</h1>", " <h1 class='balloon-title'>Umfrage (Böckinger Straße)</h1>",
" <div class='balloon-content' style='height:250px; margin-right: 0px;'", " <div class='balloon-content' style='height:250px; margin-right: 0px;'",
" </div>", " </div>",
...@@ -619,7 +619,7 @@ ...@@ -619,7 +619,7 @@
] ]
},{ },{
"template": [ "template": [
"<div class='balloon' style='width: 200px; background-color: #3C3C3C; color: #FFFFFF;' id='myBalloonNord'>", "<div class='balloon' style='width: 200px; background-color: #3C3C3C; color: #FFFFFF;' id='myBalloon'>",
" <button class='infobtn' onclick='NordbahnhofText()'></button>", " <button class='infobtn' onclick='NordbahnhofText()'></button>",
" <h1 class='balloon-title' style='color: #FFFFFF;'>Nordbahnhof Planungskonzept</h1>", " <h1 class='balloon-title' style='color: #FFFFFF;'>Nordbahnhof Planungskonzept</h1>",
" <div class='balloon-content' style='margin-right: 0px;'", " <div class='balloon-content' style='margin-right: 0px;'",
...@@ -657,6 +657,37 @@ ...@@ -657,6 +657,37 @@
"layerNames": [ "layerNames": [
"ProjektNord" "ProjektNord"
] ]
},{
"template": [
"<div class='balloon' style='width: 200px; background-color: #3C3C3C; color: #FFFFFF;' id='myBalloon'>",
"<button class='infobtn' onclick='NoiseText()'></button>",
" <h1 class='balloon-title' style='color: #FFFFFF;'>Noise Sensor</h1>",
" <div class='balloon-content' style='margin-right: 0px;'",
" </div>",
"<div class='box-3'>",
"<div class='btn btn-three' onclick='getNoiseData()'>",
"<span>Get Noise Data</span>",
"</div><br>",
"<br></div><br>",
"<p>noise_LAeq: </p><p id='noise_laeq'>&nbsp;</p><br>",
"<p>noise_LA_min: </p><p id='noise_lamin'>&nbsp;</p><br>",
"<p>noise_LA_max: </p><p id='noise_lamax'>&nbsp;</p><br>",
"<span></span>",
"</div>",
"<% %>"
],
"minTop": "balloonHeight + 10",
"minLeft": "70",
"layerTypes": [
""
],
"layerNames": [
"NoiseLocation"
]
}, },
{ {
"template": [ "template": [
...@@ -1408,6 +1439,27 @@ ...@@ -1408,6 +1439,27 @@
} }
}, },
"heightAboveGround": 0 "heightAboveGround": 0
},{
"name": "NoiseLocation",
"url": "./datasource-data/NoiseData/NoisePoint.geojson",
"type": "vcs.vcm.layer.GeoJSON",
"datasourceId": "...",
"activeOnStartup": true,
"exclusive": false,
"projection": {
"epsg": "4326",
"proj4": ""
},
"altitudeMode": "relativeToGround",
"style": {
"image": {
"icon": {
"src": "./datasource-data/NoiseData/noise.png",
"scale": 1
}
}
},
"heightAboveGround": 0
} }
], ],
"viewpoints": [ "viewpoints": [
......
.loader {
border: 2px solid #f3f3f3;
border-radius: 50%;
border-top: 2px solid #3498db;
width: 12px;
height: 12px;
-webkit-animation: spin 2s linear infinite; /* Safari */
animation: spin 2s linear infinite;
}
/* Safari */
@-webkit-keyframes spin {
0% { -webkit-transform: rotate(0deg); }
100% { -webkit-transform: rotate(360deg); }
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
.Travelpoint{
font-size: 12pt;
margin: 5px;
font-weight: bold;
}
.walkingshape {
height: 50px;
border-left-style: solid;
border-color:#1e90ff;
border-left-width: 10px;
width: 60px;
margin-left:30px;
padding-left:5px;
/* text-align: center; */
/* background-color: #1e90ff; */
}
.busshape {
height: 50px;
width: 60px;
margin-left:30px;
/* text-align: center; */
border-color: #ff8c00;
border-left-style: solid;
border-left-width: 10px;
padding-left:5px;
}
.subwayshape {
height: 50px;
width: 60px;
margin-left:30px;
/* text-align: center; */
border-color: #ff8c00;
border-left-style: solid;
border-left-width: 10px;
padding-left:5px;
}
\ No newline at end of file
#btn_StreetDay, #btn_RailDay{
background-color: #ffcc33; /* yellow */
border: none;
color: white;
width:3.2em;
height:1.8em;
/* padding: 15px 32px; */
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
border-radius: 2px;
box-shadow: 0 8px 16px 0 rgba(255,204,51,0.2), 0 6px 20px 0 rgba(0,0,0,0.19);
}
#btn_StreetDay:hover, #btn_RailDay:hover{
background-color: #af8a1c;
box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2), 0 6px 20px 0 rgba(0,0,0,0.19);
cursor: pointer;
}
#btn_StreetNight, #btn_RailNight{
background-color: #3583f8; /* yellow */
border: none;
color: white;
width:3.2em;
height:1.8em;
/* padding: 15px 32px; */
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
border-radius: 2px;
box-shadow: 0 8px 16px 0 #3583f833, 0 6px 20px 0 rgba(0,0,0,0.19);
}
#btn_StreetNight:hover, #btn_RailNight:hover{
background-color: #235fb9;
box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2), 0 6px 20px 0 rgba(0,0,0,0.19);
cursor: pointer;
}
#btn_StreetOff, #btn_RailOff{
background-color: #424242; /* yellow */
border: none;
color: white;
width:2.4em;
height:1.8em;
/* padding: 15px 32px; */
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
border-radius: 2px;
box-shadow: 0 8px 16px 0 #27272733, 0 6px 20px 0 rgba(0,0,0,0.19);
}
#btn_StreetOff:hover, #btn_RailOff:hover{
background-color: #161616;
box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2), 0 6px 20px 0 rgba(0,0,0,0.19);
cursor: pointer;
}
#btn_NoiseSensOn, #btn_NoiseSensOff, .btn_on, .btn_off{
background-color: #424242; /* yellow */
border: none;
color: white;
width:4em;
height:1.8em;
/* padding: 15px 32px; */
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
border-radius: 2px;
box-shadow: 0 8px 16px 0 #27272733, 0 6px 20px 0 rgba(0,0,0,0.19);
}
#btn_NoiseSensOn:hover, #btn_NoiseSensOff:hover, .btn_on:hover, .btn_off:hover{
background-color: #161616;
box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2), 0 6px 20px 0 rgba(0,0,0,0.19);
cursor: pointer;
}
#tourstart-btn, #balloon-startscreen{
box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2), 0 6px 20px 0 rgba(0,0,0,0.19);
}
.btn-three{
box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2), 0 6px 20px 0 rgba(0,0,0,0.19);
}
/* .btn_home{
box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2), 0 6px 20px 0 rgba(0,0,0,0.19);
width:6em;
height:2.3em;
border-radius: 4px;
text-align: center;
margin-top: -15px;
} */
.btn_standard{
background-color: #424242; /* yellow */
border: none;
color: white;
/* padding: 15px 32px; */
text-align: center;
text-decoration: none;
display: inline-block;
border-radius: 2px;
box-shadow: 0 8px 16px 0 #27272733, 0 6px 20px 0 rgba(0,0,0,0.19);
}
.btn_standard:hover{
background-color: #161616;
box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2), 0 6px 20px 0 rgba(0,0,0,0.19);
cursor: pointer;
}
\ No newline at end of file
{"id": "LFwfxQb4d2CX8CBhL", "type": "FeatureCollection", "features":[{"type":"Feature","geometry":{"type":"Point","coordinates":[9.15884470936,48.77543604444,-0.013149800758705666]},"properties":{},"vcsMeta":{},"id":"mPWksRx2XR6bd7DQ8Ter9EPW"}],"featureType":"simple","vcsMeta": {"version":"1.0","altitudeMode":"clampToGround"}}
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -152,6 +152,8 @@ ...@@ -152,6 +152,8 @@
<link rel="stylesheet" href="templates/story/story.css"> <link rel="stylesheet" href="templates/story/story.css">
<link rel="stylesheet" href="templates/cus_Menu.css"> <link rel="stylesheet" href="templates/cus_Menu.css">
<link rel="stylesheet" href="sources/nouislider.css"> <link rel="stylesheet" href="sources/nouislider.css">
<link rel="stylesheet" href="css/loading.css">
<!-- <link rel="stylesheet" href="css/menu.css"> -->
</head> </head>
...@@ -179,9 +181,14 @@ ...@@ -179,9 +181,14 @@
</div> </div>
<button class="accordion">Acoustics</button> <button class="accordion">Acoustics</button>
<div class="sub-menu"> <div class="sub-menu">
<a href="#" style="margin-left:0.4rem;">Lärmkarte (Straße)</a> <a><strong>Lärmkarten:</strong></a><br>
<div class="switch-toggle switch-3 switch-candy"> <button id ="btn_StreetDay" onclick="noisemap('Streetday')">Day</button>
<button id ="btn_StreetNight" onclick="noisemap('Streetnight')">Night</button>
<button id ="btn_StreetOff" onclick="noisemap('offS')">Off</button>
<a href="#" style="margin-left:0.4rem;">Straße</a><br>
<!-- <div class="switch-toggle switch-3 switch-candy">
<button id ="btn_StreetDay">Day</button>
<input id="on" name="state-d" type="radio" checked="" /> <input id="on" name="state-d" type="radio" checked="" />
<label for="on" onclick="noisemap('Streetday')">Day</label> <label for="on" onclick="noisemap('Streetday')">Day</label>
...@@ -191,10 +198,15 @@ ...@@ -191,10 +198,15 @@
<input id="off" name="state-d" type="radio" checked="checked" /> <input id="off" name="state-d" type="radio" checked="checked" />
<label for="off" onclick="noisemap('offS')">OFF</label> <label for="off" onclick="noisemap('offS')">OFF</label>
</div><br> </div><br> -->
<button id ="btn_RailDay" onclick="noisemap('Railday')">Day</button>
<a href="#" style="margin-left:0.4rem;">Lärmkarte (Bahn)</a> <button id ="btn_RailNight" onclick="noisemap('Railnight')">Night</button>
<div class="switch-toggle switch-3 switch-candy"> <button id ="btn_RailOff" onclick="noisemap('offR')">Off</button>
<a href="#" style="margin-left:0.4rem;">Bahn</a><br>
<a><strong>Noise Sensors:</strong></a><br>
<button id ="btn_NoiseSensOn" onclick="noisesens('on')">On</button>
<button id ="btn_NoiseSensOff" onclick="noisesens('off')">Off</button><br>
<!-- <div class="switch-toggle switch-3 switch-candy">
<input id="onR" name="state-d" type="radio" checked="" /> <input id="onR" name="state-d" type="radio" checked="" />
<label for="onR" onclick="noisemap('Railday')">Day</label> <label for="onR" onclick="noisemap('Railday')">Day</label>
...@@ -205,13 +217,16 @@ ...@@ -205,13 +217,16 @@
<input id="offR" name="state-d" type="radio" checked="checked" /> <input id="offR" name="state-d" type="radio" checked="checked" />
<label for="offR" onclick="noisemap('offR')">OFF</label> <label for="offR" onclick="noisemap('offR')">OFF</label>
</div> </div> -->
</div> </div>
<button class="accordion">Mobility</button> <button class="accordion">Mobility</button>
<div class="sub-menu"> <div class="sub-menu">
<a href="#" onclick="" >Bauarbeiten</a> <button class = "btn_on" onclick="getAccidents('CONSTRUCTION')">On</button>
<div class="switch-toggle switch-3 switch-candy"> <button class = "btn_off" onclick="deleteAccidents('CONSTRUCTION')">Off</button>
<a href="#" onclick="" >Bauarbeiten</a><br>
<!-- <div class="switch-toggle switch-3 switch-candy">
<input id="acc-on" name="state-d" type="radio" checked="" /> <input id="acc-on" name="state-d" type="radio" checked="" />
<label for="on" onclick="getAccidents('CONSTRUCTION')">ON</label> <label for="on" onclick="getAccidents('CONSTRUCTION')">ON</label>
...@@ -219,9 +234,11 @@ ...@@ -219,9 +234,11 @@
<input id="acc-off" name="state-d" type="radio" checked="true"/> <input id="acc-off" name="state-d" type="radio" checked="true"/>
<label for="na" onclick="deleteAccidents('CONSTRUCTION')">OFF</label> <label for="na" onclick="deleteAccidents('CONSTRUCTION')">OFF</label>
</div><br> </div><br> -->
<button class = "btn_on" onclick="getAccidents('ROAD_CLOSURE')">On</button>
<button class = "btn_off" onclick="deleteAccidents('ROAD_CLOSURE')">Off</button>
<a href="#" onclick="" >Straßenschließungen</a> <a href="#" onclick="" >Straßenschließungen</a>
<div class="switch-toggle switch-3 switch-candy"> <!-- <div class="switch-toggle switch-3 switch-candy">
<input id="road-on" name="state-d" type="radio" checked="" /> <input id="road-on" name="state-d" type="radio" checked="" />
<label for="on" onclick="getAccidents('ROAD_CLOSURE')">ON</label> <label for="on" onclick="getAccidents('ROAD_CLOSURE')">ON</label>
...@@ -229,8 +246,19 @@ ...@@ -229,8 +246,19 @@
<input id="road-off" name="state-d" type="radio" checked="true"/> <input id="road-off" name="state-d" type="radio" checked="true"/>
<label for="na" onclick="deleteAccidents('ROAD_CLOSURE')">OFF</label> <label for="na" onclick="deleteAccidents('ROAD_CLOSURE')">OFF</label>
</div> </div> -->
<a href="#" onclick="drawFlow();" >Verkehrsflow</a> <button class = "btn_on" onclick="drawFlow()">On</button>
<button class = "btn_off" onclick="deleteFlow()">Off</button>
<a href="#">Verkehrsflow</a>
<!-- <div class="switch-toggle switch-3 switch-candy">
<input id="flow-on" name="state-d" type="radio" checked="" />
<label for="on" onclick="drawFlow()">ON</label>
<input id="flow-off" name="state-d" type="radio" checked="true"/>
<label for="na" onclick="deleteFlow()">OFF</label>
</div> -->
</div> </div>
<button class="accordion" onclick="Navigationshow();getPosition();" >Navigation</button> <button class="accordion" onclick="Navigationshow();getPosition();" >Navigation</button>
<!-- <div class="sub-menu"> <!-- <div class="sub-menu">
...@@ -260,9 +288,9 @@ ...@@ -260,9 +288,9 @@
<!--img src="images/Logo_SV.png" width="150"--> <!--img src="images/Logo_SV.png" width="150"-->
<strong>M4_Lab</strong> <br>Platform <strong>M4_Lab</strong> <br>Platform
</h1> </h1>
<button id="tourstart-btn" onclick="stopStory(); removebuildings();getTraffic();getFlow();getFlowtest();" class="buttonset one"><span class="i18n_balloon_startscreen_btn">Start</span> <button id="tourstart-btn" onclick="stopStory(); removebuildings();" class="buttonset one"><span class="i18n_balloon_startscreen_btn">Start</span>
</button> </button>
<!-- getNAVcar(); --> <!-- getNAVcar(); -------Test back to start: getFlow();getFlowtest();getTraffic(); -->
</div> </div>
<div class="dialog-image-balloon"></div> <div class="dialog-image-balloon"></div>
<div class="balloon-left-edge"></div> <div class="balloon-left-edge"></div>
...@@ -271,7 +299,7 @@ ...@@ -271,7 +299,7 @@
<!-- Content Tour --> <!-- Content Tour -->
<div id="tour-frame" style="display: none; overflow-y: scroll;"> <div id="tour-frame" style="display: none; overflow-y: scroll;">
<div class="tour-top-navi" style="z-index:99"> <div class="tour-top-navi" style="z-index:99">
<a href="#" onclick="goHome()" id = "testing" class="top-nav buttonset one"><i class="fa fa-home"></i>Home</a> <a href="#" onclick="goHome()" id = "testing" class=" top-nav buttonset one btn_home"><i class="fa fa-home"></i>Home</a>
<!-- <a href="#energiefahrrad" class="top-nav buttonset one"><i class="fa fa-bicycle"></i> Projekt 2</a> <!-- <a href="#energiefahrrad" class="top-nav buttonset one"><i class="fa fa-bicycle"></i> Projekt 2</a>
<a href="#wea" class="top-nav buttonset one"><i class="fa fa-bolt"></i> Projekt 3</a> <a href="#wea" class="top-nav buttonset one"><i class="fa fa-bolt"></i> Projekt 3</a>
<a href="#projects" id="back" class="top-nav buttonset one"><i class="fa fa-bolt"></i> Back to Projekt View 3</a> --> <a href="#projects" id="back" class="top-nav buttonset one"><i class="fa fa-bolt"></i> Back to Projekt View 3</a> -->
...@@ -624,27 +652,53 @@ ...@@ -624,27 +652,53 @@
<div style='width:100%;margin-top:200px;' id="chartNordB"></div> <div style='width:100%;margin-top:200px;' id="chartNordB"></div>
<!-- <div id="slider-color"></div> --> <!-- <div id="slider-color"></div> -->
</div> </div>
<!-- ======================================================================================================================================================================== -->
<!-- Noise -->
<div id="NoiseInfo" class="SideInfo" style="display:none;">
<!-- <h1 class="sticky" id="headNoise">Lärmdaten</h1>
<br> -->
<h2>Historical Noise Data</h2>
<!-- <p>The specific space heating demand wurde mit SimStadt simuliert. Die Werte sind in [kWh/m²·a] angegeben.</p><br>
<button onclick="HistNoiseData()">GetData</button>
<button onclick="showgraphNoise()">GetData</button> -->
<div id="unconstrained"></div><br>
<span class="example-val" id="unconstrained-values"></span>
<div style='width:100%;margin-top:200px;' id="chartNoise"></div>
<!-- <div id="slider-color"></div> -->
</div>
<!-- ======================================================================================================================================================================== -->
<!-- Navigation -->
<div id="Navigation" class="SideInfo" style="display:none;"> <div id="Navigation" class="SideInfo" style="display:none;">
<h1 class="sticky" id="headNordB">Navigationsberechner</h1> <h1 class="sticky" id="headNordB">Navigationsberechner</h1>
<p class="contentOne">Bitte wählen Sie einen Start und Endpunkt für ihre Route aus.</p> <p class="contentOne">Bitte wählen Sie einen Start und Endpunkt für ihre Route aus.</p>
<button onclick="getStart('Start');">Startpunkt</button> <!-- <button onclick="setRouteCar();">TestPunkt</button> -->
<input type="text" id="Spunktlat" name="Spunktlat"> <div style="width:34em;">
<input type="text" id="Spunktlon" name="Spunktlon"><br><br> <button class="btn_standard" style="width:10em;height:2em;" onclick="getStart('Start');">Startpunkt</button>
<input style="width:12em;height:2em;" type="text" id="Spunktlat" name="Spunktlat">
<button onclick="getStart('End');">Endpunkt</button> <input style="width:12em;height:2em;" type="text" id="Spunktlon" name="Spunktlon"><br><br>
<input type="text" id="Epunktlat" name="Epunktlat">
<input type="text" id="Epunktlon" name="Epunktlon"><br><br> <button class="btn_standard" style="width:10em;height:2em;" onclick="getStart('End');">Endpunkt</button>
<input style="width:12em;height:2em;" type="text" id="Epunktlat" name="Epunktlat">
<input style="width:12em;height:2em;" type="text" id="Epunktlon" name="Epunktlon"><br><br>
<!-- <select> <!-- <select>
<option>mit Parkplatz</option> <option>mit Parkplatz</option>
<option>ohne Parkplatz</option> <option>ohne Parkplatz</option>
</select> --> </select> -->
<button onclick="showRoute();">Route berechnen</button> <button class="btn_standard" id="buttonCar" style="width:13em;height:2em;" onclick="setRouteCar();">Route berechnen (Auto)</button>
<button onclick="drawnavcar();drawnavpub();">Route anzeigen</button> <button class="btn_standard" id="buttonPub" style="width:13em;height:2em;" onclick="setRoutePublic();">Route berechnen (Öffis)<div id="loaderPub" style="display:none;" class="loader"></div></button>
<button onclick="deletenav();">Route löschen</button><br><br> <button class="btn_standard" style="width:8em;height:2em;" onclick="deletenav();">Route löschen</button><br><br>
<p class="contentOne">Duration with Car</p> <p class="contentOne">Duration with Car</p>
<input type="text" id="Routeduration" name="Duration"><br> <input type="text" id="Routeduration" name="Duration"><br>
<p class="contentOne">Duration with Public</p> <p class="contentOne">Duration with Public</p>
<input type="text" id="RoutedurationPub" name="Duration"> <input type="text" id="RoutedurationPub" name="Duration">
<br>
<div id="PubRouteShow" style="margin-top:1em;">
<!-- <a>Startpunkt</a>
<div class="walkingshape"></div>
<a>Endpunkt</a> -->
</div>
</div>
</div> </div>
</div> </div>
<div id="tour-button" title="Karte/Story umschalten"> <div id="tour-button" title="Karte/Story umschalten">
...@@ -669,7 +723,9 @@ ...@@ -669,7 +723,9 @@
<script src="templates/slider.js"></script> <script src="templates/slider.js"></script>
<script src="templates/UserBalloon.js"></script> <script src="templates/UserBalloon.js"></script>
<script src="js/navigation.js"></script> <script src="js/navigation.js"></script>
<script src="js/noise.js"></script>
<link href="templates/sliders.css" rel="stylesheet"> <link href="templates/sliders.css" rel="stylesheet">
<link rel="stylesheet" href="css/menu.css">
<script> <script>
var startVCM = function() { var startVCM = function() {
......
...@@ -62,7 +62,7 @@ function getAccidents(type){ ...@@ -62,7 +62,7 @@ function getAccidents(type){
if (type == "ROAD_CLOSURE"){ if (type == "ROAD_CLOSURE"){
roadclose = new vcs.vcm.layer.GeoJSON({ roadclose = new vcs.vcm.layer.GeoJSON({
name: "ROAD_CLOSURE", name: "ROAD_CLOSURE",
url: "http://localhost:8083/CONSTRUCTION", url: "http://localhost:8083/ROAD_CLOSURE",
data: geojson, data: geojson,
projection: { projection: {
epsg: 4326 epsg: 4326
...@@ -205,9 +205,10 @@ catch (err) { ...@@ -205,9 +205,10 @@ catch (err) {
}; };
function drawFlow(){ function drawFlow(){
// url: "http://localhost:8083/FLOW",
flowlayer = new vcs.vcm.layer.GeoJSON({ flowlayer = new vcs.vcm.layer.GeoJSON({
name: "FLOW", name: "FLOW",
url: "http://localhost:8083/FLOW", url: "http://localhost:8083/TrafficFlow",
data: geojson, data: geojson,
projection: { projection: {
epsg: 4326 epsg: 4326
...@@ -218,6 +219,18 @@ function drawFlow(){ ...@@ -218,6 +219,18 @@ function drawFlow(){
framework.addLayer(flowlayer) framework.addLayer(flowlayer)
flowlayer.activate(true); flowlayer.activate(true);
} }
function deleteFlow(){
var layern = ["FLOW"]
var layers = framework.getLayers();
for (var i = 0; i< layers.length; i++) {
var layer = layers[i];
if(layern.indexOf(layer.name) >= 0){
layer.activate(false);
}
}
framework.removeLayerByName("FLOW")
}
function drawnavcar(){ function drawnavcar(){
var layern = ["NAVCAR"] var layern = ["NAVCAR"]
var layers = framework.getLayers(); var layers = framework.getLayers();
...@@ -284,3 +297,386 @@ function drawnavpub(){ ...@@ -284,3 +297,386 @@ function drawnavpub(){
framework.addLayer(navcarlayer) framework.addLayer(navcarlayer)
navcarlayer.activate(true); navcarlayer.activate(true);
} }
//-- Set point in the map
function setPoint(location, pointd){
var datapoint = {
slat:"",
slon:"",
sloc:"",
}
datapoint.slat = pointd.lat
datapoint.slon = pointd.lon
datapoint.sloc = location
var layern = [location + "point"]
var layers = framework.getLayers();
// hide layer if it already exists
for (var i = 0; i< layers.length; i++) {
var layer = layers[i];
if(layern.indexOf(layer.name) >= 0){
layer.activate(false);
}
}
// delete layer if it already exists
framework.removeLayerByName(location + "point")
// visualizing with vcs GeoJson function
pointlayer = new vcs.vcm.layer.GeoJSON({
name: location + "point",
url: "http://localhost:8083/addPoint?slat=" + pointd.lat + "&slon=" + pointd.lon + "&sloc=" + location,
data: geojson,
projection: {
epsg: 4326
},
altitudeMode : "relativeToGround",
style: {
image: {
icon: {
src: "./templates/locationSM.png",
scale: 0.5
}
}
},
heightAboveGround: 0
})
framework.addLayer(pointlayer)
pointlayer.activate(true);
}
// Test Funktion
function setRouteCar(){
var resetBtn = document.getElementById("buttonCar");
resetBtn.disabled = true;
resetBtn.innerHTML = '<div id="loaderCar" class="loader"></div>'
// var loaderBtn = document.getElementById("loaderCar");
// loaderBtn.display = "block";
pointsoe="";
var datapoint = {
slat:"",
slon:"",
sloc:"Start",
elat:"",
elon:"",
eloc:"End"
}
datapoint.slat = document.getElementById('Spunktlat').value
datapoint.slon = document.getElementById('Spunktlon').value
datapoint.sloc = "Start"
datapoint.elat = document.getElementById('Epunktlat').value
datapoint.elon = document.getElementById('Epunktlon').value
datapoint.eloc = "End"
var layern = ["CarRoute"]
var layers = framework.getLayers();
// hide layer if it already exists
for (var i = 0; i< layers.length; i++) {
var layer = layers[i];
if(layern.indexOf(layer.name) >= 0){
layer.activate(false);
}
}
// delete layer if it already exists
framework.removeLayerByName("CarRoute")
// visualizing with vcs GeoJson function
pointlayer = new vcs.vcm.layer.GeoJSON({
name: "CarRoute",
url: "http://localhost:8083/Routecalc2?slat=" + datapoint.slat + "&slon=" + datapoint.slon + "&sloc=" + datapoint.sloc + "&elat=" + datapoint.elat + "&elon=" + datapoint.elon + "&eloc=" + datapoint.eloc,
data: geojson,
projection: {
epsg: 4326
},
altitudeMode : "relativeToGround",
style: {
image: {
icon: {
src: "./templates/locationSM.png",
scale: 0.5
}
}
},
heightAboveGround: 0
})
framework.addLayer(pointlayer)
pointlayer.activate(true);
// var mainlayer;
var layern = ["CarRoute"]
var layers = framework.getLayers();
for (var i = 0; i< layers.length; i++) {
var layer = layers[i];
if(layern.indexOf(layer.name) >= 0){
mainlayer = layer
}
}
var objectlist = [];
var layerData = {}
var test = 0;
var timeout = setInterval(function() {
if("l" in layerData) {
for (key in layerData.l) {
test +=1;
objectlist.push(layerData.l[key])
}
console.log(test)
console.log(objectlist)
calcTime(objectlist,"Routeduration");
clearInterval(timeout);
isFinished = true;
} else{
layerData = getLayerforData("CarRoute")
}
}, 1000);
}
function setRoutePublic(){
document.getElementById("PubRouteShow").innerHTML = "";
var resetBtn = document.getElementById("buttonPub");
resetBtn.disabled = true;
resetBtn.innerHTML = '<div id="loaderCar" class="loader"></div>'
pointsoe = "";
var datapoint = {
slat:"",
slon:"",
sloc:"Start",
elat:"",
elon:"",
eloc:"End"
}
var testingThing;
datapoint.slat = document.getElementById('Spunktlat').value
datapoint.slon = document.getElementById('Spunktlon').value
datapoint.sloc = "Start"
datapoint.elat = document.getElementById('Epunktlat').value
datapoint.elon = document.getElementById('Epunktlon').value
datapoint.eloc = "End"
var layern = ["PublicRoute"]
var layers = framework.getLayers();
// hide layer if it already exists
for (var i = 0; i< layers.length; i++) {
var layer = layers[i];
if(layern.indexOf(layer.name) >= 0){
layer.activate(false);
}
}
// delete layer if it already exists
framework.removeLayerByName("PublicRoute")
// visualizing with vcs GeoJson function
pointlayer = new vcs.vcm.layer.GeoJSON({
name: "PublicRoute",
url: "http://localhost:8083/navPublicT2?slat=" + datapoint.slat + "&slon=" + datapoint.slon + "&sloc=" + datapoint.sloc + "&elat=" + datapoint.elat + "&elon=" + datapoint.elon + "&eloc=" + datapoint.eloc,
data: testingThing,
projection: {
epsg: 4326
},
altitudeMode : "relativeToGround",
style: {
image: {
icon: {
src: "./templates/locationSM.png",
scale: 0.5
}
}
},
heightAboveGround: 0
})
framework.addLayer(pointlayer)
pointlayer.activate(true);
// --- get the Data from the geoJson
//======in progress
// var mainlayer;
var layern = ["PublicRoute"]
var layers = framework.getLayers();
for (var i = 0; i< layers.length; i++) {
var layer = layers[i];
if(layern.indexOf(layer.name) >= 0){
mainlayer = layer
}
}
var objectlist = [];
var layerData = {}
var test = 0;
var timeout = setInterval(function() {
if("l" in layerData) {
for (key in layerData.l) {
test +=1;
objectlist.push(layerData.l[key])
}
console.log(test)
console.log(objectlist)
calcTime(objectlist,"RoutedurationPub");
clearInterval(timeout);
isFinished = true;
} else{
layerData = getLayerforData("PublicRoute")
}
}, 1000);
// var newmain = mainlayer.options.commonLayer.source
////["00c943b2-de4c-4898-bf4b-680b49cd0643"].I
//var testing = Object.getOwnPropertyNames(newmain.l).sort()
}
function calcTime(list,location){
var daystime = 0;
var minutestime = 0;
var secondstime = 0;
var hourstime = 0;
for (var i = 0; i< list.length; i++) {
daystime += parseFloat(list[i].I.daysDifference)
minutestime += parseFloat(list[i].I.minutesDifference)
secondstime += parseFloat(list[i].I.secondsDifference)
hourstime += parseFloat(list[i].I.hoursDifference)
if (location == "RoutedurationPub"){
if (i == 0){
var newPoint = document.createElement("div");
newPoint.className = "Travelpoint";
newPoint.innerHTML = "Startpunkt"
// var textnode = document.createTextNode(list[i].I.arrivalPlace.name);
document.getElementById("PubRouteShow").appendChild(newPoint);
}
if (list[i].I.transportInfo.mode == "pedestrian"){
var newDiv = document.createElement("div");
newDiv.className = "walkingshape";
newDiv.innerHTML = "zu Fuß"
document.getElementById("PubRouteShow").appendChild(newDiv);
if (list[i].I.arrivalPlace.name){
var newPoint = document.createElement("div");
newPoint.className = "Travelpoint";
newPoint.innerHTML = list[i].I.arrivalPlace.name
// var textnode = document.createTextNode(list[i].I.arrivalPlace.name);
document.getElementById("PubRouteShow").appendChild(newPoint);
}
} else if (list[i].I.transportInfo.mode == "subway"){
var newDiv = document.createElement("div");
newDiv.className = "subwayshape";
newDiv.innerHTML = "mit U-Bahn"
document.getElementById("PubRouteShow").appendChild(newDiv);
var newPoint = document.createElement("div");
newPoint.className = "Travelpoint";
newPoint.innerHTML = list[i].I.arrivalPlace.name
// var textnode = document.createTextNode(list[i].I.arrivalPlace.name);
document.getElementById("PubRouteShow").appendChild(newPoint);
} else if (list[i].I.transportInfo.mode == "bus"){
var newDiv = document.createElement("div");
newDiv.className = "busshape";
newDiv.innerHTML = "mit Bus"
document.getElementById("PubRouteShow").appendChild(newDiv);
var newPoint = document.createElement("div");
newPoint.className = "Travelpoint";
newPoint.innerHTML = list[i].I.arrivalPlace.name
// var textnode = document.createTextNode(list[i].I.arrivalPlace.name);
document.getElementById("PubRouteShow").appendChild(newPoint);
}else if (list[i].I.transportInfo.mode == "cityTrain"){
var newDiv = document.createElement("div");
newDiv.className = "subwayshape";
newDiv.innerHTML = "mit S-Bahn"
document.getElementById("PubRouteShow").appendChild(newDiv);
var newPoint = document.createElement("div");
newPoint.className = "Travelpoint";
newPoint.innerHTML = list[i].I.arrivalPlace.name
// var textnode = document.createTextNode(list[i].I.arrivalPlace.name);
document.getElementById("PubRouteShow").appendChild(newPoint);
}
}
// test +=1;
// objectlist.push(layerData.l[key])
}
if (hourstime > 59) {
var days = Math.floor(hourstime / 24);
daystime += parseFloat(days);
var hours = hourstime - days * 24;
hourstime = parseFloat(hours)
}
if (minutestime > 59) {
var hours = Math.floor(minutestime / 60);
hourstime += parseFloat(hours);
var minutes = minutestime - hours * 60;
minutestime = parseFloat(minutes)
}
if (secondstime > 59) {
var minutes = Math.floor(secondstime / 60);
minutestime += parseFloat(minutes);
var seconds = secondstime - minutes * 60;
secondstime = parseFloat(seconds)
}
if (hourstime == 0){
document.getElementById(location).value = minutestime + " min " + secondstime + " sek";
} else if (daystime == 0){
document.getElementById(location).value = hourstime + " h " + minutestime + " min " + secondstime + " sek";
} else{
document.getElementById(location).value = daystime + " d " + hourstime + " h " + minutestime + " min " + secondstime + " sek";
}
if (location == "RoutedurationPub"){
var resetBtn = document.getElementById("buttonPub");
resetBtn.disabled = false;
resetBtn.innerHTML = "Route berechnen (Öffis)"
var newPoint = document.createElement("div");
newPoint.className = "Travelpoint";
newPoint.innerHTML = "Endpunkt"
// var textnode = document.createTextNode(list[i].I.arrivalPlace.name);
document.getElementById("PubRouteShow").appendChild(newPoint);
// var textnode = document.createTextNode("Endpunkt");
// document.getElementById("PubRouteShow").appendChild(textnode);
// var newDiv = document.createElement("div");
// newDiv.className = "walkingshape";
// var loaderBtn = document.getElementById("loaderPub");
// loaderBtn.display = "none";
// document.getElementById("PubRouteShow").appendChild(newDiv);
} else if (location == "Routeduration"){
var resetBtn = document.getElementById("buttonCar");
resetBtn.disabled = false;
resetBtn.innerHTML = "Route berechnen (Auto)"
// var loaderBtn = document.getElementById("loaderCar");
// loaderBtn.display = "none";
}
};
function getLayerforData(name){
var layern = [name]
var layers = framework.getLayers();
var mainlayer2
for (var i = 0; i< layers.length; i++) {
var layer = layers[i];
if(layern.indexOf(layer.name) >= 0){
mainlayer2 = layer
return mainlayer2.options.commonLayer.source
}
}
}
\ No newline at end of file
...@@ -253,13 +253,16 @@ function publictransport(){ ...@@ -253,13 +253,16 @@ function publictransport(){
}; };
function deletenav(){ function deletenav(){
var layernend = ["EndpointNav"] document.getElementById("PubRouteShow").innerHTML = "";
document.getElementById("Routeduration").value = "";
document.getElementById("RoutedurationPub").value = "";
var layernend = ["Endpoint"]
var layernavpub = ["NAVPUB"] var layernavpub = ["PublicRoute"]
var layern = ["Startpoint"] var layern = ["Startpoint"]
var layerncar = ["NAVCAR"] var layerncar = ["CarRoute"]
var layers = framework.getLayers(); var layers = framework.getLayers();
...@@ -269,7 +272,7 @@ function deletenav(){ ...@@ -269,7 +272,7 @@ function deletenav(){
layer1.activate(false); layer1.activate(false);
} }
} }
framework.removeLayerByName("NAVCAR") framework.removeLayerByName("CarRoute")
...@@ -288,7 +291,7 @@ function deletenav(){ ...@@ -288,7 +291,7 @@ function deletenav(){
layer3.activate(false); layer3.activate(false);
} }
}framework.removeLayerByName("EndpointNav") }framework.removeLayerByName("Endpoint")
for (var i = 0; i< layers.length; i++) { for (var i = 0; i< layers.length; i++) {
...@@ -297,5 +300,5 @@ function deletenav(){ ...@@ -297,5 +300,5 @@ function deletenav(){
layer4.activate(false); layer4.activate(false);
} }
} }
framework.removeLayerByName("NAVPUB") framework.removeLayerByName("PublicRoute")
} }
\ No newline at end of file
function getNoiseData() {
try {
$.ajax({
type: "GET",
url: '/NoiseRealTime',
}).done(function (newdata) {
convertdata(newdata);
});
function convertdata(data) {
flow = data;
console.log(flow)
for (var i = 0; i<= flow[0].sensordatavalues.length -1; i++){
if (flow[0].sensordatavalues[i].value_type == "noise_LAeq"){
document.getElementById("noise_laeq").innerHTML = flow[0].sensordatavalues[i].value;
} else if(flow[0].sensordatavalues[i].value_type == "noise_LA_min") {
document.getElementById("noise_lamin").innerHTML = flow[0].sensordatavalues[i].value;
} else if(flow[0].sensordatavalues[i].value_type == "noise_LA_max") {
document.getElementById("noise_lamax").innerHTML = flow[0].sensordatavalues[i].value;
}
}
}
return flow
}
catch (err) {
console.log('loading Gas Values from DB failed!');
}
}
function noisemap(areatime){
var StreetD = false;
var StreetN = false;
var RailD = false;
var RailN = false;
if (areatime == "offS"){
StreetD = false;
StreetN = false;
} else if (areatime == "offR") {
RailD = false;
RailN = false;
} else if (areatime == "Streetday") {
StreetD = true;
StreetN = false;
RailD = false;
RailN = false;
} else if (areatime == "Streetnight") {
StreetD = false;
StreetN = true;
RailD = false;
RailN = false;
} else if (areatime == "Railday") {
StreetD = false;
StreetN = false;
RailD = true;
RailN = false;
} else if (areatime == "Railnight") {
StreetD = false;
StreetN = false;
RailD = false;
RailN = true;
}
var layerStreetD = ["Streetday"]
var layerStreetN = ["Streetnight"]
var layerRailD = ["Railday"]
var layerRailN = ["Railnight"]
var layers = framework.getLayers();
for (var i = 0; i< layers.length; i++) {
var layer = layers[i];
if(layerStreetD.indexOf(layer.name) >= 0){
layer.activate(StreetD);
} else if (layerStreetN.indexOf(layer.name) >= 0){
layer.activate(StreetN);
} else if (layerRailD.indexOf(layer.name) >= 0){
layer.activate(RailD);
} else if (layerRailN.indexOf(layer.name) >= 0){
layer.activate(RailN);
}
}
}
function noisesens(status){
var layerOn = ["NoiseLocation"]
var layers = framework.getLayers();
for (var i = 0; i< layers.length; i++) {
var layer = layers[i];
if(layerOn.indexOf(layer.name) >= 0){
if(status == "on"){
layer.activate(true);
} else if (status == "off"){
layer.activate(false);
}
}
}
}
let histNoise
function HistNoiseData() {
try {
$.ajax({
async: false,
type: "POST",
url: '/getNoiseHist',
data: "",
}).done(function (histwinddata) {
convertdata(histwinddata);
});
function convertdata(histwinddt) {
histNoise = histwinddt;
showgraphNoise();
}
console.log(histNoise[0]);
}
catch (err) {
console.log('-> function gethistWind() failed!\n' + err);
}
}
function showgraphNoise(){
var i;
var noise_LA_max = 0
var noise_LA_maxnumb = 0
var noise_LA_min = 0
var noise_LAeq = 0
var datas = []
var datasMin = []
var dataseq = []
console.log(histNoise.length)
var sDay = new Date('1995-12-17T03:24:00');
for (i = 0; i < histNoise.length; i++) {
if (sameDay(sDay,new Date(histNoise[i].timestamp))){
noise_LA_max = noise_LA_max + parseFloat(histNoise[i].noise_LA_max)
noise_LA_min = noise_LA_min + parseFloat(histNoise[i].noise_LA_min)
noise_LAeq = noise_LAeq + parseFloat(histNoise[i].noise_LAeq)
noise_LA_maxnumb = noise_LA_maxnumb + 1
// console.log(noise_LA_maxnumb)
} else if (noise_LA_maxnumb != 0){
var valuestuff = noise_LA_max / noise_LA_maxnumb
var valuemin = noise_LA_min / noise_LA_maxnumb
var valueeq = noise_LAeq / noise_LA_maxnumb
console.log(sDay.getFullYear() +"-"+(parseInt(sDay.getMonth()) + 1 )+"-"+sDay.getDate())
datas.push({x: new Date(sDay.getFullYear() +"-"+(parseInt(sDay.getMonth()) + 1 )+"-"+sDay.getDate()).getTime(), y: parseFloat(valuestuff.toFixed(2))})
datasMin.push({x: new Date(sDay.getFullYear() +"-"+(parseInt(sDay.getMonth()) + 1 )+"-"+sDay.getDate()).getTime(), y: parseFloat(valuemin.toFixed(2))})
dataseq.push({x: new Date(sDay.getFullYear() +"-"+(parseInt(sDay.getMonth()) + 1 )+"-"+sDay.getDate()).getTime(), y: parseFloat(valueeq.toFixed(2))})
noise_LA_max = 0
noise_LA_min = 0
noise_LAeq = 0
noise_LA_maxnumb = 0
}
sDay = new Date(histNoise[i].timestamp)
}
console.log(dataseq)
console.log("--------")
console.log([{
x: new Date('2018-02-12').getTime(),
y: 76
}, {
x: new Date('2018-02-12').getTime(),
y: 76
}])
var options = {
chart: {
type: "area",
height: 300,
foreColor: "#999",
stacked: false,
dropShadow: {
enabled: true,
enabledSeries: [0],
top: -2,
left: 2,
blur: 5,
opacity: 0.06
}
},
colors: ['#7F0000','#00E396', '#0090FF'],
stroke: {
curve: "smooth",
width: 3
},
dataLabels: {
enabled: false
},
series: [{
name: 'Noise_LA_max',
data: datas
}, {
name: 'Noise_LAeq',
data: dataseq
}, {
name: 'Noise_LA_min',
data: datasMin
}],
markers: {
size: 0,
strokeColor: "#fff",
strokeWidth: 3,
strokeOpacity: 1,
fillOpacity: 1,
hover: {
size: 6
}
},
xaxis: {
type: "datetime",
axisBorder: {
show: false
},
axisTicks: {
show: false
}
},
yaxis: {
labels: {
offsetX: 14,
offsetY: -5
},
tooltip: {
enabled: true
}
},
grid: {
padding: {
left: -5,
right: 5
}
},
tooltip: {
x: {
format: "dd MMM yyyy"
},
},
legend: {
position: 'top',
horizontalAlign: 'left'
},
fill: {
type: 'gradient',
gradient: {
shadeIntensity: 1,
inverseColors: false,
opacityFrom: 0.5,
opacityTo: 0,
stops: [0, 90, 100]
},
}
};
document.getElementById("chartNoise").innerHTML = "";
var chart = new ApexCharts(document.querySelector("#chartNoise"), options);
chart.render();
}
function sameDay(d1, d2) {
return d1.getFullYear() === d2.getFullYear() &&
d1.getMonth() === d2.getMonth() &&
d1.getDate() === d2.getDate();
}
\ No newline at end of file
...@@ -11,12 +11,8 @@ var ballonContent = { ...@@ -11,12 +11,8 @@ var ballonContent = {
loc:"" loc:""
} }
// var Startlat
// var Startlon
// var Endlat
// var Endlon
// var pointsoe
// Get Position from clicking on the map
function getPosition() { function getPosition() {
var map = vcs.vcm.Framework.getInstance().getActiveMap(); var map = vcs.vcm.Framework.getInstance().getActiveMap();
var CViewer = map.viewer var CViewer = map.viewer
...@@ -32,7 +28,6 @@ function getPosition() { ...@@ -32,7 +28,6 @@ function getPosition() {
if (cartesian) { if (cartesian) {
console.log(cartesian) console.log(cartesian)
var cartographic = Cesium.Cartographic.fromCartesian(cartesian); var cartographic = Cesium.Cartographic.fromCartesian(cartesian);
// var geographic = Cesium.geographic.fromCartesion(cartesian);
console.log(cartographic) console.log(cartographic)
var longitudeString = Cesium.Math.toDegrees( var longitudeString = Cesium.Math.toDegrees(
cartographic.longitude cartographic.longitude
...@@ -42,36 +37,39 @@ function getPosition() { ...@@ -42,36 +37,39 @@ function getPosition() {
cartographic.latitude cartographic.latitude
); );
ballonContent.lat = latitudeString; ballonContent.lat = latitudeString;
// alert( "Lon: " + longitudeString +
// "\u00B0" +
// "\nLat: " +
// (" " + latitudeString).slice(-7) +
// "\u00B0");
// PostUserInput();
if (pointsoe == "Start"){ if (pointsoe == "Start"){
point.lat = ballonContent.lat var pointd = {
point.lon = ballonContent.lon lat:"",
point.loc = "Start" lon:"",
loc:""
}
pointd.lat = ballonContent.lat
pointd.lon = ballonContent.lon
pointd.loc = "Start"
var text = document.getElementById('Spunktlat'); var text = document.getElementById('Spunktlat');
text.value = ballonContent.lat; text.value = ballonContent.lat;
var text = document.getElementById('Spunktlon'); var text = document.getElementById('Spunktlon');
text.value = ballonContent.lon; text.value = ballonContent.lon;
// visualize a Point at the clicked location
PostNavPoint("Start"); setPoint("Start", pointd);
} else if (pointsoe == "End"){ } else if (pointsoe == "End"){
point.lat = ballonContent.lat var pointd = {
point.lon = ballonContent.lon lat:"",
point.loc = "End" lon:"",
loc:""
}
pointd.lat = ballonContent.lat
pointd.lon = ballonContent.lon
pointd.loc = "End"
var text = document.getElementById('Epunktlat'); var text = document.getElementById('Epunktlat');
text.value = ballonContent.lat; text.value = ballonContent.lat;
var text = document.getElementById('Epunktlon'); var text = document.getElementById('Epunktlon');
text.value = ballonContent.lon; text.value = ballonContent.lon;
PostNavPoint("End"); // visualize a Point at the clicked location
setPoint("End", pointd);
} }
......
...@@ -210,6 +210,8 @@ function Questionnaire() { ...@@ -210,6 +210,8 @@ function Questionnaire() {
document.getElementById("projektOne").style.display = "none"; document.getElementById("projektOne").style.display = "none";
document.getElementById("Energiekonzept").style.display = "none"; document.getElementById("Energiekonzept").style.display = "none";
document.getElementById("NordbahnhofInfo").style.display = "none"; document.getElementById("NordbahnhofInfo").style.display = "none";
document.getElementById("NoiseInfo").style.display = "none";
document.getElementById("Navigation").style.display = "none";
document.getElementById("UmfrageOne").style.display = "block"; document.getElementById("UmfrageOne").style.display = "block";
showTour(); showTour();
...@@ -230,6 +232,7 @@ function Navigationshow() { ...@@ -230,6 +232,7 @@ function Navigationshow() {
document.getElementById("projektOne").style.display = "none"; document.getElementById("projektOne").style.display = "none";
document.getElementById("Energiekonzept").style.display = "none"; document.getElementById("Energiekonzept").style.display = "none";
document.getElementById("UmfrageOne").style.display = "none"; document.getElementById("UmfrageOne").style.display = "none";
document.getElementById("NoiseInfo").style.display = "none";
document.getElementById("Navigation").style.display = "block"; document.getElementById("Navigation").style.display = "block";
document.getElementById("NordbahnhofInfo").style.display = "none"; document.getElementById("NordbahnhofInfo").style.display = "none";
...@@ -241,62 +244,23 @@ function NordbahnhofText() { ...@@ -241,62 +244,23 @@ function NordbahnhofText() {
document.getElementById("Energiekonzept").style.display = "none"; document.getElementById("Energiekonzept").style.display = "none";
document.getElementById("UmfrageOne").style.display = "none"; document.getElementById("UmfrageOne").style.display = "none";
document.getElementById("Navigation").style.display = "none"; document.getElementById("Navigation").style.display = "none";
document.getElementById("NoiseInfo").style.display = "none";
document.getElementById("NordbahnhofInfo").style.display = "block"; document.getElementById("NordbahnhofInfo").style.display = "block";
showTour(); showTour();
showgraph(); showgraph();
} }
function noisemap(areatime){ function NoiseText() {
document.getElementById("projektOne").style.display = "none";
var StreetD = false; document.getElementById("Energiekonzept").style.display = "none";
var StreetN = false; document.getElementById("UmfrageOne").style.display = "none";
var RailD = false; document.getElementById("Navigation").style.display = "none";
var RailN = false; document.getElementById("NordbahnhofInfo").style.display = "none";
if (areatime == "offS"){ document.getElementById("NoiseInfo").style.display = "block";
StreetD = false;
StreetN = false;
} else if (areatime == "offR") {
RailD = false;
RailN = false;
} else if (areatime == "Streetday") {
StreetD = true;
StreetN = false;
RailD = false;
RailN = false;
} else if (areatime == "Streetnight") {
StreetD = false;
StreetN = true;
RailD = false;
RailN = false;
} else if (areatime == "Railday") {
StreetD = false;
StreetN = false;
RailD = true;
RailN = false;
} else if (areatime == "Railnight") {
StreetD = false;
StreetN = false;
RailD = false;
RailN = true;
}
var layerStreetD = ["Streetday"]
var layerStreetN = ["Streetnight"]
var layerRailD = ["Railday"]
var layerRailN = ["Railnight"]
var layers = framework.getLayers();
for (var i = 0; i< layers.length; i++) { showTour();
var layer = layers[i]; HistNoiseData();
if(layerStreetD.indexOf(layer.name) >= 0){
layer.activate(StreetD);
} else if (layerStreetN.indexOf(layer.name) >= 0){
layer.activate(StreetN);
} else if (layerRailD.indexOf(layer.name) >= 0){
layer.activate(RailD);
} else if (layerRailN.indexOf(layer.name) >= 0){
layer.activate(RailN);
}
}
} }
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment