forked from geopython/pygeoapi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcollection.html
More file actions
334 lines (300 loc) · 11.4 KB
/
Copy pathcollection.html
File metadata and controls
334 lines (300 loc) · 11.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
{% extends "_base.html" %}
{% block title %}{{ super() }} {{ data['title'] }} {% endblock %}
{% block desc %}{{ data.get('description','') | truncate(250) }}{% endblock %}
{% block tags %}{{ data.get('keywords',[]) | join(',') }}{% endblock %}
{% block crumbs %}{{ super() }}
/ <a href="{{ data['collections_path'] }}">{% trans %}Collections{% endtrans %}</a>
/ <a href="./{{ data['id'] }}">{{ data['title'] | truncate( 25 ) }}</a>
{% endblock %}
{% block extrahead %}
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.3.1/dist/leaflet.css"/>
<script src="https://unpkg.com/leaflet@1.3.1/dist/leaflet.js"></script>
<script src="https://unpkg.com/leaflet-imageoverlay-ogcapi@0.1.0/Leaflet.ImageOverlay.OGCAPI.js"></script>
<script src="{{ config['server']['url'] }}/static/js/default.js"></script>
{% endblock %}
{% block body %}
<section id="collection">
<div class="row">
<div class="col-sm">
<h1>{{ data['title'] }}</h1>
<p>{{ data['description'] }}</p>
<p>
{% for kw in data['keywords'] %}
<span class="badge text-bg-primary bg-primary">{{ kw }}</span>
{% endfor %}
</p>
</div>
</div>
<div class="row">
<div class="col-sm-12 mb-2">
<div id="collection-map"></div>
</div>
</div>
{% set ns = namespace(header_printed=false) %}
{% for link in data['links'] %}
{% if link['rel'] == 'license' %}
{% if not ns.header_printed %}
<h3>{% trans %}License{% endtrans %}</h3>
{% set ns.header_printed = true %}
{% endif %}
<ul>
<li>
<div>
<a title="{{ link['title'] }}" href="{{ link['href'] }}">{{ link['title'] or link['href'] }}<a>
</li>
</ul>
{% endif %}
{% endfor %}
{% if data['itemType'] == 'feature' or data['itemType'] == 'record' %}
<h3>{% trans %}Browse{% endtrans %}</h3>
<ul>
<li>
<div>
<a title="{% trans %}Browse Items{% endtrans %}" href="{{ data['collections_path'] }}/{{ data['id'] }}/items">
{% trans %}Browse through the items of{% endtrans %} "{{ data['title'] }}"</a></div>
</li>
</ul>
<h3>{% trans %}Queryables{% endtrans %}</h3>
<ul>
<li>
<div>
<a title="{% trans %}Display Queryables{% endtrans %}" href="{{ data['collections_path'] }}/{{ data['id'] }}/queryables">
{% trans %}Display Queryables of{% endtrans %} "{{ data['title'] }}"</a></div>
</li>
</ul>
<h3>{% trans %}Schema{% endtrans %}</h3>
<ul>
<li>
<div>
<a title="{% trans %}Display Schema{% endtrans %}" href="{{ data['collections_path'] }}/{{ data['id'] }}/schema">
{% trans %}Display Schema of{% endtrans %} "{{ data['title'] }}"</a></div>
</li>
</ul>
{% endif %}
{% for provider in config['resources'][data['id']]['providers'] %}
{% if 'tile' in provider['type'] %}
<h3>{% trans %}Tiles{% endtrans %}</h3>
<ul>
<li>
<div>
<a title="{% trans %}Display Tiles{% endtrans %}" href="{{ data['collections_path'] }}/{{ data['id'] }}/tiles">{% trans %}Display Tiles of{% endtrans %} "{{ data['title'] }}"</a>
</div>
</li>
</ul>
{% endif %}
{% if 'coverage' in provider['type'] %}
<h3>{% trans %}Coverage{% endtrans %}</h3>
<ul>
<li>
<div>
<a title="{% trans %}Display Coverage{% endtrans %}" href="{{ data['collections_path'] }}/{{ data['id'] }}/coverage">
{% trans %}Display Coverage of{% endtrans %} "{{ data['title'] }}"</a></div>
</li>
</ul>
<h3>{% trans %}Schema{% endtrans %}</h3>
<ul>
<li>
<div>
<a title="{% trans %}Display Schema{% endtrans %}" href="{{ data['collections_path'] }}/{{ data['id'] }}/schema">
{% trans %}Display Schema of{% endtrans %} "{{ data['title'] }}"</a></div>
</li>
</ul>
{% endif %}
{% endfor %}
{%- if data['data_queries'] -%}
<h3>Data Queries</h3>
<table class="table table-striped table-bordered">
<tr>
<th>Query Name</th>
<th>Query Location</th>
</tr>
{% for query_name, query in data['data_queries'].items() %}
<tr>
<td>{{ query_name }}</td>
<td><a title="{{ query_name }}" href="{{ query['link']['href'] }}">{{ query['link']['href'] }}</a></td>
</tr>
{% endfor %}
<caption><em>Note: EDR Queries may require query parameters not provided in the Query Location.</em></caption>
</table>
{%- endif -%}
{% if 'parameter_names' in data %}
<h3>Parameters</h3>
<table class="table table-striped table-bordered">
<tr>
<th>id</th>
<th>name</th>
<th>units</th>
</tr>
{% for parameter in data['parameter_names'].values() %}
<tr>
<td>{{ parameter['id'] }}</td>
<td>{{ parameter['observedProperty']['label'].values()|first }}{% if parameter['observedProperty']['description'] %}<br/><i>{{ parameter['observedProperty']['description'].values()|first }}</i>{% endif %}</td>
<td>{{ parameter['unit']['symbol']['value'] }}</td>
</tr>
{% endfor %}
</table>
{% endif %}
<h3>{% trans %}Links{% endtrans %}</h3>
<ul>
{% for link in data['links'] %}
<li>
<a title="{{ link['rel'] }}" href="{{ link['href'] }}">
<span>{{ link['title'] }}</span> (<span>{{ link['type'] }}</span>)
</a></li>
{% endfor %}
</ul>
{% if data['itemType'] == 'feature' %}
<h3>{% trans %}Reference Systems{% endtrans %}</h3>
<ul>
{% for crs in data['crs'] %}
<li>
<a title="{{ crs }}" href="{{ crs }}"><span>{{ crs }}</span></a>
</li>
{% endfor %}
</ul>
<h3>{% trans %}Storage CRS{% endtrans %}</h3>
<ul>
<li>
{% trans %}CRS{% endtrans %}: <a title="{{ data['storageCrs'] }}" href="{{ data['storageCrs'] }}"><span>{{ data['storageCrs'] }}</span></a>
</li>
<li>
{% trans %}Epoch{% endtrans %}: <a><span>{{ data['storageCrsCoordinateEpoch'] or '_(not specified)' }}</span></a>
</li>
</ul>
{% endif %}
</section>
{% endblock %}
{% block extrafoot %}
<script>
var map = L.map('collection-map').setView([{{ 0 }}, {{ 0 }}], 1);
map.addLayer(new L.TileLayer(
'{{ config['server']['map']['url'] }}', {
maxZoom: 18,
attribution: '{{ config['server']['map']['attribution'] | safe }}'
}
));
var bbox = gen_safe_bbox({{ data['extent']['spatial']['bbox'][0] }});
var bbox_layer = L.polygon([
[bbox[1], bbox[0]],
[bbox[3], bbox[0]],
[bbox[3], bbox[2]],
[bbox[1], bbox[2]]
]);
var lbounds = bbox_layer.getBounds();
// Make sure that we pass valid coordinates to the imageOverlay
function clampLat(lat) {
return Math.max(-85.0511, Math.min(lat, 85.0511));
}
var sw = lbounds.getSouthWest();
var ne = lbounds.getNorthEast();
var clampedSw = L.latLng(clampLat(sw.lat), sw.lng);
var clampedNe = L.latLng(clampLat(ne.lat), ne.lng);
var clampedBounds = L.latLngBounds(clampedSw, clampedNe);
var ogcapi_layer = null;
var image_overlay = null;
{# if this collection has a map representation, add it to the map #}
{% for link in data['links'] %}
{% if link['rel'] == 'http://www.opengis.net/def/rel/ogc/1.0/map' and link['href'] %}
ogcapi_layer = L.imageOverlay.ogcapi("{{ data['base_url'] }}", {
collection: "{{ data['id'] }}",
"opacity": .7,
"transparent": true,
"bounds": clampedBounds
});
image_layer = L.imageOverlay("{{ link['href'] }}", clampedBounds, {opacity: 0.7, transparent: true});
bbox_layer.setStyle({
fillOpacity: 0
});
bbox_layer.setStyle({
fillOpacity: 0
});
{% endif %}
{% endfor %}
// Check bounds and toggle the visibility of the imageOverlay, accordingly
function toggleOverlayVisibility() {
if (ogcapi_layer) {
var currentBounds = map.getBounds();
var west = currentBounds.getWest();
var east = currentBounds.getEast();
var centerLng = map.getCenter().lng;
var viewWidth = east - west;
var isWithinBounds = (viewWidth <= 360) && (centerLng >= -180 && centerLng <= 180);
if (isWithinBounds) {
if (!map.hasLayer(ogcapi_layer)) {
map.addLayer(ogcapi_layer);
}
map.removeLayer(image_layer);
} else {
if (map.hasLayer(ogcapi_layer)) {
map.removeLayer(ogcapi_layer);
}
map.addLayer(image_layer);
}
}
}
map.on('moveend', toggleOverlayVisibility);
map.addLayer(bbox_layer);
map.fitBounds(clampedBounds, {maxZoom: 10});
// Run the initial visibility check
toggleOverlayVisibility();
// Allow to get bbox query parameter of a rectangular area specified by
// dragging the mouse while pressing the Ctrl key
var firstCorner;
var secondCorner;
var currentBoundingBox;
var boundingBox;
var drawingBoundingBox = false;
map.on('mousedown', setFirstCorner);
map.on('mouseup', setSecondCorner);
map.on('mousemove', drawCurrentBoundingBox);
map.on('click', boundingBoxInfo);
function boundingBoxInfo(e) {
if (map.hasLayer(boundingBox)) {
var bboxCoords = boundingBox.getBounds().toBBoxString();
L.popup({maxWidth:"auto"})
.setLatLng(boundingBox.getBounds().getCenter())
.setContent(`bbox=${bboxCoords}`)
.addTo(map);
}
}
function setFirstCorner(e) {
if (e.originalEvent.ctrlKey) {
if (map.hasLayer(boundingBox)) {
map.removeLayer(boundingBox);
}
map.dragging.disable();
firstCorner = e.latlng;
drawingBoundingBox = true;
} else if (map.hasLayer(boundingBox) && !boundingBox.getBounds().contains(e.latlng)) {
map.removeLayer(boundingBox);
}
}
function setSecondCorner(e) {
if (map.hasLayer(currentBoundingBox)) {
map.removeLayer(currentBoundingBox);
}
if (e.originalEvent.ctrlKey) {
if (drawingBoundingBox) {
drawingBoundingBox = false;
secondCorner = e.latlng;
var bounds = [firstCorner, secondCorner];
boundingBox = L.rectangle(bounds, {color:"#ff7800", weight:1});
boundingBox.addTo(map);
}
}
drawingBoundingBox = false;
map.dragging.enable();
}
function drawCurrentBoundingBox(e) {
if (drawingBoundingBox) {
if (map.hasLayer(currentBoundingBox)) {
map.removeLayer(currentBoundingBox);
}
secondCorner = e.latlng;
var bounds = [firstCorner, secondCorner];
currentBoundingBox = L.rectangle(bounds, {dashArray:"4 1", weight:0.4});
currentBoundingBox.addTo(map);
}
}
</script>
{% endblock %}