Commit 79bae861 authored by Pettersson Tomas's avatar Pettersson Tomas

added limits for changing enddate

parent 8d8d2300
......@@ -577,11 +577,14 @@ var EXTrajectory = (function (_super) {
var currentlength = self.drawnfeature.geometry.coordinates.length;
var wantedTimeIncrementlength = Math.round(((Math.abs(this.from - this.to) / 1000) / 60) / timeIncrement);
var coords = self.drawnfeature.geometry.coordinates.slice(0);
var index = 1;
while (coords.length < wantedTimeIncrementlength) {
// too small, add random points
var index = self.getRandomInt(1, currentlength - 1);
// too small, add points
if (index >= coords.length - 1)
index = 1;
var newpoint = [(coords[index][0] + coords[index + 1][0]) / 2, (coords[index][1] + coords[index + 1][1]) / 2];
coords.splice(index + 1, 0, newpoint);
index += 2;
}
while (coords.length > wantedTimeIncrementlength) {
// too big, remove random points
......
This diff is collapsed.
......@@ -469,16 +469,34 @@ class EXTrajectory extends STWkit.AccordionCard {
self.endDateInput.onchange = function (evt) {
var date = moment.utc(self.endDateInput.value + ' ' + self.endTimeInput.value, self.datetimeFormat);
self.to = date.clone();
var newdate = moment.utc(self.endDateInput.value + ' ' + self.endTimeInput.value, self.datetimeFormat);
if (newdate.isBefore(self.from)) {
self.endDateInput.value = self.to.format(self.dateFormat);
self.endTimeInput.value = self.to.startOf('hour').format(self.timeFormat);
return;
}
var diff = Math.abs(self.from - self.to);
var nrofhours = Math.round(((diff/1000)/60)/60);
if (nrofhours > 72) return;
self.to = newdate.clone();
self.refreshTrajectory();
self.fireChangeFn(self);
};
self.endTimeInput.onchange = function (evt) {
var date = moment.utc(self.endDateInput.value + ' ' + self.endTimeInput.value, self.datetimeFormat);
self.to = date.clone();
var newdate = moment.utc(self.endDateInput.value + ' ' + self.endTimeInput.value, self.datetimeFormat);
if (newdate.isBefore(self.from)) {
self.endDateInput.value = self.to.format(self.dateFormat);
self.endTimeInput.value = self.to.startOf('hour').format(self.timeFormat);
return;
}
var diff = Math.abs(self.from - self.to);
var nrofhours = Math.round(((diff/1000)/60)/60);
if (nrofhours > 72) return;
self.to = newdate.clone();
self.refreshTrajectory();
self.fireChangeFn(self);
};
......@@ -672,17 +690,19 @@ class EXTrajectory extends STWkit.AccordionCard {
var coords = self.drawnfeature.geometry.coordinates.slice(0);
var index = 1;
while(coords.length < wantedTimeIncrementlength) {
// too small, add random points
var index = self.getRandomInt(1, currentlength-1);
// too small, add points
if (index >= coords.length-1) index = 1;
var newpoint = [(coords[index][0]+coords[index+1][0])/2,(coords[index][1]+coords[index+1][1])/2];
coords.splice(index+1, 0, newpoint);
index += 2;
}
while(coords.length > wantedTimeIncrementlength) {
// too big, remove random points
var index = self.getRandomInt(1, currentlength-1);
var index:number = self.getRandomInt(1, currentlength-1);
coords.splice(index, 1);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment