當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript boolean-point-in-polygon.default函數代碼示例

本文整理匯總了TypeScript中@turf/boolean-point-in-polygon.default函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript default函數的具體用法?TypeScript default怎麽用?TypeScript default使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了default函數的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: booleanContains

/**
 * Boolean-contains returns True if the second geometry is completely contained by the first geometry.
 * The interiors of both geometries must intersect and, the interior and boundary of the secondary (geometry b)
 * must not intersect the exterior of the primary (geometry a).
 * Boolean-contains returns the exact opposite result of the `@turf/boolean-within`.
 *
 * @name booleanContains
 * @param {Geometry|Feature<any>} feature1 GeoJSON Feature or Geometry
 * @param {Geometry|Feature<any>} feature2 GeoJSON Feature or Geometry
 * @returns {boolean} true/false
 * @example
 * var line = turf.lineString([[1, 1], [1, 2], [1, 3], [1, 4]]);
 * var point = turf.point([1, 2]);
 *
 * turf.booleanContains(line, point);
 * //=true
 */
export default function booleanContains(feature1: Feature<any> | Geometry, feature2: Feature<any> | Geometry) {
    const geom1 = getGeom(feature1);
    const geom2 = getGeom(feature2);
    const type1 = geom1.type;
    const type2 = geom2.type;
    const coords1 = geom1.coordinates;
    const coords2 = geom2.coordinates;

    switch (type1) {
    case "Point":
        switch (type2) {
        case "Point":
            return compareCoords(coords1, coords2);
        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":
            return isMultiPointInPoly(geom1, geom2);
        default:
            throw new Error("feature2 " + type2 + " geometry not supported");
        }
    default:
        throw new Error("feature1 " + type1 + " geometry not supported");
    }
}
開發者ID:Turbo87,項目名稱:turf,代碼行數:70,代碼來源:index.ts

示例2: booleanContains

/**
 * Boolean-contains returns True if the second geometry is completely contained by the first geometry.
 * The interiors of both geometries must intersect and, the interior and boundary of the secondary (geometry b)
 * must not intersect the exterior of the primary (geometry a).
 * Boolean-contains returns the exact opposite result of the `@turf/boolean-within`.
 *
 * @name booleanContains
 * @param {Geometry|Feature<any>} feature1 GeoJSON Feature or Geometry
 * @param {Geometry|Feature<any>} feature2 GeoJSON Feature or Geometry
 * @returns {boolean} true/false
 * @example
 * var line = turf.lineString([[1, 1], [1, 2], [1, 3], [1, 4]]);
 * var point = turf.point([1, 2]);
 *
 * turf.booleanContains(line, point);
 * //=true
 */
export default function booleanContains(feature1: Feature<any> | Geometry, feature2: Feature<any> | Geometry) {
    const geom1 = getGeom(feature1);
    const geom2 = getGeom(feature2);
    const type1 = getType(feature1);
    const type2 = getType(feature2);
    const coords1 = getCoords(feature1);
    const coords2 = getCoords(feature2);

    switch (type1) {
    case 'Point':
        switch (type2) {
        case 'Point':
            return compareCoords(coords1, coords2);
        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':
            return isMultiPointInPoly(geom1, geom2);
        default:
            throw new Error('feature2 ' + type2 + ' geometry not supported');
        }
    default:
        throw new Error('feature1 ' + type1 + ' geometry not supported');
    }
}
開發者ID:OlympicsORG,項目名稱:turf,代碼行數:70,代碼來源:index.ts

示例3: disjoint

/**
 * Disjoint operation for simple Geometries (Point/LineString/Polygon)
 *
 * @private
 * @param {Geometry<any>} geom1 GeoJSON Geometry
 * @param {Geometry<any>} geom2 GeoJSON Geometry
 * @returns {boolean} true/false
 */
function disjoint(geom1, geom2) {
    switch (geom1.type) {
    case 'Point':
        switch (geom2.type) {
        case 'Point':
            return !compareCoords(geom1.coordinates, geom2.coordinates);
        case 'LineString':
            return !isPointOnLine(geom2, geom1);
        case 'Polygon':
            return !booleanPointInPolygon(geom1, geom2);
        }
        /* istanbul ignore next */
        break;
    case 'LineString':
        switch (geom2.type) {
        case 'Point':
            return !isPointOnLine(geom1, geom2);
        case 'LineString':
            return !isLineOnLine(geom1, geom2);
        case 'Polygon':
            return !isLineInPoly(geom2, geom1);
        }
        /* istanbul ignore next */
        break;
    case 'Polygon':
        switch (geom2.type) {
        case 'Point':
            return !booleanPointInPolygon(geom2, geom1);
        case 'LineString':
            return !isLineInPoly(geom1, geom2);
        case 'Polygon':
            return !isPolyInPoly(geom2, geom1);
        }
    }
}
開發者ID:OlympicsORG,項目名稱:turf,代碼行數:43,代碼來源:index.ts

示例4: isMultiPointInPoly

function isMultiPointInPoly(multiPoint, polygon) {
    var output = true;
    var oneInside = false;
    for (var i = 0; i < multiPoint.coordinates.length; i++) {
        var isInside = booleanPointInPolygon(multiPoint.coordinates[1], polygon);
        if (!isInside) {
            output = false;
            break;
        }
        if (!oneInside) {
            isInside = booleanPointInPolygon(multiPoint.coordinates[1], polygon, {ignoreBoundary: true});
        }
    }
    return output && isInside;
}
開發者ID:OlympicsORG,項目名稱:turf,代碼行數:15,代碼來源:index.ts

示例5: isPolyInPoly

/**
 * Is Polygon (geom1) in Polygon (geom2)
 * Only takes into account outer rings
 * See http://stackoverflow.com/a/4833823/1979085
 *
 * @private
 * @param {Geometry|Feature<Polygon>} feature1 Polygon1
 * @param {Geometry|Feature<Polygon>} feature2 Polygon2
 * @returns {boolean} true/false
 */
function isPolyInPoly(feature1: Polygon, feature2: Polygon) {
    for (const coord1 of feature1.coordinates[0]) {
        if (booleanPointInPolygon(coord1, feature2)) {
            return true;
        }
    }
    for (const coord2 of feature2.coordinates[0]) {
        if (booleanPointInPolygon(coord2, feature1)) {
            return true;
        }
    }
    const doLinesIntersect = lineIntersect(polygonToLine(feature1), polygonToLine(feature2));
    if (doLinesIntersect.features.length > 0) {
        return true;
    }
    return false;
}
開發者ID:Turbo87,項目名稱:turf,代碼行數:27,代碼來源:index.ts

示例6: booleanPointInPolygon

 fences.filter(fence => {
   if (fence.geojson) { // some fences are incomplete
     // todo: first fastpass with fence bounding boxes
     // https://github.com/mourner/flatbush
     let poly = turfhelp.polygon(fence.geojson.coordinates)
     return booleanPointInPolygon(pt, poly)
   }
 }))
開發者ID:icecondor,項目名稱:api,代碼行數:8,代碼來源:api.ts

示例7: isMultiPointInPoly

export function isMultiPointInPoly(polygon: Polygon, multiPoint: MultiPoint) {
    for (const coord of multiPoint.coordinates) {
        if (!booleanPointInPolygon(coord, polygon, {ignoreBoundary: true})) {
            return false;
        }
    }
    return true;
}
開發者ID:Turbo87,項目名稱:turf,代碼行數:8,代碼來源:index.ts

示例8: isPolyInPoly

/**
 * Is Polygon (geom1) in Polygon (geom2)
 * Only takes into account outer rings
 * See http://stackoverflow.com/a/4833823/1979085
 *
 * @private
 * @param {Geometry|Feature<Polygon>} feature1 Polygon1
 * @param {Geometry|Feature<Polygon>} feature2 Polygon2
 * @returns {boolean} true/false
 */
function isPolyInPoly(feature1, feature2) {
    for (var i = 0; i < feature1.coordinates[0].length; i++) {
        if (booleanPointInPolygon(feature1.coordinates[0][i], feature2)) {
            return true;
        }
    }
    for (var i2 = 0; i2 < feature2.coordinates[0].length; i2++) {
        if (booleanPointInPolygon(feature2.coordinates[0][i2], feature1)) {
            return true;
        }
    }
    var doLinesIntersect = lineIntersect(polygonToLine(feature1), polygonToLine(feature2));
    if (doLinesIntersect.features.length > 0) {
        return true;
    }
    return false;
}
開發者ID:OlympicsORG,項目名稱:turf,代碼行數:27,代碼來源:index.ts

示例9: isLineInPoly

function isLineInPoly(polygon: Polygon, lineString: LineString) {
    for (const coord of lineString.coordinates) {
        if (booleanPointInPolygon(coord, polygon)) {
            return true;
        }
    }
    const doLinesIntersect = lineIntersect(lineString, polygonToLine(polygon));
    if (doLinesIntersect.features.length > 0) {
        return true;
    }
    return false;
}
開發者ID:Turbo87,項目名稱:turf,代碼行數:12,代碼來源:index.ts


注:本文中的@turf/boolean-point-in-polygon.default函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。