-
Notifications
You must be signed in to change notification settings - Fork 2
/
hike_map.html
322 lines (291 loc) · 14.6 KB
/
hike_map.html
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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="Map Viewer for HIKE Fault Database 2021" content="">
<meta name="Schiegl" content="">
<title>HIKE Fault Database</title>
<meta name="" content="">
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<link rel="stylesheet" href="https://bootswatch.com/4/simplex/bootstrap.min.css">
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css"
integrity="sha512-xodZBNTC5n17Xt2atTPuE1HxjVMSvLVW9ocqUKLsCC5CXdbqCmblAshOMAS6/keqq/sMZMZ19scR4PsZChSR7A=="
crossorigin="" />
<link rel="stylesheet" href="css/FontAwesome/all.min.css" />
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"
integrity="sha512-XQoYMqMTK8LvdxXYG3nZ448hOEQiglfqkJs1NOQV44cWnUrBc8PkAOcXy20w0vlaXaVUearIOBhiXZ5V3ynxwA=="
crossorigin=""></script>
<style>
@charset "utf-8";
#map {
position: absolute;
top: 0;
bottom: 0;
right: 0;
left: 0;
background: white;
outline: 10;
}
#info-pane {
position: absolute;
top: 10px;
right: 10px;
z-index: 400;
padding: 1em;
background: white;
}
.loading {
position: absolute;
top: 50%;
left: 50%;
z-index: 1000;
color: red;
width: 3rem;
height: 3rem;
text-align: center;
vertical-align: middle;
}
.faultLabel {
font-size: 10px;
padding: 0px;
opacity: 1;
}
.leaflet-tooltip {
background-color: rgba(255, 255, 255, .5);
border: 1px;
}
a {
text-decoration: none;
}
.popUpText {
font-size: 80%;
line-height: 100%;
margin-top: -5px;
margin-bottom: 4px;
}
/* .leaflet-tooltip-left:before {
right: 0;
margin-right: -12px;
border-left-color: rgba(0, 0, 0, 0);
}
.leaflet-tooltip-right:before {
left: 0;
margin-left: -12px;
border-right-color: rgba(0, 0, 0, 0);
} */
</style>
</head>
<body>
<div id="map"></div>
<div class="loading">
<span class="spinner-border text-primary" role="status"></span>
</div>
<!-- <div class="loading" id="pc">
</div> -->
<script>
let urlParams = new URLSearchParams(window.location.search);
let USER_LANG = (navigator.language || navigator.language).substring(0, 2);
//console.log(USER_LANG);
let URI = 'https://data.geoscience.earth/ncl/geoera/hike/faults/493';
if (urlParams.has('uri')) {
//USER_LANG = urlParams.get('lang');
URI = decodeURI(urlParams.get('uri').replace(/["';><]/gi, ''));
if (URI.includes('europe-geology')){
URI = URI.replace('voc.europe-geology.eu','data.geoscience.earth/ncl/geoera')
}
console.log(URI);
} else {
}
let map = L.map('map').setView([47, 11], 3);
L.tileLayer.wms('https://ows.mundialis.de/services/service?', {
'layers': 'OSM-WMS',
'opacity': '0.6',
'format': 'image/png',
'attribution': '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap contributors</a>, <a href="https://geoera.eu/projects/hike10/"> GeoERA - HIKE Fault Database</a>'
}).addTo(map);
let queryDownLoad = encodeURIComponent(`PREFIX dcterms:<http://purl.org/dc/terms/>
PREFIX geoera:<https://data.geoscience.earth/ncl/geoera/>
PREFIX skos:<http://www.w3.org/2004/02/skos/core#>
PREFIX geosparql:<http://www.opengis.net/ont/geosparql#>
PREFIX foaf:<http://xmlns.com/foaf/0.1/>
SELECT DISTINCT ?uri (MIN(?L) AS ?label) (MIN(?D) AS ?def) (IF(MIN(BOUND(?cs)),skos:topConceptOf,MIN(?T)) AS ?type)
(COALESCE(GROUP_CONCAT(DISTINCT ?l; separator = ';'),"") as ?links)
WHERE {
VALUES ?c {<${URI}>}
VALUES ?rel {skos:related dcterms:relation geosparql:sfTouches skos:exactMatch skos:closeMatch}
VALUES ?attr {foaf:page foaf:depiction skos:exactMatch skos:closeMatch}
{?c skos:narrower* ?n . BIND(?n AS ?uri) BIND(IF(?n=?c,"", skos:narrower) AS ?T)}
UNION
{?c ?rel ?r . BIND(?r AS ?uri) BIND(?rel AS ?T) FILTER(REGEX(STR(?r),"fault"))}
?uri skos:prefLabel ?Len . filter(lang(?Len)='en')
OPTIONAL {?uri skos:prefLabel ?Lx . filter(lang(?Lx)='${USER_LANG}')} BIND(coalesce(?Lx,?Len,"") as ?L)
OPTIONAL {?uri skos:definition ?Den . filter(lang(?Den)='en')}
OPTIONAL {?uri skos:definition ?Dx . filter(lang(?Dx)='${USER_LANG}')} BIND(coalesce(?Dx,?Den,"") as ?D)
OPTIONAL {?uri ?attr ?l}
OPTIONAL {?uri skos:topConceptOf ?cs}
}
GROUP BY ?uri`);
fetch(`https://resource.geolba.ac.at/PoolParty/sparql/geoera?query=${queryDownLoad}&format=application/json`)
.then(res => res.json())
.then(jsonData => {
let selectedURIs = jsonData.results.bindings.map(a => ({
id: a.uri.value.split('/').pop(),
uri: a.uri.value,
type: a.type.value,
label: a.label.value,
def: a.def.value,
links: a.links.value
}));
//console.log(selectedURIs.length);
//console.log(selectedURIs);
let numbers = jsonData.results.bindings
.map(a => [a.uri.value.split('/').pop(), a.label.value, a.def.value, a.links.value, a.type
.value
]);
//console.log(selectedURIs);
let wfsFeatures = [];
const nql = 40; //network query limit defined by SQL DB proxy => max length "where in"
let st = selectedURIs.map(a => a.id);
let searchIDs = new Array(Math.ceil(st.length / nql))
.fill()
.map(_ => st.splice(0, nql));
let promises = [];
//console.log(searchIDs);
searchIDs.forEach(s_part => {
let orPart = (s_part.length > 1) ? ['<ogc:Or>', '</ogc:Or>'] : ['', ''];
let ogcFilter = `<ogc:Filter>
<ogc:And>
${orPart[0]}
<ogc:PropertyIsEqualTo>
<ogc:PropertyName>ms:concept_id</ogc:PropertyName>
<ogc:Literal>
${s_part.join(`</ogc:Literal>
</ogc:PropertyIsEqualTo>
<ogc:PropertyIsEqualTo>
<ogc:PropertyName>ms:concept_id</ogc:PropertyName>
<ogc:Literal>`)}
</ogc:Literal>
</ogc:PropertyIsEqualTo>
${orPart[1]}
<ogc:Or>
<ogc:PropertyIsGreaterThan>
<ogc:PropertyName>ms:depth</ogc:PropertyName>
<ogc:Literal>-100</ogc:Literal>
</ogc:PropertyIsGreaterThan>
<ogc:PropertyIsNull>
<ogc:PropertyName>ms:depth</ogc:PropertyName>
</ogc:PropertyIsNull>
</ogc:Or>
</ogc:And>
</ogc:Filter>`;
promises.push(
fetch(
(`https://geusegdi01.geus.dk/egdi/wfs/3034/
?SERVICE=WFS
&VERSION=1.0.0
&REQUEST=GetFeature
&TYPENAME=hike_all_faults_layer
&MAXFEATURES=100000
&Filter=${ogcFilter}
&outputformat=geojson`).replace(/\r?\n|\r|\s/g, "")
)
.then(res => res.text())
.then(data => { //console.log(JSON.parse(data.toString()).features);
wfsFeatures = wfsFeatures.concat(JSON.parse(data.toString()).features);
})
.catch(error => {
alert('Error when querying the WFS');
})
);
});
Promise.all(promises).then(() => {
//console.log(wfsFeatures);
try {
let allCoords = wfsFeatures.map(a => a.geometry).filter(a => a.type ==
'MultiLineString').map(a => a.coordinates).flat(2).concat(wfsFeatures.map(
a => a.geometry).filter(a => a.type ==
'LineString').map(a => a.coordinates).flat());
let avg = (arr) => arr.reduce((a, b) => a + b) / arr.length;
map.setView([avg(allCoords.map(a => parseFloat(a[1]))), avg(allCoords.map(a =>
parseFloat(a[0])))], 8);
//console.log(wfsFeatures.map(a => a.properties.local_name));
let showToolTip = true;
let labels = wfsFeatures.map(a => a.properties.local_name);
if ((labels.length - [...new Set(labels)].length) > 20) {
showToolTip = false;
}
for (let i of wfsFeatures) {
let toolTipLabel = i.properties.local_name;
if (toolTipLabel.length > 25) {
toolTipLabel = toolTipLabel.replace(' Fault', '<br>Fault').replace(
' Subfault', '<br>Subfault');
}
let coords = [];
if (i.geometry.type == 'MultiLineString') {
coords = i.geometry.coordinates;
} else {
coords.push(i.geometry.coordinates);
}
let titleSuffix = ``;
let lineStyle = {};
let selConcept = selectedURIs.find(a => a.id == i.properties.concept_id);
switch (selConcept.type) {
case "http://www.opengis.net/ont/geosparql#sfTouches":
lineStyle.color = 'black';
lineStyle.weight = 2;
lineStyle.dashArray = '15, 7';
titleSuffix =
`<h4>a delimitation of ${selectedURIs.find(a => a.type == '').label}</h4>`;
break;
case "http://www.w3.org/2004/02/skos/core#topConceptOf":
lineStyle.color = '#33A3FF';
lineStyle.weight = 3;
break;
default:
lineStyle.color = 'red';
lineStyle.weight = 5;
}
for (let j of coords) {
L.polyline(j.map(a => [a[1], a[0]]), lineStyle).addTo(map)
.bindPopup(`<h2><a href="https://schmar00.github.io/project-vocabularies/?uri=${i.properties.concept_uri}" target="_blank">${selConcept.label}</a></h2>
${titleSuffix}
${(selConcept.def.length>0)?(`<div class="popUpText">${selConcept.def.substr(0,400)+'..'}</div>`):''}
Fault type: <a href="${i.properties.fault_type_uri}" target="_blank">${i.properties.fault_type}</a>
, Time: <a href="${i.properties.timing_uri}" target="_blank">${i.properties.timing}</a><br>
Observation method: <a href="${i.properties.observ_meth_uri}" target="_blank">${i.properties.observ_meth}</a><br>
Dip angle: ${i.properties.dip_angle}
, Dip direction: ${i.properties.dip_direct}
, Strike: ${i.properties.strike}<br>
Movement sense: <a href="${i.properties.move_sense_uri}" target="_blank">${i.properties.move_sense}</a><br>
Offset determination: <a href="${i.properties.offset_det_uri}" target="_blank">${i.properties.offset_det}</a><br>
Reference surface: <a href="${i.properties.ref_surf_uri}" target="_blank">${i.properties.ref_surf}</a><br>
${(selConcept.links.length>0)?
(`see also: <a target="_blank" href="${selConcept.links.split(';').join('"> <i class="fas fa-sm fa-external-link-alt"></i></a><a href="')}"> <i class="fas fa-sm fa-external-link-alt"></i></a>`):
''}`)
.bindTooltip(
toolTipLabel, {
permanent: showToolTip,
className: "faultLabel",
offset: [0, 0]
});
}
}
L.tileLayer.wms('https://egditest01.geus.dk/egdi/wms/', {
'layers': 'hike_faultdb_overview',
'mapname': 'hike_preview',
'transparent': 'true',
'opacity': '0.4',
'format': 'image/png'
}).addTo(map);
let popup = L.popup();
$('.loading').hide();
} catch (e) {
$('.loading').hide();
alert('map data not found');
}
});
});
</script>
</body>
</html>