comparison client/src/lib/geo.js @ 5154:a33f1d51d1b7

Changed FD coordinate calculation from polygon to multipolygon.
author Raimund Renkert <raimund@renkert.org>
date Wed, 01 Apr 2020 15:48:07 +0200
parents 5d9c7fcda566
children
comparison
equal deleted inserted replaced
5153:adf7b9f1273b 5154:a33f1d51d1b7
21 */ 21 */
22 22
23 import { 23 import {
24 lineString as turfLineString, 24 lineString as turfLineString,
25 point as turfPoint, 25 point as turfPoint,
26 polygon as turfPolygon 26 multiPolygon as turfMultiPolygon
27 } from "@turf/helpers"; 27 } from "@turf/helpers";
28 28
29 import Feature from "ol/Feature"; 29 import Feature from "ol/Feature";
30 import { GeoJSON } from "ol/format"; 30 import { GeoJSON } from "ol/format";
31 // import booleanWithin from "@turf/boolean-within"; 31 // import booleanWithin from "@turf/boolean-within";
187 const calculateFairwayCoordinates = (profileLine, fairwayGeometry, depth) => { 187 const calculateFairwayCoordinates = (profileLine, fairwayGeometry, depth) => {
188 // both geometries have to be in EPSG:4326 188 // both geometries have to be in EPSG:4326
189 // uses turfjs distance() function 189 // uses turfjs distance() function
190 let fairwayCoordinates = []; 190 let fairwayCoordinates = [];
191 var line = turfLineString(profileLine.getCoordinates()); 191 var line = turfLineString(profileLine.getCoordinates());
192 var polygon = turfPolygon(fairwayGeometry.getCoordinates()); 192 var polygon = turfMultiPolygon(fairwayGeometry.getCoordinates());
193 var intersects = lineIntersect(line, polygon); 193 var intersects = lineIntersect(line, polygon);
194 194
195 let opts = { units: "meters" }; 195 let opts = { units: "meters" };
196 let pStartPoint = profileLine.getCoordinates()[0]; 196 let pStartPoint = profileLine.getCoordinates()[0];
197 197