Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
ol_geom_LineString.prototype.lineRef = function (p) {
var p0, p1, s;
var coord = this.getCoordinates();
var s0 = 0;
for (var i=1; i=0 && s<=1) {
var pi = [p0[0] + s*(p1[0]-p0[0]), p0[1] + s*(p1[1]-p0[1])];
if (ol_coordinate_dist2d(p,pi) < 1e-10) {
return s0 + s*ol_coordinate_dist2d(p0, p1);
}
} else {
s0 += ol_coordinate_dist2d(p0,p1);
}
}
// Point is not on the linestring
return false;
};
ol_geom_LineString.prototype.lineRef = function (p) {
var p0, p1, s;
var coord = this.getCoordinates();
var s0 = 0;
for (var i=1; i=0 && s<=1) {
var pi = [p0[0] + s*(p1[0]-p0[0]), p0[1] + s*(p1[1]-p0[1])];
if (ol_coordinate_dist2d(p,pi) < 1e-10) {
return s0 + s*ol_coordinate_dist2d(p0, p1);
}
} else {
s0 += ol_coordinate_dist2d(p0,p1);
}
}
// Point is not on the linestring
return false;
};
if (a < 1e-10) {
if (d0 > dl) a = -dl/2;
else {
dl = d0;
a = -d0/2;
}
}
else a = a/2 -dl;
} else {
coords.push(g[0]);
}
// Linear interpol
for (var i=1; i
ol_geom_LineString.prototype.lineRef = function (p) {
var p0, p1, s;
var coord = this.getCoordinates();
var s0 = 0;
for (var i=1; i=0 && s<=1) {
var pi = [p0[0] + s*(p1[0]-p0[0]), p0[1] + s*(p1[1]-p0[1])];
if (ol_coordinate_dist2d(p,pi) < 1e-10) {
return s0 + s*ol_coordinate_dist2d(p0, p1);
}
} else {
s0 += ol_coordinate_dist2d(p0,p1);
}
}
// Point is not on the linestring
return false;
};
c[1] += dc[1];
if (this.destination) {
// Reach the destination
if ( Math.sign(this.path[this.destination][0]-c[0]) != Math.sign(this.dir[0])
|| Math.sign(this.path[this.destination][1]-c[1]) != Math.sign(this.dir[1]) ) {
this.destination++;
// End of the path ?
if (this.destination >= this.path.length) {
this.stop();
this.setCoordinate (this.path[this.destination-1]);
this.destination = 0;
this.dispatchEvent({ type:'destination' });
} else {
// Overpass ?
var dl = ol_coordinate_dist2d (c, this.path[this.destination-1]);
while (true) {
var ds = ol_coordinate_dist2d(this.path[this.destination], this.path[this.destination-1]);
if (ds > dl) break;
else {
dl -= ds;
this.destination++;
// End of the path ?
if (this.destination >= this.path.length) {
this.stop();
this.setCoordinate (this.path[this.destination-1]);
this.destination = 0;
this.dispatchEvent({ type:'destination' });
return;
}
}
}
if (this.destination) {
// Reach the destination
if ( Math.sign(this.path[this.destination][0]-c[0]) != Math.sign(this.dir[0])
|| Math.sign(this.path[this.destination][1]-c[1]) != Math.sign(this.dir[1]) ) {
this.destination++;
// End of the path ?
if (this.destination >= this.path.length) {
this.stop();
this.setCoordinate (this.path[this.destination-1]);
this.destination = 0;
this.dispatchEvent({ type:'destination' });
} else {
// Overpass ?
var dl = ol_coordinate_dist2d (c, this.path[this.destination-1]);
while (true) {
var ds = ol_coordinate_dist2d(this.path[this.destination], this.path[this.destination-1]);
if (ds > dl) break;
else {
dl -= ds;
this.destination++;
// End of the path ?
if (this.destination >= this.path.length) {
this.stop();
this.setCoordinate (this.path[this.destination-1]);
this.destination = 0;
this.dispatchEvent({ type:'destination' });
return;
}
}
}
// New position on end of the segment
features.forEach (function (f) {
var n = f.getGeometry().getClosestPoint(p);
var d = ol_coordinate_dist2d(n,p);
if (ddist) f0=null;
if (seg) {
c = this.getCoordinates();
seg[0] = c[c.length-2];
seg[1] = c[c.length-1];
}
return this.getLastCoordinate();
}
if (!seg) seg=[];
var s = 0;
var coord = this.getCoordinates();
for (var i=1; i= r) {
var p0 = seg[0] = coord[i-1];
var p1 = seg[1] = coord[i];
d = ol_coordinate_dist2d(p0,p1)
return [
p0[0] + (r-s) * (p1[0]-p0[0]) /d,
p0[1] + (r-s) * (p1[1]-p0[1]) /d
];
}
s += d;
}
};
}
return this.getFirstCoordinate();
}
if (this.getLength()-r < 1e-10) {
if (seg) {
c = this.getCoordinates();
seg[0] = c[c.length-2];
seg[1] = c[c.length-1];
}
return this.getLastCoordinate();
}
if (!seg) seg=[];
var s = 0;
var coord = this.getCoordinates();
for (var i=1; i= r) {
var p0 = seg[0] = coord[i-1];
var p1 = seg[1] = coord[i];
d = ol_coordinate_dist2d(p0,p1)
return [
p0[0] + (r-s) * (p1[0]-p0[0]) /d,
p0[1] + (r-s) * (p1[1]-p0[1]) /d
];
}
s += d;
}
};