{% load static %}
<!doctype html>

<!--
 Project: EOxClient <https://github.com/EOX-A/EOxClient>
 Authors: Daniel Santillan <daniel.santillan@eox.at>

 Copyright (C) 2014 EOX IT Services GmbH

 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
 in the Software without restriction, including without limitation the rights
 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 copies of the Software, and to permit persons to whom the Software is
 furnished to do so, subject to the following conditions:

 The above copyright notice and this permission notice shall be included in all
 copies of this Software or works derived from this Software.

 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 THE SOFTWARE.
-->
<head>
        <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
        <meta charset="UTF-8">
        <title>EOxServer - Webclient</title>
        <link rel="icon" href="//eox.at/wp-content/uploads/2015/06/cropped-eox_eye-192x192.png" sizes="192x192" />
        <link rel="apple-touch-icon-precomposed" href="//eox.at/wp-content/uploads/2015/06/cropped-eox_eye-180x180.png" />
      </head>
      <body>
        <header id="header" style="width: 100%; height:70px;">
          <h3 style="width:100%;text-align:center;
          color: #006699;">EOxServer - Webclient
          <a href="//eox.at"><img src="//eox.at/wp-content/uploads/2017/09/EOX_Logo.svg" alt="EOX" style="height:25px;margin-left:10px"/></a>
          </h3>
        </header>
        <div id="app" style="width: 100%; top: 60px; bottom: 0; position: absolute; margin: 0; padding:0;"></div>
        <script src="{% static 'prism.js' %}"></script>
        <script>
        var baseUrl = "{{path}}";
        var config = {
          "settings": {
              "rightPanelOpen": true,
              "leftPanelOpen": false,
              "leftPanelTabIndex": 0,
              "tutorial": "once",
              "uploadEnabled": false,
              "downloadEnabled": true,
              "searchEnabled" : true,
              "searchDebounceTime": 500,
              "language": "en",
              "timeDomain": [
                  "{{start_time_full}}",
                  "{{end_time_full}}",
              ],
              "constrainTimeDomain": true,
              "displayTimeDomain": [
                  "{{start_time_full}}",
                  "{{end_time_full}}",
              ],
              "displayInterval": "P1096D",
              "selectedTimeDomain": [
                  "{{start_time}}",
                  "{{end_time}}",
              ],
              "selectableInterval": "P1096D",
              "timeSliderControls": true,
              "maxTooltips": 1,
              //"center": [12, 49],
              //"zoom": 5,
              "extent": [{{ bbox }}],
              "maxZoom": 15,
              "footprintFillColor": "rgba(0, 0, 0, 0.2)",
              "footprintStrokeColor": "rgba(0, 0, 0, 1)",
              "filterFillColor": "rgba(0, 165, 255, 0)",
              "filterStrokeColor": "rgba(0, 165, 255, 1)",
              "filterOutsideColor": "rgba(0, 0, 0, 0.5)",
              "selectedFootprintFillColor": "rgba(255, 0, 0, 0.2)",
              "selectedFootprintStrokeColor": "rgba(255, 0, 0, 1)",
              "highlightFillColor": "rgba(246, 182, 0, 0.5)",
              "highlightStrokeColor": "rgba(246, 182, 0, 1)",
              "highlightStrokeWidth": 3,
              "translations": {
                  "en": {
                      "Cloud Cover": "Cloud coverage (%)",
                      "Error: NoApplicableCode": "Search timed out. Please refine the filter criteria.",
                  }
              },
          },
          "baseLayers": [
              {
                  "id": "terrain-light",
                  "displayName": "EOX Terrain-Light",
                  "display": {
                      "id": "terrain-light",
                      "visible": true,
                      "protocol": "WMTS",
                      "urls": [
                          "//d.s2maps-tiles.eu/wmts/",
                          "//e.s2maps-tiles.eu/wmts/"
                      ],
                      "matrixSet": "WGS84",
                      "format": "image/png",
                      "projection": "EPSG:4326",
                      "style": "default",
                      "attribution": "Terrain-Light { Data &copy; <a href=\"//www.openstreetmap.org/copyright\" target=\"_blank\">OpenStreetMap</a> contributors and <a href='javascript:;' onClick='toggle(terrain_attribution)'>others</a>, Rendering &copy; <a href=\"//eox.at\" target=\"_blank\">EOX</a> }"
                  }
              }, {
                  "id": "terrain",
                  "displayName": "EOX Terrain",
                  "display": {
                      "id": "terrain",
                      "visible": false,
                      "protocol": "WMTS",
                      "urls": [
                          "//d.s2maps-tiles.eu/wmts/",
                          "//e.s2maps-tiles.eu/wmts/"
                      ],
                      "matrixSet": "WGS84",
                      "format": "image/png",
                      "projection": "EPSG:4326",
                      "style": "default",
                      "attribution": "Terrain { Data &copy; <a href=\"//www.openstreetmap.org/copyright\" target=\"_blank\">OpenStreetMap</a> contributors and <a href='javascript:;' onClick='toggle(terrain_attribution)'>others</a>, Rendering &copy; <a href=\"//eox.at\" target=\"_blank\">EOX</a> }"
                  }
              },  {
                  "id": "s2cloudless",
                  "displayName": "EOX Sentinel-2 cloudless",
                  "display": {
                      "id": "s2cloudless-2018",
                      "visible": false,
                      "protocol": "WMTS",
                      "urls": [
                          "//d.s2maps-tiles.eu/wmts/",
                          "//e.s2maps-tiles.eu/wmts/"
                      ],
                      "matrixSet": "WGS84",
                      "format": "image/png",
                      "projection": "EPSG:4326",
                      "style": "default",
                      "attribution": "<a xmlns:dct=\"//purl.org/dc/terms/\" href=\"//s2maps.eu\" property=\"dct:title\">Sentinel-2 cloudless - //s2maps.eu</a> by <a xmlns:cc=\"//creativecommons.org/ns#\" href=\"s://eox.at\" property=\"cc:attributionName\" rel=\"cc:attributionURL\">EOX IT Services GmbH</a> (Contains modified Copernicus Sentinel data 2017 &amp; 2018)"
                  }
              }
          ],
          "layers": [
          {% for layer in layers %}
            {
                  "id": "{{ layer.identifier }}",
                  "displayName": "{% if layer.webclient_extra.display_name %}{{ layer.webclient_extra.display_name }}{% else %}{{ layer.identifier }}{% endif %}",
                  {% if layer.webclient_extra.color %}"displayColor":"{{ layer.webclient_extra.color }}",{% endif %}
                  "display": {
                      "id":  "{{ layer.identifier }}",
                      "visible": {% if layer.webclient_extra.default_visible %}true{% else %}true{% endif %},
                      "protocol": 'WMS',
                      "url": "{% url 'ows' %}",
                      "format": 'image/png',
                      "projection": 'EPSG:4326',
                      "style": '',
                      "useMilliseconds": true,
                      "maxZoom": 15,
                  },
                  "detailsDisplay": {
                      "id": "{{ layer.identifier }}",
                      "visible": {% if layer.webclient_extra.default_visible %}true{% else %}true{% endif %},
                      "protocol": 'WMS',
                      "url": "{% url 'ows' %}",
                      "format": 'image/png',
                      "projection": 'EPSG:4326',
                      "style": '',
                      "useMilliseconds": true,
                      "maxZoom": {% if layer.webclient_extra.max_zoom %}{{layer.webclient_extra.max_zoom}}{% else %}15{% endif %},
                      "options": [{
                        "name": "Style",
                        "target": "detailsDisplay.extraParameters.LAYERS",
                        "values": [
                            {
                                "label": "Default",
                                "value": "{{ layer.identifier }}",
                            },
                            {% for product_type in layer.collection_type.allowed_product_types.all %}
                            {% for browse_type in product_type.browse_types.all %}
                            {
                                "label": "{{ browse_type.name }}",
                                "value": "{{ layer.identifier }}__{{ browse_type.name }}",
                            },
                            {% endfor %}
                            {% endfor %}
                        ]
                    }],
                  },
                  "search": {
                      "protocol": "OpenSearch",
                      "url": "{% url 'opensearch:collection:description' collection_id=layer.identifier %}",
                      "id": "{{ layer.identifier }}",
                      "histogramBinCount": {% if layer.webclient_extra.histogram_bin_count %}{{layer.webclient_extra.histogram_bin_count}}{% else %}28{% endif %},
                      "format": "application/atom+xml",
                      "method": "GET",
                      "histogramThreshold":{% if layer.webclient_extra.histogram_threshold %}{{layer.webclient_extra.histogram_threshold}}{% else %}600{% endif %},
                      "lightweightBuckets": true,
                      "searchLimit": {% if layer.webclient_extra.search_limit %}{{layer.webclient_extra.search_limit}}{% else %}600{% endif %},
                      "loadMore": {% if layer.webclient_extra.load_more %}{{layer.webclient_extra.load_more}}{% else %}600{% endif %},
                      "countZeroRecords": true,
                      "parametersFilterSettings": {
                          "collapsed": false,
                      },
                  }
              }{% if forloop.last %}{% else %},{% endif%}
      {% endfor %}
          ],
          "overlayLayers": [
              {
                  "id": "overlay_base",
                  "displayName": "EOX Borders and Labels",
                  "display": {
                      "id": "overlay_base",
                      "visible": false,
                      "protocol": "WMTS",
                      "urls": [
                          "//d.tiles.maps.eox.at/wmts/",
                          "//e.tiles.maps.eox.at/wmts/"
                      ],
                      "matrixSet": "WGS84",
                      "style": "default",
                      "format": "image/png",
                      "projection": "EPSG:4326",
                      "attribution": "Overlay { Data &copy; <a href=\"//www.openstreetmap.org/copyright\" target=\"_blank\">OpenStreetMap</a> contributors, Rendering &copy; <a href=\"//eox.at\" target=\"_blank\">EOX</a> and <a href=\"//github.com/mapserver/basemaps\" target=\"_blank\">MapServer</a> }"
                  }
              }
          ]
      };

          var app = new Application({
            config: config,
            container: document.getElementById('app'),
          });
          app.start();
        </script>
      </body>