空间查询,将米转换为弧度?

发布于 2024-09-06 22:22:40 字数 305 浏览 3 评论 0原文

我有已加载到地理数据类型中的地理数据。出于非常具体的目的,我现在需要将其存储为几何图形。但是,我需要执行这样的查询。

DECLARE @radius INT -- e.g. 3000 metres

DECLARE @geo geometry -- my starting shape

SET @geo = @geo.STBuffer(@radius) -- this obviously doesnt work.. 

SELECT Geo FROM GeometryTable 
WHERE Geo.STWithin (@geo) = 1

I have geographic data that was loaded into the geography datatype. For very specific purposes, I now need to have store this as a geometry. However, I need to perform a query like this.

DECLARE @radius INT -- e.g. 3000 metres

DECLARE @geo geometry -- my starting shape

SET @geo = @geo.STBuffer(@radius) -- this obviously doesnt work.. 

SELECT Geo FROM GeometryTable 
WHERE Geo.STWithin (@geo) = 1

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

幽蝶幻影 2024-09-13 22:22:40

米是长度的单位,而弧度是角度的单位,所以我认为你不能。

您想计算弧长吗?

请查看以下链接:

Meters are a measure of length while radians are a measure of an angle so i don't think you can.

Are you trying to calculate an arc length?

Take a look at the links below:

§对你不离不弃 2024-09-13 22:22:40

如果有人可以验证该技术或提供更好的替代方案,那么这个技巧可能会起作用,那么他们就会得到可接受的答案。

基本上,我想我可以使用地理的 STBuffer,它将在我的地理形状周围应用正确的半径(以米为单位),然后转换回几何形状。由于形状最初是作为地理加载的,因此所有点都是相同的。这种形状翻转应该会给我一个结果几何图形,周围有一个非常准确的缓冲区。

DECLARE @radius INT -- e.g. 3000 metres

DECLARE @geo geometry -- my starting shape

SET @geo = GEOMETRY::STGeomFromWKB(GEOGRAPHY::STGeomFromWKB(@geo.STAsBinary(),
           4326).STBuffer(@radius).STAsBinary(),4326)

SELECT Geo FROM GeometryTable 
WHERE Geo.STWithin (@geo) = 1

This trick might work, if someone can validate this technique or provide a better alternative then they'll get the accepted answer.

Basically, I am thinking I can use the STBuffer of a geography which will apply the correct radius in metres around my geographical shape and then I convert back to a geometry. As the shapes were loaded originally as geography all the points are the same. This shape-flip should give me a resulting geometry with a pretty accurate buffer around it.

DECLARE @radius INT -- e.g. 3000 metres

DECLARE @geo geometry -- my starting shape

SET @geo = GEOMETRY::STGeomFromWKB(GEOGRAPHY::STGeomFromWKB(@geo.STAsBinary(),
           4326).STBuffer(@radius).STAsBinary(),4326)

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