CityLookup
Appearance
A GeoInfo use case...
weather underground is a great source of data;
cityLookup is a start at N3 rules for mapping city names to lat/long. by DanConnolly, 2003/03/10.
The input data should look like this:
<r:RDF
xmlns:r="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:k="http://opencyc.sourceforge.net/daml/cyc.daml#"
xmlns:usps="http://www.w3.org/2000/10/swap/pim/usps#"
xmlns:map="http://www.w3.org/2000/10/swap/pim/earthMap#"
>
<r:Description r:about="#austin">
<map:cityName>Austin</map:cityName>
<k:inRegion>
<r:Description>
<usps:stateAbbr>TX</usps:stateAbbr>
</r:Description>
</k:inRegion>
</r:Description>
</r:RDF>
Then (see CwmTips if you don't have cwm running yet) you run cwm like this...
$ python cwm.py --chatty=15 --rdf input.rdf \
--n3 http://www.w3.org/2000/10/swap/pim/cityLookup --think \
--purge-rules >,out.rdf
The --chatty=15 flag produces some diagnostics like this...
Reading getForecast?query=Austin%2CTX Concluding definitively CITY->austin PG->getForecast?query=Austin%2CTX LON->"-97.7505" LAT->"30.30587" _g24->0_work
and the output looks like this:
<r:RDF
xmlns:cityl="file:/home/connolly/w3ccvs/WWW/2000/10/swap/pim/cityLookup#"
xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
xmlns:k="http://opencyc.sourceforge.net/daml/cyc.daml#"
xmlns:map="http://www.w3.org/2000/10/swap/pim/earthMap#"
xmlns:r="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:usps="http://www.w3.org/2000/10/swap/pim/usps#">
<r:Description r:about=",aus.rdf#austin">
<cityl:formVal>Austin%2CTX</cityl:formVal>
<cityl:weatherPage r:resource="http://www.wunderground.com/cgi-bin/findweather/getForecast?query=Austin%2CTX"/>
<k:inRegion r:parseType="Resource">
<usps:stateAbbr>TX</usps:stateAbbr>
</k:inRegion>
<map:cityName>Austin</map:cityName>
<geo:lat>30.30587959</geo:lat>
<geo:long>-97.75051880</geo:long>
</r:Description>
</r:RDF>
For a more complex example, see Dan Connolly's travel schedule in RDF
scraped from his homepage and munged ala the above. Details are
in the Makefile.