• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript boolean-point-in-polygon.default函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript boolean-point-on-line.default函数代码示例发布时间:2022-05-28
下一篇:
TypeScript bearing.default函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap