Skip to content

Commit

Permalink
[UPD] setMaxD, setScale #1092
Browse files Browse the repository at this point in the history
  • Loading branch information
Viglino committed Aug 5, 2024
1 parent 8a20e1e commit b1dd609
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 5 deletions.
27 changes: 22 additions & 5 deletions examples/layer/map.layer.idw.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,28 @@ <h1>ol-ext: IDW layer</h1>
<div id="map"></div>
<div class="options">
Click on the map to add a new measure.
<br/> Value:
<input id="value" type="number" value="50" min="0" max="100" />
<label><input id="random" type="checkbox" checked="checked" /> random</label>
<button onclick="idw.getSource().clear()">clear</button>
<button onclick="$('body').toggleClass('fullscreen'); map.updateSize()">FullScreen</button>
<ul>
<li>
Value:
<input id="value" type="number" value="50" min="0" max="100" />
<label><input id="random" type="checkbox" checked="checked" /> random</label>
</li>
<li>
Scale: <select onchange="idw.setScale(this.value)">
<option valule="1">1</option>
<option valule="2">2</option>
<option valule="4" selected>4</option>
<option valule="8">8</option>
</select>
</li>
<li>
Max distance: <input type="range" step="100000" min="0" max="4000000" value="0" onchange="idw.setMaxD(this.value)">
</li>
<li style="padding-top: 1em; float: right;">
<button onclick="idw.getSource().clear()">clear</button>
<button onclick="$('body').toggleClass('fullscreen'); map.updateSize()">FullScreen</button>
</li>
</ul>
</div>

<script type="text/javascript">
Expand Down
14 changes: 14 additions & 0 deletions src/source/IDW.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,20 @@ var ol_source_IDW = class olsourceIDW extends ol_source_ImageCanvas {
this.set('maxD', parseFloat(options.maxD) || 0)
this._weight = typeof (options.weight) === 'function' ? options.weight : function (f) { return f.get(options.weight || 'weight'); };
}
/** Set IDW scale
* @param {number} scale
*/
setScale(scale) {
this.set('scale', parseFloat(scale) || 4);
this.changed();
}
/** Set IDW max distance
* @param {number} [dist] max distance in proj units
*/
setMaxD(dist) {
this.set('maxD', parseFloat(dist) || 0);
this.changed();
}
/** Get the source
*/
getSource() {
Expand Down

0 comments on commit b1dd609

Please sign in to comment.