31346

How to check if geocode is close to or on path defined in a KML LineString with PHP or MySQL

Question:

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!

Answer1:

You need to break this down into two problems:

<ul><li>Generate a set of polygons from each section of your path.</li> <li>Do a simple point in polygon test on the above polygons.</li> </ul>

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

Answer2:

pnpoly is actually quite fast if done correctly. I wrote a check against many hundreds of thousands of polygon vertices in MySQL <em>well</em> 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?

Recommend

  • Error: Aesthetics must be either length 1 or the same as the data (4)
  • Parse weird bug in Swift that causes ACL write permissions to change to an objectId
  • R ggplot2 combining geom_tile and coord_map(“moll”)
  • Javascript : access return of other function
  • What is the fastest way to select nearest geographical place from mysql database?
  • Tokenize python source code examples (in Python)
  • How do you open .txt file containing matrix in Matlab?
  • Google map in top corner left
  • Less Conflicting Session Manager for Zope 2
  • In C what exactly happens if i use () to initialize a double dimension array instead of the {}?
  • What Makes These Two Array Adds Different?
  • MYSQ & MVC3 SQL connection error \\ ProviderManifestToken but I am using MySQL
  • Laravel: Getting Session ID oddly truncates when using foreach
  • Does Mobilefirst provide a provision to access web services directly?
  • What does 'Language neutral' mean with regard to MAKELANGID?
  • Excel's Macro-Recorder usage
  • How to use carriage return with multiple line?
  • Moving mysql files across servers
  • Yii2: Config params vs. const/define
  • How to avoid particles glitching together in an elastic particle collision simulator?
  • Recording logins for password protected directories
  • Installing Hadoop, Java Exception about illegal characters at index 7?
  • Android screen density dpi vs ppi
  • Splitting given String into two variables - php
  • Different response to non-authenticated users and AJAX calls
  • How would I use PHP exceptions to define a redirect?
  • Check if a string to interpolate provides expected placeholders
  • How to extract text from Word files using C#?
  • How to check if every primary key value is being referenced as foreign key in another table
  • Join two tables and save into third-sql
  • How to model a transition system with SPIN
  • Weird JavaScript statement, what does it mean?
  • ORA-29908: missing primary invocation for ancillary operator
  • Comma separated Values
  • need help with bizarre java.net.HttpURLConnection behavior
  • How can I remove ASP.NET Designer.cs files?
  • python draw pie shapes with colour filled
  • Is there any way to bind data to data.frame by some index?
  • How can i traverse a binary tree from right to left in java?
  • Converting MP3 duration time