Skip to content

Commit

Permalink
[UPD] WMS capabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
Viglino committed Oct 16, 2024
1 parent 823ab01 commit 3fa8c42
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion examples/layer/map.wmscapabilities.html
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ <h1>ol-ext: WMS Capabilities control</h1>
target: document.body,
srs: ['EPSG:2154'],
cors: true,
optional: 'token',
optional: 'token,apikey',
services: {
'BRGM': 'https://geoservices.brgm.fr/geologie',
'OSM': 'https://wms.openstreetmap.fr/wms',
Expand Down
12 changes: 11 additions & 1 deletion examples/routing/map.control.isochrone.html
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ <h1>ol-ext: Geoportail isochrone</h1>

search.on('isochrone', function(iso) {
if (!batch.length && iso.iteration === 0) vector.getSource().clear();
// Simplify using closing operation with jsts
if (Number($('.simplify').val())) {
// Simplify using closing operation with jsts
var simpli = Number($('.simplify').val());
var parser = new jsts.io.OL3Parser();
var geom = iso.feature.getGeometry();
Expand All @@ -126,6 +126,7 @@ <h1>ol-ext: Geoportail isochrone</h1>
buffered = jsts.simplify.DouglasPeuckerSimplifier.simplify(buffered, Math.min(10, simpli/10))
iso.feature.setGeometry(parser.write(buffered));
}
console.log(currentFeature)
vector.getSource().addFeature(iso.feature);
setTimeout(function() {
map.getView().fit(vector.getSource().getExtent(), { duration:1000 });
Expand All @@ -147,10 +148,12 @@ <h1>ol-ext: Geoportail isochrone</h1>
/* BATCH mode: load a geojson file */
var batch = [];
var current_iteration = 0;
var currentFeature = null;
var dialog = new ol.control.Dialog();
map.addControl(dialog);

function dosearch() {
currentFeature = null;
if (!batch.length) {
dialog.hide();
return;
Expand All @@ -166,6 +169,7 @@ <h1>ol-ext: Geoportail isochrone</h1>
var pt = batch[0].getGeometry().getFirstCoordinate();
var val = search.get('method')==='distance' ? search.get('distance')*1000 : (search.get('hour')||0)*60*60+(search.get('minute')||0)*60;
if (val) {
currentFeature = batch[0];
search.search(pt, val, current_iteration-1)
} else {
batch = [];
Expand All @@ -182,6 +186,12 @@ <h1>ol-ext: Geoportail isochrone</h1>
current_iteration = search.get('iter')+1;
dosearch();
});

// Restart after error
function reRun() {
current_iteration++;
dosearch();
}
</script>

</body>
Expand Down
8 changes: 7 additions & 1 deletion src/control/WMSCapabilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,7 @@ var ol_control_WMSCapabilities = class olcontrolWMSCapabilities extends ol_contr
}
}.bind(this))
}
this._optional = optional;

// Get request params
var request = this.getRequestParam(options)
Expand Down Expand Up @@ -727,6 +728,8 @@ var ol_control_WMSCapabilities = class olcontrolWMSCapabilities extends ol_contr
}
}

Object.keys(this._optional).forEach(o => source_opt.params[o] = this._optional[o])

// Resolution to zoom
var view = new ol_View({
projection: this.getMap().getView().getProjection()
Expand Down Expand Up @@ -834,8 +837,11 @@ var ol_control_WMSCapabilities = class olcontrolWMSCapabilities extends ol_contr
title: this._elements.formTitle.value
}
}
if (this._elements.formMap.value)

Object.keys(this._optional).forEach(o => options.source.params[o] = this._optional[o])
if (this._elements.formMap.value) {
options.source.params.MAP = this._elements.formMap.value
}
return options
}
/** Fill dialog form
Expand Down
2 changes: 2 additions & 0 deletions src/control/WMTSCapabilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ var ol_control_WMTSCapabilities = class olcontrolWMTSCapabilities extends ol_con
* @returns {boolean}
*/
isSupportedSet(tm) {
console.log(tm)
if (/^PM_.*/.test(tm.TileMatrixSet)) return true;
return this.supportedSets.indexOf(tm.TileMatrixSet) >= 0;
}
/** Return a WMTS options for the given capabilities
Expand Down

0 comments on commit 3fa8c42

Please sign in to comment.