如何从地理中获取点的索引?
如何获取 LineString 中的点的索引?
我正在使用 SQL Server 2008 R2。
我确实有一个保存 LineString 的地理类型。
我现在想要获取此 LineString 上两个点的索引。这样我就知道哪个首先发生。
这有可能吗?
因为现在我正在用 while 循环为自己做这件事...但是当我的数据库中有更多数据时它真的很慢:/
编辑: 好吧,现在我'我尝试遵循 SQL 的解决方案来使用 CHARINDEX。
更多背景信息:
我确实有一个地理点,我确实有一个线串。我确实从线串中得到了以我的点为中心的半径的交点。好的,现在我想尝试从 LineString 上的这一点获取第一个交点的索引。
所以我的线串中确实有一些数字,例如这些模式“1.123456或12.123456或123.123456”,我的搜索点也类似于“1.123456或12.123456或123.123456”
问题是< strong>STIntersection 给了我一些不同的数字后面的小数位处可变。我考虑过一些字符串格式,但我不知道应该如何解决这个问题。如果有一些不错的正则表达式功能,我想这会让我的生活更轻松:) 我浏览了所有这些 函数 但找不到任何东西满足我的需求。
也许一些更有经验的人可以帮助我。
谢谢!
How can i get the index of a point which is in my LineString?
I am using SQL Server 2008 R2.
I do have a geography type where a LineString is saved in.
I want now to get the index of two points on this LineString. So that I know which one occurs first.
Is this somehow possible?
Because right now i'm doing it for my self with a while loop... but it's really slow when i've got some more data in my database :/
EDIT: Ok, right now i'm trying to follow the solution from SQL to use CHARINDEX.
Some more background info:
I do have a geo point, I do have a linestring. I did get the intersecting points with a radius around my point from the linestring. Ok, now i want to try to get with the first intersecting point the index from this point on the LineString.
So i do have in my linestring some numbers like these patterns "1.123456 or 12.123456 or 123.123456" and my search point is also something like "1.123456 or 12.123456 or 123.123456"
The Problem is, that STIntersection gives me some different numbers back which are variable at the fractional digits. I thought about some string formatting, but i don't know how i should solve this. If there would be some nice regex features i think it would make my life easyier :)
I had a look through all of these functions but couldn't find anything for my needs.
Maybe some more experienced people could help me with that.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果数据类型是 varchar,则使用。请看下文。
您可以使用 CharIndex
一旦您获得第一个出现点,现在您可以检查另一个出现点。
有关详细信息,您可以查看此处
In case the datatype is varchar used. Please see below.
You can use CharIndex
Once you have got the first occurrence point, Now you can check for another.
For more information you can check here