Commit b8d04daa authored by Patrick's avatar Patrick
Browse files

some test updates to serveralternative.js

parent adf1a565
...@@ -14,34 +14,167 @@ console.log("on 8080"); ...@@ -14,34 +14,167 @@ console.log("on 8080");
var IDGeojson = 100000
app.post('/newBallon', function(req,res){
try {
const data = req.body;
console.log("data ==============")
console.log(data.id);
args.gmlid = data.id
console.log(data[0]);
console.log(data[1]);
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();
}
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": [ 9.195387, 48.835579 ] } }' +
' ]' +
' }'
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 // name of the file
var filename = 'vcm/config.json'; var filename = 'vcm/configcopy.json';
var contentSync = fs.readFileSync(filename); var contentSync = fs.readFileSync(filename);
console.log('Content of the file : ' + contentSync); console.log('Content of the file : ' + contentSync);
console.log(contentSync.includes('"balloonTypes":')); console.log(contentSync.includes('"balloonTypes":'));
// var newtext = contentSync.replace("balloonTypes","this is a test") var newtext = contentSync.toString().replace('"layers": [','"layers": [' +
'{' +
'"name": "'+ IDGeojson +'",' +
'"url": "./templates/'+IDGeojson+'.geojson",' +
// "balloonTypes": [ '"type": "vcs.vcm.layer.GeoJSON",' +
// {adfafas '"datasourceId": "...",'+
// "template": [ '"activeOnStartup": true,'+
// "<div class='balloon' id='myBalloon'>", '"exclusive": false,' +
// " <h1 class='balloon-title'><%= obj.title %></h1>", '"projection": {' +
// " <div class='balloon-content'>", ' "epsg": "4326",' +
// " <%= obj.description %>", ' "proj4": ""' +
// " </div>", '},' +
// " <div class='balloon-close-col'>", '"altitudeMode": "relativeToGround",' +
// " <button class='close-balloon'><i class='fa fa-times fa-lg'></i></button>", '"style": {' +
// " </div>", ' "image": {' +
// " <div class='dialog-image-balloon'></div>", ' "icon": {' +
// " <div class='balloon-left-edge'></div>", ' "src": "./templates/test.png",' +
// "</div>" ' "scale": 0.5' +
// ], ' }' +
// "minTop": "balloonHeight + 70", ' }' +
// "minLeft": "70", '},' +
// "layerNames": [], '"heightAboveGround": 0' +
// "layerTypes": [ '},')
// "vcs.vcm.layer.Vector" var ballonText = "\"balloonTypes\": [" +
// ] "{" +
// }, "\"template\": [" +
\ No newline at end of file "\"<div class='balloon' onclick='' id='myBalloon'>\"," +
"\" <h1 class='balloon-title'>Test</h1>\"," +
"\" <div class='balloon-content' style='height:290px; margin-right: 0px;'\"," +
"\" </div>\"," +
"\"<p class='balloon-text'><span>Das hier ist ein Test Ballon. Er wurde von einem User erstellt.</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
...@@ -146,6 +146,18 @@ ...@@ -146,6 +146,18 @@
"type": "vcs.vcm.widgets.BalloonInfo", "type": "vcs.vcm.widgets.BalloonInfo",
"name": "Balloon Info", "name": "Balloon Info",
"balloonTypes": [ "balloonTypes": [
{"template": [
"<div class='balloon' onclick='' id='myBalloon'>",
" <h1 class='balloon-title'>Test</h1>",
" <div class='balloon-content' style='height:290px; margin-right: 0px;'",
" </div>","<p class='balloon-text'><span>Das hier ist ein Test Ballon. Er wurde von einem User erstellt.</span><br></p>",
"</div>","<% %>"
],
"minTop": "balloonHeight + 10",
"minLeft": "70",
"layerTypes": [""],
"layerNames": ["100002"]
},
{ {
"template": [ "template": [
"<div class='balloon' id='myBalloon'>", "<div class='balloon' id='myBalloon'>",
...@@ -842,6 +854,21 @@ ...@@ -842,6 +854,21 @@
} }
], ],
"layers": [ "layers": [
{"name": "100002",
"url": "./templates/100002.geojson",
"type": "vcs.vcm.layer.GeoJSON",
"datasourceId": "...",
"activeOnStartup": true,
"exclusive": false,
"projection": { "epsg": "4326", "proj4": ""},"altitudeMode": "relativeToGround",
"style": {
"image": {
"icon": {
"src": "./templates/lightning.png",
"scale": 0.5
}
}},
"heightAboveGround": 0},
{ {
"name": "Böckingerstrasse", "name": "Böckingerstrasse",
"url": "./datasource-data/f02945f6-7978-4abc-940b-4c47af169b12/tileset.json", "url": "./datasource-data/f02945f6-7978-4abc-940b-4c47af169b12/tileset.json",
......
This diff is collapsed.
{
"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": [ 9.193587, 48.835579 ] } }
]
}
{ "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": [ 9.195387, 48.835579 ] } } ] }
\ No newline at end of file
{ "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": [ 9.195387, 48.835579 ] } } ] }
\ No newline at end of file
var ballonContent = {
header: "Test",
Content: "This is a test",
lat: "",
lon: "",
categorie: ""
}
function PostUserInput(){
try {
$.ajax({
async: false,
type: "POST",
url: '/newBallon',
data: ballonContent
}).done(function (SimSMid) {
return(SimSMid)
// convertdata(SimSMid);
});
// function convertdata(SimSMids) {
// SimSOutput = SimSMids;
// }
// // console.log(currentwind);
// return SimSOutput;
}
catch (err) {
console.log('-> function PostUserInput() failed!\n' + err);
}
}
\ No newline at end of file
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