diff --git a/serveralternative.js b/serveralternative.js new file mode 100644 index 0000000000000000000000000000000000000000..f2c195da0f100e8416c8d28c90fbe9d570b7b955 --- /dev/null +++ b/serveralternative.js @@ -0,0 +1,194 @@ +const http = require('http'); +const fs = require('fs'); +const express = require('express') +const app = express(); +const bodyParser = require('body-parser') +const soap = require('soap'); +app.use(bodyParser.urlencoded({ extended: false })) +app.use(bodyParser.json()) +const request = require('ajax-request'); + +app.use(express.static('vcm')); +app.listen(process.env.PORT || 8083); +console.log("on 8083"); + + + +var IDGeojson = 100000 +var ballonContent = { + header: "Test", + Content: "This is a test", + lat: "", + lon: "", + categorie: "locationSM.png" +} + +app.post('/newBallon', 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); + } +}); + +// List all the filenames before renaming + + + +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\"" + + "]" + + "}," +} \ No newline at end of file diff --git a/vcm/config.json b/vcm/config.json index f2ac8d0ddfed451800d83a9a40c952bcc78747a9..12324b4dbc944eb0c4b42f5fd798b1a376e4043d 100644 --- a/vcm/config.json +++ b/vcm/config.json @@ -754,15 +754,7 @@ "showCompass": true, "rotationPerFrame": 0.5 }, - { - "useLocalCRS": false, - "type": "vcs.vcm.widgets.Planning", - "serviceUrl": "http://smartvillages.online/", - "projectId": "Q4at5xXnP93Erwtm5", - "scenarioId": "2JQ3od8igw4LRzTR5", - "userLocalCRS": true - }, - { + { "type": "vcs.vcm.widgets.OverviewMap", "name": "Overview Map", "layerName": "Openstreetmap layer",