SQL空间的多边形内而外 [英] SQL Spatial polygon inside out

查看:220
本文介绍了SQL空间的多边形内而外的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我允许用户通过点击绘制画在Silverlight多边形。然后通过点我环路,将它们转换为经度和纬度,然后保存到SQL(在地理位置列)。

I am allowing users to draw a polygon in Silverlight by clicking to draw. Then I loop through the points, convert them to longitude and latitude and then save to SQL (in a geography column).

现在的问题是,因为世界是正圆形和所有的,它只有在用户按顺时针方向画作品。否则,它试图使多边形右轮世界和失败。

The problem is that because of the world being round and all that, it only works if the user draws clockwise. Otherwise it tries to make the polygon right round the world and fails.

那么,如何做到这一点是否正确?我一定要找出他们正在绘制哪种方式,如果是的话怎么办?

So how do I do this correctly? Do I have to work out which way they are drawing, and if so how?

推荐答案

您可以检查的结果 EnvelopeAngle()方法地理为180,然后用在 ReorientObject()功能进行校正。

You can check if the result of the EnvelopeAngle() method for the geography was 180, then use the ReorientObject() function to correct it.

下面是示例:

--A CW polygon
DECLARE @G3 GEOGRAPHY = 'POLYGON ((45 45, 44 45, 44 46, 45 46, 45 45))';    
SELECT @G3.EnvelopeAngle();                --180
SELECT @G3.ReorientObject().STAsText();    --POLYGON ((44 46, 44 45, 45 45, 45 46, 44 46))

这篇关于SQL空间的多边形内而外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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