寻找最近的边(多边形) [英] Find Nearest Sides (Polygon)

查看:83
本文介绍了寻找最近的边(多边形)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为所有sql粉丝设置了一个谜题。


想象一个有12个边的多边形(SideA,SideB,SideC等)


在这个多边形内有96个点(Pt1,Pt2,Pt3等)。


现在让我说我有一个表,每个点到每一边的距离
距离

Pt1 SideA 25.6683

Pt1 SideB 37.6778

Pt1 SideC 576.8383

Pt2 SideA 352.2652

Pt2 SideB 3.8953

Pt2 SideC 46.9563






我需要做的是,对于每个点,找到最近的两个边。所以我需要对点名进行排序,找到该点的距离中的两个最小值,并报告一侧。


我该怎么做?我们很难用正确的语法包裹我们的大脑。


感谢您的帮助!

I have a puzzle for all you sql fans.

Imagine a polygon with 12 sides (SideA, SideB, SideC, etc)

Within this polygon are 96 points (Pt1, Pt2, Pt3, etc).

Now let''s say I have a table that has the distances from each point to each side
Point Side Distance
Pt1 SideA 25.6683
Pt1 SideB 37.6778
Pt1 SideC 576.8383
Pt2 SideA 352.2652
Pt2 SideB 3.8953
Pt2 SideC 46.9563


etc.

What I need to do is, for each point, find the two closest sides. So I need to sort on point name, find the two minimum values in Distance for that point, and report the side.

How do I do this? We are having a hard time wrapping our brains around the correct syntax.

Thanks for any help!

推荐答案


我为你所有的sql粉丝都有一个谜题。


想象一个有12个边的多边形(SideA,SideB,SideC等)


在这个多边形内有96个点(Pt1,Pt2,Pt3等)。


现在让我们说我有一张桌子从每个点到每一侧的距离
距离

Pt1 SideA 25.6683

Pt1 SideB 37.6778

Pt1 SideC 576.8383

Pt2 SideA 352.2652

Pt2 SideB 3.8953

Pt2 SideC 46.9563 <无线电通信/>





我需要做的是,对于每个点,找到最近的两个边。所以我需要对点名进行排序,找到该点的距离中的两个最小值,并报告一侧。


我该怎么做?我们很难用正确的语法包裹我们的大脑。


感谢您的帮助!
I have a puzzle for all you sql fans.

Imagine a polygon with 12 sides (SideA, SideB, SideC, etc)

Within this polygon are 96 points (Pt1, Pt2, Pt3, etc).

Now let''s say I have a table that has the distances from each point to each side
Point Side Distance
Pt1 SideA 25.6683
Pt1 SideB 37.6778
Pt1 SideC 576.8383
Pt2 SideA 352.2652
Pt2 SideB 3.8953
Pt2 SideC 46.9563


etc.

What I need to do is, for each point, find the two closest sides. So I need to sort on point name, find the two minimum values in Distance for that point, and report the side.

How do I do this? We are having a hard time wrapping our brains around the correct syntax.

Thanks for any help!



我不认为导出基于代码的解决方案会有什么问题,但SQL是我的弱点。我想象它必须涉及一个子查询,类似于:

I don''t think that it would be much of a problem to derive a code based solution, but SQL is my weakness. I''m imagine that it would have to involve a Sub-Query, something along the lines of:

展开 | 选择 | Wrap | 行号


尝试这个

Try This

展开 | 选择 | Wrap | 行号


我会有一个一旦我得到1/2小时左右的备用,我就看看这个。


在同一时间,请告知我们迄今为止提交的任何建议是否有效(可能救我的努力;))。
I''ll have a look at this as soon as I get a spare 1/2 an hour or so.

In the mean-time, let us know if any of the suggestions so far submitted work (may save me the effort ;)).


这篇关于寻找最近的边(多边形)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆