Changeset 3b7e9f6 for src/webapp/webclient/js
- Timestamp:
- Oct 28, 2018, 4:37:10 PM (8 years ago)
- Branches:
- debian/bullseye, master
- Children:
- 2fa2ef8
- Parents:
- 46eee06
- File:
-
- 1 moved
-
src/webapp/webclient/js/GnuBoat.Webclient.js (moved) (moved from src/webapp/webclient/js/GnuBoat.js ) (38 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/webapp/webclient/js/GnuBoat.Webclient.js
r46eee06 r3b7e9f6 1 1 /* 2 2 3 Copyright (C) 2016 - 201 7EngSaS - Engineering Solutions and Services Langenbach. All rights reserved.3 Copyright (C) 2016 - 2018 EngSaS - Engineering Solutions and Services Langenbach. All rights reserved. 4 4 5 5 This library is free software; you can redistribute it and/or … … 22 22 /** @namespace GnuBoat JavaScript namespace */ 23 23 var GnuBoat = GnuBoat || {}; 24 /** @namespace GnuBoat Webserver JavaScript namespace */ 25 GnuBoat.Webclient = GnuBoat.Webclient || {}; 24 26 25 27 /** 26 28 * @brief Sets the webservice base url, used by any other functions 27 29 */ 28 GnuBoat. setServer = function(baseUrl)30 GnuBoat.Webclient.setServer = function(baseUrl) 29 31 { 30 32 if(baseUrl.slice(-1) != "/") 31 33 baseUrl += "/"; 32 GnuBoat. private.serverBaseUrl = baseUrl;34 GnuBoat.Webclient.private.serverBaseUrl = baseUrl; 33 35 34 36 var link = document.createElement("a"); … … 39 41 40 42 /** 41 * @brief Used to display user messages42 */43 GnuBoat.displayMessage = function(text)44 {45 $("#message").empty();46 $(text).appendTo("#message");47 location.hash = "#messages";48 }49 50 /**51 43 * @brief Fetches the data shown in the display area from the webservice 52 44 */ 53 GnuBoat. displayDataGet = function()54 { 55 if(GnuBoat. private.serverBaseUrl == null){45 GnuBoat.Webclient.displayDataGet = function() 46 { 47 if(GnuBoat.Webclient.private.serverBaseUrl == null){ 56 48 GnuBoat.displayMessage('<span class="error">No server set/found</span>'); 57 49 return; 58 50 } 59 var gnuboatApi = GnuBoat. private.serverBaseUrl;60 $.getJSON(gnuboatApi, GnuBoat. private.displayDataSet);51 var gnuboatApi = GnuBoat.Webclient.private.serverBaseUrl; 52 $.getJSON(gnuboatApi, GnuBoat.Webclient.private.displayDataSet); 61 53 }; 62 54 … … 64 56 * @brief Gets the metadata of all maps, provided by the tileserver 65 57 */ 66 GnuBoat. getMapInfos = function()67 { 68 if(GnuBoat. private.serverBaseUrl == null){58 GnuBoat.Webclient.getMapInfos = function() 59 { 60 if(GnuBoat.Webclient.private.serverBaseUrl == null){ 69 61 GnuBoat.displayMessage('<span class="error">No server set/found</span>'); 70 62 return; 71 63 } 72 $.getJSON(GnuBoat. private.serverBaseUrl +"tileserver.php?/index.json", GnuBoat.private.mapInfos);64 $.getJSON(GnuBoat.Webclient.private.serverBaseUrl +"tileserver.php?/index.json", GnuBoat.Webclient.private.mapInfos); 73 65 }; 74 66 … … 76 68 * @brief Fetches the list of available logfiles and adds them to the log file download form 77 69 */ 78 GnuBoat. logfilesLoad = function()79 { 80 if(GnuBoat. private.serverBaseUrl == null){70 GnuBoat.Webclient.logfilesLoad = function() 71 { 72 if(GnuBoat.Webclient.private.serverBaseUrl == null){ 81 73 GnuBoat.displayMessage('<span class="error">No server set/found</span>'); 82 74 return; 83 75 } 84 76 $("#logfilesForm").empty(); 85 $.getJSON(GnuBoat. private.serverBaseUrl +"?request=logfiles", function(data){86 GnuBoat. private.updateMapModus(data);77 $.getJSON(GnuBoat.Webclient.private.serverBaseUrl +"?request=logfiles", function(data){ 78 GnuBoat.Webclient.private.updateMapModus(data); 87 79 if(!Array.isArray(data) || data.length < 1){ 88 80 $("<p>No Logfiles found!</p>").appendTo("#logfilesForm"); … … 106 98 * @brief Sends a shutdown request to the webservice 107 99 */ 108 GnuBoat. shutdown = function()109 { 110 if(GnuBoat. private.serverBaseUrl == null){100 GnuBoat.Webclient.shutdown = function() 101 { 102 if(GnuBoat.Webclient.private.serverBaseUrl == null){ 111 103 GnuBoat.displayMessage('<span class="error">No server set/found</span>'); 112 104 return; 113 105 } 114 $.getJSON(GnuBoat. private.serverBaseUrl +"?request=shutdown", function(data){106 $.getJSON(GnuBoat.Webclient.private.serverBaseUrl +"?request=shutdown", function(data){ 115 107 var shutdownTime = data["shutdownstart"]; 116 108 var shutdownDate = Date.parse(shutdownTime); … … 127 119 * @brief Uploads a map and refreshes the maps metadata on success 128 120 */ 129 GnuBoat. uploadMap = function(form)130 { 131 if(GnuBoat. private.serverBaseUrl == null){121 GnuBoat.Webclient.uploadMap = function(form) 122 { 123 if(GnuBoat.Webclient.private.serverBaseUrl == null){ 132 124 displayMessage('<span class="error">No server set/found</span>'); 133 125 return; … … 137 129 $.ajax({ 138 130 type: 'POST', 139 url: GnuBoat. private.serverBaseUrl +'?request=map',131 url: GnuBoat.Webclient.private.serverBaseUrl +'?request=map', 140 132 data: new FormData($("#mapTileUpload")[0]), 141 133 contentType: false, … … 151 143 $("#mapTileUploadProgress").hide(); 152 144 $("#mapFileInput").show(); 153 GnuBoat. getMapInfos();145 GnuBoat.Webclient.getMapInfos(); 154 146 }, 155 147 error: function(jqXHR, exception, errorThrown){ … … 166 158 * @brief Setups up GnuBoat to be able to start() after configured a server with setServer(). 167 159 */ 168 GnuBoat. initialize = function()169 { 170 $("#mapModusSelect").change(function(){ GnuBoat. private.mapModusChanged(); });160 GnuBoat.Webclient.initialize = function() 161 { 162 $("#mapModusSelect").change(function(){ GnuBoat.Webclient.private.mapModusChanged(); }); 171 163 $("#mapTileUploadProgress").hide(); 172 $("#logfilesReload").click(GnuBoat. logfilesLoad);173 $("#shutdownButton").click(GnuBoat. shutdown);164 $("#logfilesReload").click(GnuBoat.Webclient.logfilesLoad); 165 $("#shutdownButton").click(GnuBoat.Webclient.shutdown); 174 166 175 167 $("#mapTileUpload").validate({ … … 183 175 }, 184 176 submitHandler: function(form){ 185 GnuBoat. uploadMap(form);177 GnuBoat.Webclient.uploadMap(form); 186 178 } 187 179 }); … … 201 193 var fieldOfView = 75; 202 194 203 GnuBoat. private.renderScene = new THREE.Scene();204 GnuBoat. private.renderScene.background = new THREE.Color(0xEEEEEE);205 206 GnuBoat. private.renderCamera = new THREE.PerspectiveCamera(75, width/height, 0.1, 1000000);207 GnuBoat. private.renderCamera.up = new THREE.Vector3(0, 0, 1);208 GnuBoat. private.renderCamera.position.set(-0.01, -0.01, 15000);209 GnuBoat. private.renderCamera.lookAt(GnuBoat.private.renderScene.position);210 211 GnuBoat. private.renderRenderer = new THREE.WebGLRenderer();212 GnuBoat. private.renderRenderer.setSize(width, height);213 GnuBoat. private.renderRenderer.setPixelRatio( window.devicePixelRatio );214 document.getElementById("rendering").appendChild(GnuBoat. private.renderRenderer.domElement);215 216 GnuBoat. private.renderControls = new THREE.OrbitControls( GnuBoat.private.renderCamera, GnuBoat.private.renderRenderer.domElement );217 GnuBoat. private.renderControls.zoomSpeed = 2;195 GnuBoat.Webclient.private.renderScene = new THREE.Scene(); 196 GnuBoat.Webclient.private.renderScene.background = new THREE.Color(0xEEEEEE); 197 198 GnuBoat.Webclient.private.renderCamera = new THREE.PerspectiveCamera(75, width/height, 0.1, 1000000); 199 GnuBoat.Webclient.private.renderCamera.up = new THREE.Vector3(0, 0, 1); 200 GnuBoat.Webclient.private.renderCamera.position.set(-0.01, -0.01, 15000); 201 GnuBoat.Webclient.private.renderCamera.lookAt(GnuBoat.Webclient.private.renderScene.position); 202 203 GnuBoat.Webclient.private.renderRenderer = new THREE.WebGLRenderer(); 204 GnuBoat.Webclient.private.renderRenderer.setSize(width, height); 205 GnuBoat.Webclient.private.renderRenderer.setPixelRatio( window.devicePixelRatio ); 206 document.getElementById("rendering").appendChild(GnuBoat.Webclient.private.renderRenderer.domElement); 207 208 GnuBoat.Webclient.private.renderControls = new THREE.OrbitControls( GnuBoat.Webclient.private.renderCamera, GnuBoat.Webclient.private.renderRenderer.domElement ); 209 GnuBoat.Webclient.private.renderControls.zoomSpeed = 2; 218 210 } 219 211 … … 223 215 * Call initialize() and setServer() before start() 224 216 */ 225 GnuBoat. start = function()226 { 227 if(GnuBoat. private.serverBaseUrl == null){217 GnuBoat.Webclient.start = function() 218 { 219 if(GnuBoat.Webclient.private.serverBaseUrl == null){ 228 220 GnuBoat.displayMessage('<span class="error">No server set/found</span>'); 229 221 return; 230 222 } 231 223 232 GnuBoat. getMapInfos();233 GnuBoat. displayDataGet();234 if(GnuBoat. private.timerDisplay == null)235 GnuBoat. private.timerDisplay = setInterval(GnuBoat.displayDataGet, 10000);236 GnuBoat. logfilesLoad();237 238 GnuBoat. private.animate();224 GnuBoat.Webclient.getMapInfos(); 225 GnuBoat.Webclient.displayDataGet(); 226 if(GnuBoat.Webclient.private.timerDisplay == null) 227 GnuBoat.Webclient.private.timerDisplay = setInterval(GnuBoat.Webclient.displayDataGet, 10000); 228 GnuBoat.Webclient.logfilesLoad(); 229 230 GnuBoat.Webclient.private.animate(); 239 231 } 240 232 … … 242 234 * @brief Stops querying the webservice 243 235 */ 244 GnuBoat. stop = function()245 { 246 if(GnuBoat. private.timerDisplay != null){247 clearInterval(GnuBoat. private.timerDisplay);248 GnuBoat. private.timerDisplay = null;236 GnuBoat.Webclient.stop = function() 237 { 238 if(GnuBoat.Webclient.private.timerDisplay != null){ 239 clearInterval(GnuBoat.Webclient.private.timerDisplay); 240 GnuBoat.Webclient.private.timerDisplay = null; 249 241 } 250 242 } … … 253 245 * @brief Private methods and properties of GnuBoat 254 246 */ 255 GnuBoat. private = {247 GnuBoat.Webclient.private = { 256 248 map: null, 257 249 mapLayerCurrent: null, … … 303 295 304 296 var keysDisplay = []; 305 for(var key in GnuBoat. private.dataMappings){306 if(GnuBoat. private.dataMappings[key]["display"] === true)297 for(var key in GnuBoat.Webclient.private.dataMappings){ 298 if(GnuBoat.Webclient.private.dataMappings[key]["display"] === true) 307 299 keysDisplay.push(key); 308 300 } … … 330 322 331 323 // map displays logged data 332 if(!GnuBoat. private.mapModusLive)324 if(!GnuBoat.Webclient.private.mapModusLive) 333 325 return; 334 326 else if(!("track" in data)){ … … 336 328 return; 337 329 } 338 GnuBoat. private.mapAddTracks(data["track"]);330 GnuBoat.Webclient.private.mapAddTracks(data["track"]); 339 331 }, 340 332 … … 342 334 { 343 335 var mapMetadataIndex = $("#mapSelect").val(); 344 if(GnuBoat. private.mapsMetadata == null){336 if(GnuBoat.Webclient.private.mapsMetadata == null){ 345 337 console.log("No mapsMetadata set"); 346 338 return; 347 339 } 348 if(mapMetadataIndex < 0 || mapMetadataIndex >= GnuBoat. private.mapsMetadata.length){340 if(mapMetadataIndex < 0 || mapMetadataIndex >= GnuBoat.Webclient.private.mapsMetadata.length){ 349 341 console.log("Map metadata is outside of range :"+ mapMetadataIndex.toString()); 350 342 console.log(mapsMetadata); 351 343 return; 352 344 } 353 var mapMetadata = GnuBoat. private.mapsMetadata[mapMetadataIndex];345 var mapMetadata = GnuBoat.Webclient.private.mapsMetadata[mapMetadataIndex]; 354 346 355 347 var latitudeTop = mapMetadata["bounds"][3]; … … 365 357 var mapZoomStart = (mapZoomMax - mapZoomMin)/2 + mapZoomMin; 366 358 367 GnuBoat. private.mapBounds = new L.LatLngBounds(359 GnuBoat.Webclient.private.mapBounds = new L.LatLngBounds( 368 360 new L.LatLng(latitudeBottom, longitudeLeft), 369 361 new L.LatLng(latitudeTop, longitudeRight)); 370 362 371 if(GnuBoat. private.map == null){363 if(GnuBoat.Webclient.private.map == null){ 372 364 // only initialize the map (viewport) once 373 GnuBoat. private.map = L.map('mapViewport');374 GnuBoat. private.map.on('overlayadd', function(layerObject){ GnuBoat.private.mapOverlayLegendSwitch(layerObject.layer); });375 GnuBoat. private.map.on('overlayremove', function(layerObject){ GnuBoat.private.mapOverlayLegendSwitch(layerObject.layer); });376 } 377 GnuBoat. private.map.setView([latitudeCenter, longitudeCenter], mapZoomStart);378 379 if(GnuBoat. private.mapLayerCurrent != null){380 GnuBoat. private.map.removeLayer(GnuBoat.private.mapLayerCurrent);381 if(GnuBoat. private.mapControl)382 GnuBoat. private.mapControl.removeLayer(GnuBoat.private.mapLayerCurrent);383 GnuBoat. private.mapLayerCurrent = null;384 } 385 GnuBoat. private.mapLayerCurrent = L.tileLayer(mapMetadata["tiles"][0], {365 GnuBoat.Webclient.private.map = L.map('mapViewport'); 366 GnuBoat.Webclient.private.map.on('overlayadd', function(layerObject){ GnuBoat.Webclient.private.mapOverlayLegendSwitch(layerObject.layer); }); 367 GnuBoat.Webclient.private.map.on('overlayremove', function(layerObject){ GnuBoat.Webclient.private.mapOverlayLegendSwitch(layerObject.layer); }); 368 } 369 GnuBoat.Webclient.private.map.setView([latitudeCenter, longitudeCenter], mapZoomStart); 370 371 if(GnuBoat.Webclient.private.mapLayerCurrent != null){ 372 GnuBoat.Webclient.private.map.removeLayer(GnuBoat.Webclient.private.mapLayerCurrent); 373 if(GnuBoat.Webclient.private.mapControl) 374 GnuBoat.Webclient.private.mapControl.removeLayer(GnuBoat.Webclient.private.mapLayerCurrent); 375 GnuBoat.Webclient.private.mapLayerCurrent = null; 376 } 377 GnuBoat.Webclient.private.mapLayerCurrent = L.tileLayer(mapMetadata["tiles"][0], { 386 378 minZoom: mapZoomMin, maxZoom: mapZoomMax, 387 bounds: GnuBoat. private.mapBounds,379 bounds: GnuBoat.Webclient.private.mapBounds, 388 380 attribution: mapMetadata["name"], 389 381 opacity: 0.85 390 }).addTo(GnuBoat. private.map);391 if(GnuBoat. private.mapControl != null)392 GnuBoat. private.mapControl.addBaseLayer(GnuBoat.private.mapLayerCurrent, "Map");382 }).addTo(GnuBoat.Webclient.private.map); 383 if(GnuBoat.Webclient.private.mapControl != null) 384 GnuBoat.Webclient.private.mapControl.addBaseLayer(GnuBoat.Webclient.private.mapLayerCurrent, "Map"); 393 385 else{ 394 GnuBoat. private.mapControl = L.control.layers({"Map": GnuBoat.private.mapLayerCurrent}, GnuBoat.private.mapOverlaysToList(), {hideSingleBase: true, sortLayers: true, }).addTo(GnuBoat.private.map);386 GnuBoat.Webclient.private.mapControl = L.control.layers({"Map": GnuBoat.Webclient.private.mapLayerCurrent}, GnuBoat.Webclient.private.mapOverlaysToList(), {hideSingleBase: true, sortLayers: true, }).addTo(GnuBoat.Webclient.private.map); 395 387 } 396 388 397 389 // configure render scene for new map 398 GnuBoat. private.renderSetupMap();390 GnuBoat.Webclient.private.renderSetupMap(); 399 391 }, 400 392 401 393 mapInfos: function(data) 402 394 { 403 GnuBoat. private.mapsMetadata = data;395 GnuBoat.Webclient.private.mapsMetadata = data; 404 396 405 397 $("#mapSelect").empty(); … … 410 402 }); 411 403 412 GnuBoat. private.mapSetup();413 $("#mapSelect").change(function(){ GnuBoat. private.mapSetup(); });404 GnuBoat.Webclient.private.mapSetup(); 405 $("#mapSelect").change(function(){ GnuBoat.Webclient.private.mapSetup(); }); 414 406 }, 415 407 … … 417 409 { 418 410 var overlays = {}; 419 for(var key in GnuBoat. private.mapPolylines){420 overlays[key] = GnuBoat. private.mapPolylines[key];411 for(var key in GnuBoat.Webclient.private.mapPolylines){ 412 overlays[key] = GnuBoat.Webclient.private.mapPolylines[key]; 421 413 } 422 414 return overlays; … … 425 417 renderSetupMap: function() 426 418 { 427 if(GnuBoat. private.mapBounds == null)419 if(GnuBoat.Webclient.private.mapBounds == null) 428 420 return; 429 421 430 422 // add map bounds 431 if(GnuBoat. private.renderMapBounds != null)432 GnuBoat. private.renderScene.remove(GnuBoat.private.renderMapBounds);433 var m1 = GnuBoat. private.mercator(GnuBoat.private.mapBounds.getSouth(), GnuBoat.private.mapBounds.getWest());434 var m2 = GnuBoat. private.mercator(GnuBoat.private.mapBounds.getSouth(), GnuBoat.private.mapBounds.getEast());435 var m3 = GnuBoat. private.mercator(GnuBoat.private.mapBounds.getNorth(), GnuBoat.private.mapBounds.getEast());436 var m4 = GnuBoat. private.mercator(GnuBoat.private.mapBounds.getNorth(), GnuBoat.private.mapBounds.getWest());423 if(GnuBoat.Webclient.private.renderMapBounds != null) 424 GnuBoat.Webclient.private.renderScene.remove(GnuBoat.Webclient.private.renderMapBounds); 425 var m1 = GnuBoat.Webclient.private.mercator(GnuBoat.Webclient.private.mapBounds.getSouth(), GnuBoat.Webclient.private.mapBounds.getWest()); 426 var m2 = GnuBoat.Webclient.private.mercator(GnuBoat.Webclient.private.mapBounds.getSouth(), GnuBoat.Webclient.private.mapBounds.getEast()); 427 var m3 = GnuBoat.Webclient.private.mercator(GnuBoat.Webclient.private.mapBounds.getNorth(), GnuBoat.Webclient.private.mapBounds.getEast()); 428 var m4 = GnuBoat.Webclient.private.mercator(GnuBoat.Webclient.private.mapBounds.getNorth(), GnuBoat.Webclient.private.mapBounds.getWest()); 437 429 var geometryMapBounds = new THREE.Geometry(); 438 430 var materialMapBounds = new THREE.LineBasicMaterial({color: 0x66BD66, linewidth: 1}); … … 446 438 vertex = new THREE.Vector3(m4.x - m1.x, m4.y - m1.y, 2); 447 439 geometryMapBounds.vertices.push(vertex); 448 GnuBoat. private.renderMapBounds = new THREE.LineLoop(geometryMapBounds, materialMapBounds);449 GnuBoat. private.renderScene.add(GnuBoat.private.renderMapBounds);440 GnuBoat.Webclient.private.renderMapBounds = new THREE.LineLoop(geometryMapBounds, materialMapBounds); 441 GnuBoat.Webclient.private.renderScene.add(GnuBoat.Webclient.private.renderMapBounds); 450 442 451 443 // add 500m grid 452 if(GnuBoat. private.renderGrid != null)453 GnuBoat. private.renderScene.remove(GnuBoat.private.renderGrid);444 if(GnuBoat.Webclient.private.renderGrid != null) 445 GnuBoat.Webclient.private.renderScene.remove(GnuBoat.Webclient.private.renderGrid); 454 446 geometryMapBounds.computeBoundingBox(); 455 447 var maxLength = Math.max(geometryMapBounds.boundingBox.getSize().x, geometryMapBounds.boundingBox.getSize().y); 456 GnuBoat. private.renderGrid = new THREE.GridHelper(maxLength, Math.round(maxLength / 500.0), 0xCCCCCC, 0xCCCCCC);457 GnuBoat. private.renderGrid.geometry.rotateX( Math.PI / 2 );458 GnuBoat. private.renderGrid.translateX(maxLength / 2.0);459 GnuBoat. private.renderGrid.translateY(maxLength / 2.0);460 GnuBoat. private.renderScene.add(GnuBoat.private.renderGrid);448 GnuBoat.Webclient.private.renderGrid = new THREE.GridHelper(maxLength, Math.round(maxLength / 500.0), 0xCCCCCC, 0xCCCCCC); 449 GnuBoat.Webclient.private.renderGrid.geometry.rotateX( Math.PI / 2 ); 450 GnuBoat.Webclient.private.renderGrid.translateX(maxLength / 2.0); 451 GnuBoat.Webclient.private.renderGrid.translateY(maxLength / 2.0); 452 GnuBoat.Webclient.private.renderScene.add(GnuBoat.Webclient.private.renderGrid); 461 453 462 454 var distance = 150; 463 455 var fieldOfView = 2 * Math.atan(maxLength / (2.0 * distance) ) * 180.0 / Math.PI; 464 GnuBoat. private.renderCamera.position.set(-10, -5, 100);465 GnuBoat. private.renderCamera.fov = fieldOfView;466 GnuBoat. private.renderCamera.lookAt(GnuBoat.private.renderScene.position);467 GnuBoat. private.renderCamera.zoom = 5;468 GnuBoat. private.renderCamera.updateProjectionMatrix();456 GnuBoat.Webclient.private.renderCamera.position.set(-10, -5, 100); 457 GnuBoat.Webclient.private.renderCamera.fov = fieldOfView; 458 GnuBoat.Webclient.private.renderCamera.lookAt(GnuBoat.Webclient.private.renderScene.position); 459 GnuBoat.Webclient.private.renderCamera.zoom = 5; 460 GnuBoat.Webclient.private.renderCamera.updateProjectionMatrix(); 469 461 }, 470 462 471 463 drawDensityEstimation: function(densityPoints, gradient, maximum, minimum) 472 464 { 473 var colors = GnuBoat. private.gradientToRenderColors(gradient, maximum, minimum);465 var colors = GnuBoat.Webclient.private.gradientToRenderColors(gradient, maximum, minimum); 474 466 // converting all indizes into numbers to sort them correctly 475 467 // in descending order e.g. 10, 2, 1, 0 and not 2, 10, 1, 0 … … 485 477 var geometry = new THREE.Geometry(); 486 478 var mercatorSouthWest = {x: 0, y: 0}; 487 if(GnuBoat. private.mapBounds != null)488 mercatorSouthWest = GnuBoat. private.mercator(GnuBoat.private.mapBounds.getSouth(), GnuBoat.private.mapBounds.getWest());479 if(GnuBoat.Webclient.private.mapBounds != null) 480 mercatorSouthWest = GnuBoat.Webclient.private.mercator(GnuBoat.Webclient.private.mapBounds.getSouth(), GnuBoat.Webclient.private.mapBounds.getWest()); 489 481 490 482 for(var i = 0; i < densityPoints.length; i++){ 491 var mercator = GnuBoat. private.mercator(densityPoints[i].latitude, densityPoints[i].longitude);483 var mercator = GnuBoat.Webclient.private.mercator(densityPoints[i].latitude, densityPoints[i].longitude); 492 484 var vertex = new THREE.Vector3(mercator.x - mercatorSouthWest.x, mercator.y - mercatorSouthWest.y, (densityPoints[i].depth * -1) + maximum); 493 485 var step = (densityPoints[i].depth - minimum)/(maximum-minimum); … … 505 497 } 506 498 // point cloud 507 if(GnuBoat. private.renderCloud != null)508 GnuBoat. private.renderScene.remove(GnuBoat.private.renderCloud);509 GnuBoat. private.renderCloud = new THREE.Points(geometry, material);510 GnuBoat. private.renderScene.add(GnuBoat.private.renderCloud);499 if(GnuBoat.Webclient.private.renderCloud != null) 500 GnuBoat.Webclient.private.renderScene.remove(GnuBoat.Webclient.private.renderCloud); 501 GnuBoat.Webclient.private.renderCloud = new THREE.Points(geometry, material); 502 GnuBoat.Webclient.private.renderScene.add(GnuBoat.Webclient.private.renderCloud); 511 503 }, 512 504 513 505 animate: function() 514 506 { 515 requestAnimationFrame(GnuBoat. private.animate);516 if(GnuBoat. private.renderCloud != null){507 requestAnimationFrame(GnuBoat.Webclient.private.animate); 508 if(GnuBoat.Webclient.private.renderCloud != null){ 517 509 var scaleZ = $("#renderScaleZ").val(); 518 if(GnuBoat. private.renderCloud.scale.z != scaleZ)519 GnuBoat. private.renderCloud.scale.set(1, 1, scaleZ);520 } 521 522 GnuBoat. private.renderControls.update();523 GnuBoat. private.renderRenderer.render(GnuBoat.private.renderScene, GnuBoat.private.renderCamera);510 if(GnuBoat.Webclient.private.renderCloud.scale.z != scaleZ) 511 GnuBoat.Webclient.private.renderCloud.scale.set(1, 1, scaleZ); 512 } 513 514 GnuBoat.Webclient.private.renderControls.update(); 515 GnuBoat.Webclient.private.renderRenderer.render(GnuBoat.Webclient.private.renderScene, GnuBoat.Webclient.private.renderCamera); 524 516 }, 525 517 … … 572 564 // live modus is automatically activated on displayDataSet 573 565 if(modus == "live"){ 574 GnuBoat. private.mapModusLive = true;566 GnuBoat.Webclient.private.mapModusLive = true; 575 567 return; 576 568 } 577 569 // remove overlays 578 if(GnuBoat. private.mapControl != null){579 for(var key in GnuBoat. private.dataMappings){580 if(GnuBoat. private.dataMappings[key]["map"] === true)581 if(key in GnuBoat. private.mapPolylines){582 GnuBoat. private.mapControl.removeLayer(GnuBoat.private.mapPolylines[key]);583 GnuBoat. private.mapPolylines[key].remove();584 delete GnuBoat. private.mapPolylines[key];570 if(GnuBoat.Webclient.private.mapControl != null){ 571 for(var key in GnuBoat.Webclient.private.dataMappings){ 572 if(GnuBoat.Webclient.private.dataMappings[key]["map"] === true) 573 if(key in GnuBoat.Webclient.private.mapPolylines){ 574 GnuBoat.Webclient.private.mapControl.removeLayer(GnuBoat.Webclient.private.mapPolylines[key]); 575 GnuBoat.Webclient.private.mapPolylines[key].remove(); 576 delete GnuBoat.Webclient.private.mapPolylines[key]; 585 577 } 586 578 } 587 579 } 588 GnuBoat. private.mapModusLive = false;580 GnuBoat.Webclient.private.mapModusLive = false; 589 581 $.post({ 590 url: GnuBoat. private.serverBaseUrl +'?request=replay',582 url: GnuBoat.Webclient.private.serverBaseUrl +'?request=replay', 591 583 data: { logfile: modus }, 592 584 success: function(data){ … … 604 596 return; 605 597 } 606 GnuBoat. private.mapAddTracks(data["track"]);598 GnuBoat.Webclient.private.mapAddTracks(data["track"]); 607 599 } 608 600 }); … … 611 603 mapAddTracks: function(track) 612 604 { 613 if(GnuBoat. private.map == null){605 if(GnuBoat.Webclient.private.map == null){ 614 606 console.log("No map in use"); 615 607 return; … … 623 615 624 616 var keysMap = []; 625 for(var key in GnuBoat. private.dataMappings){626 if(GnuBoat. private.dataMappings[key]["map"] === true)617 for(var key in GnuBoat.Webclient.private.dataMappings){ 618 if(GnuBoat.Webclient.private.dataMappings[key]["map"] === true) 627 619 keysMap.push(key); 628 620 } … … 654 646 var key = keysMap[i]; 655 647 if(points[key].length > 0){ 656 var palette = GnuBoat. private.mapHotlineGradientDefault.palette;657 var paletteLegend = GnuBoat. private.mapHotlineGradientDefault.palette;658 if("gradient" in GnuBoat. private.dataMappings[key]){659 palette = GnuBoat. private.gradientToPalette(GnuBoat.private.dataMappings[key]["gradient"], maximas[key], minimas[key]);648 var palette = GnuBoat.Webclient.private.mapHotlineGradientDefault.palette; 649 var paletteLegend = GnuBoat.Webclient.private.mapHotlineGradientDefault.palette; 650 if("gradient" in GnuBoat.Webclient.private.dataMappings[key]){ 651 palette = GnuBoat.Webclient.private.gradientToPalette(GnuBoat.Webclient.private.dataMappings[key]["gradient"], maximas[key], minimas[key]); 660 652 // use original palette, to use absolute values, if possible 661 paletteLegend = GnuBoat. private.dataMappings[key]["gradient"]["palette"];653 paletteLegend = GnuBoat.Webclient.private.dataMappings[key]["gradient"]["palette"]; 662 654 } 663 655 664 656 var legendTable = $('<table id="'+ key +'" class="hidden"></table>'); 665 $("<tr><th colspan=2>"+ GnuBoat. private.dataMappings[key]["titleShort"] +" in "+ GnuBoat.private.dataMappings[key]["unit"] +"</th></tr>").appendTo(legendTable);657 $("<tr><th colspan=2>"+ GnuBoat.Webclient.private.dataMappings[key]["titleShort"] +" in "+ GnuBoat.Webclient.private.dataMappings[key]["unit"] +"</th></tr>").appendTo(legendTable); 666 658 $("<tr><th>Level</th><th>Color</th></tr>").appendTo(legendTable); 667 659 // converting all indizes into numbers to sort them correctly … … 689 681 legendTable.appendTo("#mapLegend"); 690 682 691 if(key in GnuBoat. private.mapPolylines){692 GnuBoat. private.mapPolylines[key].setStyle(hotlineOptions);693 GnuBoat. private.mapPolylines[key].setLatLngs(points[key]);694 if(GnuBoat. private.map.hasLayer(GnuBoat.private.mapPolylines[key]))695 GnuBoat. private.mapOverlayLegendSwitch(GnuBoat.private.mapPolylines[key]);696 GnuBoat. private.mapPolylines[key].unbindPopup();683 if(key in GnuBoat.Webclient.private.mapPolylines){ 684 GnuBoat.Webclient.private.mapPolylines[key].setStyle(hotlineOptions); 685 GnuBoat.Webclient.private.mapPolylines[key].setLatLngs(points[key]); 686 if(GnuBoat.Webclient.private.map.hasLayer(GnuBoat.Webclient.private.mapPolylines[key])) 687 GnuBoat.Webclient.private.mapOverlayLegendSwitch(GnuBoat.Webclient.private.mapPolylines[key]); 688 GnuBoat.Webclient.private.mapPolylines[key].unbindPopup(); 697 689 } 698 690 else{ 699 GnuBoat. private.mapPolylines[key] = L.hotline(points[key], hotlineOptions);700 if(GnuBoat. private.mapControl){701 var name = GnuBoat. private.dataMappings[key]["titleLong"] +" in "+ GnuBoat.private.dataMappings[key]["unit"] +" ("+ GnuBoat.private.dataMappings[key]["titleShort"] +")";702 GnuBoat. private.mapControl.addOverlay(GnuBoat.private.mapPolylines[key], name);691 GnuBoat.Webclient.private.mapPolylines[key] = L.hotline(points[key], hotlineOptions); 692 if(GnuBoat.Webclient.private.mapControl){ 693 var name = GnuBoat.Webclient.private.dataMappings[key]["titleLong"] +" in "+ GnuBoat.Webclient.private.dataMappings[key]["unit"] +" ("+ GnuBoat.Webclient.private.dataMappings[key]["titleShort"] +")"; 694 GnuBoat.Webclient.private.mapControl.addOverlay(GnuBoat.Webclient.private.mapPolylines[key], name); 703 695 } 704 if(GnuBoat. private.dataMappings[key]["mapActive"] === true)705 GnuBoat. private.mapPolylines[key].addTo(GnuBoat.private.map);706 } 707 GnuBoat. private.mapPolylines[key].bindPopup(legendTable[0].outerHTML);708 } 709 } 710 var gradient = GnuBoat. private.mapHotlineGradientDefault.palette;711 if("gradient" in GnuBoat. private.dataMappings["waterdepth"])712 gradient = GnuBoat. private.dataMappings["waterdepth"]["gradient"];713 GnuBoat. private.drawDensityEstimation(densityPoints, gradient, maximas["waterdepth"], minimas["waterdepth"]);696 if(GnuBoat.Webclient.private.dataMappings[key]["mapActive"] === true) 697 GnuBoat.Webclient.private.mapPolylines[key].addTo(GnuBoat.Webclient.private.map); 698 } 699 GnuBoat.Webclient.private.mapPolylines[key].bindPopup(legendTable[0].outerHTML); 700 } 701 } 702 var gradient = GnuBoat.Webclient.private.mapHotlineGradientDefault.palette; 703 if("gradient" in GnuBoat.Webclient.private.dataMappings["waterdepth"]) 704 gradient = GnuBoat.Webclient.private.dataMappings["waterdepth"]["gradient"]; 705 GnuBoat.Webclient.private.drawDensityEstimation(densityPoints, gradient, maximas["waterdepth"], minimas["waterdepth"]); 714 706 }, 715 707 … … 717 709 { 718 710 if(!("palette" in gradient)){ 719 return GnuBoat. private.mapHotlineGradientDefault.palette;711 return GnuBoat.Webclient.private.mapHotlineGradientDefault.palette; 720 712 } 721 713 if(!("absolute" in gradient) || !gradient.absolute){ … … 726 718 if(range == 0){ 727 719 console.log("Range is zero --> Could not make gradient relative"); 728 return GnuBoat. private.mapHotlineGradientDefault.palette;720 return GnuBoat.Webclient.private.mapHotlineGradientDefault.palette; 729 721 } 730 722 var palette = {}; … … 751 743 } 752 744 if(!addedStop) 753 return GnuBoat. private.mapHotlineGradientDefault.palette;745 return GnuBoat.Webclient.private.mapHotlineGradientDefault.palette; 754 746 return palette; 755 747 }, … … 757 749 gradientToRenderColors: function(gradient, maximum, minimum) 758 750 { 759 var paletteRelative = GnuBoat. private.gradientToPalette(gradient, maximum, minimum);751 var paletteRelative = GnuBoat.Webclient.private.gradientToPalette(gradient, maximum, minimum); 760 752 761 753 var colors = {}; … … 769 761 { 770 762 var overlayKey = null; 771 for(var key in GnuBoat. private.mapPolylines){772 if(GnuBoat. private.mapPolylines.hasOwnProperty(key)){773 if(GnuBoat. private.mapPolylines[key] === layer){763 for(var key in GnuBoat.Webclient.private.mapPolylines){ 764 if(GnuBoat.Webclient.private.mapPolylines.hasOwnProperty(key)){ 765 if(GnuBoat.Webclient.private.mapPolylines[key] === layer){ 774 766 overlayKey = key; 775 767 break; … … 778 770 } 779 771 // ECMAScript 6 780 // var overlayKey = Object.keys(GnuBoat. private.mapPolylines).find(key => GnuBoat.private.mapPolylines[key] === overlay);772 // var overlayKey = Object.keys(GnuBoat.Webclient.private.mapPolylines).find(key => GnuBoat.Webclient.private.mapPolylines[key] === overlay); 781 773 if(overlayKey == null) 782 774 return;
Note:
See TracChangeset
for help on using the changeset viewer.
