问题描述
我有一组多边形的点(存储为经度/经度),我想在PHP中计算该多边形的经度/经度中心点.
I have a set of points (stored as lat/lon) for a polygon, I want to compute the lat/lon center point of the polygon in PHP.
基本上与Google Maps中的getCenter()函数执行相同的操作 LatLngBounds .
Basically to do the same thing as the getCenter() function in Google Maps LatLngBounds.
关于如何实现这一目标的任何想法?
Any ideas on how I can achieve this?
推荐答案
您正在寻找的是多边形的质心-非常容易计算.如果您使用的是经度/纬度,则由于多边形实际上位于球体(椭圆体)的表面上,因此事情变得复杂了.
What you are looking for is the centroid of the polygon - which is pretty easy to compute. If you are using latitude/longitude the matter is complicated by the fact the the polygon is actually on the surface of a sphere (ellipsoid).
顺便说一句,为什么不只看一下Google api javascript代码?
As an aside, why not just look at the Google api javascript code?
这篇关于在PHP中计算多边形的纬度经度中心点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!