import {ol_coordinate_equal} from "./GeomUtils.js"; import ol_geom_LineString from "ol/geom/LineString.js"; /** Split a lineString by a point or a list of points * NB: points must be on the line, use getClosestPoint() to get one * @param {ol.Coordinate | Array} pt points to split the line * @param {Number} tol distance tolerance for 2 points to be equal */ ol_geom_LineString.prototype.splitAt = function(pt, tol) { var i; if (!pt) return [this]; if (!tol) tol = 1e-10; // Test if list of points if (pt.length && pt[0].length) { var result = [this]; for (i=0; i split if (split) { ci.push(pt); c.push (new ol_geom_LineString(ci)); ci = [pt]; } } ci.push(c0[i+1]); } if (ci.length>1) c.push (new ol_geom_LineString(ci)); if (c.length) return c; else return [this]; } // import('ol-ext/geom/LineStringSplitAt')