0

I'm trying to find the zip codes contained within an MKPolygon overlay. I know it's trivial to find the zip code a coordinate is contained within. What about the area contained by a polygon?

A few approaches I'm considering:

  1. Simply use the zip codes from the coordinates of the line bounding the polygon. The inaccuracy of this method would increase as the polygon area increases.

  2. Check points within the CGPath bounding the polygon, convert to map coordinates, and obtain their zip codes. Though you can check if a path contains a point, you can't get individual points within the path to convert to coordinates (as they'd be too numerous).

  3. Get the locality (city) for one of the points on the line bounding the polygon, get all zip codes within that locality, and check if they intersect the polygon. I'm still investigating how this would actually be implemented.

More/better ideas are much appreciated!

Benjamin Martin
  • 1,795
  • 3
  • 15
  • 17

1 Answers1

1

You'll probably want a geo-specific point-in-polygon search for this for the best accuracy. I'd look into integrating SpatiaLite into your app and load up a zip code polygon database to query against.

incanus
  • 5,100
  • 1
  • 13
  • 20