结合几个DbGeography多边形 [英] combine several DbGeography polygons

查看:69
本文介绍了结合几个DbGeography多边形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找组合多个多边形以减少点数的方法.这是前进的方向吗?

I am looking for ways to combine several polygons to reduce the number of points. Would this be the way forward:

var pol1 = DbGeography.PolygonFromText("POLYGON ((-2.91790532309701 53.3657440952224, -2.91790532309701 53.3567508791632, -2.90283703655041 53.3567508791632, -2.9028338560513 53.3657440952224, -2.91790532309701 53.3657440952224))", 4326);
var pol2 = DbGeography.PolygonFromText("POLYGON ((-2.90283703655041 53.3657440952224, -2.90283703655041 53.3567508791632, -2.88776875000381 53.3567508791632, -2.88776556950469 53.3657440952224, -2.90283703655041 53.3657440952224))", 4326);
var pol3 = DbGeography.PolygonFromText("POLYGON ((-2.91641048851245 53.3747373112816, -2.91641048851245 53.3657440952224, -2.90133902146673 53.3657440952224, -2.90133583925323 53.3747373112816, -2.91641048851245 53.3747373112816))", 4326);

var combined = (pol1.Union(pol2)).Union(pol3);

基本上,如果多边形相互接触,我希望将它们组合在一起.不相交的多边形应保持不相交.

Basically, if the polygons touch each other, I want them to be combined. Disjoint polygons should remain disjoint.

目前,我不确定Union是否实现与TSQL函数STUnion()相同的功能.

At the moment I am not sure whether Union achieves the same as the TSQL function STUnion().

PS:我只是在TSQL中运行STUnion,并注意到它也不会产生预期的结果(即,联合在组合的多边形内包含点).

PS: I just run STUnion in TSQL and noticed that it also does not produce the intended results (i.e. the union contains points within the combined polygon).

推荐答案

这不是我看到的结果.

这是一个查询:

declare @pol1 Geography, @pol2 Geography

set @pol1 = Geography::STPolyFromText('POLYGON ((-2.91790532309701 53.3657440952224, -2.91790532309701 53.3567508791632, -2.90283703655041 53.3567508791632, -2.9028338560513 53.3657440952224, -2.91790532309701 53.3657440952224))', 4326);
set @pol2 = Geography::STPolyFromText('POLYGON ((-2.90283703655041 53.3657440952224, -2.90283703655041 53.3567508791632, -2.88776875000381 53.3567508791632, -2.88776556950469 53.3657440952224, -2.90283703655041 53.3657440952224))', 4326);

select @pol1.STUnion(@pol2)

结果如下:

如果从问题中添加@ pol3,则可能会看到接缝形式.尝试使用几何图形"而不是地理图形"运行查询,接缝将消失.我怀疑那是将其推出的大地之堡,因此,如果使用地理",您可能需要更多的点来将其缝合在一起".

If you add the @pol3 from your question, you might see a seam form. Try running the query with Geometry instead of Geography, and the seam will disappear. I suspect that's the buldge of the earth pushing it out, so you might need more points to 'stitch it together' if using Geography.

(我实际上是想让它不加入,

(I'm actually trying to get it not to join, as described here.)

这篇关于结合几个DbGeography多边形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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