. mombe.org
home of the mad cow
  Not A Blog
home :: systems

Friday, August 29, 2008

ATOM to KML converter

A friend of mine is currently on a href="http://www.asclme.org/the-asclme-project/research-cruises/2008-cruise.html">research
cruise and has been href="http://www.asclme.org/lang-en/the-asclme-project/research-cruises/2008-cruise/cruise-blog.html?">blogging along the way. Each time he blogs, he posts a position update in the form
of a link to Google Maps.

It occurred to me that it'd be nice to have a real-time route map of where
he'd been, and that a Google maps
would be a good way to do this. The problem was getting the data
to create the mashup. His blog includes an href="http://en.wikipedia.org/wiki/Atom_(standard)">Atom Syndication
Format feed for syndication, so I figured that what I needed was a way
to automatically convert this data into something Google maps could

I've been playing a fair amount with Google's href="http://en.wikipedia.org/wiki/Keyhole_Markup_Language">Keyhole Markup
Language (KML) for work reasons — we use it to record GIS data
about our network infrastructure for use in href="http://earth.google.com/">Google Earth. KML works nicely in Maps
too, so it seemed that what I really needed was a way to take ATOM data from
a blog and convert it to KML.

A little bit of PHP later and I had what I needed. A script that read the
ATOM, extracted position information from it, and converted that into a KML
script I could use in my href="http://www.blog.asclme.org/map/">mashup.

Figuring that this would probably be useful to someone else, I've tried to
make my ATOM to KML converter as generic as possible. I knows nothing of
the particular blog, and extracts everything it needs to know from the blog

The result is available as href="/data/systems/patches/atomtokml-php.asis">atomtokml.php.

You'll need Apache and href="http://php.net/">PHP (with the XML, PREG and cURL extensions), as
well as the SimplePie ATOM PHP class. The
latter is simplepie.inc and need to go somewhere in PHP's search

Configuration is easy or non-existent. There are a couple of variables at
the top of the atomtokml.php script that you may need to set.

To use it, simply call it from a web browser. By default it'll probably
open in in Google Earth. You can also use the href="http://code.google.com/apis/maps/documentation/reference.html#GGeoXml">GGeoXml function to load it in a Maps mashup.

The script understands a few parameters to make life easier. nocache=1 will disable SimplePie's ATOM cache and fetch the feed
directly from source again — useful for forcing a reload. text=1 will display the resulting KML as text/plain rather
than application/vnd.google-earth.kml+xml, which will probably make
it display in your browser — useful for finding out why a post didn't
make it into the KML. Finally, feed=URL will override the
default feed URL and fetch a different ATOM feed — this'll let you use
the same script for multiple blogs.

From a blogger's perspective, there are two ways to get a post into the KML.
The first is to make sure your ATOM feed has the longitude & latitude
fields set for each post. Realising that most blogging software doesn't
support this, the second is to post links to href="http://maps.google.com/">Google Maps in entries you want to
appear. The script can parse Google Maps' permalink format and extract
longitude & latitude from the URL.

As usual, YMMMV.

UPDATE 2008/08/31: bug fixes
I've updated atomtokml.php to fix a few bugs in the KML output (it seems I didn't read the spec properly). The output now validates correctly in a couple of different KML validators. Unfortunately it seems that, having done this, Google Earth doesn't parse a KML 2.2. file properly :) It'll load fine, but if you turn verbose warnings on, you'll get warned about some of the imported elements.

posted by guy at: 09:53 SAST | path: /systems | permanent link

Monday, July 21, 2008

Building Mozilla Weave on FreeBSD

Mozilla Lab's Weave project provides bookmark and user data synchronisation between browsers.
It's very useful, but doesn't currently support FreeBSD. Since I run href="http://mozilla.com/firefox">Firefox 3.0 on FreeBSD, this is a
little irritating to me ;) So, following the hints on Weave's wiki, I
attempted to build Weave on my BSD box.

The script I came up with is a nasty hack. There must be a cleaner way to
do this. Nevertheless, it successfully builds Weave 0.2.5 on FreeBSD
7.0-RELEASE against the Firefox 3.0.1 sources.

To build Weave, you'll need a working ports system that's reasonably
up-to-date (has href="http://freshports.org/www/firefox3">www/firefox3). You'll also
need gmake and python installed.

Download the latest href="http://hg.mozilla.org/labs/weave/index.cgi/archive/tip.tar.gz">Weave
sources and untar them. Then copy my href="/data/systems/patches/buildweave.sh.asis">script into the
top-level source directory (weave-c8bce0724360 at time of writing). cd into
this directory, and run the href="/data/systems/patches/buildweave.sh.asis">buildweave.sh script.
You'll be left with an XPI installer ready to install.

For those who're lazy, here's my href="/data/systems/patches/weave-FreeBSD.xpi.asis">pre-compiled version of
Weave 0.2.5 for FreeBSD 7.0.

UPDATE 2008/08/10: Weave 0.2.6 released
Weave's been updated, so here's a pre-compiled version of 0.2.6.

UPDATE 2008/10/20: Weave 0.2.7 released
Weave's been updated, so here's a pre-compiled version of 0.2.7.

posted by guy at: 09:00 SAST | path: /systems | permanent link

Thursday, May 29, 2008

EPrints, SPAM & deleting users

We run an instance of EPrints 2.3 and
noticed recently that it was getting lots of SPAM. Well, more specifically,
that a lot of spammers had registered accounts on the system with meaningful
usernames like "cunnilingus". Fortunately our self-archiving
policy requires that user submissions are approved, but nevertheless the
multitude of irrelevent accounts was irritating.

It was then that I discovered that EPrints doesn't have a command-line way
to delete users. There's a create_user, but no remove_user. Not being one who is daunted by such problems, I set
about writing one. It turned out to be quite simple.

Since I'm a firm believer of making the wheel available, here's what href="/data/systems/patches/remove_user.asis">I came up with. YMMV and all that.

posted by guy at: 09:04 SAST | path: /systems | permanent link

Bloxsom Powered

© 2002-2005, webmaster@mombe.org
RSS Valid XHTML 1.0!

Creative Commons License