Unaware and Don’t Care

, , — Barry on May 27, 2008 at 10:02 pm

I drove with a friend to Kent, WA to visit another friend last weekend.  Aside from getting high blood pressure when I found out my longtime friend is a Republican who voted for Bush and yet haven’t even heard of Scooter Libby or Abu Ghraib, and getting a painfully annoying sunburn, I also tried to explain what open source is to my friends.

During the course of conversation, Jeff, my friend Steve’s fellow SCCA Time Trial racing and Subaru STi owning friend, mentioned a couple of open source projects that allow him to flash the Engine Control Unit (ECU) of his car, which is friggin’ sweet.

I was slightly surprised later to find that neither of my friends knew what open source is.  That was because I know a bunch of geeky people who work on software and know what open source is and know IE is responsible for the death of Jesus.  (They are also left leaning, Democrat voting, socialist-commies!)  It was a reminder that outside the circle of software developers, CIOs, and tech company executives and lawyers, not many people know what open source is.  Or even care.

That’s totally okay.  It doesn’t matter.  The only thing that matters is the quality of the software.  How many among the millions of Firefox users use it because of it’s open source?  Or even know that it is?  (Please save Jesus by using Firefox.  Or Opera.  Or Safari.  Or…OmniWeb?  Just stop using IE!)

Anyway.  I don’t think I explained open source very well.  I used a counter example with Windows.

How would you explain open source to people who don’t know about software development?

PHP: lolwut?

— Barry on February 1, 2008 at 7:19 pm

While I was helping out on a project, I noticed something that’s just so…PHP.

>> class O { var $u; }

>> $f = new O();
O::__set_state(array(
'u' => NULL,
))
>> $f->u = array('c'=>'k');
array (
'c' => 'k',
)
>> empty($f->u->c);
false

Gah! If you are new to the project and combing code to debug something, that’s difficult to notice when $f->u->c is only used in empty() calls within a bunch of if statements. However, PHP does throw a “trying to get property of non-object” notice if you try to access the non-existent value.

Campus Map Part II (of I): Nothing is Ever Simple

— Barry on December 28, 2007 at 6:07 am

I received a bit of feedback on my previous post.  Based on that, I’ll write more about some stuff we did because we had to.

There wasn’t an introduction to the project last time, so here’s a quickie.  Store GIS data in MySQL, deliver that data to the Google Maps API with PHP, profit!

Whining Mode: On.

The first issue wasn’t so much that there was no existent solution, but more why the hell was it so hard to find.  I’ve already mentioned in the previous post that we need to generate map tiles, and since we are stacking images, these tiles need transparent backgrounds.  And I don’t mean your one color transparency with ImageColorTransparent, but fit for the 21st century alpha channel transparency.  (Partly because IE6 requires it; amazingly one color transparency backgrounds worked in the modern browsers.)

This should be easy.  And it is once you figured out the right functions to call, but getting there was a pain.  I don’t know if it was the poor documentation in the PHP manual, the bad examples I saw, or I was just sleep deprived and really dumb.  It was probably all three ingredients with some weak sauce thrown in for that extra FAIL flavor.

At the beginning when I was just learning the GD functions by creating simple sample images, I’d manage to get PHP segfault on me.  Not an error message, not an exception, but segfault!  Just for calling a certain combination of GD functions.  (Not sure if order mattered.)

Anyway, I just wanted to bitch.

After I had the tiles working, I wanted to add anti-aliasing to them.  Luckily, GD’s ImageAntiAlias “does not support alpha components”.  Did I say “luckily”?  I mean “WTF, FINE!”  Learning from a user comment in the PHP doc, I made the original “master” image much bigger, and then used ImageCopyResampled to create the scaled down, pseudo-anti-aliased tiles.

They look much better.  But of course now the tile generation process is even slower (while keeping the memory footprint the same).

MySQL stores the GIS data in some sort of binary format.  There are no corresponding native PHP types.  That means whenever we retrieve data, we’d need to wrap AsText around the appropriate fields.  And then parse the returned text into something useful with regular expressions.  Now I have two problems.

Actually, I’ve got three.  CakePHP doesn’t provide a way to wrap a MySQL function around a column for its built-in find methods, nor does it offer a way to register callbacks on the records returned, so I can have CakePHP automatically perform the parsing.  (We’re using CakePHP, because, um, it’s the kind of the default around the office.  It’s far better than no framework at all.  But not awesome enough for me not to curse at it.)

Yep, had to cheesy hack that stuff in.

In the previous post I said one of the consequences of using tiles was having to move the click handling to PHP, i.e. whenever someone clicks on the map, send the latitude/longitude back to the server to check if she clicked on something (building, parking lot, whatever).  Since MySQL already has functions that test relationships between geometries, I can just use it for this purpose.

O Reader, surely you’ve noticed the pattern and know what’s coming…

Not if I RTFM!  “Currently, MySQL does not implement these functions according to the specification. Those that are implemented return the same result as the corresponding MBR-based functions.“  OMG wut good iz u then!?  A solution was implemented in PHP instead.

No choice really.

« Previous PageNext Page »
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License. | chenb•log