0
FUN WITH MAPS & PHP
Chris Shiflett — @shiflett — shiflett.org
Web aficionado, author, blogger, soccer player, bike
Who am I?   rider, beer drinker, music lover, Brooklynite.
0. Landice




   Dettifoss
TRAVELOG

Tag everything
– #landice


Blog
– every night


Timeline Visualizations
– maps?


A!regate and Plot
– photos, t...
1. Research




   Sjónarsker
EXISTING TOOLS

GPS
– Garmin GPS 60CSx


GPSBabel
– gpsbabel.org


EveryTrail
– everytrail.com


HoudahGeo
– houdah.com/ho...
2. Reykjavík




    Stóra-Víti
3. Photos




  Kirkjufell
<?xml version="1.0" encoding="UTF-8"?>
<gpx
  version="1.0"
  creator="GPSBabel - http://gpsbabel.org/"
  xmlns:xsi="http:...
PARSING GPX
$xml = simplexml_load_file('trip.gpx');

foreach($xml->trk as $part) {
    foreach ($part->trkseg->trkpt as $p...
4. Maps




 Bláa lónið
Garmin GPS 60CSx               Nikon D300




                   HoudahGeo
EVERYTRAIL
$query = $db->prepare("SELECT     lat, lon
                       FROM       points
                       WHERE      time...
// FIXME: http://tr.im/selectclosest
$sql = "SELECT   lat, lon, elevation,
                 ABS(timestamp - :timestamp) as...
FLICKR API

$flickrMethod = 'flickr.photos.getInfo';
$apiUrl = "http://api.flickr.com/services/rest/?
method={$flickrMetho...
Google Maps   OpenStreetMaps
5. Challenges




   Stykkishólmur
CLUSTERS
PERFORMANCE


20,000 points loaded on a
single map is very slow

You don’t need a# points
for every view

Mature solutions...
6. Storytelling




     Reykjavík
7. Future




   Tjörnin
TRAILS




GPX Tracking
GEOLOCATION API




 http://mozi#a.com/en-US/firefox/geolocation/
  http://dev.w3.org/geo/api/spec-source.html
Click here
FEEDBACK?


Fo#ow me on Twitter
– @shiflett


Comment on my blog
– shiflett.org


Email me
– chris@shiflett.org
Thanks for listening!




Chris Shiflett — @shiflett — shiflett.org
Fun with Maps and PHP
Fun with Maps and PHP
Fun with Maps and PHP
Fun with Maps and PHP
Fun with Maps and PHP
Fun with Maps and PHP
Fun with Maps and PHP
Fun with Maps and PHP
Fun with Maps and PHP
Fun with Maps and PHP
Fun with Maps and PHP
Fun with Maps and PHP
Upcoming SlideShare
Loading in...5
×

Fun with Maps and PHP

4,980

Published on

On a recent road trip around Iceland, my friends (PHP developers Andrei and Helgi) and I decided to make a travel site. We brought our cameras, GPS, and Flips, and we used PHP to:

* Aggregate our experience in the form of photos (Flickr), tweets (Twitter), and videos (Vimeo).
* Geotag all of these assets, so we'd remember precisely where we were.
* Create a map that marks our path each day and plots our photos, tweets, and videos.

We made most of this while taking in scenic views and experiencing all Iceland has to offer, and we learned a lot about geotagging, GPSes, time zones, and maps along the way. This talks shows you how to do the same, but you'll have to buy your own flight.

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
4,980
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
13
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Transcript of "Fun with Maps and PHP"

  1. 1. FUN WITH MAPS & PHP Chris Shiflett — @shiflett — shiflett.org
  2. 2. Web aficionado, author, blogger, soccer player, bike Who am I? rider, beer drinker, music lover, Brooklynite.
  3. 3. 0. Landice Dettifoss
  4. 4. TRAVELOG Tag everything – #landice Blog – every night Timeline Visualizations – maps? A!regate and Plot – photos, tweets, videos, etc.
  5. 5. 1. Research Sjónarsker
  6. 6. EXISTING TOOLS GPS – Garmin GPS 60CSx GPSBabel – gpsbabel.org EveryTrail – everytrail.com HoudahGeo – houdah.com/houdahGeo/
  7. 7. 2. Reykjavík Stóra-Víti
  8. 8. 3. Photos Kirkjufell
  9. 9. <?xml version="1.0" encoding="UTF-8"?> <gpx version="1.0" creator="GPSBabel - http://gpsbabel.org/" xmlns:xsi="http://w3.org/2001/XMLSchema-instance" xmlns="http://topografix.com/GPX/1/0" xsi:schemaLocation="http://topografix.com/GPX/1/0 http://topografix.com/GPX/1/0/gpx.xsd"> <time>2009-06-14T23:52:23Z</time> <bounds minlat="64.143006038" minlon="-21.955686333" maxlat="64.153455254" maxlon="-21.915427381"/> <trk> <name>14-JUN-09 01</name> <number>1</number> <trkseg> <trkpt lat="64.150910676" lon="-21.946594650"> <ele>13.115112</ele> <time>2009-06-14T21:01:25Z</time> </trkpt> <trkpt lat="64.150785115" lon="-21.945423950"> <ele>13.595825</ele> <time>2009-06-14T21:02:08Z</time> </trkpt> </trkseg> </trk> </gpx>
  10. 10. PARSING GPX $xml = simplexml_load_file('trip.gpx'); foreach($xml->trk as $part) { foreach ($part->trkseg->trkpt as $point) { /* $point['lat'] $point['lon'] $point->time $point->ele */ } }
  11. 11. 4. Maps Bláa lónið
  12. 12. Garmin GPS 60CSx Nikon D300 HoudahGeo
  13. 13. EVERYTRAIL
  14. 14. $query = $db->prepare("SELECT lat, lon FROM points WHERE timestamp > '$start' AND timestamp < '$end' ORDER BY timestamp"); $query->execute(); $points = array(); while ($row = $query->fetch()) { $points[] = array('lat' => $row['lat'], 'lon' => $row['lon']); } $trip['points'] = $points; $json = json_encode($trip); file_put_contents("/tmp/landice-$day.json", $json);
  15. 15. // FIXME: http://tr.im/selectclosest $sql = "SELECT lat, lon, elevation, ABS(timestamp - :timestamp) as distance FROM points ORDER BY distance LIMIT 1" $select = $this->db->prepare($sql);   foreach ($this->photos as $photo) { $id = (string)$photo['id'];   // Get lat and lon from points table. $select->execute(array('timestamp' => $photo['timestamp'])); $row = $select->fetch(); $this->photos[$id]['lat'] = $row['lat']; $this->photos[$id]['lon'] = $row['lon']; $this->photos[$id]['elevation'] = $row['elevation']; }
  16. 16. FLICKR API $flickrMethod = 'flickr.photos.getInfo'; $apiUrl = "http://api.flickr.com/services/rest/? method={$flickrMethod}&api_key={$this->apiKey}&photo_id={$id}"; $xml = simplexml_load_file($apiUrl);   $title = (string)$xml->photo->title; $desc = (string)$xml->photo->description;
  17. 17. Google Maps OpenStreetMaps
  18. 18. 5. Challenges Stykkishólmur
  19. 19. CLUSTERS
  20. 20. PERFORMANCE 20,000 points loaded on a single map is very slow You don’t need a# points for every view Mature solutions exist –http://tr.im/polyline
  21. 21. 6. Storytelling Reykjavík
  22. 22. 7. Future Tjörnin
  23. 23. TRAILS GPX Tracking
  24. 24. GEOLOCATION API http://mozi#a.com/en-US/firefox/geolocation/ http://dev.w3.org/geo/api/spec-source.html
  25. 25. Click here
  26. 26. FEEDBACK? Fo#ow me on Twitter – @shiflett Comment on my blog – shiflett.org Email me – chris@shiflett.org
  27. 27. Thanks for listening! Chris Shiflett — @shiflett — shiflett.org
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×