Commit c8897ff3 authored by Patrick's avatar Patrick
Browse files

update here test

parent bf137ad8
Showing with 1413 additions and 11 deletions
+1413 -11
node_modules
node_modules
codepoly.js 0 → 100644
/*
* Copyright (C) 2019 HERE Europe B.V.
* Licensed under MIT, see full license in LICENSE
* SPDX-License-Identifier: MIT
* License-Filename: LICENSE
*/
const DEFAULT_PRECISION = 5;
const ENCODING_TABLE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
const DECODING_TABLE = [
62, -1, -1, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1, -1,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
22, 23, 24, 25, -1, -1, -1, -1, 63, -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51
];
const FORMAT_VERSION = 1;
const ABSENT = 0;
const LEVEL = 1;
const ALTITUDE = 2;
const ELEVATION = 3;
// Reserved values 4 and 5 should not be selectable
const CUSTOM1 = 6;
const CUSTOM2 = 7;
const Num = typeof BigInt !== "undefined" ? BigInt : Number;
function decode(encoded) {
const decoder = decodeUnsignedValues(encoded);
const header = decodeHeader(decoder[0], decoder[1]);
const factorDegree = 10 ** header.precision;
const factorZ = 10 ** header.thirdDimPrecision;
const { thirdDim } = header;
let lastLat = 0;
let lastLng = 0;
let lastZ = 0;
const res = [];
let i = 2;
for (;i < decoder.length;) {
const deltaLat = toSigned(decoder[i]) / factorDegree;
const deltaLng = toSigned(decoder[i + 1]) / factorDegree;
lastLat += deltaLat;
lastLng += deltaLng;
if (thirdDim) {
const deltaZ = toSigned(decoder[i + 2]) / factorZ;
lastZ += deltaZ;
res.push([lastLat, lastLng, lastZ]);
i += 3;
} else {
res.push([lastLat, lastLng]);
i += 2;
}
}
if (i !== decoder.length) {
throw new Error('Invalid encoding. Premature ending reached');
}
return {
...header,
polyline: res,
};
}
function decodeChar(char) {
const charCode = char.charCodeAt(0);
return DECODING_TABLE[charCode - 45];
}
function decodeUnsignedValues(encoded) {
let result = Num(0);
let shift = Num(0);
const resList = [];
encoded.split('').forEach((char) => {
const value = Num(decodeChar(char));
result |= (value & Num(0x1F)) << shift;
if ((value & Num(0x20)) === Num(0)) {
resList.push(result);
result = Num(0);
shift = Num(0);
} else {
shift += Num(5);
}
});
if (shift > 0) {
throw new Error('Invalid encoding');
}
return resList;
}
function decodeHeader(version, encodedHeader) {
if (+version.toString() !== FORMAT_VERSION) {
throw new Error('Invalid format version');
}
const headerNumber = +encodedHeader.toString();
const precision = headerNumber & 15;
const thirdDim = (headerNumber >> 4) & 7;
const thirdDimPrecision = (headerNumber >> 7) & 15;
return { precision, thirdDim, thirdDimPrecision };
}
function toSigned(val) {
// Decode the sign from an unsigned value
let res = val;
if (res & Num(1)) {
res = ~res;
}
res >>= Num(1);
return +res.toString();
}
function encode({ precision = DEFAULT_PRECISION, thirdDim = ABSENT, thirdDimPrecision = 0, polyline }) {
// Encode a sequence of lat,lng or lat,lng(,{third_dim}). Note that values should be of type BigNumber
// `precision`: how many decimal digits of precision to store the latitude and longitude.
// `third_dim`: type of the third dimension if present in the input.
// `third_dim_precision`: how many decimal digits of precision to store the third dimension.
const multiplierDegree = 10 ** precision;
const multiplierZ = 10 ** thirdDimPrecision;
const encodedHeaderList = encodeHeader(precision, thirdDim, thirdDimPrecision);
const encodedCoords = [];
let lastLat = Num(0);
let lastLng = Num(0);
let lastZ = Num(0);
polyline.forEach((location) => {
const lat = Num(Math.round(location[0] * multiplierDegree));
encodedCoords.push(encodeScaledValue(lat - lastLat));
lastLat = lat;
const lng = Num(Math.round(location[1] * multiplierDegree));
encodedCoords.push(encodeScaledValue(lng - lastLng));
lastLng = lng;
if (thirdDim) {
const z = Num(Math.round(location[2] * multiplierZ));
encodedCoords.push(encodeScaledValue(z - lastZ));
lastZ = z;
}
});
return [...encodedHeaderList, ...encodedCoords].join('');
}
function encodeHeader(precision, thirdDim, thirdDimPrecision) {
// Encode the `precision`, `third_dim` and `third_dim_precision` into one encoded char
if (precision < 0 || precision > 15) {
throw new Error('precision out of range. Should be between 0 and 15');
}
if (thirdDimPrecision < 0 || thirdDimPrecision > 15) {
throw new Error('thirdDimPrecision out of range. Should be between 0 and 15');
}
if (thirdDim < 0 || thirdDim > 7 || thirdDim === 4 || thirdDim === 5) {
throw new Error('thirdDim should be between 0, 1, 2, 3, 6 or 7');
}
const res = (thirdDimPrecision << 7) | (thirdDim << 4) | precision;
return encodeUnsignedNumber(FORMAT_VERSION) + encodeUnsignedNumber(res);
}
function encodeUnsignedNumber(val) {
// Uses variable integer encoding to encode an unsigned integer. Returns the encoded string.
let res = '';
let numVal = Num(val);
while (numVal > 0x1F) {
const pos = (numVal & Num(0x1F)) | Num(0x20);
res += ENCODING_TABLE[pos];
numVal >>= Num(5);
}
return res + ENCODING_TABLE[numVal];
}
function encodeScaledValue(value) {
// Transform a integer `value` into a variable length sequence of characters.
// `appender` is a callable where the produced chars will land to
let numVal = Num(value);
const negative = numVal < 0;
numVal <<= Num(1);
if (negative) {
numVal = ~numVal;
}
return encodeUnsignedNumber(numVal);
}
module.exports = {
encode,
decode,
ABSENT,
LEVEL,
ALTITUDE,
ELEVATION,
};
......@@ -9,11 +9,14 @@ app.use(bodyParser.json())
const request_ajax = require('ajax-request');
const request = require('request');
const polycalc = require('./codepoly.js');
const { isEmptyObject } = require('jquery');
//console.log(polycalc)
app.use(express.static('vcm'));
app.listen(process.env.PORT || 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
//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
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) => {
......@@ -30,6 +33,13 @@ request('https://traffic.ls.hereapi.com/traffic/6.3/incidents.json?apiKey=9Grm-6
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",
......@@ -103,7 +113,27 @@ app.get('/FLOW', function (req, res) {
}
});
// 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('/CONSTRUCTION', function (req, res) {
console.log('command angekommen!')
......@@ -153,7 +183,7 @@ function buildFLOW(){
var JsonFeature = [];
var length = flow.body.RWS[0].RW.length;
console.log(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;
......@@ -326,12 +356,131 @@ function buildFLOW(){
}
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": [
128,
128,
128,
1
],
"width": 2,
"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": [
128,
128,
128,
1
],
"width": 2,
"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": 2,
"lineDash": null
}
}
}
})
// console.log(JsonFeature)
return JsonFeature
}
function buildJSON(type){
var JsonFeature = [];
var length = accident.body.TRAFFIC_ITEMS.TRAFFIC_ITEM.length;
console.log(length)
// console.log(length)
for (var i = 0; i <= length - 1; i++){
// console.log(accident.body.TRAFFIC_ITEMS.TRAFFIC_ITEM[i])
......@@ -355,7 +504,7 @@ function buildJSON(type){
if (type == 'CONSTRUCTION'){
console.log(i)
// console.log(i)
if (TRAFFIC_ITEM_TYPE_DESC == "CONSTRUCTION"){
......@@ -451,7 +600,28 @@ app.post('/FLOWtest', function (req, res) {
}
});
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",
......@@ -461,17 +631,17 @@ var ballonContent = {
categorie: "locationSM.png"
}
app.post('/newBallon', function(req,res){
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);
// 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;
......@@ -499,8 +669,135 @@ app.post('/newBallon', function(req,res){
}
});
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() {
......@@ -629,4 +926,230 @@ function writeBallon() {
"\"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 ');
}
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()
};
// res.json(testjsonsflow);
console.log(navcarjson);
console.log('.../route calc successful!');
res.json(navcarjson);
}
catch (err) {
console.log('.../loadSetP failed!\n' + err);
}
});
var responseStuff
var navPublicjson
app.post('/navPublicT', function (req, res) {
console.log('command angekommen ////// Route/////!')
const pointData = req.body;
console.log(pointData.slat);
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(responseStuff);
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 = 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": [
128,
128,
128,
1
],
"width": 2,
"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": [
128,
128,
128,
1
],
"width": 2,
"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": 2,
"lineDash": null
}
}
}
})
// console.log(JsonFeature)
return JsonFeature
}
\ No newline at end of file
......@@ -232,6 +232,20 @@
</div>
<a href="#" onclick="drawFlow();" >Verkehrsflow</a>
</div>
<button class="accordion">Navigation</button>
<div class="sub-menu">
<a href="#" onclick="Navigationshow();getPosition();" >Car</a>
<div class="switch-toggle switch-3 switch-candy">
<input id="acc-on" name="state-d" type="radio" checked="" />
<label for="on" onclick="drawnavcar()">ON</label>
<input id="acc-off" name="state-d" type="radio" checked="true"/>
<label for="na" onclick="">OFF</label><br><br>
</div><br>
</div>
</div>
</div>
<!-- Drop down menu ends here -->
......@@ -248,6 +262,7 @@
</h1>
<button id="tourstart-btn" onclick="stopStory(); removebuildings();getTraffic();getFlow();getFlowtest();" class="buttonset one"><span class="i18n_balloon_startscreen_btn">Start</span>
</button>
<!-- getNAVcar(); -->
</div>
<div class="dialog-image-balloon"></div>
<div class="balloon-left-edge"></div>
......@@ -609,7 +624,21 @@
<div style='width:100%;margin-top:200px;' id="chartNordB"></div>
<!-- <div id="slider-color"></div> -->
</div>
<div id="Navigation" class="SideInfo" style="display:none;">
<h1 class="sticky" id="headNordB">Navigationsberechner</h1>
<p class="contentOne">Bitte wählen Sie einen Start und Endpunkt für ihre Route aus.</p>
<button onclick="getStart('Start');">Startpunkt</button>
<input type="text" id="Spunktlat" name="Spunktlat">
<input type="text" id="Spunktlon" name="Spunktlon"><br><br>
<button onclick="getStart('End');">Endpunkt</button>
<input type="text" id="Epunktlat" name="Epunktlat">
<input type="text" id="Epunktlon" name="Epunktlon"><br><br>
<button onclick="showRoute();">Route berechnen</button>
<button onclick="drawnavcar();">Route anzeigen</button>
<input type="text" id="Routeduration" name="Duration">
</div>
</div>
<div id="tour-button" title="Karte/Story umschalten">
<i class="fa"></i>
......@@ -631,6 +660,8 @@
<script src="sources/nouislider.js"></script>
<script src="https://cdn.jsdelivr.net/npm/apexcharts"></script>
<script src="templates/slider.js"></script>
<script src="templates/UserBalloon.js"></script>
<script src="js/navigation.js"></script>
<link href="templates/sliders.css" rel="stylesheet">
<script>
......@@ -651,6 +682,7 @@
<script src='lib/vcm_ui.js'></script>
<script src="js/here.js"></script>
<script src="js/codepoly.js"></script>
<script src="templates/custom.js"></script>
<script src="templates/newDevBahn.js"></script>
<script src="templates/cus_Menu.js"></script>
......
/*
* Copyright (C) 2019 HERE Europe B.V.
* Licensed under MIT, see full license in LICENSE
* SPDX-License-Identifier: MIT
* License-Filename: LICENSE
*/
const DEFAULT_PRECISION = 5;
const ENCODING_TABLE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
const DECODING_TABLE = [
62, -1, -1, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1, -1,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
22, 23, 24, 25, -1, -1, -1, -1, 63, -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51
];
const FORMAT_VERSION = 1;
const ABSENT = 0;
const LEVEL = 1;
const ALTITUDE = 2;
const ELEVATION = 3;
// Reserved values 4 and 5 should not be selectable
const CUSTOM1 = 6;
const CUSTOM2 = 7;
const Num = typeof BigInt !== "undefined" ? BigInt : Number;
function decode(encoded) {
const decoder = decodeUnsignedValues(encoded);
const header = decodeHeader(decoder[0], decoder[1]);
const factorDegree = 10 ** header.precision;
const factorZ = 10 ** header.thirdDimPrecision;
const { thirdDim } = header;
let lastLat = 0;
let lastLng = 0;
let lastZ = 0;
const res = [];
let i = 2;
for (;i < decoder.length;) {
const deltaLat = toSigned(decoder[i]) / factorDegree;
const deltaLng = toSigned(decoder[i + 1]) / factorDegree;
lastLat += deltaLat;
lastLng += deltaLng;
if (thirdDim) {
const deltaZ = toSigned(decoder[i + 2]) / factorZ;
lastZ += deltaZ;
res.push([lastLat, lastLng, lastZ]);
i += 3;
} else {
res.push([lastLat, lastLng]);
i += 2;
}
}
if (i !== decoder.length) {
throw new Error('Invalid encoding. Premature ending reached');
}
return {
...header,
polyline: res,
};
}
function decodeChar(char) {
const charCode = char.charCodeAt(0);
return DECODING_TABLE[charCode - 45];
}
function decodeUnsignedValues(encoded) {
let result = Num(0);
let shift = Num(0);
const resList = [];
encoded.split('').forEach((char) => {
const value = Num(decodeChar(char));
result |= (value & Num(0x1F)) << shift;
if ((value & Num(0x20)) === Num(0)) {
resList.push(result);
result = Num(0);
shift = Num(0);
} else {
shift += Num(5);
}
});
if (shift > 0) {
throw new Error('Invalid encoding');
}
return resList;
}
function decodeHeader(version, encodedHeader) {
if (+version.toString() !== FORMAT_VERSION) {
throw new Error('Invalid format version');
}
const headerNumber = +encodedHeader.toString();
const precision = headerNumber & 15;
const thirdDim = (headerNumber >> 4) & 7;
const thirdDimPrecision = (headerNumber >> 7) & 15;
return { precision, thirdDim, thirdDimPrecision };
}
function toSigned(val) {
// Decode the sign from an unsigned value
let res = val;
if (res & Num(1)) {
res = ~res;
}
res >>= Num(1);
return +res.toString();
}
function encode({ precision = DEFAULT_PRECISION, thirdDim = ABSENT, thirdDimPrecision = 0, polyline }) {
// Encode a sequence of lat,lng or lat,lng(,{third_dim}). Note that values should be of type BigNumber
// `precision`: how many decimal digits of precision to store the latitude and longitude.
// `third_dim`: type of the third dimension if present in the input.
// `third_dim_precision`: how many decimal digits of precision to store the third dimension.
const multiplierDegree = 10 ** precision;
const multiplierZ = 10 ** thirdDimPrecision;
const encodedHeaderList = encodeHeader(precision, thirdDim, thirdDimPrecision);
const encodedCoords = [];
let lastLat = Num(0);
let lastLng = Num(0);
let lastZ = Num(0);
polyline.forEach((location) => {
const lat = Num(Math.round(location[0] * multiplierDegree));
encodedCoords.push(encodeScaledValue(lat - lastLat));
lastLat = lat;
const lng = Num(Math.round(location[1] * multiplierDegree));
encodedCoords.push(encodeScaledValue(lng - lastLng));
lastLng = lng;
if (thirdDim) {
const z = Num(Math.round(location[2] * multiplierZ));
encodedCoords.push(encodeScaledValue(z - lastZ));
lastZ = z;
}
});
return [...encodedHeaderList, ...encodedCoords].join('');
}
function encodeHeader(precision, thirdDim, thirdDimPrecision) {
// Encode the `precision`, `third_dim` and `third_dim_precision` into one encoded char
if (precision < 0 || precision > 15) {
throw new Error('precision out of range. Should be between 0 and 15');
}
if (thirdDimPrecision < 0 || thirdDimPrecision > 15) {
throw new Error('thirdDimPrecision out of range. Should be between 0 and 15');
}
if (thirdDim < 0 || thirdDim > 7 || thirdDim === 4 || thirdDim === 5) {
throw new Error('thirdDim should be between 0, 1, 2, 3, 6 or 7');
}
const res = (thirdDimPrecision << 7) | (thirdDim << 4) | precision;
return encodeUnsignedNumber(FORMAT_VERSION) + encodeUnsignedNumber(res);
}
function encodeUnsignedNumber(val) {
// Uses variable integer encoding to encode an unsigned integer. Returns the encoded string.
let res = '';
let numVal = Num(val);
while (numVal > 0x1F) {
const pos = (numVal & Num(0x1F)) | Num(0x20);
res += ENCODING_TABLE[pos];
numVal >>= Num(5);
}
return res + ENCODING_TABLE[numVal];
}
function encodeScaledValue(value) {
// Transform a integer `value` into a variable length sequence of characters.
// `appender` is a callable where the produced chars will land to
let numVal = Num(value);
const negative = numVal < 0;
numVal <<= Num(1);
if (negative) {
numVal = ~numVal;
}
return encodeUnsignedNumber(numVal);
}
// module.exports = {
// encode,
// decode,
// ABSENT,
// LEVEL,
// ALTITUDE,
// ELEVATION,
// };
var traffic;
var flow;
var navcar;
var navcardata;
var geojson;
var geolat;
var geolong;
var originalJson;
var pol;
function getNAVcar(){
// var incidents = getTraffic()
try {
$.ajax({
type: "POST",
url: '/NavCARdata',
}).done(function (newdata) {
convertdata(newdata);
});
function convertdata(data) {
navcardata = data;
console.log(navcardata)
}
return navcardata
}
catch (err) {
console.log('loading Gas Values from DB failed!');
}
// pol = decode(navcar.body.routes[0].sections[0].polyline)
// geolat = traffic.body.TRAFFIC_ITEMS.TRAFFIC_ITEM[0].LOCATION.GEOLOC.ORIGIN.LATITUDE;
// geolong = traffic.body.TRAFFIC_ITEMS.TRAFFIC_ITEM[0].LOCATION.GEOLOC.ORIGIN.LONGITUDE;
// var type = traffic.body.TRAFFIC_ITEMS.TRAFFIC_ITEM[0].TRAFFIC_ITEM_DESCRIPTION[0].value;
// roadclose = new vcs.vcm.layer.GeoJSON({
// name: "ROAD_CLOSURE",
// url: "http://localhost:8083/CONSTRUCTION",
// data: geojson,
// projection: {
// epsg: 4326
// },
// altitudeMode : "relativeToGround",
// style: {
// image: {
// icon: {
// src: "./img/traffic/icons8-straßensperre-64.png",
// scale: 1
// }
// }
// },
// heightAboveGround: 0
// })
// framework.addLayer(roadclose)
// roadclose.activate(true);
};
function getAccidents(type){
// var incidents = getTraffic()
console.log(traffic);
......@@ -106,6 +155,30 @@ catch (err) {
console.log('loading Gas Values from DB failed!');
}
};
function getNAV(){
// var incidents = getTraffic()
// geolat = traffic.body.TRAFFIC_ITEMS.TRAFFIC_ITEM[0].LOCATION.GEOLOC.ORIGIN.LATITUDE;
// geolong = traffic.body.TRAFFIC_ITEMS.TRAFFIC_ITEM[0].LOCATION.GEOLOC.ORIGIN.LONGITUDE;
// var type = traffic.body.TRAFFIC_ITEMS.TRAFFIC_ITEM[0].TRAFFIC_ITEM_DESCRIPTION[0].value;
try {
$.ajax({
type: "POST",
url: '/NavCARdata',
}).done(function (newdata) {
convertdata(newdata);
});
function convertdata(data) {
navcar = data;
console.log(navcar)
}
return navcar
}
catch (err) {
console.log('loading Gas Values from DB failed!');
}
};
function getFlowtest(){
// var incidents = getTraffic()
......@@ -145,7 +218,30 @@ function drawFlow(){
framework.addLayer(flowlayer)
flowlayer.activate(true);
}
function drawnavcar(){
var layern = ["NAVCAR"]
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("NAVCAR")
navcarlayer = new vcs.vcm.layer.GeoJSON({
name: "NAVCAR",
url: "http://localhost:8083/NAVCAR",
data: geojson,
projection: {
epsg: 4326
},
altitudeMode : "relativeToGround",
heightAboveGround: 0
})
framework.addLayer(navcarlayer)
navcarlayer.activate(true);
}
function getTraffic() {
try {
$.ajax({
......
function getStart(point){
pointsoe = point;
}
var pointsoe ="";
function PostNavPoint(testing){
try {
$.ajax({
async: true,
type: "POST",
url: '/navPoint',
data: point
}).done(function (SimSMid) {
console.log(SimSMid)
convertdata();
return(SimSMid)
});
function convertdata() {
console.log("angekommen......")
if (testing == "Start"){
showStartPoint();
} else if (testing == "End"){
showEndPoint();
}
}
// // console.log(currentwind);
// return SimSOutput;
}
catch (err) {
console.log('-> function PostUserInput() failed!\n' + err);
}
}
function showStartPoint(){
var layern = ["Startpoint"]
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("Startpoint")
console.log("testStartpointvis")
Startpointlayer = new vcs.vcm.layer.GeoJSON({
name: "Startpoint",
url: "http://localhost:8083/Startpoint",
data: geojson,
projection: {
epsg: 4326
},
altitudeMode : "relativeToGround",
style: {
image: {
icon: {
src: "./templates/locationSM.png",
scale: 0.5
}
}
},
heightAboveGround: 0
})
framework.addLayer(Startpointlayer)
Startpointlayer.activate(true);
}
function showEndPoint(){
var layern = ["EndpointNav"]
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("EndpointNav")
// console.log("testStartpointvis")
Endpointlayer = new vcs.vcm.layer.GeoJSON({
name: "EndpointNav",
url: "http://localhost:8083/Endpoint",
data: geojson,
projection: {
epsg: 4326
},
altitudeMode : "relativeToGround",
style: {
image: {
icon: {
src: "./templates/locationSM.png",
scale: 0.5
}
}
},
heightAboveGround: 0
})
framework.addLayer(Endpointlayer)
Endpointlayer.activate(true);
}
function showRoute(){
var datapointSend = {
slat:"",
slon:"",
sloc:"",
elat: "",
elon: "",
eloc: ""
}
datapointSend.slat = document.getElementById("Spunktlat").value;
datapointSend.slon = document.getElementById("Spunktlon").value;
datapointSend.elat = document.getElementById("Epunktlat").value;
datapointSend.elon = document.getElementById("Epunktlon").value;
try {
$.ajax({
async: true,
type: "POST",
url: '/Routecalc',
data: datapointSend
}).done(function (SimSMid) {
console.log(SimSMid)
convertdata(SimSMid);
return(SimSMid)
});
function convertdata(data) {
console.log("angekommen......")
document.getElementById("Routeduration").value = data.features[0].properties.minutesDifference + " min " + data.features[0].properties.secondsDifference + " sek";
if (testing == "Start"){
// showStartPoint();
} else if (testing == "End"){
// showEndPoint();
}
// drawnavcar();
}
// // console.log(currentwind);
// return SimSOutput;
}
catch (err) {
console.log('-> function PostUserInput() failed!\n' + err);
}
try {
$.ajax({
async: true,
type: "POST",
url: '/navPublicT',
data: datapointSend
}).done(function (SimSMid) {
console.log(SimSMid)
// convertdata();
return(SimSMid)
});
function convertdata() {
console.log("angekommen......")
if (testing == "Start"){
showStartPoint();
} else if (testing == "End"){
showEndPoint();
}
}
// // console.log(currentwind);
// return SimSOutput;
}
catch (err) {
console.log('-> function PostUserInput() failed!\n' + err);
}
}
function publictransport(){
var datapointSend = {
slat:"",
slon:"",
sloc:"",
elat: "",
elon: "",
eloc: ""
}
datapointSend.slat = document.getElementById("Spunktlat").value;
datapointSend.slon = document.getElementById("Spunktlon").value;
datapointSend.elat = document.getElementById("Epunktlat").value;
datapointSend.elon = document.getElementById("Epunktlon").value;
console.log(datapointSend);
try {
$.ajax({
async: true,
type: "get",
url: '/navPublicT',
data: datapointSend
}).done(function (SimSMid) {
console.log(SimSMid)
// convertdata();
return(SimSMid)
});
function convertdata() {
console.log("angekommen......")
if (testing == "Start"){
showStartPoint();
} else if (testing == "End"){
showEndPoint();
}
}
// // console.log(currentwind);
// return SimSOutput;
}
catch (err) {
console.log('-> function PostUserInput() failed!\n' + err);
}
};
\ No newline at end of file
var ballonContent = {
header: "Test",
Content: "This is a test",
lat: "",
lon: "",
categorie: ""
}
var point = {
lat:"",
lon:"",
loc:""
}
// var Startlat
// var Startlon
// var Endlat
// var Endlon
// var pointsoe
function getPosition() {
var map = vcs.vcm.Framework.getInstance().getActiveMap();
var CViewer = map.viewer
var CScene = map.viewer.scene
if (document.getElementById("Navigation").style.display == "block"){
// Mouse over the globe to see the cartographic position
handler = new Cesium.ScreenSpaceEventHandler(CScene.canvas);
handler.setInputAction(function (movement) {
var cartesian = CViewer.camera.pickEllipsoid(
movement.position,
CScene.globe.ellipsoid
);
if (cartesian) {
console.log(cartesian)
var cartographic = Cesium.Cartographic.fromCartesian(cartesian);
// var geographic = Cesium.geographic.fromCartesion(cartesian);
console.log(cartographic)
var longitudeString = Cesium.Math.toDegrees(
cartographic.longitude
);
ballonContent.lon = longitudeString;
var latitudeString = Cesium.Math.toDegrees(
cartographic.latitude
);
ballonContent.lat = latitudeString;
// alert( "Lon: " + longitudeString +
// "\u00B0" +
// "\nLat: " +
// (" " + latitudeString).slice(-7) +
// "\u00B0");
// PostUserInput();
if (pointsoe == "Start"){
point.lat = ballonContent.lat
point.lon = ballonContent.lon
point.loc = "Start"
var text = document.getElementById('Spunktlat');
text.value = ballonContent.lat;
var text = document.getElementById('Spunktlon');
text.value = ballonContent.lon;
PostNavPoint("Start");
} else if (pointsoe == "End"){
point.lat = ballonContent.lat
point.lon = ballonContent.lon
point.loc = "End"
var text = document.getElementById('Epunktlat');
text.value = ballonContent.lat;
var text = document.getElementById('Epunktlon');
text.value = ballonContent.lon;
PostNavPoint("End");
}
} else {
}
}, Cesium.ScreenSpaceEventType.LEFT_CLICK)
}
}
\ No newline at end of file
......@@ -56,6 +56,7 @@ function showtourSpecific(specify) {
document.getElementById("UmfrageOne").style.display = "none";
document.getElementById("NordbahnhofInfo").style.display = "none";
document.getElementById("Energiekonzept").style.display = "none";
document.getElementById("Navigation").style.display = "none";
document.getElementById("projektOne").style.display = "block";
showTour();
......@@ -104,6 +105,7 @@ function EnergiekonzeptFunction(content){
document.getElementById("UmfrageOne").style.display = "none";
document.getElementById("NordbahnhofInfo").style.display = "none";
document.getElementById("Navigation").style.display = "none";
document.getElementById("projektOne").style.display = "none";
document.getElementById("Energiekonzept").style.display = "block";
showTour();
......@@ -224,11 +226,21 @@ function goHome(){
vcs.vcm.Framework.getInstance().getActiveMap().gotoViewPoint(viewp)
}
function Navigationshow() {
document.getElementById("projektOne").style.display = "none";
document.getElementById("Energiekonzept").style.display = "none";
document.getElementById("UmfrageOne").style.display = "none";
document.getElementById("Navigation").style.display = "block";
document.getElementById("NordbahnhofInfo").style.display = "none";
showTour();
}
//---------------------------------------------------------------------------------------
function NordbahnhofText() {
document.getElementById("projektOne").style.display = "none";
document.getElementById("Energiekonzept").style.display = "none";
document.getElementById("UmfrageOne").style.display = "none";
document.getElementById("Navigation").style.display = "none";
document.getElementById("NordbahnhofInfo").style.display = "block";
showTour();
......
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