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

TypeScript line-intersect.default函数代码示例

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

本文整理汇总了TypeScript中@turf/line-intersect.default函数的典型用法代码示例。如果您正苦于以下问题:TypeScript default函数的具体用法?TypeScript default怎么用?TypeScript default使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了default函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: booleanValid

/**
 * booleanValid checks if the geometry is a valid according to the OGC Simple Feature Specification.
 *
 * @name booleanValid
 * @param {Geometry|Feature<any>} feature GeoJSON Feature or Geometry
 * @returns {boolean} true/false
 * @example
 * var line = turf.lineString([[1, 1], [1, 2], [1, 3], [1, 4]]);
 *
 * turf.booleanValid(line); // => true
 * turf.booleanValid({foo: "bar"}); // => false
 */
export default function booleanValid(feature: Feature<any> | Geometry) {
    // Automatic False
    if (!feature.type) return false;

    // Parse GeoJSON
    const geom = getGeom(feature);
    const type = geom.type;
    const coords = geom.coordinates;

    switch (type) {
    case 'Point':
        return coords.length > 1;
    case 'MultiPoint':
        for (var i = 0; i < coords.length; i++) {
            if (coords[i].length < 2) return false;
        }
        return true;
    case 'LineString':
        if (coords.length < 2) return false
        for (var i = 0; i < coords.length; i++) {
            if (coords[i].length < 2) return false;
        }
        return true;
    case 'MultiLineString':
        if (coords.length < 2) return false
        for (var i = 0; i < coords.length; i++) {
            if (coords[i].length < 2) return false;
        }
        return true;
    case 'Polygon':
        for (var i = 0; i < geom.coordinates.length; i++) {
            if (coords[i].length < 4) return false
            if (!checkRingsClose(coords[i])) return false
            if (checkRingsForSpikesPunctures(coords[i])) return false
            if (i > 0) {
                if (lineIntersect(polygon([coords[0]]), polygon([coords[i]])).features.length > 1) return false
            }
        }
        return true
    case 'MultiPolygon':
        for (var i = 0; i < geom.coordinates.length; i++) {
            var poly: any = geom.coordinates[i];

            for (var ii = 0; ii < poly.length; ii++) {
                if (poly[ii].length < 4) return false
                if (!checkRingsClose(poly[ii])) return false
                if (checkRingsForSpikesPunctures(poly[ii])) return false
                if (ii === 0) {
                    if (!checkPolygonAgainstOthers(poly, geom.coordinates, i)) return false
                }
                if (ii > 0) {
                    if (lineIntersect(polygon([poly[0]]), polygon([poly[ii]])).features.length > 1) return false
                }
            }
        }
        return true
    default: return false;
    }
}
开发者ID:Turbo87,项目名称:turf,代码行数:71,代码来源:index.ts


示例2: isLineOnLine

function isLineOnLine(lineString1, lineString2) {
    var doLinesIntersect = lineIntersect(lineString1, lineString2);
    if (doLinesIntersect.features.length > 0) {
        return true;
    }
    return false;
}
开发者ID:OlympicsORG,项目名称:turf,代码行数:7,代码来源:index.ts


示例3: doLineStringAndPolygonCross

function doLineStringAndPolygonCross(lineString, polygon: Polygon) {
    const line: any = polygonToLine(polygon);
    const doLinesIntersect = lineIntersect(lineString, line);
    if (doLinesIntersect.features.length > 0) {
        return true;
    }
    return false;
}
开发者ID:Turbo87,项目名称:turf,代码行数:8,代码来源:index.ts


示例4: isLineInPoly

function isLineInPoly(polygon, lineString) {
    for (var i = 0; i < lineString.coordinates.length; i++) {
        if (booleanPointInPolygon(lineString.coordinates[i], polygon)) {
            return true;
        }
    }
    var doLinesIntersect = lineIntersect(lineString, polygonToLine(polygon));
    if (doLinesIntersect.features.length > 0) {
        return true;
    }
    return false;
}
开发者ID:OlympicsORG,项目名称:turf,代码行数:12,代码来源:index.ts


示例5: 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


示例6: flattenEach

    flattenEach(lines, function (line: any) {
        const coords: any = getCoords(line);

        for (let i = 0; i < coords.length - 1; i++) {
            //start
            const start = point(coords[i]);
            start.properties.dist = distance(pt, start, options);
            //stop
            const stop = point(coords[i + 1]);
            stop.properties.dist = distance(pt, stop, options);
            // sectionLength
            const sectionLength = distance(start, stop, options);
            //perpendicular
            const heightDistance = Math.max(start.properties.dist, stop.properties.dist);
            const direction = bearing(start, stop);
            const perpendicularPt1 = destination(pt, heightDistance, direction + 90, options);
            const perpendicularPt2 = destination(pt, heightDistance, direction - 90, options);
            const intersect = lineIntersects(
                lineString([perpendicularPt1.geometry.coordinates, perpendicularPt2.geometry.coordinates]),
                lineString([start.geometry.coordinates, stop.geometry.coordinates])
            );
            let intersectPt = null;
            if (intersect.features.length > 0) {
                intersectPt = intersect.features[0];
                intersectPt.properties.dist = distance(pt, intersectPt, options);
                intersectPt.properties.location = length + distance(start, intersectPt, options);
            }

            if (start.properties.dist < closestPt.properties.dist) {
                closestPt = start;
                closestPt.properties.index = i;
                closestPt.properties.location = length;
            }
            if (stop.properties.dist < closestPt.properties.dist) {
                closestPt = stop;
                closestPt.properties.index = i + 1;
                closestPt.properties.location = length + sectionLength;
            }
            if (intersectPt && intersectPt.properties.dist < closestPt.properties.dist) {
                closestPt = intersectPt;
                closestPt.properties.index = i;
            }
            // update length
            length += sectionLength;
        }

    });
开发者ID:Turbo87,项目名称:turf,代码行数:47,代码来源:index.ts


示例7: 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


示例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: 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


示例9: doLineStringsCross

function doLineStringsCross(lineString1, lineString2) {
    var doLinesIntersect = lineIntersect(lineString1, lineString2);
    if (doLinesIntersect.features.length > 0) {
        for (var i = 0; i < lineString1.coordinates.length - 1; i++) {
            for (var i2 = 0; i2 < lineString2.coordinates.length - 1; i2++) {
                var incEndVertices = true;
                if (i2 === 0 || i2 === lineString2.coordinates.length - 2) {
                    incEndVertices = false;
                }
                if (isPointOnLineSegment(lineString1.coordinates[i], lineString1.coordinates[i + 1], lineString2.coordinates[i2], incEndVertices)) {
                    return true;
                }
            }
        }
    }
    return false;
}
开发者ID:Turbo87,项目名称:turf,代码行数:17,代码来源:index.ts


示例10: segmentEach

 segmentEach(feature2, (segment2) => {
     if (lineIntersect(segment1, segment2).features.length) overlap++;
 });
开发者ID:Turbo87,项目名称:turf,代码行数:3,代码来源:index.ts



注:本文中的@turf/line-intersect.default函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript line-segment.default函数代码示例发布时间:2022-05-28
下一篇:
TypeScript invariant.getType函数代码示例发布时间: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