English 中文(简体)
How to check if geocode is close to or on path defined in a KML LineString with PHP or MySQL
原标题:

I have a KML file defining several paths/routes (representing actual roads) enclosed in the <LineString><coordinates></coordinates></LineString> tags. Parsing the file to other formats (arrays/MySQL) is already in place, so that s not a problem.

Given a point (longitude/latitude) I would like to be able to check if the point is on or close to (within a few meters) one of the routes in the KML file. I ve been looking for a solution in PHP, but I haven t been able to find one - and I m not really sure, what I m looking for. This does however seem to me like a common problem, so I suspect someone already solved the problem. Does anybody know of a solution? ;)

Thanks in advance!

最佳回答

You need to break this down into two problems:

  • Generate a set of polygons from each section of your path.
  • Do a simple point in polygon test on the above polygons.

There should be some php out there to accomplish those two tasks.

问题回答

pnpoly is actually quite fast if done correctly. I wrote a check against many hundreds of thousands of polygon vertices in MySQL well under second processing. Pulling the data into PHP and performing the pnpoly loop there can do it in not a whole lot more time.

Post the code you re using?





相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...

热门标签