【问题标题】:Point In Polygon using T-Sql使用 T-Sql 在多边形中点
【发布时间】:2013-11-13 09:34:49
【问题描述】:

我正在创建一个地图应用程序,用户可以在 Google 地图上以交互方式绘制多边形。

我需要将此多边形数据发送回 Sql Server,并根据多边形内数据库中的 LatLng 位置确定要返回哪些记录。

有没有人知道如何执行此操作或可用的例程。 提前致谢

【问题讨论】:

    标签: polygon


    【解决方案1】:

    如果您有一个与您的记录关联的地理列,您可以使用它来查询多边形内的项目。 Link 让您开始。这是一个例子:

    --What Items are within the Bermuda Triangle? 
    ---Note that Well-Known Text representation of a polygon is composed of points defined by Longitude then Latitude.
    ---Note that the points are defined in a counter-clockwise order so that the polygon is the interior of the triangle.  
    DECLARE @BermudaTriangle geography = geography::STPolyFromText
    ('POLYGON((
        -80.190262  25.774252,
        -66.118292 18.466465,
        -64.75737 32.321384,
        -80.190262 25.774252
    ))', 4326)
    
    SELECT ItemID, ReportedGPSPoint.Lat, ReportedGPSPoint.Long
    FROM Items
    WHERE ReportedGPSPoint.STIntersects(@BermudaTriangle) = 1
    

    【讨论】:

    • 非常感谢您的回复。但我遇到的问题是如何以正确的逆时针顺序从谷歌地图上的多边形中获取坐标。
    • 我会说这将是一个单独的问题。将其作为单独的问题发布,使用google-maps tag
    猜你喜欢
    • 1970-01-01
    • 2012-04-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-19
    • 1970-01-01
    相关资源
    最近更新 更多