Today’s iPod discovery

I’ve had this iPod since April. (One thing this blog is good for is that I can use it to check on the petty details of my life.) All this time I’ve had it in an incase leather case, which puts a rubber membrane on top of the scroll wheel. That membrane kind of slows down the scrolling, so I usually use the new “Search” function because scrolling through however many hundreds of artists or thousands of albums to find the one that’s been running through my head all night is too damn slow. But today I took it out of the case for some reason, and something amazing happened. I was scrolling though the list of artists, and suddenly I got a gigantic “A” in the middle of the screen, and each tick of the scroll wheel moved one letter instead of just one album. Once I got to the first letter of the artist I wanted (Captain Tractor, btw), I paused and it went back to slow scrolling through the individual items. This is very cool – it really speeds up scrolling to where I want. Once again, Apple pleasantly surrprises me with user interface delight.

Now if only they’d make it so that going fast goes to scrolling through the first letters, then one quick pause and you’re in quick scrolling through second letters, and such.

Now I’m even more confused than before

As I wrote in Rants and Revelations » C Paul Program, C Paul Rant, I’m trying to “recreate” a C program that I wrote back in 2001. I’m using the same shapelib library for reading ESRI shape files, I’m using (what I think is) the same algorithm for doing point in polygon tests, and it’s using the same shape file, one that was published on the ESRI web site back when Nunavut first became a territory. And it seems to be up and running.

So I wrote a little perl script that goes through my database and picks out the 3400+ waypoints that are in Canada and which come from DAFIF, and run them through both the old and new program. Both the old and new programs are looking at the same shape file. So you’d expect the exact same results, right? Wrong. There are 309 points that the old program assigns provinces to that the new program says are outside of any provincial boundary. Some of those are ones that I’d already noticed were assigned to provinces even though they were way out at sea and probably shouldn’t be, but some were airports that are near the coast or on islands. That’s a problem.

My first suspicion was that the algorithm as published used floats, but I’d converted it to using doubles because face it, these days computers are so damn fast. But I switched back to floats and now there are 314 differences. Some of the original 309 are now back to what they were, but some points have jumped provinces, like COMPR which moved from Alberta to Saskatchewan (which Google Maps just barely agrees with, by the way) and KITAR which moved from British Columbia to Yukon Territory (which Google Maps says is a toss up). But most importantly, it didn’t “fix” any of the coastal or island airports that ended up with no province. I’m not convinced that’s a net positive. So I’ve gone back to using doubles.

Ok, one other difference is that the notes for the algorithm mentioned a way to compensate for shapes with holes in them by inserting (0.0,0.0) points between the rings. I don’t think I did that before. So I tried without. No dice – still 309 differences.

And then I remembered one other difference. I call SHPRewindObject on each shape as I read it. According to the docs, that’s supposed to fix any problems with shapes that go the wrong way round. But no, that didn’t change anything either.

So I’m left with a mystery about why there is a difference between the old program and the new one. Since I don’t have a GIS program that can read and manipulate shape files, I think my next step will have to be to turn these shape files into Google Maps API polygons so I can plot these wayward points and see if the problem is in the shapes or in the algorithm.

Google gets their collective fingers out

Well, only four months late, but I finally got the check I’ve been waiting for from Google.

See:
Rants and Revelations » Oh Google, you are so devoid of any semblance of clue and
Rants and Revelations » Hey, Google for previous ranting about this subject.

I won’t rant about the fact that they only allow $30 a day for meal expenses, and my breakfast in the hotel cost more than that. Nope, I won’t.

C Paul Program, C Paul Rant

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[4]” 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.

Sniff, sniff. Good bye old friend.

My favourite airplane, our club’s Piper Lance, is up for sale on eBay Motors:

eBay Motors: 1977 Piper Lance PA-32-300R – Great Buy, Flies Often! (item 140161831797 end time Oct-14-07 17:00:00 PDT)

Personally I think the reserve is too high, but I think they’re just trying to find out what the market will really bear. It looks like the only bidders so far are dealers bidding less than half what it’s really worth, looking for a totally desperate seller, and we’re not there yet.

But the plane’s annual is due in December, and we were told last year that the engine probably won’t pass another annual, and there just aren’t enough club members willing to pay the surcharge to justify spending the money for an engine and prop overhaul. So this plane is going to get sold, somehow.

So good bye, old friend. I’ll miss your speed, your load capacity, and your outstanding interior room. But mostly I’ll miss the fact that it felt like a good solid honest plane.