At 2007-07-13T22:16:40+1200, Jim Cheetham wrote:
> I can't remember the problem; was it just that you couldn't find a
> working parser to turn the SVG into an image?

The major problem is that the current implementation seems to be written
specifically for the Adobe SVG browser plugin.

If you dig around in the site to find the SVG map data and visit it with
Firefox, it'll render the map (slowly), but none of the interactive features
work.  Not too surprising.

> Did anyone poke about in the SVG itself and see if it was organised enough
> to be useful non-visually? (Remembering that it's all XML; it might be
> parseable)

You might be able to do something with it given enough effort, but the Right
Thing to do would be to let Environment Canterbury know how unhappy you are
that all this useful information is bundled up in such an inaccessible way.

Along with the SVG map data, there's a list of platform numbers and physical
locations in another SVG file.  I've attached a trivial parser for that in
the hopes that it might inspire someone...

Cheers,
-mjg
-- 
Matthew Gregan                     |/
                                  /|                    [EMAIL PROTECTED]
#! /usr/bin/env python

import sys
import xml.sax

class Handler(xml.sax.handler.ContentHandler):
    def __init__(self):
        self.in_title = False
        self.title_text = []
        self.pos = None

    def startElement(self, name, attrs):
        if name == 'use':
            self.pos = int(attrs['x']), int(attrs['y'])
        if name == 'title':
            self.in_title = True

    def endElement(self, name):
        if name == 'title':
            self.printPlatform()
            self.in_title = False
            self.title_text = []
            self.pos = None

    def characters(self, text):
        if self.in_title:
            self.title_text.append(text)

    def printPlatform(self):
        flat = ''.join(self.title_text)
        id, name = flat.split(' ', 1)
        id = int(id[1:])
        print 'platform: %d, location: %s, position: %r' % (id, name, self.pos)

def main(args):
    for path in args:
        xml.sax.parse(path, Handler())

if __name__ == '__main__':
    main(sys.argv[1:])

Reply via email to