如何从地理中获取点的索引?

发布于 2024-11-16 21:01:22 字数 956 浏览 4 评论 0原文


如何获取 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

隔岸观火 2024-11-23 21:01:22

如果数据类型是 varchar,则使用。请看下文。

您可以使用 CharIndex

DECLARE @document varchar(64)

SELECT @document = 'abcdef12345wuerzelchen'
SELECT CHARINDEX('abc', @document)

一旦您获得第一个出现点,现在您可以检查另一个出现点。

Declare @position int
Set @position = CHARINDEX('abc', @document)    
SELECT CHARINDEX('wuerzelchen', @document, @position)

有关详细信息,您可以查看此处

In case the datatype is varchar used. Please see below.

You can use CharIndex

DECLARE @document varchar(64)

SELECT @document = 'abcdef12345wuerzelchen'
SELECT CHARINDEX('abc', @document)

Once you have got the first occurrence point, Now you can check for another.

Declare @position int
Set @position = CHARINDEX('abc', @document)    
SELECT CHARINDEX('wuerzelchen', @document, @position)

For more information you can check here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文