首页 > 解决方案 > 使用PHP:从给定点查找多边形中最近的点

问题描述

我有一个由多边形坐标组成的 mysql 表。在另一个表中,我有标记的坐标。我需要找到从标记到多边形的最近点

我正在尝试转换一些算法但没有得到任何地方

查找最接近点的多边形顶点的索引

还尝试转换 javascript 选项

https://gis.stackexchange.com/questions/309515/find-closest-point-using-l-geometryutil-closest-and-open-its-popup

在折线上找到最接近 latlng 的点

但我不知道如何在服务器端 PHP 或 mysql 中实现它

Table 1

Id              Polygon
1               POLYGON((9.99954289860805 44.0511003950809,
                9.99959799860805 44.0510457950809,9.99959799860805 44.0509783950809,
                9.99957439860805 44.0508603950809,9.99961729860804 44.0508873950809,
                9.99971659860803 44.0509201950809,9.999906998608 44.0509567950809,
                10.000177898608 44.0509779950809,10.000272598608 44.0509802950809,
                44.0513239950809,9.99954289860805 44.0511003950809))

Table 2
Id             Marker
1              10.3333333322,45.3222222222

Output
A coordinate inside polygon or one of the coordinate of polygon

标签: phpmysqlalgorithmmapscoordinates

解决方案


推荐阅读