RDFMapper 2.0 is now available. Version 2.0 uses Fabl for manipulation of RDF, and offers substantially more flexibility.
RDFMapper is a web service that searches an RDF or RSS file for resources with geographic locations, and returns a map overlayed with dots representing located resources. Clicking on a dot displays a web page representing the clicked resource (see these examples). Arbitrary images can be treated as maps, so the service can be used for any kind of image annotation.
RSS is translated into RDF before processing, and thus does not play a central role in the technology; for brevity, mention of RSS is omitted in the rest of this description.
The parameters to the web service specify what RDF file is to be mapped, what basemap (eg of San Francisco or the world) is to appear in the background, how to extract the relevant data from an RDF resource for mapping, and how to generate the web page describing the resource. Geographic data may be expressed in several ways, including the RDFIG Geo vocabulary, and the combined use of the Dublin Core and RDFGeom2d vocabularies.
The base URL of the service is http://www.mapbureau.com/rdfmapper/v1.php; the parameters are appended in the usual form of an HTTP GET request. Here is an example:
http://www.mapbureau.com/rdfmapper/v1.php?ctype=rdf&basemap=http://www.mapbureau.com/basemaps/sanfrancisco.0.xml&content=http://www.geourl.com/rdf/?lat=37.76038%26lon=-122.43872&extractor=http://www.mapbureau.com/rdfmapper/geourl_extractor.xml&generator=http://www.mapbureau.com/rdfmapper/geourl_script.js
RDFMapper maps can be embedded freely in web pages using the IFRAME or OBJECT tags. For example:
<object type="text/html" data="URL of RDFMapper MAP" width="90%" height=500 border=1>
Here is a page with an embedded map.
RDFMapper bears some general resemblance to the web mapping and web feature services as specified by the OpenGIS consortium, but differs in using RDF as the fundamental technology, and in its more specialized purpose. There is a substantial amount of work going on concerning RDF and geography; see the GeoInfo wiki for links.
The following pages aid invocation of RDFMapper by automatically building RDFMapper URLs from form input.
Here are the details:
Parameters to the service
basemapThe basemap parameter is the URL of a file in the RDFMap format describing the basemap, or of a non-progressive jpeg. In the former case, the underlying image file may also be a non-progressive jpeg, or it may a swf (Macromedia Flash) file. An RDFMap file serves to specify the geographic projection associated with its image; this projection information is required for geographic mapping (as opposed to image annotation). http://www.mapbureau.com/basemaps/astoria.0.xml is an example an RDFMap file using the UTM Zone 10 North projection. This catalog contains basemaps that can be used with RDFMapper. When viewing the catalog, the line beneath the map displays the URL of the RDFMap file for the current selection; this URL is suitable for use as the basemap parameter to RDFMapper.
contentURL of the RDF file containing the data to be mapped.
extractor and generatorWe have defined standard extractors and generators for RSS and for GeoURL. For many applications these standard options will suffice, and can be invoked simply by plugging the appropriate values in for the extractor and generator parameters as illustrated by the examples. The detailed explanations below are relevant only if more flexibility is needed.
The extractor and generator parameters together describe how to generate a web page from an RDF resource. The extractor defines how to fill in fields of a JavaScript object from properties of the resource. The generator then takes this object and writes out HTML. Specifically, the generator file should define a JavaScript function named writePage, taking as arguments the document to write into, and the object containing the data to be written. Here is an example:
function writePage(doc,content)
{
doc.writeln( '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">');
doc.writeln( '<html><head><title>Selected item</title>');
doc.writeln( '<link rel="stylesheet" type="text/css"');
doc.writeln( ' href="http://www.mapbureau.com/rdfmapper/examples/style0.css">');
doc.writeln( '</head><body>');
doc.writeln( '<p><center><b>'+content.title+'</b><p>');
doc.writeln( content.description);
doc.writeln( '</body></html>');
}
Here, the JavaScript object content has been endowed with title and description properties. The extractor specifies how this is done. Here is an example:
<?xml version="1.0" encoding="UTF-8"?> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://nurl.org/0/computer/software/RDF/extract" > <extractor> <assignments> <rdf:Seq> <rdf:li> <assign> <to>title</to> <from rdf:resource="http://purl.org/rss/1.0/title"/> </assign> </rdf:li> <rdf:li> <assign> <to>description</to> <from rdf:resource="http://purl.org/rss/1.0/description"/> </assign> </rdf:li> </rdf:Seq> </assignments> <locators> <rdf:Seq> <rdf:Seq/> </rdf:Seq> </locators> </extractor> </rdf:RDF>
An extractor is an RDF resource with assignments and locators properties. The assignments property specifies how to derive the values of JavaScript properties from an RDF resource. Specifically, assignments are members of the class assign. In turn, an assign resource has a to property, and an from property. The value of to is the name nm of the JavaScript property to be assigned. The value of from is either an RDF property P, or a sequence of RDF properties P0,...PN. The assign denotes an operation on a JavaScript object J, and a resource R: it sets J.nm to the value of R.P, or R.P0...PN respectively. Here, R.P means RDF property selection - R.P is that RDF value V such that <R,P,V> is a triple in the RDF graph. If R.P is a literal, this literal is assigned to the JavaScript property, and if it is a resource, the URI of the resource is assigned. If R.P is undefined, or is a resource without a URI, then no assignment is done. Multi-valued properties are not supported in the current version of RDFMapper.
So, an extractor tells how to build a JavaScript object from an RDF object, and the script tells how to write out an HTML page for that JavaScript object. When a dot is clicked on the map, the extractor is run on the resource that it represents, and then the script processses the resulting object; the final outcome is the page that appears after the click.
The remaining issue is how locations are extracted from RDF. The locators property of an extractor determines this by indicating what "parts" of a resource R might be relevant to its location. Each such part, in turn, might have a location specified by either the Dublin Core property for location (dc:coverage), or by the Geo vocabulary - ie a geo:lat property for its latitude, and a geo:long for its longitude. In the former case, the value of a of the dc:coverage property should be a geom2d:Point from the RDFGeom2d vocabulary.
There is also a way to embed location information into literal values. This is useful because it allows location tagging of any content (such as weblog posts) without need for access to its RDF or XML representation. Specifially, a string of the form
<span style="display:none"><geo:lat>46.1</geo:lat><geo:long>124</geo:long></span>
or
<span style="display:none"><geom2d:x>200</geom2d:x><geom2d:y>-300</geom2d:y></span>
may appear inside the HTML values of RDF properties, representing for example the text of weblog posts. If this kind of embedding is included, the post is in XHTML, and the namespaces geo and geom2d are defined in the header, then the result is well-formed XML that can be manipulated by XML processing tools (XSLT, RSS syndicators, etc). The namespace definitions are:
xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:geom2d="http://nurl.org/0/geom2d/1.0/"
http://www.mapbureau.com/rdfmapper/examples/astoria_places.xml contains examples.
The first part of a resource with location data among those designated by locators determines the location assigned to R. All of the resources appearing in the content RDF file are candidates for mapping; only those that have a location as determined in this way appear on the map.
Here is a more precise account of location extraction. The value of locators is a sequence each of whose members is either an RDF property, or a sequence of RDF properties (a path). Each of these, when construed as a selector on an RDF resource R, determines an RDF value V. The set V0...VN of these values are the candidates for determining R's location.
In the above example, the only member of locators is the empty sequence <rdf:Seq/>, denoting the null path. The value of path selection on R with the null path is R itself, so, in our example the locator set consists of just R. So, R will be mapped if it has a dc:coverage or geo:lat, geo:long properties (it is not a literal, so RDFMapLocation strings are not relevant). In the GeoURL case, it is the foaf:topic property of a resource to which location data is attached, so its locator specification looks like this:
<locators> <rdf:Seq> <rdf:li> <rdf:Property rdf:resource="http://xmlns.com/foaf/0.1/topic"/> </rdf:li> </rdf:Seq> </locators>
ctype
RDFMapper is capable of mapping content in other formats than RDF; internally, this is accomplished by translating to RDF first. The ctype (short for "content type") parameter designates the format of the content file. Currently, there are three alternatives: rdf, rss, and html. The rss option handles the RSS 0.9x and RSS 2.0 dialects. rdf is the default.
The html option for ctype allows any HTML file be annotated in a manner that supports mapping via RDFMapper, via the technique introduced by RSSify. A region of HTML appearing between <span class="rss:item"> and its matching </span> is transformed into an rss:item resource in RDF (with rss: denoting the RSS 1.0 namespace). Within such an item span, appearance of a subspans with tags <span class="rss:description"> or <span class="rss:title"> are transformed into the values of the rss:description, rss:title properties in the RDF, respectively. Thereafter, the usual rules for mapping apply. For compatablity with Blogmapper, the RDFMapper HTML scraper also supports use of <rss:title>,<rss:title>, and <rss:description> in place of the corresponding <span> tags.
Special treatment of the title property
The value assigned by the extractor to the Javascript property title (if any) receives special treatment: the titles appear in alphabetical order in the directory of mapped items.
Design notes
RDFMapper was designed and implemented by Chris Goad. Some of the underlying ideas go back to the original implementation of Blogmapper, conceived by Chris Goad and Jason Harlan.
The extract vocabulary is an impoverished scheme for specifying how to extract data from RDF. It is a stopgap that can that can handle only simple cases, but cases that are useful in practice.
This vocabulary is a primitive example of using RDF to describe computation. A full implementation of the idea is under development, in the form of the Fabl programming language. When Fabl is ready, it will take over the role of extract.
Several alternatives were available for implementing the RDFMapper concept, including use of a client-side JavaScript RDF parser such as Jim Ley's, or using RDQL or other RDF manipulation tools on the server side for extraction. (XSLT is not a good fit for the RDF context.) These alternatives would have increased the power of RDF extraction, but we chose the primitive approach based on the extract vocabulary for its consistency with our long range plans.