forked from yql/yql-tables
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |