Mercurial > gemma
changeset 2272:f06e9e0cb790
client: improved fairway calculation for cross cut.
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Thu, 14 Feb 2019 16:15:36 +0100 |
parents | 91ca0cdd2e35 |
children | 4eeaba4ef573 |
files | client/src/lib/geo.js |
diffstat | 1 files changed, 6 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/client/src/lib/geo.js Thu Feb 14 16:12:34 2019 +0100 +++ b/client/src/lib/geo.js Thu Feb 14 16:15:36 2019 +0100 @@ -24,7 +24,8 @@ import distance from "@turf/distance"; import { lineString as turfLineString, - polygon as turfPolygon + polygon as turfPolygon, + point as turfPoint } from "@turf/helpers"; import lineSplit from "@turf/line-split"; import lineSlice from "@turf/line-slice"; @@ -199,16 +200,15 @@ ); startPoint = line1.geometry.coordinates[0]; endPoint = line1.geometry.coordinates[1]; - } else if (booleanWithin(line, polygon)) { + } else if ( + booleanContains(polygon, turfPoint(line.geometry.coordinates[0])) && + booleanContains(polygon, turfPoint(line.geometry.coordinates[1])) + ) { startPoint = line.geometry.coordinates[0]; endPoint = line.geometry.coordinates[1]; } else { let split = lineSplit(line, polygon); for (let feature of split.features) { - if (booleanWithin(feature, polygon)) { - startPoint = feature.geometry.coordinates[0]; - endPoint = feature.geometry.coordinates[1]; - } if (booleanContains(polygon, feature)) { startPoint = feature.geometry.coordinates[0]; endPoint = feature.geometry.coordinates[1];