17 June 2005 I love PerlEspecially CPAN. We're nearing launch day for the new Waterscape, and while Paul, Jon and Aaron do all the funky dynamic site stuff, I'm working on the mapping. Those who have been reading carefully will remember that we're using Flash for the maps. The waterways are rendered as vectors on top of pre-shrunk Ordnance Survey raster tiles. Up until now, I'd been trying not to think about one big problem with this. It works great at 1:50,000 scale and anything like that. But when you zoom out, you might need to show several entire waterways in one view. As our data is accurate to the nearest metre or so, this would mean some really hefty vectors, which take ages to load and end up boggling your Flash Player. The obvious solution is to simplify the waterway polylines for small scale maps. Usually, you'd run the polyline through Douglas-Peucker and get a nice simplified line. But this misses an opportunity. Douglas-Peucker produces another polyline, whereas Flash will happily render bezier curves. Using Beziers should allow us to have much more accurate paths with much less data. So, the plan is: use Perl to make an Illustrator file out of the polylines; run Illustrator's 'Simplify Path' function to turn them into beziers; export as an Illustrator 8 file (dead easy to parse); and upload the resulting paths into the MySQL database using another Perl parsing script. All of this is fine... but Illustrator works in cubic beziers for maximum artistry, while Flash uses simpler, easier-to-render quadratic beziers. Until today, I was stumped at this point. Fortunately, for times like this, we have CPAN. Comments |