v1.6.04 - apply getSegmentId for routes and rivers

This commit is contained in:
Azgaar 2021-03-05 14:16:03 +03:00
parent ee324a3fef
commit 08a49c1d72
3 changed files with 20 additions and 53 deletions

View file

@ -359,7 +359,7 @@ void function addFindAll() {
}()
// get segment of any point on polyline
function getSegmentId(points, point) {
function getSegmentId(points, point, step = 10) {
if (points.length === 2) return 1;
const d2 = (p1, p2) => (p1[0] - p2[0]) ** 2 + (p1[1] - p2[1]) ** 2;
@ -371,7 +371,7 @@ function getSegmentId(points, point) {
const p2 = points[i+1];
const length = Math.sqrt(d2(p1, p2));
const segments = Math.ceil(length / 10);
const segments = Math.ceil(length / step);
const dx = (p2[0] - p1[0]) / segments;
const dy = (p2[1] - p1[1]) / segments;