简体   繁体   English

ST_BUFFER 和 ST_WITHIN 可以用于线串中的线串吗?

[英]Can ST_BUFFER and ST_WITHIN be used for linestrings within a linestring?

I am working with MariaDB and trying to get data based on the condition of linestrings that are within another linestring.我正在使用 MariaDB 并尝试根据另一个线串内的线串条件获取数据。 To allow linestrings not having to be exactly within (due to GPX variability in coordinates), I want to include a buffer.为了允许线串不必完全在其中(由于 GPX 坐标的可变性),我想包含一个缓冲区。

SELECT * FROM tableX WHERE ST_WITHIN(ST_BUFFER( linestring ,r), (SELECT linestring FROM tableY WHERE id=@id) ) SELECT * FROM tableX WHERE ST_WITHIN( linestring ( linestring ,r), (SELECT linestring FROM linestring WHERE id=@id) )

I expect to retrieve at least one row, since this row is also retrieved with the same query without the buffer (so, I would expect this is equal to r=0).我希望至少检索一行,因为这一行也是用相同的查询检索的,没有缓冲区(所以,我希望这等于 r=0)。 However, no matter how small or big r is, I get an empty table .但是,无论 r 有多大或多小,我都会得到一张空表

In the documentation it says that ST_BUFFER applies to all geometry objects, but I have only seen examples with points in either linestrings / polygons.在文档中它说 ST_BUFFER 适用于所有几何对象,但我只看到线串/多边形中的点的示例。 It made me wonder if it is even possible to apply this function to linestrings within a linestring?这让我想知道是否可以将此 function 应用于线串中的线串?

I have found the solution.我找到了解决方案。

First, the ST_BUFFER creates a polygon geometry object so the ST_BUFFER function should be used only for the second argument of ST_WITHIN - since a polygon object can never be within a linestring object by definition. First, the ST_BUFFER creates a polygon geometry object so the ST_BUFFER function should be used only for the second argument of ST_WITHIN - since a polygon object can never be within a linestring object by definition.

Second, the radius should be way smaller than 1 (do not think in integers).其次,半径应该远小于 1(不要以整数计算)。 While visualizing the results, one can see this corresponds to a huge circle range around the linestring.在可视化结果时,可以看到这对应于线串周围的一个巨大的圆圈范围。 The radius I found for my solution was r=0.001.我为我的解决方案找到的半径是 r=0.001。

Hope that it is of help to anyone else.希望它对其他人有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM