SQL Server 2008地理LineString大小限制 [英] Sql Server 2008 geography LineString size limitations

查看:157
本文介绍了SQL Server 2008地理LineString大小限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Sql Server 2008中遇到了地理类型Linestrings的可能大小限制. 当我用STGeomFromText()创建一个包含567个包含Long,Lat和Z坐标的点的线串时,一切正常.

today i ran into a possible size limitation of geography type Linestrings within Sql Server 2008. when i create a Linestring with STGeomFromText() that contains 567 points containing Long,Lat and Z coordinates, everything works fine.

但是,如果我在线串上再添加一个点,则会得到一个:

However, if i add one more point to the linestring i get an:

ArgumentException 24200:指定的输入不代表有效的地理实例.

ArgumentException 24200: The specified input does not represent a valid geography instance.

我找不到有关sql server的地理类型行字符串或类似内容的大小限制的任何文档.

I was not able to find any documentation regarding size limitations of sql server´s geography type linestrings or something similar.

这是地理限制还是STGeomFromtext()功能的限制? 没有人有一些指向一些更详细信息的链接,还是解决此问题的唯一方法,那就是将线串分成几个较小的线串,并组合成一个多线串.

Is this a limitation of geography or just of the STGeomFromtext() function? Does anyone has some links to some more detailed information or is the only way to get around this splitting the linestring up into several smaller linestrings grouped together in a multilinestring.

感谢您的帮助;)

推荐答案

我还没有听说过LINESTRING的尺寸限制(肯定不短于567分).

I haven't heard about any size limitations on LINESTRING (certainly not as short as 567 points).

我只是尝试了一个例子

DECLARE @geom GEOGRAPHY
SET @geom = GEOGRAPHY::STGeomFromText(
  'LINESTRING (142.98873903132778 -11.006193013241768
   , 142.9891970000001 -11.005916999999954
   -- SNIP 1,119 points
   , 142.04362479801711 -11.629451936538608 )', 4326)
SELECT @geom, @geom.STNumPoints()

效果很好(创建LINESTRING并计数1,122点).

which worked fine (creates the LINESTRING and counts 1,122 points).

您的示例是否以567分或仅一组特定的点失败(您可以与我们分享这些点)?我想我想知道您的第568个点是否使您的GEOGRAPHY实例大于半球?例如,如果我通过添加另一个点(0,0)来改变我的示例,则该点会迫使GEOGRAPHY太大:

Does your example fail with ANY 567 points - or just a specific set of points (can you share them with us?). I guess I'm wondering whether your 568th point makes your GEOGRAPHY instance larger than a hemisphere? For example, if I change my example by adding another point (0,0) which forces the GEOGRAPHY to be too large:

DECLARE @geom GEOGRAPHY
SET @geom = GEOGRAPHY::STGeomFromText(
  'LINESTRING (142.98873903132778 -11.006193013241768
   , 142.9891970000001 -11.005916999999954
   -- SNIP 1,119 points
   , 142.04362479801711 -11.629451936538608
   , 0 0 )', 4326)         -- ADDED ANOTHER POINT !
SELECT @geom, @geom.STNumPoints()

我得到了 ArgumentException 24205:指定的输入不代表有效的地理实例,因为它超出了一个半球.每个地理实例必须适合一个半球.导致此错误的常见原因是多边形的环向错误.显然,与您的错误不完全相同-但我认为无论如何我都会提出它> [最后跳到UPDATE以获得更好的主意]

I get ArgumentException 24205: The specified input does not represent a valid geography instance because it exceeds a single hemisphere. Each geography instance must fit inside a single hemisphere. A common reason for this error is that a polygon has the wrong ring orientation. which obviously isn't the exact same error as you - but I thought I'd raise it anyway [Skip to the UPDATE at the end for a better idea]

我对您的第二个问题是:它可以与GEOMETRY数据类型一起使用吗?例如.如果我将上面的"breaking"示例更改为使用GEOMETRY,则可以正常工作:

My second question to you is: does it work with the GEOMETRY datatype? Eg. if I change my "breaking" example above to use GEOMETRY then it works fine:

DECLARE @geom GEOMETRY    -- using GEOMETRY type instead
SET @geom = GEOMETRY::STGeomFromText(
  'LINESTRING (142.98873903132778 -11.006193013241768
   , 142.9891970000001 -11.005916999999954
   -- SNIP 1,119 points
   , 142.04362479801711 -11.629451936538608
   , 0 0 )', 4326)         -- THIS POINT BREAKS GEOGRAPHY but works now!
SELECT @geom, @geom.STNumPoints()

如果您可以发布有关特定问题的更多详细信息,则可能表明存在潜在问题.还可以添加是否要在SQL Management Studio中输入点,还是通过代码(是C#和SQL数据类型汇编)来添加点?您收到的错误消息的全文是什么(如果超出上面引用的范围,请参阅我的错误).

If you can post some more details on your specific problem it might suggest the underlying problem. Also could you add whether you are entering the points in SQL Management Studio or via code (is it C# and SQL data types assembly)? What is the full text of the error message you receive (if there is more than what you quoted above - see my error).

但是简短的答案是我认为没有567分的限制".

But the short answer is "I don't think there is a 567-point limit".

更新:

UPDATE: Ed's post contains the exact error you get (System.ArgumentException: 24200) - so if you can get you data working in GEOMETRY instead, this might be worth a try:

...能够获取要转换为的几何 使用以下查询的地理位置:

...able to get the geometry to convert to a geography using the following query:

SELECT dbo.MakeValidGeographyFromGeometry(GEOM.Reduce(.0000001)) FROM ZillowNeighborhoods WHERE ID = 3499

那么这里发生了什么?首先 所有,在减少中使用的公差 方法很小.那么多少 顶点从 还原原始几何图形?事实证明 删除了6个顶点.一种 与SQL Server快速讨论 空间开发商透露 在当前验证过程中 一些非常接近的顶点可以移动 稍微造成边缘 交叉/重叠(请记住 地理边缘不直 线...).在下一个版本的SQL中 服务器(SQL11),我们更改了 基本的方法论并消除了 这个问题.现在,我们将不得不 使用Reduce解决此问题 公差很小.

So what is happening here? First of all, the tolerance used in the Reduce method is very small. So how many vertex points were removed from the original geometry by Reduce? It turns out that 6 vertices were removed. A quick discussion with the SQL Server spatial developers revealed that during current validation processing some very close vertices can shift slightly and cause edges to cross/overlap (remember that geographic edges are not straight lines...). In the next release of SQL Server (SQL11), we have changed the underlying methodology and eliminated this issue. For now, we will have to workaround this issue using Reduce with very small tolerances.

这篇关于SQL Server 2008地理LineString大小限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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