Changeset 3b7e9f6 for src/webapp


Ignore:
Timestamp:
Oct 28, 2018, 4:37:10 PM (8 years ago)
Author:
Joachim Langenbach <joachim.langenbach@…>
Branches:
debian/bullseye, master
Children:
2fa2ef8
Parents:
46eee06
Message:
  • Removed not needed styles from GnuBoatColors.css
  • Added subnamespace GnuBoat.Webclient in javascripts
  • Moved common methods into GnuBoat.js (like displayMessage())
  • side-menu.css: Menu is hidden by default (independend from display resolution
Location:
src/webapp
Files:
1 added
3 edited
2 moved

Legend:

Unmodified
Added
Removed
  • src/webapp/build.xml

    r46eee06 r3b7e9f6  
    77        </fileset>
    88        <fileset dir="./common/css/" id="filesCommonCss">
     9        </fileset>
     10        <fileset dir="./common/js/" id="filesCommonJs">
    911        </fileset>
    1012        <fileset dir="../icon/" id="filesGnuboatIcons">
    … …  
    2729                <copy todir="${builddir}/webclient/resources">
    2830                        <fileset refid="filesGnuboatIcons"/>
    29                 </copy>
    30                
    31                 <copy todir="${builddir}/webclient/resources">
    3231                        <fileset refid="filesCommonResources"/>
    3332                </copy>
    3433                <copy todir="${builddir}/webclient/css">
    3534                        <fileset refid="filesCommonCss"/>
     35                </copy>
     36                <copy todir="${builddir}/webclient/js">
     37                        <fileset refid="filesCommonJs"/>
    3638                </copy>
    3739        </target>
  • src/webapp/common/css/GnuBoatColors.css

    r46eee06 r3b7e9f6  
    3333        --gnuboat-warning: var(--gnuboat-red);
    3434}
    35 
    36 .backgroundblue {
    37         background-color: var(--gnuboat-primary-middle);
    38         background-image: linear-gradient(var(--gnuboat-primary-light), var(--gnuboat-primary-middle));
    39 }
    40 
    41 .backgroundgreen {
    42         background-color: var(--gnuboat-secondary-middle);
    43         background-image: linear-gradient(var(--gnuboat-secondary-light), var(--gnuboat-secondary-middle));
    44 }
    45 
    46 .l-box {
    47         padding: 1em;
    48 }
    49 
    50 .header h1 img {
    51         height: 2em;
    52         width: auto;
    53 }
    54 
    55 #display {
    56         background-color: var(--gnuboat-primary-light);
    57         height: 9em;
    58         min-width: 14em;
    59         font-size: 12pt;
    60         font-weight: normal;
    61         padding: 0mm;
    62         position:relative;
    63         line-height: 1.5em;
    64         color: black;
    65 }
    66 
    67 #display h2 {
    68         font-size: 12pt;
    69         font-weight: normal;
    70         margin: 0em;
    71         padding: 0em;
    72 }
    73 
    74 #display span {
    75         font-size: 24pt;
    76         font-weight: bold;
    77         margin: 0em;
    78         padding: 0em;
    79 }
    80 
    81 #display #speedthroughwater {
    82         position: absolute;
    83         top: 0.5em;
    84         left: 0.5em;
    85 }
    86 
    87 #display .important {
    88         font-size: 40pt;
    89         line-height: 0.6em;
    90 }
    91 
    92 #display #speedoverground {
    93         position: absolute;
    94         top:  0.5em;
    95         left: 7em;
    96 }
    97 
    98 #display #waterdepth {
    99         position: absolute;
    100         top: 5em;
    101         left: 0.5em;
    102 }
    103 
    104 #display #watertemperature {
    105         position: absolute;
    106         top: 5em;
    107         left: 7em;
    108 }
    109 
    110 #display #gpsfix {
    111         position: absolute;
    112         top: 5em;
    113         left: 11em;
    114 }
    115 
    116 .viewportGeometry {
    117 /*      width: 100%; */
    118         height: 24em;
    119 }
    120 
    121 #mapViewport {
    122         border: 1px solid #347C7C;
    123         margin-top: 1em;
    124 }
    125 
    126 .shutdown-button {
    127         background-color: #8C1C00;
    128         color: white;
    129         font-weight: bold;
    130         height: 3em;
    131         width: 100%;
    132         margin-top: 3em;
    133 }
    134 
    135 #message .error {
    136         font-weight: bold;
    137         color: #8C1C00;
    138 }
    139 
    140 #message .info {
    141         font-weight: bold;
    142         color: #45A545;
    143 }
    144 
    145 .logfiles-reload-button, .logfiles-reload-button:hover, .logfiles-reload-button:active, .logfiles-reload-button:focus {
    146         float: right;
    147         background:url('../resources/view-refresh.svg') no-repeat left center;
    148 }
    149 
    150 .hidden {
    151         display: none;
    152 }
    153 
    154 #mapLgend table {
    155         margin-top: 0.25em;
    156         margin-left: 1em;
    157 }
    158 
    159 #mapLegend table tr td.level {
    160         text-align: right;
    161 }
  • src/webapp/common/css/side-menu.css

    r46eee06 r3b7e9f6  
    227227Hides the menu at `48em`, but modify this based on your app's needs.
    228228*/
    229 @media (min-width: 48em) {
     229@media (min-width: 99999em) {
    230230
    231231    .header,
    … …  
    254254}
    255255
    256 @media (max-width: 48em) {
     256@media (max-width: 99999em) {
    257257    /* Only apply this when the window is small. Otherwise, the following
    258258    case results in extra padding on the left:
  • src/webapp/webclient/index.html

    r46eee06 r3b7e9f6  
    4343                <link rel="stylesheet" href="css/side-menu.css" type="text/css"/>
    4444                <script language="javascript" src="js/GnuBoat.js" type="text/javascript"></script>
     45                <script language="javascript" src="js/GnuBoat.Webclient.js" type="text/javascript"></script>
    4546                <script language="javascript" type="text/javascript">
    4647                        var active = 'active';
    … …  
    7273                                });
    7374
    74                                 GnuBoat.initialize();
    75                                 GnuBoat.setServer("../webservice");
    76                                 GnuBoat.start();
     75                                GnuBoat.Webclient.initialize();
     76                                GnuBoat.Webclient.setServer("../webservice");
     77                                GnuBoat.Webclient.start();
    7778                        });
    7879                </script>
  • src/webapp/webclient/js/GnuBoat.Webclient.js

    r46eee06 r3b7e9f6  
    11/*
    22
    3     Copyright (C) 2016 - 2017 EngSaS - Engineering Solutions and Services Langenbach. All rights reserved.
     3    Copyright (C) 2016 - 2018 EngSaS - Engineering Solutions and Services Langenbach. All rights reserved.
    44
    55    This library is free software; you can redistribute it and/or
    … …  
    2222/** @namespace GnuBoat JavaScript namespace */
    2323var GnuBoat = GnuBoat || {};
     24/** @namespace GnuBoat Webserver JavaScript namespace */
     25GnuBoat.Webclient = GnuBoat.Webclient || {};
    2426
    2527/**
    2628 * @brief Sets the webservice base url, used by any other functions
    2729 */
    28 GnuBoat.setServer = function(baseUrl)
     30GnuBoat.Webclient.setServer = function(baseUrl)
    2931{
    3032        if(baseUrl.slice(-1) != "/")
    3133                baseUrl += "/";
    32         GnuBoat.private.serverBaseUrl = baseUrl;
     34        GnuBoat.Webclient.private.serverBaseUrl = baseUrl;
    3335       
    3436        var link = document.createElement("a");
    … …  
    3941
    4042/**
    41  * @brief Used to display user messages
    42  */
    43 GnuBoat.displayMessage = function(text)
    44 {
    45         $("#message").empty();
    46         $(text).appendTo("#message");
    47         location.hash = "#messages";
    48 }
    49 
    50 /**
    5143 * @brief Fetches the data shown in the display area from the webservice
    5244 */
    53 GnuBoat.displayDataGet = function()
    54 {
    55         if(GnuBoat.private.serverBaseUrl == null){
     45GnuBoat.Webclient.displayDataGet = function()
     46{
     47        if(GnuBoat.Webclient.private.serverBaseUrl == null){
    5648                GnuBoat.displayMessage('<span class="error">No server set/found</span>');
    5749                return;
    5850        }
    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);
    6153};
    6254
    … …  
    6456 * @brief Gets the metadata of all maps, provided by the tileserver
    6557 */
    66 GnuBoat.getMapInfos = function()
    67 {
    68         if(GnuBoat.private.serverBaseUrl == null){
     58GnuBoat.Webclient.getMapInfos = function()
     59{
     60        if(GnuBoat.Webclient.private.serverBaseUrl == null){
    6961                GnuBoat.displayMessage('<span class="error">No server set/found</span>');
    7062                return;
    7163        }
    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);
    7365};
    7466
    … …  
    7668 * @brief Fetches the list of available logfiles and adds them to the log file download form
    7769 */
    78 GnuBoat.logfilesLoad = function()
    79 {
    80         if(GnuBoat.private.serverBaseUrl == null){
     70GnuBoat.Webclient.logfilesLoad = function()
     71{
     72        if(GnuBoat.Webclient.private.serverBaseUrl == null){
    8173                GnuBoat.displayMessage('<span class="error">No server set/found</span>');
    8274                return;
    8375        }
    8476        $("#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);
    8779                if(!Array.isArray(data) || data.length < 1){
    8880                        $("<p>No Logfiles found!</p>").appendTo("#logfilesForm");
    … …  
    10698 * @brief Sends a shutdown request to the webservice
    10799 */
    108 GnuBoat.shutdown = function()
    109 {
    110         if(GnuBoat.private.serverBaseUrl == null){
     100GnuBoat.Webclient.shutdown = function()
     101{
     102        if(GnuBoat.Webclient.private.serverBaseUrl == null){
    111103                GnuBoat.displayMessage('<span class="error">No server set/found</span>');
    112104                return;
    113105        }
    114         $.getJSON(GnuBoat.private.serverBaseUrl +"?request=shutdown", function(data){
     106        $.getJSON(GnuBoat.Webclient.private.serverBaseUrl +"?request=shutdown", function(data){
    115107                var shutdownTime = data["shutdownstart"];
    116108                var shutdownDate = Date.parse(shutdownTime);
    … …  
    127119 * @brief Uploads a map and refreshes the maps metadata on success
    128120 */
    129 GnuBoat.uploadMap = function(form)
    130 {
    131         if(GnuBoat.private.serverBaseUrl == null){
     121GnuBoat.Webclient.uploadMap = function(form)
     122{
     123        if(GnuBoat.Webclient.private.serverBaseUrl == null){
    132124                displayMessage('<span class="error">No server set/found</span>');
    133125                return;
    … …  
    137129        $.ajax({
    138130                type: 'POST',
    139                 url: GnuBoat.private.serverBaseUrl +'?request=map',
     131                url: GnuBoat.Webclient.private.serverBaseUrl +'?request=map',
    140132                data: new FormData($("#mapTileUpload")[0]),
    141133                contentType: false,
    … …  
    151143                        $("#mapTileUploadProgress").hide();
    152144                        $("#mapFileInput").show();
    153                         GnuBoat.getMapInfos();
     145                        GnuBoat.Webclient.getMapInfos();
    154146                },
    155147                error: function(jqXHR, exception, errorThrown){
    … …  
    166158 * @brief Setups up GnuBoat to be able to start() after configured a server with setServer().
    167159 */
    168 GnuBoat.initialize = function()
    169 {
    170         $("#mapModusSelect").change(function(){ GnuBoat.private.mapModusChanged(); });
     160GnuBoat.Webclient.initialize = function()
     161{
     162        $("#mapModusSelect").change(function(){ GnuBoat.Webclient.private.mapModusChanged(); });
    171163        $("#mapTileUploadProgress").hide();
    172         $("#logfilesReload").click(GnuBoat.logfilesLoad);
    173         $("#shutdownButton").click(GnuBoat.shutdown);
     164        $("#logfilesReload").click(GnuBoat.Webclient.logfilesLoad);
     165        $("#shutdownButton").click(GnuBoat.Webclient.shutdown);
    174166
    175167        $("#mapTileUpload").validate({
    … …  
    183175                },
    184176                submitHandler: function(form){
    185                         GnuBoat.uploadMap(form);
     177                        GnuBoat.Webclient.uploadMap(form);
    186178                }
    187179        });
    … …  
    201193        var fieldOfView = 75;
    202194       
    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;
    218210}
    219211
    … …  
    223215 * Call initialize() and setServer() before start()
    224216 */
    225 GnuBoat.start = function()
    226 {
    227         if(GnuBoat.private.serverBaseUrl == null){
     217GnuBoat.Webclient.start = function()
     218{
     219        if(GnuBoat.Webclient.private.serverBaseUrl == null){
    228220                GnuBoat.displayMessage('<span class="error">No server set/found</span>');
    229221                return;
    230222        }
    231223       
    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();
    239231}
    240232
    … …  
    242234 * @brief Stops querying the webservice
    243235 */
    244 GnuBoat.stop = function()
    245 {
    246         if(GnuBoat.private.timerDisplay != null){
    247                 clearInterval(GnuBoat.private.timerDisplay);
    248                 GnuBoat.private.timerDisplay = null;
     236GnuBoat.Webclient.stop = function()
     237{
     238        if(GnuBoat.Webclient.private.timerDisplay != null){
     239                clearInterval(GnuBoat.Webclient.private.timerDisplay);
     240                GnuBoat.Webclient.private.timerDisplay = null;
    249241        }
    250242}
    … …  
    253245 * @brief Private methods and properties of GnuBoat
    254246 */
    255 GnuBoat.private = {
     247GnuBoat.Webclient.private = {
    256248        map: null,
    257249        mapLayerCurrent: null,
    … …  
    303295
    304296                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)
    307299                                keysDisplay.push(key);
    308300                }
    … …  
    330322               
    331323                // map displays logged data
    332                 if(!GnuBoat.private.mapModusLive)
     324                if(!GnuBoat.Webclient.private.mapModusLive)
    333325                        return;
    334326                else if(!("track" in data)){
    … …  
    336328                        return;
    337329                }
    338                 GnuBoat.private.mapAddTracks(data["track"]);
     330                GnuBoat.Webclient.private.mapAddTracks(data["track"]);
    339331        },
    340332       
    … …  
    342334        {
    343335                var mapMetadataIndex = $("#mapSelect").val();
    344                 if(GnuBoat.private.mapsMetadata == null){
     336                if(GnuBoat.Webclient.private.mapsMetadata == null){
    345337                        console.log("No mapsMetadata set");
    346338                        return;
    347339                }
    348                 if(mapMetadataIndex < 0 || mapMetadataIndex >= GnuBoat.private.mapsMetadata.length){
     340                if(mapMetadataIndex < 0 || mapMetadataIndex >= GnuBoat.Webclient.private.mapsMetadata.length){
    349341                        console.log("Map metadata is outside of range :"+ mapMetadataIndex.toString());
    350342                        console.log(mapsMetadata);
    351343                        return;
    352344                }
    353                 var mapMetadata = GnuBoat.private.mapsMetadata[mapMetadataIndex];
     345                var mapMetadata = GnuBoat.Webclient.private.mapsMetadata[mapMetadataIndex];
    354346               
    355347                var latitudeTop = mapMetadata["bounds"][3];
    … …  
    365357                var mapZoomStart = (mapZoomMax - mapZoomMin)/2 + mapZoomMin;
    366358               
    367                 GnuBoat.private.mapBounds = new L.LatLngBounds(
     359                GnuBoat.Webclient.private.mapBounds = new L.LatLngBounds(
    368360                                new L.LatLng(latitudeBottom, longitudeLeft),
    369361                                new L.LatLng(latitudeTop, longitudeRight));
    370362               
    371                 if(GnuBoat.private.map == null){
     363                if(GnuBoat.Webclient.private.map == null){
    372364                        // 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], {
    386378                        minZoom: mapZoomMin, maxZoom: mapZoomMax,
    387                         bounds: GnuBoat.private.mapBounds,
     379                        bounds: GnuBoat.Webclient.private.mapBounds,
    388380                        attribution: mapMetadata["name"],
    389381                        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");
    393385                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);
    395387                }
    396388               
    397389                // configure render scene for new map
    398                 GnuBoat.private.renderSetupMap();
     390                GnuBoat.Webclient.private.renderSetupMap();
    399391        },
    400392       
    401393        mapInfos: function(data)
    402394        {
    403                 GnuBoat.private.mapsMetadata = data;
     395                GnuBoat.Webclient.private.mapsMetadata = data;
    404396               
    405397                $("#mapSelect").empty();
    … …  
    410402                });
    411403               
    412                 GnuBoat.private.mapSetup();
    413                 $("#mapSelect").change(function(){ GnuBoat.private.mapSetup(); });
     404                GnuBoat.Webclient.private.mapSetup();
     405                $("#mapSelect").change(function(){ GnuBoat.Webclient.private.mapSetup(); });
    414406        },
    415407       
    … …  
    417409        {
    418410                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];
    421413                }
    422414                return overlays;
    … …  
    425417        renderSetupMap: function()
    426418        {
    427                 if(GnuBoat.private.mapBounds == null)
     419                if(GnuBoat.Webclient.private.mapBounds == null)
    428420                        return;
    429421
    430422                // 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());
    437429                var geometryMapBounds = new THREE.Geometry();
    438430                var materialMapBounds = new THREE.LineBasicMaterial({color: 0x66BD66, linewidth: 1});
    … …  
    446438                vertex = new THREE.Vector3(m4.x - m1.x, m4.y - m1.y, 2);
    447439                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);
    450442
    451443                // 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);
    454446                geometryMapBounds.computeBoundingBox();
    455447                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);
    461453               
    462454                var distance = 150;
    463455                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();
    469461        },
    470462       
    471463        drawDensityEstimation: function(densityPoints, gradient, maximum, minimum)
    472464        {
    473                 var colors = GnuBoat.private.gradientToRenderColors(gradient, maximum, minimum);
     465                var colors = GnuBoat.Webclient.private.gradientToRenderColors(gradient, maximum, minimum);
    474466                // converting all indizes into numbers to sort them correctly
    475467                // in descending order e.g. 10, 2, 1, 0 and not 2, 10, 1, 0
    … …  
    485477                var geometry = new THREE.Geometry();
    486478                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());
    489481               
    490482                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);
    492484                        var vertex = new THREE.Vector3(mercator.x - mercatorSouthWest.x, mercator.y - mercatorSouthWest.y, (densityPoints[i].depth * -1) + maximum);
    493485                        var step = (densityPoints[i].depth - minimum)/(maximum-minimum);
    … …  
    505497                }
    506498                // 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);
    511503        },
    512504       
    513505        animate: function()
    514506        {
    515                 requestAnimationFrame(GnuBoat.private.animate);
    516                 if(GnuBoat.private.renderCloud != null){
     507                requestAnimationFrame(GnuBoat.Webclient.private.animate);
     508                if(GnuBoat.Webclient.private.renderCloud != null){
    517509                        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);
    524516        },
    525517       
    … …  
    572564                // live modus is automatically activated on displayDataSet
    573565                if(modus == "live"){
    574                         GnuBoat.private.mapModusLive = true;
     566                        GnuBoat.Webclient.private.mapModusLive = true;
    575567                        return;
    576568                }
    577569                // 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];
    585577                                        }
    586578                        }
    587579                }
    588                 GnuBoat.private.mapModusLive = false;
     580                GnuBoat.Webclient.private.mapModusLive = false;
    589581                $.post({
    590                         url: GnuBoat.private.serverBaseUrl +'?request=replay',
     582                        url: GnuBoat.Webclient.private.serverBaseUrl +'?request=replay',
    591583                        data: { logfile: modus },
    592584                        success: function(data){
    … …  
    604596                                        return;
    605597                                }
    606                                 GnuBoat.private.mapAddTracks(data["track"]);
     598                                GnuBoat.Webclient.private.mapAddTracks(data["track"]);
    607599                        }
    608600                });
    … …  
    611603        mapAddTracks: function(track)
    612604        {
    613                 if(GnuBoat.private.map == null){
     605                if(GnuBoat.Webclient.private.map == null){
    614606                        console.log("No map in use");
    615607                        return;
    … …  
    623615               
    624616                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)
    627619                                keysMap.push(key);
    628620                }
    … …  
    654646                        var key = keysMap[i];
    655647                        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]);
    660652                                        // 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"];
    662654                                }
    663655                               
    664656                                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);
    666658                                $("<tr><th>Level</th><th>Color</th></tr>").appendTo(legendTable);
    667659                                // converting all indizes into numbers to sort them correctly
    … …  
    689681                                legendTable.appendTo("#mapLegend");
    690682                       
    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();
    697689                                }
    698690                                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);
    703695                                        }
    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"]);
    714706        },
    715707       
    … …  
    717709        {
    718710                if(!("palette" in gradient)){
    719                         return GnuBoat.private.mapHotlineGradientDefault.palette;
     711                        return GnuBoat.Webclient.private.mapHotlineGradientDefault.palette;
    720712                }
    721713                if(!("absolute" in gradient) || !gradient.absolute){
    … …  
    726718                if(range == 0){
    727719                        console.log("Range is zero --> Could not make gradient relative");
    728                         return  GnuBoat.private.mapHotlineGradientDefault.palette;
     720                        return  GnuBoat.Webclient.private.mapHotlineGradientDefault.palette;
    729721                }
    730722                var palette = {};
    … …  
    751743                }
    752744                if(!addedStop)
    753                         return GnuBoat.private.mapHotlineGradientDefault.palette;
     745                        return GnuBoat.Webclient.private.mapHotlineGradientDefault.palette;
    754746                return palette;
    755747        },
    … …  
    757749        gradientToRenderColors: function(gradient, maximum, minimum)
    758750        {
    759                 var paletteRelative = GnuBoat.private.gradientToPalette(gradient, maximum, minimum);
     751                var paletteRelative = GnuBoat.Webclient.private.gradientToPalette(gradient, maximum, minimum);
    760752
    761753                var colors = {};
    … …  
    769761        {
    770762                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){
    774766                                        overlayKey = key;
    775767                                        break;
    … …  
    778770                }
    779771                // 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);
    781773                if(overlayKey == null)
    782774                        return;
Note: See TracChangeset for help on using the changeset viewer.