检查Google Map Point是否是PHP中的多边形 [英] Check if Google Map Point is in polygon from PHP

查看:221
本文介绍了检查Google Map Point是否是PHP中的多边形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找一种方法来检查点是否是多边形的一部分;这个多边形从文件加载。



所有与此问题相关的答案都是用javascript解决的,但是我需要在服务器端执行此操作;这是因为不需要将结果显示给用户作为网络客户端,因此需要将其存储起来,并作为参数来选择一个用户(使用该系统)的区域(多边形)。 p>

我在寻找Google Maps API for PHP,但看起来它根本不存在。我发现这一个,但它与Google无关,也重点关注在前端。



我还查找了一个REST API;将内容加载到我的php并解析它将是相对容易的,但是看起来像Google将所有的努力放在JS API上。



有没有任何解决方法这个?



编辑1 :按照@Spacedman的要求,文件格式为KML



澄清1 :我预计Google为此提供了一个工具(与JS存在);解析文件通过算法检查是可行性,我必须检查它是否正常工作。

解决方案

你有没有尝试在您最喜欢的搜索引擎中搜索php point in polygon?热门排名:



http: //assemblysys.com/php-point-in-polygon-algorithm/



它使用扫描线算法,并且有一些示例。所有你需要做的是将你的多边形文件读入正确的格式(你忽略了你所拥有的格式)并调用该函数。


I've been looking for a way to check if a point is part of a polygon; this polygon is loaded from a file.

All the answers related to this question are solved with javascript, but I require to do this on server-side; this because the result does not need to be shown to the user as a webclient, it needs to be stored and later be used as a parameter to select a group of users (that use the system) inside that area (polygon).

I looked for a Google Maps API for PHP but it looks like it does not exists at all. I found this one, but it is not related to Google and also focuses on the front end.

I also looked for a REST API; it would have been relatively easy to load the content to my php and parse it, but looks like Google put all its efforts on the JS API.

Is there any workaround for this?

Edit 1: As @Spacedman requested, the file format is a KML

Clarification 1: I expected that Google provide a tool for this (as it exists with JS); parsing the file to check via an algorithm is a posibility and I'll have to check if it works properly.

解决方案

Did you try searching for "php point in polygon" in your favourite search engine? Top hit:

http://assemblysys.com/php-point-in-polygon-algorithm/

It uses a scanline algorithm, and there's some examples. All you need to do is read your polygon file into the right format (you neglected to say what format you have) and call the function.

这篇关于检查Google Map Point是否是PHP中的多边形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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