You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using the time filtering ability of feature layers to filter specific layers by a start and end time on each field. For this, I have defined the timeField with both a start and an end and defined the layer as having a to and a from to be used as the time range over which a feature should appear.
The function featureWithinTimeRange(feature) , which I have copied below, is used to determine if a feature falls within a time range. When a feature has a start and end time it evaluates to true if either the start or end time of the feature falls within the layer's set time range. I believe that this is operating under the assumption that there are 5 cases:
A feature's start and end fall before the from time.
A feature's start falls before the from time and its end falls between from and to.
A feature's start and end times fall between the from and to times.
A feature's start time falls between the from and to times, and its end time falls after to.
A feature's start and end fall after the to time.
The middle three cases should evaluate to true, and are implemented in the code below:
_featureWithinTimeRange: function (feature) {
if (!this.options.from || !this.options.to) {
return true;
}
var from = +this.options.from.valueOf();
var to = +this.options.to.valueOf();
if (typeof this.options.timeField === 'string') {
var date = +feature.properties[this.options.timeField];
return (date >= from) && (date <= to);
}
if (this.options.timeField.start && this.options.timeField.end) {
var startDate = +feature.properties[this.options.timeField.start];
var endDate = +feature.properties[this.options.timeField.end];
return ((startDate >= from) && (startDate <= to)) || ((endDate >= from) && (endDate <= to));
}
},
However, I believe that there should be a sixth case:
The from and to times fall between the feature's start and end times.
In the current code, this will not evaluate to true, however in my application I would like the feature to persist over its entire time range even if the from and to represent a time within that range.
In this case, the final return statement would have one more or case as follows: return ((startDate >= from) && (startDate <= to)) || ((endDate >= from) && (endDate <= to)) || ((startDate <= from) && (endDate >= to));
Please let me know if there was a reason to exclude this case and I can make the necessary changes to my own code to get the proper functionality that I'm looking for.
Thank you
The text was updated successfully, but these errors were encountered:
All
L.version
):1.5.1
L.esri.VERSION
):2.3.1
I am using the time filtering ability of feature layers to filter specific layers by a start and end time on each field. For this, I have defined the
timeField
with both astart
and anend
and defined the layer as having ato
and afrom
to be used as the time range over which a feature should appear.The function
featureWithinTimeRange(feature)
, which I have copied below, is used to determine if a feature falls within a time range. When a feature has a start and end time it evaluates to true if either the start or end time of the feature falls within the layer's set time range. I believe that this is operating under the assumption that there are 5 cases:start
andend
fall before thefrom
time.start
falls before thefrom
time and itsend
falls betweenfrom
andto
.start
andend
times fall between thefrom
andto
times.start
time falls between thefrom
andto
times, and itsend
time falls afterto
.start
andend
fall after theto
time.The middle three cases should evaluate to true, and are implemented in the code below:
However, I believe that there should be a sixth case:
from
andto
times fall between the feature'sstart
andend
times.In the current code, this will not evaluate to true, however in my application I would like the feature to persist over its entire time range even if the
from
andto
represent a time within that range.In this case, the final return statement would have one more or case as follows:
return ((startDate >= from) && (startDate <= to)) || ((endDate >= from) && (endDate <= to)) || ((startDate <= from) && (endDate >= to));
Please let me know if there was a reason to exclude this case and I can make the necessary changes to my own code to get the proper functionality that I'm looking for.
Thank you
The text was updated successfully, but these errors were encountered: