A new MKPolygon Catgeory! Intersecting Polygons


Hi all! As my first open source project I decided to add some functionality to the MKPolygon class. MKPolygon, which conforms to MKOverlay has one method to see if it interesects with a MKMapRect but I thought to myself, “hey is that all you can do?” Why can I not test whether I intersect with a non-rectangular object? Why can I not take two MKPolygons and have a method that gives me the union of those?

Introducing a new MKPolygon category, MKPolygon+MKPolygonIntersections that takes two MKPolygons and return to you a new MKPolygon that represents the interesected area (union).

The github project is here: github.com/geeksweep/MKPolygon- … ersections and included is my project file, so you can easily check it out and run it! There are also screenshots available. I have the project set up to run on an iPad so if you want to test it out on the iPhone you’ll have the change the .xib/view controller code or make a new universal project. The view code is just there to give you an idea of how to set everything up in order to use the category. It also should work in the simulator but in the past I have had issues getting overlays to draw correctly.

It has, at this time, some specific limitations that you can check out in the README but its a great start and works great otherwise. You can also check out the blog post about it on geeksweep.com

Let me know what you think! I would like to thank all the material/books/insight from Big Nerd Ranch in helping me understand key concepts that has me to the point of finishing a big project like this one!