从mysql数据库中选择最近的多边形或点

时间:2013-09-16 14:00:24

标签: php mysql coordinates polygon

我的桌子上装满了多边形,包括它们的ID,名称,坐标和中心点和类型。 就像:

> id             (int)
> name           (varchar)
> type           (set)
> polygon        (polygon)
> center_point   (point)  

我的多边形就像这样 enter image description here

每个黑色都有一个红色靠近它......没有其他的情感......只是每个黑色都有一个红色靠近它。

我有每个type ='black'多边形的id,我的问题是如何选择最近的type ='red'


编辑:

一些示例数据。 “父母”是黑色多边形之一,“儿童#”是红色多边形中的两个。 我需要找到方法找出哪一个最接近...也许是“center_point”......

---- Parent polygon

polygon : [
                    25,20 ; 
                    60,20 ; 
                    60,45 ;
                    25,45 ; 
                    25,20 ;
                ]
center_point : [
                        45,45
                        ]






---- Children 1

polygon : [
                    10,320;
                    80,320;
                    80,370;
                    10,370;
                    10,320;
                ]
center_point : [
                        45,345
                        ]


---- Children 2

polygon : [
                    490,265;
                    570,265;
                    570,320;
                    490,320;
                    490,265;
                ]
center_point : [
                        530,290
                        ]

0 个答案:

没有答案