Headache

As well as my on-again, off-again progress with wrestling with spherical trig, last night I also got a whopper of a headache. I don’t think I’ve ever had one worse – I’ve had a couple that were just as bad, so I knew it probably wasn’t an aneurism or something. But I just wanted to curl up and die. I took four ipuprophen and a tylenol, and put a cold wet washcloth on my head and lay down with all the lights off. After an hour or two, I felt better enough to get out of my clothes and into bed, but 18 hours later I still have a bit of a hang-over from it.

Math is hard

I spent the whole weekend trying to get some DAFIF boundary and special use airspace data into my waypoint generators. It’s something I promised Kevin from Flight Master a while back.

Well, it turns out not to be all that easy. Part of the problem is simplifying the data from the formats that DAFIF provides it into something that I can put into a relational database and then spit out in a format that Flight Master can use. But the problems I spent most of the weekend on are doing spherical trig. The DAFIF data defines arcs two ways – either as the center point, radius, direction and the start and end bearings, or as the center point, radius, direction, and the start and end points. Flight Master wants just the former, so I have to detect the second case, and use one of the formulas in Ed Williams’ Aviation Formulary to find the bearings, with a little help from "use Math::Trig;". A couple of places, the DAFIF data gives both definitions, which is useful to test my implementation. So that problem was solved.

Now comes the other problem – the one that I spent most of Sunday on and still haven’t solved: How to find the actual geographic extents of circles and arcs. For circles I can go back to the Aviation Formulary and project from the center the radius at 0, 90, 180 and 270 degrees. I’m sure there are wierd cases near the poles where that doesn’t give the actual extremes, but to hell with it, this is as close as I’m going to get. BTW: This is where the intrepid hero discovers that perl’s “%” operator only works on integers, and after kicking himself over the wierd results for a while writes his own “mod” function.

But discovering the geographic extents of an arc is harder. I still haven’t licked it – I think I’m going to have to look at the arc’s start and end bearings and directions to determine if it does through any of the 0, 90, 180 or 270 degree bearings and project them as I did for the circle, otherwise use the end points. Doesn’t sound so hard, does it? And it probably isn’t.

The next challenge will come when I try and produce a geographic index, either using grid buckets (Kevin’s choice) or quadtrees (my choice). To do either of those is going to require proper data structures, and nested data structures, and doing this sort of thing in perl is … sub-optimal. I’d much rather use a language that has proper data structures – even a “struct” declaration in C would suffice. But my web host doesn’t have Java, and I don’t know python yet, and I don’t particularly want to delve into the mysteries of doing ODBC in C or C++, so I’m probably stuck with perl.

Wish me luck.