Conversation
…ry does not cross it
…ine-split The new @turf/line-split dependency was added to package.json but not to the tsconfig references, so monorepolint's standardTsconfig rule failed with "tsconfig.json: Expect file contents to match". Written by mrl check --fix. Verified locally: mrl check exits 100 before and 0 after; prettier and eslint clean; tsc --build succeeds; the package suite is 23/23 including the new LineInsidePolygonTouchesBoundary fixture.
|
CI went red on this branch when I merged master on 27 August; before that it was green. The cause was mine rather than the change. Upstream adopted generated tsconfig project references in the meantime (#3145, merged 7 August), and I had added
|
booleanCrossesreturnedtruefor a LineString that only touches a Polygonboundary without passing through the interior.
doLineStringAndPolygonCrosstreated any intersection between the line and thepolygon boundary as a crossing. Per the OGC definition a cross requires the line
to have parts both inside and outside the polygon. A line that merely touches the
boundary at a point (endpoint on a vertex or edge) has all of its interior on one
side, so it does not cross.
Concrete cases on the polygon
[[0,0],[0,10],[10,10],[10,0],[0,0]]:[[0,5],[5,5]]lies inside the polygon and touches the left edge. It isbooleanWithin === true, yet the old code also returnedbooleanCrosses === true,which is contradictory.
[[-5,-5],[0,0],[-5,5]]lies outside and touches a corner. The old codereturned
true.Both match the JSTS
Geometry.crossesreference, which returnsfalsefor them.The fix splits the line on the polygon boundary and checks the midpoint of each
resulting sub-segment. A cross is reported only when at least one sub-segment lies
strictly inside and another lies strictly outside. Genuine crossings still return
true.Added a false fixture for the inside-touching case.