How to use @turf/boolean-point-on-line - 9 common examples

To help you get started, we’ve selected a few @turf/boolean-point-on-line examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Turfjs / turf / packages / turf-line-overlap / index.ts View on Github external
featureEach(tree.search(segment), function (match) {
            if (doesOverlaps === false) {
                var coordsSegment = getCoords(segment).sort();
                var coordsMatch: any = getCoords(match).sort();

                // Segment overlaps feature
                if (equal(coordsSegment, coordsMatch)) {
                    doesOverlaps = true;
                    // Overlaps already exists - only append last coordinate of segment
                    if (overlapSegment) overlapSegment = concatSegment(overlapSegment, segment);
                    else overlapSegment = segment;
                // Match segments which don't share nodes (Issue #901)
                } else if (
                    (tolerance === 0) ?
                        booleanPointOnLine(coordsSegment[0], match) && booleanPointOnLine(coordsSegment[1], match) :
                        nearestPointOnLine(match, coordsSegment[0]).properties.dist <= tolerance &&
                        nearestPointOnLine(match, coordsSegment[1]).properties.dist <= tolerance) {
                    doesOverlaps = true;
                    if (overlapSegment) overlapSegment = concatSegment(overlapSegment, segment);
                    else overlapSegment = segment;
                } else if (
                    (tolerance === 0) ?
                        booleanPointOnLine(coordsMatch[0], segment) && booleanPointOnLine(coordsMatch[1], segment) :
                        nearestPointOnLine(segment, coordsMatch[0]).properties.dist <= tolerance &&
                        nearestPointOnLine(segment, coordsMatch[1]).properties.dist <= tolerance) {
                    // Do not define (doesOverlap = true) since more matches can occur within the same segment
                    // doesOverlaps = true;
                    if (overlapSegment) overlapSegment = concatSegment(overlapSegment, match);
                    else overlapSegment = match;
                }
            }
github Turfjs / turf / packages / turf-line-overlap / index.ts View on Github external
doesOverlaps = true;
                    // Overlaps already exists - only append last coordinate of segment
                    if (overlapSegment) overlapSegment = concatSegment(overlapSegment, segment);
                    else overlapSegment = segment;
                // Match segments which don't share nodes (Issue #901)
                } else if (
                    (tolerance === 0) ?
                        booleanPointOnLine(coordsSegment[0], match) && booleanPointOnLine(coordsSegment[1], match) :
                        nearestPointOnLine(match, coordsSegment[0]).properties.dist <= tolerance &&
                        nearestPointOnLine(match, coordsSegment[1]).properties.dist <= tolerance) {
                    doesOverlaps = true;
                    if (overlapSegment) overlapSegment = concatSegment(overlapSegment, segment);
                    else overlapSegment = segment;
                } else if (
                    (tolerance === 0) ?
                        booleanPointOnLine(coordsMatch[0], segment) && booleanPointOnLine(coordsMatch[1], segment) :
                        nearestPointOnLine(segment, coordsMatch[0]).properties.dist <= tolerance &&
                        nearestPointOnLine(segment, coordsMatch[1]).properties.dist <= tolerance) {
                    // Do not define (doesOverlap = true) since more matches can occur within the same segment
                    // doesOverlaps = true;
                    if (overlapSegment) overlapSegment = concatSegment(overlapSegment, match);
                    else overlapSegment = match;
                }
            }
        });
github Turfjs / turf / packages / turf-boolean-valid / index.ts View on Github external
function checkRingsForSpikesPunctures(geom) {
    for (var i = 0; i < geom.length - 1; i++) {
        var point = geom[i]
        for (var ii = i + 1; ii < geom.length - 2; ii++) {
            var seg = [geom[ii], geom[ii + 1]]
            if (isPointOnLine(point, lineString(seg))) return true
        }
    }
    return false
}
github Turfjs / turf / packages / turf-boolean-touches / index.ts View on Github external
var type2 = geom2.type;

    switch (type1) {
    case 'Point':
        switch (type2) {
        case 'LineString':
            return isPointOnLineEnd(geom1, geom2);
        case 'MultiLineString':
          var foundTouchingPoint = false
          for (var ii = 0; ii < geom2.coordinates.length; ii++) {
              if (isPointOnLineEnd(geom1, {type: 'LineString', coordinates: geom2.coordinates[ii]})) foundTouchingPoint = true;
          }
          return foundTouchingPoint
        case 'Polygon':
          for (var i = 0; i < geom2.coordinates.length; i++) {
              if (booleanPointOnLine(geom1, {type:'LineString', coordinates: geom2.coordinates[i]})) return true;
          }
          return false
        case 'MultiPolygon':
            for (var i = 0; i < geom2.coordinates.length; i++) {
                for (var ii = 0; ii < geom2.coordinates[i].length; ii++) {
                    if (booleanPointOnLine(geom1, {type:'LineString', coordinates: geom2.coordinates[i][ii]})) return true;
                }
            }
            return false;
        default:
            throw new Error('feature2 ' + type2 + ' geometry not supported');
        }
    case 'MultiPoint':
        switch (type2) {
        case 'LineString':
          var foundTouchingPoint = false;
github Turfjs / turf / packages / turf-boolean-touches / index.ts View on Github external
function isLineOnLine(lineString1, lineString2) {
    for (var i = 0; i < lineString1.coordinates.length; i++) {
        if (!booleanPointOnLine(lineString1.coordinates[i], lineString2)) {
            return false;
        }
    }
    return true;
}
github Turfjs / turf / packages / turf-boolean-within / index.ts View on Github external
function isLineOnLine(lineString1, lineString2) {
    for (var i = 0; i < lineString1.coordinates.length; i++) {
        if (!booleanPointOnLine(lineString1.coordinates[i], lineString2)) {
            return false;
        }
    }
    return true;
}
github Turfjs / turf / packages / turf-boolean-contains / index.ts View on Github external
default:
            throw new Error("feature2 " + type2 + " geometry not supported");
        }
    case "MultiPoint":
        switch (type2) {
        case "Point":
            return isPointInMultiPoint(geom1, geom2);
        case "MultiPoint":
            return isMultiPointInMultiPoint(geom1, geom2);
        default:
            throw new Error("feature2 " + type2 + " geometry not supported");
        }
    case "LineString":
        switch (type2) {
        case "Point":
            return isPointOnLine(geom2, geom1, {ignoreEndVertices: true});
        case "LineString":
            return isLineOnLine(geom1, geom2);
        case "MultiPoint":
            return isMultiPointOnLine(geom1, geom2);
        default:
            throw new Error("feature2 " + type2 + " geometry not supported");
        }
    case "Polygon":
        switch (type2) {
        case "Point":
            return booleanPointInPolygon(geom2, geom1, {ignoreBoundary: true});
        case "LineString":
            return isLineInPoly(geom1, geom2);
        case "Polygon":
            return isPolyInPoly(geom1, geom2);
        case "MultiPoint":
github Turfjs / turf / packages / turf-boolean-contains / index.ts View on Github external
export function isMultiPointOnLine(lineString: LineString, multiPoint: MultiPoint) {
    let haveFoundInteriorPoint = false;
    for (const coord of multiPoint.coordinates) {
        if (isPointOnLine(coord, lineString, {ignoreEndVertices: true})) {
            haveFoundInteriorPoint = true;
        }
        if (!isPointOnLine(coord, lineString)) {
            return false;
        }
    }
    if (haveFoundInteriorPoint) {
        return true;
    }
    return false;
}
github Turfjs / turf / packages / turf-boolean-within / index.ts View on Github external
function isMultiPointOnLine(multiPoint, lineString) {
    var foundInsidePoint = false;

    for (var i = 0; i < multiPoint.coordinates.length; i++) {
        if (!booleanPointOnLine(multiPoint.coordinates[i], lineString)) {
            return false;
        }
        if (!foundInsidePoint) {
            foundInsidePoint = booleanPointOnLine(multiPoint.coordinates[i], lineString, {ignoreEndVertices: true});
        }
    }
    return foundInsidePoint;
}

@turf/boolean-point-on-line

turf boolean-point-on-line module

MIT
Latest version published 3 years ago

Package Health Score

74 / 100
Full package analysis

Popular @turf/boolean-point-on-line functions