Introduction to Geo hacking with (amongst others) Yahoo Technology.

Post on 20-Jan-2015

9.589 views 0 download

Tags:

description

Introduction to geo technologies for hacking at the Georgia Tech Uni Hack day.

Transcript of Introduction to Geo hacking with (amongst others) Yahoo Technology.

Introduction to Geo hacking with (amongst others)

Yahoo Technology.

Chris&an Heilmann, Ignite, London, 2nd of March 2010

Geolocation is the new thing.

Good news is that it is not hard to do.

In the following half hour or so I will show you how to solve almost all Geo problems using YQL.

Using YQL in JavaScript:

There are a few different ingredients to playing with geo location.

Finding the current location.

Turning a location into a place.

Finding a geographical hierarchy.

Geo-tagging information.

Displaying geo information.

Fin

din

g t

he

cu

rre

nt

locati

on

.

Finding the current location happens in different ways.

The creepy way - IP sniffing.

Fin

din

g t

he

cu

rre

nt

locati

on

.

Fin

din

g t

he

cu

rre

nt

locati

on

.

h;p://isithackday.com/hacks/geo/js‐loca&on.html

Fin

din

g t

he

cu

rre

nt

locati

on

.

The problem with IP sniffing is accuracy.

Fin

din

g t

he

cu

rre

nt

locati

on

.

The other problem: it is not reliable.

Fin

din

g t

he

cu

rre

nt

locati

on

.

The non-creepy and more accurate way - the W3C geolocation API.

Fin

din

g t

he

cu

rre

nt

locati

on

.

Fin

din

g t

he

cu

rre

nt

locati

on

.

Firefox/(Mobile) Safari/Chrome (dev build)

Another way is of course to get location information from the user’s social presence.F

ind

ing

th

e c

urr

en

t lo

cati

on

.

Plazes, FireEagle, Twitter, Yahoo, Flickr, Foursquare, Gowalla, Brightkite, Google Buzz/Latitude, Dopplr...F

ind

ing

th

e c

urr

en

t lo

cati

on

.

Having a latitude and longitude is fine and dandy but it is ambiguous.

Tu

rnin

g a

lo

cati

on

in

to a

pla

ce

.

The same lat/lon pair could be a lot of things - the centre of a town, a point of interest...

Tu

rnin

g a

lo

cati

on

in

to a

pla

ce

.

This is why we need to turn lat/lon into something that is human readable.

Tu

rnin

g a

lo

cati

on

in

to a

pla

ce

.

This is called reverse geocoding and there are a few services for it out there.

Tu

rnin

g a

lo

cati

on

in

to a

pla

ce

.

My personal favourite (as it works world-wide) is the Flickr reverse geocoder.

Tu

rnin

g a

lo

cati

on

in

to a

pla

ce

.

Tu

rnin

g a

lo

cati

on

in

to a

pla

ce

.

h;p://www.flickr.com/services/api/flickr.places.findByLatLon.html

You can use this using YQL:

Tu

rnin

g a

lo

cati

on

in

to a

pla

ce

.

select * from flickr.places wherelat=51.5142271 and lon=‐0.1289602

To get more in-depth data, use flickr and Yahoo Geo:

Tu

rnin

g a

lo

cati

on

in

to a

pla

ce

.

select * from geo.places where woeid in (  select place.woeid from flickr.places   where lat=51.5142271 and lon=‐0.1289602)

Tu

rnin

g a

lo

cati

on

in

to a

pla

ce

.

Tu

rnin

g a

lo

cati

on

in

to a

pla

ce

.

Quick word on woeid: Use it. (Flickr, Dopplr, Twitter and Yahoo do)

Tu

rnin

g a

lo

cati

on

in

to a

pla

ce

.

What’s around a certain location?

Fin

din

g a

ge

og

rap

hic

al

hie

rarc

hy.

h;p://developer.yahoo.com/geo/

GeoPlanet gives you hierarchies:

Parent, Ancestors, Children, Siblings, Neigbours, BelongTos.

Tu

rnin

g a

lo

cati

on

in

to a

pla

ce

.

Fin

din

g a

ge

og

rap

hic

al

hie

rarc

hy.

h;p://isithackday.com/geoplanet‐explorer/?woeid=615702

Fin

din

g a

ge

og

rap

hic

al

hie

rarc

hy.

h;p://isithackday.com/geoplanet‐explorer/geodrilldown.php

Fin

din

g a

ge

og

rap

hic

al

hie

rarc

hy.

Putting it all together, we can get this:

h;p://isithackday.com/hacks/geo/geotest.php

Fin

din

g t

he

cu

rre

nt

locati

on

.

What if you have no location but only a resource?

Ge

o-t

ag

gin

g i

nfo

rmati

on

.

h;p://developer.yahoo.com/geo/placemaker/Ge

o-t

ag

gin

g i

nfo

rmati

on

.

Placemaker takes a text, or a web URL and extracts the geographical information from it.

Ge

o-t

ag

gin

g i

nfo

rmati

on

.

Ge

o-t

ag

gin

g i

nfo

rmati

on

. select * from geo.placemaker where documentContent = "Hey I am in Atlanta! I came here from London and will travel onwards to Las Vegas and Sao Paulo" and documentType="text/plain"

Ge

o-t

ag

gin

g i

nfo

rmati

on

. select * from geo.placemaker where documentURL ="h;p://icant.co.uk" and documentType="text/html" and appid=""

select * from geo.placemaker where documentURL ="h;p://newsrss.bbc.co.uk/rss/newsonline_uk_edi&on/front_page/rss.xml"and documentType="text/rss" and appid=""

Placemaker returns places and references - you can use these to enhance texts with geo information.

Ge

o-t

ag

gin

g i

nfo

rmati

on

.

To see Placemaker in action, check out the GeoMaker hack.

Ge

o-t

ag

gin

g i

nfo

rmati

on

.

h;p://github.com/codepo8/geomaker

h;p://icant.co.uk/geomaker/Ge

o-t

ag

gin

g i

nfo

rmati

on

.

Displaying geo information is done via Map APIs

Dis

pla

yin

g g

eo

in

form

ati

on

.

By far the easiest way to build a very simple map is to use the Google static maps API.

Dis

pla

yin

g g

eo

in

form

ati

on

.

<img src=”h;p://maps.google.com/maps/api/sta&cmap?sensor=false&size=200x200&maptype=roadmap&key=YOUR_MAP_KEY&markers=color:blue|label:1|37.4447,‐122.161&markers=color:blue|label:2|37.3385,‐121.886&markers=color:blue|label:3|37.3716,‐122.038&markers=color:blue|label:4|37.7792,‐122.42” alt=””>

Dis

pla

yin

g g

eo

in

form

ati

on

.

If you want to use Yahoo Maps with the data returned from the earlier YQL calls here’s the code:

Dis

pla

yin

g g

eo

in

form

ati

on

.

Dis

pla

yin

g g

eo

in

form

ati

on

.

Dis

pla

yin

g g

eo

in

form

ati

on

.

If you want to use any map provider easily without deep-diving into an API, use Mapstraction.

Dis

pla

yin

g g

eo

in

form

ati

on

.

Dis

pla

yin

g g

eo

in

form

ati

on

.

h;p://www.mapstrac&on.com/

That’s it! You have the tools, now find a cause and get geo hacking!

h;p://delicious.com/tag/geotoys

  Chris&an Heilmann  h;p://wait‐&ll‐i.com   h;p://developer‐evangelism.com  h;p://twi;er.com/codepo8   

Cheers