zoukankan      html  css  js  c++  java
  • 面是否包含点的算法

    from arcgis Javascript api:
     
    function polygonContainPoint(pt,polygon) {
        var rings = polygon.rings,
            ring, bresult = false,
            pt1, pt2, ringlength, j, i, indexrings, ringslength = rings.length;
        for (indexrings = 0; indexrings < ringslength; indexrings++) {
            ring = rings[indexrings];
            ringlength = ring.length;
            j = 0;
            for (i = 0; i < ringlength; i++) {
                j++;
                if (j === ringlength) {
                    j = 0;
                }
                pt1 = ring[i];
                pt2 = ring[j];
                if ((pt1[1] < pt.y && pt2[1] >= pt.y || pt2[1] < pt.y && pt1[1] >= pt.y) && (pt1[0] + (pt.y - pt1[1]) / (pt2[1] - pt1[1]) * (pt2[0] - pt1[0]) < pt.x)) {
                    bresult = !bresult;
                }
            }
        }
        return bresult;
    }





  • 相关阅读:
    cookie
    接上一篇
    es6
    本地文件r如何上传到github上
    npm的使用说明
    被公司996下的程序媛心路历程
    起点2020
    ES5(基本包装类型)字符串的方法
    ES5数组的方法
    css伪类
  • 原文地址:https://www.cnblogs.com/Pharaoh/p/3242607.html
Copyright © 2011-2022 走看看