-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathogc.js
executable file
·637 lines (591 loc) · 22.7 KB
/
ogc.js
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
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
var ogc = (function () {
$.findNS = function (o, nodeName) {
return o.children().filter(function () {
if (this.nodeName) return this.nodeName.toUpperCase() == nodeName.toUpperCase();
else return false;
});
};
var _cswEmptyGetRecordQuery =
'<?xml version="1.0" encoding="UTF-8"?>\
<csw:GetRecords xmlns:csw="http://www.opengis.net/cat/csw/2.0.2" service="CSW" version="2.0.2" {resultType}>\
<csw:Query typeNames="{typeNames}">\
<csw:ElementSetName>full</csw:ElementSetName>\
<csw:Constraint version="1.1.0">\
<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">\
<ogc:Or>\
<ogc:PropertyIsLike wildCard="*" singleChar="." escapeChar="!">\
<ogc:PropertyName>Type</ogc:PropertyName>\
<ogc:Literal>dataset</ogc:Literal>\
</ogc:PropertyIsLike>\
<ogc:PropertyIsLike wildCard="*" singleChar="." escapeChar="!">\
<ogc:PropertyName>Type</ogc:PropertyName>\
<ogc:Literal>series</ogc:Literal>\
</ogc:PropertyIsLike>\
</ogc:Or>\
</ogc:Filter>\
</csw:Constraint>\
</csw:Query>\
</csw:GetRecords>';
var _cswGetRecordQueryTemplate =
'<?xml version="1.0" encoding="UTF-8"?>\
<csw:GetRecords xmlns:csw="http://www.opengis.net/cat/csw/2.0.2" service="CSW" version="2.0.2" {resultType}>\
<csw:Query typeNames="{typeNames}">\
<csw:ElementSetName>full</csw:ElementSetName>\
<csw:Constraint version="1.1.0">\
<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">\
<ogc:And>\
<ogc:Or>\
<ogc:PropertyIsLike wildCard="*" singleChar="." escapeChar="!">\
<ogc:PropertyName>Type</ogc:PropertyName>\
<ogc:Literal>dataset</ogc:Literal>\
</ogc:PropertyIsLike>\
<ogc:PropertyIsLike wildCard="*" singleChar="." escapeChar="!">\
<ogc:PropertyName>Type</ogc:PropertyName>\
<ogc:Literal>series</ogc:Literal>\
</ogc:PropertyIsLike>\
</ogc:Or>\
<ogc:Or>\
<ogc:PropertyIsEqualTo matchCase="true">\
<ogc:PropertyName>Title</ogc:PropertyName>\
<ogc:Literal>{query}</ogc:Literal>\
</ogc:PropertyIsEqualTo>\
<ogc:PropertyIsEqualTo matchCase="true">\
<ogc:PropertyName>AlternateTitle</ogc:PropertyName>\
<ogc:Literal>{query}</ogc:Literal>\
</ogc:PropertyIsEqualTo>\
<ogc:PropertyIsEqualTo matchCase="true">\
<ogc:PropertyName>Identifier</ogc:PropertyName>\
<ogc:Literal>{query}</ogc:Literal>\
</ogc:PropertyIsEqualTo>\
<ogc:PropertyIsEqualTo matchCase="true">\
<ogc:PropertyName>ResourceIdentifier</ogc:PropertyName>\
<ogc:Literal>{query}</ogc:Literal>\
</ogc:PropertyIsEqualTo>\
<ogc:PropertyIsLike matchCase="false" wildCard="*" singleChar="." escapeChar="!">\
<ogc:PropertyName>Title</ogc:PropertyName>\
<ogc:Literal>*{query}*</ogc:Literal>\
</ogc:PropertyIsLike>\
<ogc:PropertyIsLike matchCase="false" wildCard="*" singleChar="." escapeChar="!">\
<ogc:PropertyName>AlternateTitle</ogc:PropertyName>\
<ogc:Literal>*{query}*</ogc:Literal>\
</ogc:PropertyIsLike>\
<ogc:PropertyIsLike matchCase="false" wildCard="*" singleChar="." escapeChar="!">\
<ogc:PropertyName>Abstract</ogc:PropertyName>\
<ogc:Literal>*{query}*</ogc:Literal>\
</ogc:PropertyIsLike>\
<ogc:PropertyIsLike matchCase="false" wildCard="*" singleChar="." escapeChar="!">\
<ogc:PropertyName>Subject</ogc:PropertyName>\
<ogc:Literal>*{query}*</ogc:Literal>\
</ogc:PropertyIsLike>\
<ogc:PropertyIsLike matchCase="false" wildCard="*" singleChar="." escapeChar="!">\
<ogc:PropertyName>OrganisationName</ogc:PropertyName>\
<ogc:Literal>*{query}*</ogc:Literal>\
</ogc:PropertyIsLike>\
</ogc:Or>\
</ogc:And>\
</ogc:Filter>\
</csw:Constraint>\
<ogc:SortBy xmlns:ogc="http://www.opengis.net/ogc">\
<ogc:SortProperty>\
<ogc:PropertyName>Relevance</ogc:PropertyName>\
<ogc:SortOrder>DESC</ogc:SortOrder>\
</ogc:SortProperty>\
</ogc:SortBy>\
</csw:Query>\
</csw:GetRecords>';
var _cswFilter = function (query, typeNames) {
var _resultType =
'resultType="results_with_summary" startPosition="1" maxRecords="30" xmlns:gmd="http://www.isotc211.org/2005/gmd"';
var _typeNames = "csw:Record";
if ((typeNames = "gmd:MD_Metadata")) {
_resultType =
'resultType="results" outputSchema="csw:IsoRecord" startPosition="1" maxRecords="30"';
_typeNames = "gmd:MD_Metadata";
}
if (query) {
return _cswGetRecordQueryTemplate
.replace(/{resultType}/g, _resultType)
.replace(/{query}/g, query)
.replace(/{typeNames}/g, _typeNames);
} else {
return _cswEmptyGetRecordQuery
.replace(/{resultType}/g, _resultType)
.replace(/{typeNames}/g, _typeNames);
}
};
var _cswParse = function (xml, cswUrl, metadataUrl, typeNames) {
var results = [];
if (typeNames === "gmd:MD_Metadata") {
$.each($(xml).find("gmd\\:MD_Metadata, MD_Metadata"), function (index, metadata) {
var layer = {};
layer.identifier = $(metadata)
.find("gmd\\:fileIdentifier, fileIdentifier")
.find("gco\\:CharacterString, CharacterString")
.text();
layer.abstract = $(metadata)
.find("gmd\\:identificationInfo, identificationInfo")
.find("gmd\\:MD_DataIdentification, MD_DataIdentification")
.find("gmd\\:abstract, abstract")
.find("gco\\:CharacterString, CharacterString")
.text();
layer.attribution = $(metadata)
.find("gmd\\:identificationInfo, identificationInfo")
.find("gmd\\:MD_DataIdentification, MD_DataIdentification")
.find("gmd\\:pointOfContact, pointOfContact")
.find("gmd\\:CI_ResponsibleParty, CI_ResponsibleParty")
.find("gmd\\:organisationName, organisationName")
.find("gco\\:CharacterString, CharacterString")
.text();
layer.image = $(metadata)
.find("gmd\\:identificationInfo, identificationInfo")
.find("gmd\\:MD_DataIdentification, MD_DataIdentification")
.find("gmd\\:graphicOverview, graphicOverview")
.find("gmd\\:fileName, fileName")
.find("gco\\:CharacterString, CharacterString")
.text();
layer.wms = $(metadata)
.find("gmd\\:protocol, protocol")
.find("gco\\:CharacterString, CharacterString")
.filter(function (index, el) {
return $(el).text().search("OGC:WMS") >= 0;
})
.parent()
.parent()
.find("gmd\\:URL, URL")
.text()
.split("?")[0];
layer.wfs = $(metadata)
.find("gmd\\:protocol, protocol")
.find("gco\\:CharacterString, CharacterString")
.filter(function (index, el) {
return $(el).text().search("OGC:WFS") >= 0;
})
.parent()
.parent()
.find("gmd\\:URL, URL")
.text()
.split("?")[0];
layer.layerid = $(metadata)
.find("gmd\\:protocol, protocol")
.find("gco\\:CharacterString, CharacterString")
.filter(function (index, el) {
return $(el).text().search("OGC:WMS") >= 0;
})
.parent()
.parent()
.find("gmd\\:name, name")
.find("gco\\:CharacterString, CharacterString")
.text();
layer.title = $(metadata)
.find("gmd\\:identificationInfo, identificationInfo")
.find("gmd\\:MD_DataIdentification, MD_DataIdentification")
.find("gmd\\:citation, citation")
.find("gmd\\:CI_Citation, CI_Citation")
.find("gmd\\:title, title")
.find("gco\\:CharacterString, CharacterString")
.text();
if (metadataUrl) {
layer.metadata = metadataUrl + layer.identifier;
}
var getRecordByIdParams =
"SERVICE=CSW&VERSION=2.0.2&REQUEST=GetRecordById&ELEMENTSETNAME=full&ID&ID=" +
layer.identifier;
var getRecordByIdUrl = cswUrl.replace(/[?&]$/, "");
getRecordByIdUrl =
getRecordByIdUrl.indexOf("?") === -1
? getRecordByIdUrl + "?" + getRecordByIdParams
: getRecordByIdUrl + "&" + getRecordByIdParams;
layer["metadata-csw"] = getRecordByIdUrl;
if (layer.layerid != "" && layer.wms != "") {
results.push(layer);
} else {
console.log("incomplete metadata document: " + layer.identifier);
}
});
} else {
$.each($(xml).find("Record"), function (index, metadata) {
var layer = {};
layer.identifier = $(metadata).find("identifier").text();
layer.image = $(metadata).find('[protocol="image/png"]').text();
layer.abstract = $(metadata).find("abstract").text();
layer.wms = $(metadata).find('[protocol="OGC:WMS"]').text().split("?")[0];
layer.wfs = $(metadata).find('[protocol="OGC:WFS"]').text().split("?")[0];
layer.layerid = $(metadata).find('[protocol="OGC:WMS"]').attr("name");
layer.title = $(metadata).find("title").first().text();
layer.attribution = "Attributions";
if (metadataUrl) {
layer.metadata = metadataUrl + layer.identifier;
}
var getRecordByIdParams =
"SERVICE=CSW&VERSION=2.0.2&REQUEST=GetRecordById&ELEMENTSETNAME=full&ID&ID=" +
layer.identifier;
var getRecordByIdUrl = cswUrl.replace(/[?&]$/, "");
getRecordByIdUrl =
getRecordByIdUrl.indexOf("?") === -1
? getRecordByIdUrl + "?" + getRecordByIdParams
: getRecordByIdUrl + "&" + getRecordByIdParams;
layer["metadata-csw"] = getRecordByIdUrl;
results.push(layer);
});
}
mv.showCSWResults(results);
};
var _cswAjax = function (url, body, metadataUrl, typeNames) {
$.ajax({
type: "POST",
url: mv.ajaxURL(url),
crossDomain: true,
data: body,
dataType: "xml",
contentType: "application/xml",
success: function (data) {
_cswParse(data, url, metadataUrl, typeNames);
},
error: function (xhr, ajaxOptions, thrownError) {
console.error("CSW request failed", {
url: url,
body: body,
xhr: xhr,
ajaxOptions: ajaxOptions,
thrownError: thrownError,
});
alert("Echec de la requête CSW :\n" + url);
},
});
};
var _wmsCapabilitiesParse = function (data, layerid) {
var layer = $(data)
.find("Layer Layer Name")
.filter(function (index, name) {
return $(name).text() === layerid;
})
.parent();
var styles = layer.find("Style");
var crs = layer.find("CRS").first().text();
config.temp.layers[layerid].projection = crs;
var lst = [];
styles.each(function (index, style) {
lst.push({
name: $(style).find("Name").text(),
src: $(style).find("OnlineResource").attr("xlink:href"),
});
});
mv.showStyles(lst, layerid);
};
var _wmsParse = function (xml, keyword) {
var results = {};
var parentLayerId = undefined;
var parentExtTitle = undefined;
// Parse one Layer item and its Layer subitems
function parseLayer(index, l) {
var layer = {};
var previousParentLayerId = parentLayerId;
var previousParentExtTitle = parentExtTitle;
var metadataUrlItemHtml;
var metadataUrlItemXml;
layer.abstract = $(l).find("Abstract").text();
layer.wms = _getWmsUrlFromGetCapabilitiesUrl(
$(xml)
.find("Capability>Request>GetCapabilities>DCPType>HTTP>Get>OnlineResource")
.attr("xlink:href")
);
layer.layerid = $(l).find(">Name").text();
layer.parentLayerId = parentLayerId;
layer.title = $(l).find(">Title").text();
layer.bbox = $(l).find(">BoundingBox");
if (parentLayerId) {
layer.extTitle = parentExtTitle + " > " + layer.title;
} else {
layer.extTitle = layer.title;
}
layer.attribution = $(l).find("Attribution Title").text();
// Get url of human readable metadata document
metadataUrlItemHtml = $(l)
.find("MetadataURL Format")
.filter(function () {
return $(this).html() == "text/html";
})
.parent()
.first();
layer["metadata"] = metadataUrlItemHtml.find("OnlineResource").attr("xlink:href");
// Get url of raw metadata document
metadataUrlItemXml = $(l)
.find("MetadataURL Format")
.filter(function () {
return $.inArray($(this).html(), ["text/xml", "text/plain"]) > -1;
})
.parent()
.first();
layer["metadata-csw"] = metadataUrlItemXml
.find("OnlineResource")
.attr("xlink:href");
// Filter layers with regard to the provided keyword
if (keyword) {
if (
layer.title.toLowerCase().search(keyword.toLowerCase()) >= 0 ||
layer.abstract.toLowerCase().search(keyword.toLowerCase()) >= 0
) {
results[layer.layerid] = layer;
}
} else {
results[layer.layerid] = layer;
}
// Parse sublayers
if ($(l).find(">Layer").length > 0) {
parentLayerId = layer.layerid;
parentExtTitle = layer.extTitle;
$(l).find(">Layer").each(parseLayer);
}
// Reset parent layer id to the previous value
parentLayerId = previousParentLayerId;
parentExtTitle = previousParentExtTitle;
}
// Search the first level Layer item(s) (there should be only one)
$(xml).find("Capability>Layer").each(parseLayer);
mv.showWMSResults(results);
};
var _getWmsUrlFromGetCapabilitiesUrl = function (getCapabilitiesUrl) {
var urlParts = decodeURI(getCapabilitiesUrl)
.replace(":80", "")
.split("#")[0]
.split("?");
if (urlParts.length == 2) {
var secondPart = urlParts[1];
urlParts.pop();
urlParts = urlParts.concat(secondPart.split("&"));
var wmsUrlParts = [];
urlParts.forEach(function (part) {
if (
!(part == "::") &&
!part.toLowerCase().startsWith("getcapabilities=") &&
!part.toLowerCase().startsWith("service=") &&
!part.toLowerCase().startsWith("version=")
) {
wmsUrlParts.push(part);
}
});
var wmsUrl = wmsUrlParts[0] + "?" + wmsUrlParts.slice(1).join("&");
return encodeURI(wmsUrl);
} else {
return encodeURI(urlParts[0]);
}
};
var _wmsAjax = function (url, keyword) {
var getCapabilitiesParams = "REQUEST=GetCapabilities&SERVICE=WMS&Version=1.3.0";
var getCapabilitiesUrl = url.replace(/[?&]$/, "");
getCapabilitiesUrl =
getCapabilitiesUrl.indexOf("?") === -1
? getCapabilitiesUrl + "?" + getCapabilitiesParams
: getCapabilitiesUrl + "&" + getCapabilitiesParams;
$.ajax({
type: "GET",
url: mv.ajaxURL(getCapabilitiesUrl),
crossDomain: true,
dataType: "xml",
contentType: "application/xml",
success: function (data) {
_wmsParse(data, keyword);
},
error: function (xhr, ajaxOptions, thrownError) {
console.error("WMS GetCapabilities request failed", {
url: getCapabilitiesUrl,
xhr: xhr,
ajaxOptions: ajaxOptions,
thrownError: thrownError,
});
alert("Echec de la requête WMS GetCapabilities :\n" + getCapabilitiesUrl);
},
});
};
var _DescribeFeatureTypeParse = function (data, typeName, layerid, url) {
var fields = [];
var layer = { wfs_url: url, fields: {} };
$(data)
.find("xsd\\:sequence, sequence")
.find("xsd\\:element, element")
.each(function (id, fld) {
var _type;
var xml_type = $(fld).attr("type");
if (xml_type.search("gml") != -1) {
_type = "geometry";
layer.geometry = $(fld).attr("name");
} else if (xml_type.search("string") != -1) {
_type = "string";
fields.push($(fld).attr("name"));
layer.fields[$(fld).attr("name")] = { type: _type };
} else {
_type = "number";
fields.push($(fld).attr("name"));
layer.fields[$(fld).attr("name")] = { type: _type };
}
if (!config.temp.layers[layerid]) {
config.temp.layers[layerid] = layer;
} else {
config.temp.layers[layerid] = { ...layer, ...config.temp.layers[layerid] };
}
});
return fields;
};
var _getFields = function (url, typeName, layerid) {
var descFeatTypeParams =
"SERVICE=WFS&VERSION=1.1.0&REQUEST=DescribeFeatureType&TYPENAME=" + typeName;
var descFeatTypeUrl = url.replace(/[?&]$/, "");
descFeatTypeUrl =
descFeatTypeUrl.indexOf("?") === -1
? descFeatTypeUrl + "?" + descFeatTypeParams
: descFeatTypeUrl + "&" + descFeatTypeParams;
return fetch(mv.ajaxURL(descFeatTypeUrl), {
mode: "cors",
headers: {
"Content-Type": "application/xml",
},
})
.then((response) => response.text())
.then((data) => {
return _DescribeFeatureTypeParse(data, typeName, layerid, url);
})
.then((fields) => {
mv.showFields(fields, layerid);
});
};
var _getStyles = function (url, layerid) {
var getCapabilitiesParams = "REQUEST=GetCapabilities&SERVICE=WMS&Version=1.3.0";
var getCapabilitiesUrl = url.replace(/[?&]$/, "");
getCapabilitiesUrl =
getCapabilitiesUrl.indexOf("?") === -1
? getCapabilitiesUrl + "?" + getCapabilitiesParams
: getCapabilitiesUrl + "&" + getCapabilitiesParams;
$.ajax({
type: "GET",
url: mv.ajaxURL(getCapabilitiesUrl),
crossDomain: true,
dataType: "xml",
contentType: "application/xml",
success: function (data) {
_wmsCapabilitiesParse(data, layerid);
},
error: function (xhr, ajaxOptions, thrownError) {
console.error("WMS GetCapabilities request failed", {
url: getCapabilitiesUrl,
xhr: xhr,
ajaxOptions: ajaxOptions,
thrownError: thrownError,
});
alert("Echec de la requête WMS GetCapabilities :\n" + getCapabilitiesUrl);
},
});
};
var _describeLayerParse = function (xml, layerid) {
return {
wfs_url: $(xml).find("LayerDescription").attr("wfs").split("?")[0],
typeName: $(xml).find("LayerDescription Query").attr("typeName"),
};
};
var _getWFSUrl = function (wmsUrl, layerid) {
var descLayerParams =
"SERVICE=WMS&VERSION=1.1.1&REQUEST=DescribeLayer&LAYERS=" + layerid;
var descLayerUrl = wmsUrl.replace(/[?&]$/, "");
descLayerUrl =
descLayerUrl.indexOf("?") === -1
? descLayerUrl + "?" + descLayerParams
: descLayerUrl + "&" + descLayerParams;
return fetch(mv.ajaxURL(descLayerUrl), {
mode: "cors",
headers: {
"Content-Type": "application/xml",
},
})
.then((response) => response.text())
.then((data) => {
return {
data: data,
describeLayer: _describeLayerParse(data, layerid),
};
});
};
return {
getDictinctValues: function (data, propertyName, option) {
var distinctValues = [];
var testValues = {};
$.each(data.features, function (id, feature) {
var value = feature.properties[propertyName];
if (!testValues[value]) {
distinctValues.push(value);
testValues[value] = true;
}
});
mv.showDistinctValues(distinctValues, option);
},
/*setLayerFinderMode: function (options) {
_mode_layerFind = options;
},*/
cswSearch: function (url, keyword, metadataUrl) {
//var typeNames = "csw:Record";
var typeNames = "gmd:MD_Metadata";
var filter = _cswFilter(keyword, typeNames);
_cswAjax(url, filter, metadataUrl, typeNames);
},
wmsSearch: function (url, keyword) {
_wmsAjax(url, keyword);
},
getFieldsFromWMS(describeLayer, layerid) {
return _getFields(describeLayer.wfs_url, describeLayer.typeName, layerid);
},
getStylesFromWMS(url, layerid) {
_getStyles(url, layerid);
},
getWfsInfosFromWms(url, layerid) {
return _getWFSUrl(url, layerid);
},
getWfsFeaturesFromWms(url, layerid) {
_getWFSUrl(url, layerid)
.then(({ describeLayer }) => describeLayer.wfs_url)
.then((wfs_url) => {
let onSuccess = (data) => {
console.log(data);
};
ogc.getFeatures(layer.wfs_url, { MAXFEATURES: 1 }, onSuccess);
});
},
getWfsFeatures(url) {
fetch(url);
},
urlToObject(url, queryParams) {
let defaultUrl = new URL(url);
let params = Object.fromEntries(defaultUrl.searchParams.entries());
let mergeParams = { ...queryParams, ...params };
defaultUrl.search = new URLSearchParams(mergeParams);
return defaultUrl;
},
getFeatures(url, props, onSuccess) {
let queryParams = {
SERVICE: "WFS",
VERSION: "1.0.0",
REQUEST: "GETFEATURE",
OUTPUTFORMAT: "application/json",
...props,
};
let newUrl = ogc.urlToObject(url, queryParams);
let stringUrl = newUrl.toString();
$.ajax({
type: "GET",
url: mv.ajaxURL(stringUrl),
crossDomain: true,
dataType: "json",
contentType: "application/json",
success: function (data) {
onSuccess(data);
},
error: function (xhr, ajaxOptions, thrownError) {
console.error("WFS GetFeature request failed", {
url: stringUrl,
xhr: xhr,
ajaxOptions: ajaxOptions,
thrownError: thrownError,
});
alert("Echec de la requête WFS GetFeature :\n" + stringUrl);
},
});
},
};
})();