Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions dist/leaflet.timedimension.control.css
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/*
* Leaflet TimeDimension v1.1.1 - 2019-11-05
* Leaflet TimeDimension v1.1.1 - 2020-11-12
*
* Copyright 2019 Biel Frontera (ICTS SOCIB)
* Copyright 2020 Biel Frontera (ICTS SOCIB)
* datacenter@socib.es
* http://www.socib.es/
* https://www.socib.es/
*
* Licensed under the MIT license.
*
* Demos:
* http://apps.socib.es/Leaflet.TimeDimension/
* https://apps.socib.es/Leaflet.TimeDimension/
*
* Source:
* git://github.com/socib/Leaflet.TimeDimension.git
Expand Down
10 changes: 5 additions & 5 deletions dist/leaflet.timedimension.min.js

Large diffs are not rendered by default.

48 changes: 30 additions & 18 deletions dist/leaflet.timedimension.src.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/*
* Leaflet TimeDimension v1.1.1 - 2019-11-05
* Leaflet TimeDimension v1.1.1 - 2020-11-12
*
* Copyright 2019 Biel Frontera (ICTS SOCIB)
* Copyright 2020 Biel Frontera (ICTS SOCIB)
* datacenter@socib.es
* http://www.socib.es/
* https://www.socib.es/
*
* Licensed under the MIT license.
*
* Demos:
* http://apps.socib.es/Leaflet.TimeDimension/
* https://apps.socib.es/Leaflet.TimeDimension/
*
* Source:
* git://github.com/socib/Leaflet.TimeDimension.git
Expand Down Expand Up @@ -612,7 +612,9 @@ L.TimeDimension.Util = {
},

sort_and_deduplicate: function(arr) {
arr = arr.slice(0).sort();
arr = arr.slice(0).sort(function (a, b) {
return a - b;
});
var result = [];
var last = null;
for (var i = 0, l = arr.length; i < l; i++) {
Expand Down Expand Up @@ -1043,22 +1045,25 @@ L.TimeDimension.Layer.WMS = L.TimeDimension.Layer.extend({

_parseTimeDimensionFromCapabilities: function(xml) {
var layers = xml.querySelectorAll('Layer[queryable="1"]');
var layerName = this._baseLayer.wmsParams.layers;
var layer = null;
var layerNames = this._baseLayer.wmsParams.layers.split(',');
var layersFiltered = [];
var times = null;

layers.forEach(function(current) {
if (current.querySelector("Name").innerHTML === layerName) {
layer = current;
if (layerNames.includes(current.querySelector("Name").innerHTML)) {
layersFiltered.push(current);
}
})
if (layer) {
times = this._getTimesFromLayerCapabilities(layer);
if (!times) {
times = this._getTimesFromLayerCapabilities(layer.parentNode);
}
if (layersFiltered.length) {
times = layersFiltered.map(this._getTimesFromLayerCapabilities);
times = times.concat(layersFiltered.map((function(node){
return this._getTimesFromLayerCapabilities(node.parentNode);
}).bind(this)))
times = times.filter(function(time){
return time!=null;
})
}

return times;
},

Expand Down Expand Up @@ -1257,7 +1262,7 @@ L.TimeDimension.Layer.GeoJson = L.TimeDimension.Layer.extend({
this._duration = this.options.duration || null;
this._addlastPoint = this.options.addlastPoint || false;
this._waitForReady = this.options.waitForReady || false;
this._defaultTime = 0;
this._updateCurrentTime = this.options.updateCurrentTime || this._updateTimeDimension;
this._availableTimes = [];
this._loaded = false;
if (this._baseLayer.getLayers().length == 0) {
Expand Down Expand Up @@ -1358,9 +1363,13 @@ L.TimeDimension.Layer.GeoJson = L.TimeDimension.Layer.extend({
}
}
this._availableTimes = L.TimeDimension.Util.sort_and_deduplicate(times);
this._updateCurrentTime = this._updateCurrentTime || (this._timeDimension && this._timeDimension.getAvailableTimes().length == 0);
if (this._timeDimension && (this._updateTimeDimension || this._timeDimension.getAvailableTimes().length == 0)) {
this._timeDimension.setAvailableTimes(this._availableTimes, this._updateTimeDimensionMode);
}
if (this._updateCurrentTime && this._timeDimension && this._availableTimes.length) {
this._timeDimension.setCurrentTime(this._availableTimes[0]);
}
},

_getFeatureTimes: function(feature) {
Expand Down Expand Up @@ -1549,16 +1558,19 @@ L.TimeDimension.Player = (L.Layer || L.Class).extend({
if (this._intervalID) return;
this._steps = numSteps || 1;
this._waitingForBuffer = false;
var startedOver = false;
if (this.options.startOver){
if (this._timeDimension.getCurrentTimeIndex() === this._getMaxIndex()){
this._timeDimension.setCurrentTimeIndex(this._timeDimension.getLowerLimitIndex() || 0);
this._timeDimension.setCurrentTimeIndex(this._timeDimension.getLowerLimitIndex() || 0);
startedOver = true;
}
}
this.release();
this._intervalID = window.setInterval(
L.bind(this._tick, this),
this._transitionTime);
this._tick();
if (!startedOver)
this._tick();
this.fire('play');
this.fire('running');
},
Expand Down
50 changes: 31 additions & 19 deletions dist/leaflet.timedimension.src.withlog.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/*
* Leaflet TimeDimension v1.1.1 - 2019-11-05
* Leaflet TimeDimension v1.1.1 - 2020-11-12
*
* Copyright 2019 Biel Frontera (ICTS SOCIB)
* Copyright 2020 Biel Frontera (ICTS SOCIB)
* datacenter@socib.es
* http://www.socib.es/
* https://www.socib.es/
*
* Licensed under the MIT license.
*
* Demos:
* http://apps.socib.es/Leaflet.TimeDimension/
* https://apps.socib.es/Leaflet.TimeDimension/
*
* Source:
* git://github.com/socib/Leaflet.TimeDimension.git
Expand Down Expand Up @@ -612,7 +612,9 @@ L.TimeDimension.Util = {
},

sort_and_deduplicate: function(arr) {
arr = arr.slice(0).sort();
arr = arr.slice(0).sort(function (a, b) {
return a - b;
});
var result = [];
var last = null;
for (var i = 0, l = arr.length; i < l; i++) {
Expand Down Expand Up @@ -1043,22 +1045,25 @@ L.TimeDimension.Layer.WMS = L.TimeDimension.Layer.extend({

_parseTimeDimensionFromCapabilities: function(xml) {
var layers = xml.querySelectorAll('Layer[queryable="1"]');
var layerName = this._baseLayer.wmsParams.layers;
var layer = null;
var layerNames = this._baseLayer.wmsParams.layers.split(',');
var layersFiltered = [];
var times = null;

layers.forEach(function(current) {
if (current.querySelector("Name").innerHTML === layerName) {
layer = current;
if (layerNames.includes(current.querySelector("Name").innerHTML)) {
layersFiltered.push(current);
}
})
if (layer) {
times = this._getTimesFromLayerCapabilities(layer);
if (!times) {
times = this._getTimesFromLayerCapabilities(layer.parentNode);
}
}

if (layersFiltered.length) {
times = layersFiltered.map(this._getTimesFromLayerCapabilities);
times = times.concat(layersFiltered.map((function(node){
return this._getTimesFromLayerCapabilities(node.parentNode);
}).bind(this)))
times = times.filter(function(time){
return time!=null;
})
}
console.log(times);
return times;
},

Expand Down Expand Up @@ -1257,7 +1262,7 @@ L.TimeDimension.Layer.GeoJson = L.TimeDimension.Layer.extend({
this._duration = this.options.duration || null;
this._addlastPoint = this.options.addlastPoint || false;
this._waitForReady = this.options.waitForReady || false;
this._defaultTime = 0;
this._updateCurrentTime = this.options.updateCurrentTime || this._updateTimeDimension;
this._availableTimes = [];
this._loaded = false;
if (this._baseLayer.getLayers().length == 0) {
Expand Down Expand Up @@ -1358,9 +1363,13 @@ L.TimeDimension.Layer.GeoJson = L.TimeDimension.Layer.extend({
}
}
this._availableTimes = L.TimeDimension.Util.sort_and_deduplicate(times);
this._updateCurrentTime = this._updateCurrentTime || (this._timeDimension && this._timeDimension.getAvailableTimes().length == 0);
if (this._timeDimension && (this._updateTimeDimension || this._timeDimension.getAvailableTimes().length == 0)) {
this._timeDimension.setAvailableTimes(this._availableTimes, this._updateTimeDimensionMode);
}
if (this._updateCurrentTime && this._timeDimension && this._availableTimes.length) {
this._timeDimension.setCurrentTime(this._availableTimes[0]);
}
},

_getFeatureTimes: function(feature) {
Expand Down Expand Up @@ -1549,16 +1558,19 @@ L.TimeDimension.Player = (L.Layer || L.Class).extend({
if (this._intervalID) return;
this._steps = numSteps || 1;
this._waitingForBuffer = false;
var startedOver = false;
if (this.options.startOver){
if (this._timeDimension.getCurrentTimeIndex() === this._getMaxIndex()){
this._timeDimension.setCurrentTimeIndex(this._timeDimension.getLowerLimitIndex() || 0);
this._timeDimension.setCurrentTimeIndex(this._timeDimension.getLowerLimitIndex() || 0);
startedOver = true;
}
}
this.release();
this._intervalID = window.setInterval(
L.bind(this._tick, this),
this._transitionTime);
this._tick();
if (!startedOver)
this._tick();
this.fire('play');
this.fire('running');
},
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
"email": "datacenter@socib.es",
"url": "https://www.socib.es/"
},
"scripts": {
"build" : "grunt"
},
"contributors": [
{
"name": "Sylvain Marcadal (Ram)",
Expand Down
22 changes: 12 additions & 10 deletions src/leaflet.timedimension.layer.wms.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,22 +290,24 @@ L.TimeDimension.Layer.WMS = L.TimeDimension.Layer.extend({

_parseTimeDimensionFromCapabilities: function(xml) {
var layers = xml.querySelectorAll('Layer[queryable="1"]');
var layerName = this._baseLayer.wmsParams.layers;
var layer = null;
var layerNames = this._baseLayer.wmsParams.layers.split(',');
var layersFiltered = [];
var times = null;

layers.forEach(function(current) {
if (current.querySelector("Name").innerHTML === layerName) {
layer = current;
if (layerNames.includes(current.querySelector("Name").innerHTML)) {
layersFiltered.push(current);
}
})
if (layer) {
times = this._getTimesFromLayerCapabilities(layer);
if (!times) {
times = this._getTimesFromLayerCapabilities(layer.parentNode);
}
if (layersFiltered.length) {
times = layersFiltered.map(this._getTimesFromLayerCapabilities);
times = times.concat(layersFiltered.map((function(node){
return this._getTimesFromLayerCapabilities(node.parentNode);
}).bind(this)))
times = times.filter(function(time){
return time!=null;
})
}

return times;
},

Expand Down