Search code examples
google-mapsgoogle-maps-api-3kmlpoint-in-polygon

Point in KML Polygon - C / C++ code


I am looking for C or C++ code to identify whether the point (a co-ordinate) lies inside a KML polygon or not.

I have searched but all I got is javascript (google maps apis) which can achieve the same. I cannot even port it directly because I have a slight modified requirement:

  1. Identify whether given co-ordinate lies within polygon of KML (the code should exclude holes in the polygon too!).
  2. Informing the caller the distance to the nearest polygon edge if the point is outside the range.

As far as I have researched, the 2nd point has not been achieved anywhere yet. I would want to know how to achieve this in C or C++? Or, have I missed searching any existing sources?

Would like to have inputs.


Solution

  • Extended the opensource libkml C++ library and implemented point in polygon in it. This is the source code:

    https://github.com/gumdal/libkml-pointinpolygon

    I am yet to achieve the 2nd point in my question above. Any leads in that matter would be appreciated though :)