My first GitHub project! – A MKPolygon Category – Polygon Intersection!

I am happy to announce my very first open source project that is now on GitHub! You can check out (no pun intended) the repo here and run it in XCode!

I have been playing around the MKMapKit framework for a while and I have solved lots of different types of geo-spatial problems before (in different programming languages) but thought that the geo-spatial functionality, surrounding MKPolygons (which conform to the MKOverlay protocol) was a bit lacking.

If you check out the MKOverlay Protocol Reference you will see that you do have a a method called ‘intersectsMapRect:(MKMapRect) ‘ but then it only tells you whether or not your shape intersects with a rectangular area or not. That could be useful but what if I wanted to test whether two non-rectangular MKPolygons intersected? What if I wanted to do something REALLY crazy and create a brand spanking new MKPolygon that was the result of the union of two non-rectangular MKPolygons? Well, if you have ever wanted to do such a thing, then you are in luck because now there is a MKPolygon category that does just that!

I accomplished this task by using some good old fashioned slope-intercept math (and had to add special test cases) and writing my own custom algorithm to figure out a lot of the rest once I calculated all of the main intersection points.

Below are screenshots from a test, using view controller code. Basically just a MapView and the view controller to handle all of the GUI stuff. When i am done drawing 2 polygons on the map, I then call the category class method to return to me a new MKPolygon and I use that new polygon as a new overlay (colored orange) on the mapview. (see the view controller code for more details).

Screenshot 2013.06.25 13.46.46

Map View

Screenshot 2013.06.25 13.48.32

Drawing Polygon 1 on the map

Screenshot 2013.06.25 13.48.50

Finished Drawing Polygon 1 – Area Filled In

Screenshot 2013.06.25 13.49.28

Drawing Polygon 2

Screenshot 2013.06.25 13.49.43

Finished Drawing Polygon 2 and the intersection of both polygons is calculated and updated on the map!

Let me know what you think!

MapKit Showcase

So I am now on this iOS project at work, that is centered around MapKit framework.  When the app starts you have a split view controller (this app is iPad only). On the left you have a table view and on the right is a map view. Each table view cell represents the location of one of many different types of custom annotations.  When you tap on a certain table view cell, (the mapview pans to the coordinate location of the annotation and a detailed view (a .xib file) is shown to show certain attributes about this annotation. While I cannot mention specifically the type of annotations are available, they are diverse.

What they want to do is have the capability to draw polygons around certain types of annotations and edit the polygons as needed. That’s where I come in. I have worked on iOS projects before using the MapKit framework but not specifically drawing shapes on the map, so this was a fun part of the framework to learn (I obviously don’t know every single method of the entire framework but I have a good feel for lots of it). Anyway, I started working on getting this functionality to work outside of the current project, just as a standalone test app to see how much I could get working/what I could get working before worrying about any integration into the current code base.

The way my code works, is that when you are in drawing mode, every single tap (recognizer) draws a MKCircle overlay at that coordinate and any subsequent tap draws a MKPolyLine overlay so that the user can clearly see what the polygon (MKPolygon) is going to look like. Obviously, with every tap, I update the MKPolyLine overlay accordingly. screenshot below:
Screenshot 2013.05.18 22.58.34Screenshot 2013.05.18 22.59.05Screenshot 2013.05.18 23.03.06When you are finished drawing the polygon you can tap “Done” and voila!… a new polygon has been created (MKPolygon overlay, yellow fill color, alpha of 0.4).

Screenshot 2013.05.18 23.08.33Below is a screenshot of two more polygons that I have added:

Screenshot 2013.05.18 23.16.02

If you expand the last image you will notice that some of the MKPolyLines appear to be jagged. I spent some time searching around to see what this was about and haven’t found an answer yet. If you know, please send me an e-mail or comment. Also, another thing that I have noticed, is that each time I add a new overlay to the map, the other overlays display some sort of “blinking” behavior. I wasn’t sure what was going on here but I did find a few questions about it in the apple dev forums and there seems to be an overlay bug with no solution as of yet. People seem to be claiming that it’s worse in iOS 6 than it was in iOS 5. Just a heads up.

To find out more of what I have accomplished so far, please head on over to the iOS page!

Fatherhood

So this Friday it’s time to join the ranks of being a daddy. As mentioned before, I knew this was coming which is why i wanted to pack as much iOS knowledge in my brain as possible because I didn’t know how much, if any, productive work I would be able to do once our little bundle arrived.

I’ll be taking some maternity leave and I am sure that I will not have time to do any coding so right now I am just going to have to take a break. Who knows when I will be back but it will happen once I start getting sleep again (many others have told me that I won’t get much sleep for a while).

Once I do start getting enough sleep to where I can go to my real job and be productive, come home and do husband/daddy things and still have time/energy for my iOS development I will start posting again.

Pig In A Poke

AndroidDeloitte.001

Brown Bag First Slide Created With KeyNote

I have been working on an outside project at work that is part of ‘practice development and training’ that is required each fiscal year. One of the main purposes, is to teach others and learn new things for yourself as you prepare the material. I also knew it would be a great opportunity to get some experience talking about my code and information gathered with others as I know this is a good skill to have.

You can pick a variety of topics where you contribute to other projects outside of what you are currently working on or create projects that you can share with your co-workers (and management) that might be beneficial to the company.  Since I was initially hired because of my java experience and the fact that they were looking to capture some work in the Android space, I talked with my manager about creating an Android ‘Brown Bag’ presentation that would serve as an introduction to Android at a high level for those in the office that were interested in Android development. It would cover the Android architecture, basic widgets, layouts and how to set up a project in Eclipse. I would also take these concepts and create a couple of sample demos and show them during the  presentation (by hooking up the Xoom tablet to the projector).

The thing was, I had never done any Android development before but as already mentioned, I had a good background in Java development. I’ve also had lots of experience writing custom GUIs and using various other frameworks such as Qt and WxWidgets so I was fairly confident that I could put together something really nice.

I spent a couple of weeks looking through the Android docs and various examples and used that to help me get a few small demos up and running quickly just so that I could have a better feel for the how the layout system works. After about a month, I had a keynote presentation pretty much finished (did I mention that I LOVE keynote?) and a couple of small demos written that consisted of different views on the screen using several different layouts available. This way I had something to show off that could tie in nicely with the presentation side of things.

AndroidDeloitte.002

Brown Bag Topics Covered – Created With Keynote

Even though you can’t see it in the slides I have some pretty awesome animations going on here (did I ever tell you that I LOVE keynote?), which made the presentation that much more interesting. Anyway, I had a few sample demos (mini-demos I called them) finished but I knew that I had time to go the extra mile and create an awesome app that would put all the topics discussed into something a little more advanced than just a small demo. The brown bag was scheduled for March 27th and March 28th (two presentations to get in 2 full groups of people) and I had to have everything done by then on account that my wife and I were pregnant (ok well I wasn’t but you get the idea) and I knew shortly after this date, I would be going on paternity leave.

What followed was an awesome app that I wrote that I know will speak to everyone’s stomach. Please refer to the Android page to find out more!

Coding Like A Maniac

I’ve been building small console apps now for a couple of weeks that implement concepts such as Categories, Blocks, Delegation etc etc as well as making sure I am familiar with built in view objects (i.e. table views). I’ve gained lots of knowledge and insight beyond just core book material that I have in front of me and have also been watching some of the videos from the Fall 2011 Stanford iTunesU iOS course to review some of the advanced topics and demonstrations that I have already watched before.

Even though I am writing iOS applications at work, the objects and views that we write and use are such a small set of what is possible so what better way to branch out and find problems to solve that I don’t make up myself. Cue Google Code Jam to provide some problems to solve in any language that you wish and of course I have been writing and solving some of these problems in Objective-C.

I’ve been having to stay busy with this because I am running out of time being that my wife and I are pregnant and are due sometime in April. I am also starting to design an Android presentation (we call them Brown Bags) that will be used to teach others about Android development at a very high level so that is going to take up some time from me the next couple of months. Meanwhile I still have my work projects. Yikes! Busy times!

Objective-C and iOS Refresher

2013-05-13 23.11.02I’ve been on Christmas vacation now for about a week and won’t go back until some time after the new year so I think that it is time to have a well needed refresher before I start on any ideas for an app or make any kind of rough app design mockup. I’ve been spending time with family, eating good and stuffing myself to the point where I don’t want to do anything but sleep and watch college bowl games but now it’s about time to have a ‘sprint’ so to speak. I will brush through standard topics just to make sure I don’t miss anything then move on to things like Categories, Protocols, Property Lists, KVC, Blocks and Core Data – most of which I have just glanced over and haven’t applied it to any sample code (I like to go through a topic or two, then come up with a code snippet to do what I have read about and then finally, look at the docs to see if there anything else to add beyond the high-level topic concepts/examples that are given to me).

This gives me the opportunity to continually use the documentation online while going more than ‘skin deep’ on topics that most books just don’t include. Speaking of books, the pic above is a list of recent material that I have accumulated, so I will be using those as my go to default source and then when I want to branch out I will look at the docs/stack overflow/google etc for any extra insight/information that I can find.

More Intelligence or Just Artificial??

AI_Dec2011

I just received this via e-mail today! That was a hard few months of learning but I am glad that I stuck with it and saw it through. I actually almost quit about half-way through because I felt like that I had too much going on and well, I probably did but I kept working through it even though I missed a couple of homework assignments(fortunately your two lowest homework scores were thrown out).

My best scores came from the topics of probabilities, search trees(general and specifically game trees – (advanced planning subtopics) ) and reinforcement learning. I guess the only somewhat bad news is that I didn’t get informed that i made the top 1% of everyone who decided to stay with it (LOTS of people dropped out for one reason or another). There was a rumor running around that 200 people got perfect scores so obviously with a 88% I didn’t make it in that ladder but I am happy that I took the course. Hopefully I can put it to good use for a future iOS or Mac OSX app or something along those lines…who knows!

Anyway hopefully I’ve become more intelligent and it’s not just artificial ;)