Skip to content

Commit

Permalink
globe image
Browse files Browse the repository at this point in the history
  • Loading branch information
codepo8 committed Jul 16, 2010
1 parent a8c1289 commit 672b036
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions geo/geo.globeimage.xml
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<table xmlns="http://query.yahooapis.com/v1/schema/table.xsd">
<meta>
<sampleQuery>select * from {table} where place="london,uk"</sampleQuery>
<author>Christian Heilmann</author>
<description>Creates an image of earth with a star at the location you defined. Returns the HTML image tag. If you provide a type parameter of "data" it returns the image as a data URI.</description>
</meta>
<bindings>
<select itemPath="" produces="XML">
<inputs>
<key id='place' type='xs:string' paramType='variable' required="true" />
<key id='type' type='xs:string' paramType='variable' required="false" />
</inputs>
<execute><![CDATA[
default xml namespace = "http://where.yahooapis.com/v1/schema.rng";
var res = y.query("select * from geo.places(1) where text='"+
place + "'").results;
var lat = res.place.centroid.latitude;
var lon = res.place.centroid.longitude;
lat = Math.round(parseInt(lat)/5)*5;
lon = Math.round(parseInt(lon)/5)*5;
var src='http://earthquake.usgs.gov/images/globes/'+
lat+'_'+lon+'.jpg';
default xml namespace = "";
if(type === 'data'){
var data = y.query('select * from data.uri where url="'+
src+'"').results;
var datauri = data..url;
var dataimg = <img/>;
dataimg.@src = data..url;
dataimg.@alt = place;
}
var img = <img/>;
img.@src = src;
img.@alt = place;
var out = (type === 'data') ? dataimg : img;
response.object = <globe>{out}</globe>;
]]></execute>
</select>
</bindings>
</table>

0 comments on commit 672b036

Please sign in to comment.