Mashup Macro - Add Latitude/Longitude
This macro 'geotags' (i.e. adds latitude and longitude values) the mashup based upon any type of geographic information including zip code, city/state/country, or places of interest.
One note: To get this macro to work, you must first register 'http://ws.geonames.org/postalCodeSearch?postalcode=20816&country=US' as a Presto service and name it 'geonames'. (You can read more about the geonames service at http://www.geonames.org.)
<?xml version="1.0" encoding="UTF-8"?> <macro xmlns="http://www.jackbe.com/2008-03-01/EMMLSchema" xmlns:myfunc="java:com.jackbe.jbp.jems.client.EMMLPrestoFunctions" name="LatLon"> <presto-meta name="macrotype">user</presto-meta> <input default="06700" name="zipcode" type="string" /> <input default="MX" name="country" type="string" /> <output name="result" type="document" />
<variables> <variable name="lat" type="string" />
<variable name="lng" type="string" />
<variable name="preliminary" type="string" /> </variables> <invoke inputvariables="zipcode,country" operation="getData" outputvariable="preliminary" service="geonames" />
<assign fromexpr="$preliminary//lat/string()" outputvariable="lat" />
<assign fromexpr="$preliminary//lng/string()" outputvariable="lng" />
<!-- Building the output -->
<constructor outputvariable="result">
<LatLon>
<lat>{$lat}</lat>
<lon>{$lng}</lon>
</LatLon>
</constructor>
</macro>
This macro is based upon an EMML program, 'Mashup Code Sample - Mashup to convert a zipcode into Lat/Long data via a REST service', by MDC Member Igo.
- Login or register to post comments
- Email this page










