首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >SqlGeography STIntersect总是返回false

SqlGeography STIntersect总是返回false
EN

Stack Overflow用户
提问于 2014-06-17 17:35:34
回答 1查看 741关注 0票数 1

这个函数我有个问题。如果点在多边形内,我将在Bing地图中检测AJAX。因为必应映射v7 API没有任何函数来检查它,所以我被迫构建自己的代码。从理论上讲,一切都是正确的,但总是返回错误。有什么想法吗?我漏掉了什么?这是我的密码

代码语言:javascript
复制
using System.Data.SqlTypes;
using Microsoft.SqlServer.Types;

...

[WebMethod]
public static bool PointIntersectPolygon(string PoiLat, string PoiLng, string[] PolyArr)
{
    SqlGeography Point;
    SqlGeography PolyGeo;
    string PolyStr = "", LatStr = "", LngStr = "";

    int Cnt=0;
    while(Cnt < PolyArr.Length) {
        LatStr = PolyArr[Cnt];
        LngStr = PolyArr[Cnt + 1];
        PolyStr = PolyStr + LngStr + " " + LatStr;

        Cnt=Cnt+2;
        if (Cnt < PolyArr.Length) { PolyStr = PolyStr + ", "; }
    }

    //Point = SqlGeography.STPointFromText(new SqlChars("point(" + PoiLng + " " + PoiLat + ")"), 4326);
    //PolyGeo = SqlGeography.STPolyFromText(new SqlChars("polygon((" + PolyStr + "))"), 4326);

    Point = SqlGeography.STPointFromText(new SqlChars("point(-95.2267532349 29.6912727356)"), 4326);
    PolyGeo = SqlGeography.STPolyFromText(new SqlChars("polygon((-95.8686820418 30.0354040414, -95.1099929810 30.1058311462, -95.0110397339 29.5988826752, -95.5437927246 29.5567703247, -95.8686820418 30.0354040414))"), 4326);
    MessageBox.Show(PolyGeo.STContains(Point).ToString());

    bool PolyPoi = (bool)PolyGeo.STContains(Point);
    return PolyPoi;
}

我注释掉了一些行,并对硬编码的值进行了检查,结果仍然是一样的。我很确定多边形里面的那个点。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-06-18 20:27:38

Server地理类型使用左手方法。也就是说,当你创建多边形的时候,不管左边是什么,当你把多边形包围起来的时候,都是多边形的内部。

您可以阅读更多内容:SqlGeography:多边形的环定向

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24270046

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档