从一组(经度/经度)点计算点的凸包 [英] Calculate Convex Hull of points from a set of (lat/long) points

查看:103
本文介绍了从一组(经度/经度)点计算点的凸包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Google Map开发一个网络应用,该应用通过创建一组给定的地理坐标/点的多边形叠加层来显示覆盖区域"/地理区域".

I am working on a web app with Google Map that I’d like to display a "coverage area"/’ geographical area" by creating a polygon overlay of a given set of geo coordinates/points.

覆盖区域"可以包含数千个地理坐标(经度和纬度数据存储在sql server中的表中).理想情况下,我想从sql服务器数据库(2008 R2)计算凸包点,以便将结果(点)传递给Google Map,以创建多边形叠加层.

The "coverage area" can consist of thousands of the geo coordinates (Longitude and Latitude data stored in a table in sql server). Ideally, I’d like to calculate the Convex Hull points from the sql server database (2008 R2) so I can pass the results (points) to the Google Map to create the polygon overlay.

此处的示例( http://www.geocodezip.com/v3_map-markers_ConvexHull.asp )正是我在寻找的东西,除了我想尽可能从SQL Server直接获得右面板上的船体点.原因是我可能必须处理数千个地理坐标.我不想从数据库中检索大量数据,然后使用JavaScript发送给客户端以计算凸包点.

The sample here (http://www.geocodezip.com/v3_map-markers_ConvexHull.asp) is exactly what I am looking for, except that I’d like to get the hull points on the right-panel straight from the SQL server if possible. The reason is that I may have to process thousands of the geo coordinates. I’d rather not to retrieve a huge amount of data from the database and then send to the client using JavaScript to calculate the convex hull points.

任何帮助将不胜感激!!!

Any help will be very much appreciated!!!

谢谢.

推荐答案

您没有提到您使用的是哪个版本,但是有一个内置的

You didn't mention what version you're on, but there's a built in ConvexHullAggregate starting in SQL 2012 that should do exactly what you're looking for.

这是链接到文档的示例的扩展,该文档获取凸包的角的坐标.假设您有一张周围的数字表(根据我的经验,这是非常有用的事情).

Here's an extension of the example in the linked to documentation that gets the coordinates of the corners of the convex hull. It assumes that you have a table of numbers laying around (a pretty useful thing in my experience).

with cte as (
    SELECT City, geography::ConvexHullAggregate(SpatialLocation) AS Hull
    FROM Person.Address
    WHERE City in ('Ottawa', 'Burnaby')
    group by City
)
select City, Number, Edge.Long as Long, Edge.Lat as Lat
from cte
cross apply (
    select Number, Hull.STPointN(Number) as Edge
    from dbadmin.dbo.Numbers
    where Number < Hull.STNumPoints()
) as HullEdges

这篇关于从一组(经度/经度)点计算点的凸包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆