Sql Server 2008 地理 LineString 大小限制
今天我遇到了 Sql Server 2008 中地理类型 Linestrings
可能存在的大小限制。 当我使用 STGeomFromText()
创建一个包含 567 个点(包含长、纬度和 Z 坐标)的线串时,一切正常。
但是,如果我向线串再添加一个点,我会得到:
ArgumentException 24200:指定的输入不代表有效的地理实例。
我找不到任何有关 sql server 地理类型线串或类似内容的大小限制的文档。
这是地理限制还是只是 STGeomFromtext()
函数的限制? 是否有人有一些更详细信息的链接,或者是解决这个问题的唯一方法,将线串分成几个较小的线串,这些线串组合在一起形成多线串。
如有任何帮助,我们将不胜感激;)
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: The specified input does not represent a valid geography instance.
I was not able to find any documentation regarding size limitations of sql server´s geography type linestrings or something similar.
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.
Any help is appreciated ;)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我还没有听说过 LINESTRING 有任何大小限制(当然不会短至 567 点)。
我刚刚尝试了一个运行良好的示例
(创建 LINESTRING 并计数 1,122 点)。
您的示例是否因任何 567 个点而失败 - 或者只是一组特定的点(您可以与我们分享吗?)。 我想我想知道你的第 568 点是否使你的 GEOGRAPHY 实例大于半球? 例如,如果我通过添加另一个点 (0,0) 来更改示例,这会强制 GEOGRAPHY 太大:
我得到 ArgumentException 24205:指定的输入不代表有效的地理实例,因为它超出了单个半球。 每个地理实例必须适合单个半球。 此错误的一个常见原因是多边形的环方向错误。这显然与您不完全相同的错误 - 但我想无论如何我都会提出它 >[跳到最后的更新以获得更好的想法]
我的第二个问题是:它是否适用于 GEOMETRY 数据类型? 例如。 如果我将上面的“破坏”示例更改为使用 GEOMETRY 那么它可以正常工作:
如果您可以发布有关您的特定问题的更多详细信息,它可能会提示潜在的问题。 您还可以补充一下,您是在 SQL Management Studio 中输入点还是通过代码(是 C# 和 SQL 数据类型程序集)输入点吗? 您收到的错误消息的全文是什么(如果超出您上面引用的内容 - 请参阅我的错误)。
但简短的回答是“我不认为有 567 分的限制”。
更新: Ed's post 包含您得到的确切错误(System.ArgumentException:24200) - 所以如果您可以让您的数据工作相反,GEOMETRY 可能值得一试:
I haven't heard about any size limitations on LINESTRING (certainly not as short as 567 points).
I just tried an example
which worked fine (creates the LINESTRING and counts 1,122 points).
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:
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]
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:
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).
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:
看来,地理线串不能包含超过有限数量的自交点。
该示例产生完全相同的错误。 边 (2 0, 3 0) 和 (3 0, 2 0) 的交集包含无限多个点。
相同的结果:
It seems, that geography linestring can't contain more then finite number of self intersection points.
This sample produces exact same error. Intersection of edges (2 0, 3 0) and (3 0, 2 0) contains of infinite number of points.
Same result for:
天哪,克雷格,
谢谢你的快速回答。 我遇到过一系列非常奇怪的行为。 例如。 提到的线串无法读入地理类型,但它可以使用几何类型。 但是,我可以选择生成的几何对象,并可以在 Management Studio 内的空间结果选项卡中查看它。 如果我在此几何对象上调用 .STNumPoints() 方法,则会出现以下异常:
如果我在调用 STNumPoints() 之前在此几何对象上调用 MakeValid(),则一切正常。 仅选择几何图形并显示它并不需要 MakeValid。
相同的数据无法读入地理类型。 如果最后一个坐标点被删除,它就像魅力一样。
我尝试执行的示例数据是:
恕我直言,它不超过一个半球。 它甚至不是一个很大的区域。
只要您不调用 STNumPoints() 或 STDistance() 之类的方法,将 @g 设置为几何并使用几何而不是 goography 调用 STGeomFromText 静态方法就可以了。
这真的很令人困惑......
编辑:
我刚刚遇到了一个更短的线串失败了。 删除最后一个点会产生有效的地理对象,而以下语句会失败:
即此 Linestring 在 24(!!!!) 点时失败,但在 23 点时有效。
如果有人知道问题可能是什么......我会有点沮丧。 附近的点太多可能是第一个线串出现的原因,但我无法相信彼此太靠近的 24 个点可能会导致此错误。
Hell Craig,
thanks for your quick answer. I´ve encountered a set of really strange behaviors. Eg. the mentioned linestring cannot be read into a geography type, but it works using geometry type. However, i can select the resulting geometry object and can view it in the spatial results tab within management studio. if i call the .STNumPoints() method on this geometry object i get the following exception :
if i call MakeValid() on this geometry object before calling STNumPoints(), everything works fine. MakeValid is not needed to just select the geometry and display it.
the same data cannot be read into a geography type. if the last coordinate points is removed it works like charm.
the sample data i tried to execute is :
which does IMHO not exceed a single hemisphere. It´s not even a big area.
setting @g as geometry and calling the STGeomFromText static method with geometry instead of goegraphy works as long as you do not call methods like STNumPoints() or STDistance() on it.
this is getting really confusing...
edit:
I´ve just encountered an even shorter Linestring that fails. removing the last point results in a valid geography object wherease the following statement fails:
i.e. that this Linestring fails with 24(!!!!) points and works with 23.
If anyone has an idea what the problem might be...i´m getting somewhat frustrated. Too much nearby points would have been a reason for the first linestring, but i just cannot believe that 24 points that are too near to each other may lead to this error.
确保您的数据不会造成 8 字形。 地理上的线不能相互交叉。
我还没有尝试过你的数据,但我想这很可能是问题所在。 我曾经从某人那里获取了大量的地图数据,发现我的几个国家(如加拿大、俄罗斯、英国)无法转换为地理位置,当我调查时,这只是偶尔出现的数字 8 的情况正在进行中。
即......越过边界的一部分,它试图折回自身,然后重新越过边界。
我只是在这里猜测,请注意...如果我今天有时间,我会获取您的数据并进行更多调查 - 不过时间是杀手。
抢
Make sure you don't cause a figure-8 with your data. A geography can't have its lines cross each other.
I haven't tried your data yet, but I imagine it could well be the problem. I once grabbed a ton of map data from someone, and found that several of my countries (like Canada, Russia, the UK) couldn't be converted into geographies, and when I investigated, it was down to the occasional figure-8 thing going on.
Ie... coming across a part of the border where it tries to double back on itself and then re-cross the border.
I'm just guessing here, mind you... if I have time today I'll grab your data and do some more investigation - time's the killer though.
Rob