1

I have an interesting problem where I want to see if a pair of Latitude/Longitude points are within the region of 4 other specified ones. An application of this is specifying 4 intersections and seeing if the address is within that region. With the Google Maps Geocoding API (http://code.google.com/apis/maps/documentation/geocoding/) it's easy to convert the intersections into the long/lat and if the area is a perfect rectangle it's easy.... but what if the street is curvey? Does something like this already exist?

Kara
  • 6,115
  • 16
  • 50
  • 57
  • There is a LatLngBounds class in the google maps api that has a method called 'contains', it can pass in a LatLng and will return true if it is within those bounds – m.t.bennett Oct 29 '12 at 00:09
  • LatLngBounds is rectangular, and I believe that questioner was asking about what to do if the four points described a quadrilateral that was not rectangular. – Kaitlin Duck Sherwood Mar 27 '13 at 22:28

1 Answers1

0

It sounds like you are looking for a point-in-polygon routine. http://en.wikipedia.org/wiki/Point_in_polygon

There are many implementations of point-in-polygon; if you are using PostGIS for your a database backend, use the ST_Intersects. There is already a question/answer on stackoverflow with code for a point-in-polygon function, see Point in Polygon Algorithm

Community
  • 1
  • 1