* @param {LineElement} line * @param {PointElement} sourcePoint * @param {string} property * @returns {{point?: PointElement, first?: boolean, last?: boolean}}
(line, sourcePoint, property)
| 85 | * @returns {{point?: PointElement, first?: boolean, last?: boolean}} |
| 86 | */ |
| 87 | function findPoint(line, sourcePoint, property) { |
| 88 | const point = line.interpolate(sourcePoint, property); |
| 89 | if (!point) { |
| 90 | return {}; |
| 91 | } |
| 92 | |
| 93 | const pointValue = point[property]; |
| 94 | const segments = line.segments; |
| 95 | const linePoints = line.points; |
| 96 | let first = false; |
| 97 | let last = false; |
| 98 | for (let i = 0; i < segments.length; i++) { |
| 99 | const segment = segments[i]; |
| 100 | const firstValue = linePoints[segment.start][property]; |
| 101 | const lastValue = linePoints[segment.end][property]; |
| 102 | if (_isBetween(pointValue, firstValue, lastValue)) { |
| 103 | first = pointValue === firstValue; |
| 104 | last = pointValue === lastValue; |
| 105 | break; |
| 106 | } |
| 107 | } |
| 108 | return {first, last, point}; |
| 109 | } |
no test coverage detected