I was playing around with the Google Maps API and loading some of my nav data into Google Maps when I noticed a few waypoints with the wrong province. Oh oh. For instance, CDT5 Buctouche Airport is marked as being in Quebec instead of New Brunswick.
The DAFIF data never provided province data, so a long time ago (March 2001 according to Google Groups) I located some shapefiles with provincial boundaries and wrote a C program to do “point in polygon” to figure out what province the points are in. Obviously there is a mistake either in my algorithm or the shapefiles. Which is too bad, because a while ago I discovered that I don’t have the source code for the program any more. Not sure where it went, but I can’t find it anywhere. Funny, that program has moved without recompiling from my home system to Gradwell hosting to Linode Virtual Private Server to my rack to back on my home system. But now it’s time to recreate it.
The first step to recreating it is to find the library I used to access shapefiles, and after a bit of searching I discovered its name and web site, and also that it’s in the default Debian distribution. Of course, being Debian, in spite of the fact that it’s a positively tiny little tar file when you install from source, they had to break it up into libshp1, libshp1-dev and shapefile packages. Was that really necessary?
The next step was to find the Point In Polygon algorithm, but fortunately the newsgroup thread that I found my asking about it in 2001 also had the pointer to the comp.graphics.algorithms FAQ for that.
Now the biggest hurdle is that I’ve got to get my mind back into C programming again. Ugh. It’s hard to think that I used to do this shit every day, and it was all second nature to me. Now I’ve got to stop and think that when the function signature says “double *” and it returns X, Y, Z, and “M” (whatever that is), that I really need to declare “double maxBounds” and pass it as “maxBounds”, but when it says “int *” and it returns a single value, I need to declare it as “int nVertices” and pass it as “&nVertices”. Even when I was doing C++ I didn’t have to deal with crap like this because C++ programmers were *far* more likely to declare a class and use that as the return type instead of passing in a huge list of arguments to return values in. There was a time when I thought C was the greatest language. And I helped write a gigantic Geographic Information Systems product in it. Those were the days.