Your SlideShare is downloading. ×
0
Geo search introduction
Geo search introduction
Geo search introduction
Geo search introduction
Geo search introduction
Geo search introduction
Geo search introduction
Geo search introduction
Geo search introduction
Geo search introduction
Geo search introduction
Geo search introduction
Geo search introduction
Geo search introduction
Geo search introduction
Geo search introduction
Geo search introduction
Geo search introduction
Geo search introduction
Geo search introduction
Geo search introduction
Geo search introduction
Geo search introduction
Geo search introduction
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Geo search introduction

2,068

Published on

Another presentation prepared for team sharing. An idea that have great potentials that is geo search.

Another presentation prepared for team sharing. An idea that have great potentials that is geo search.

Published in: Technology, Design
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,068
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
16
Comments
0
Likes
2
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. geo
search the
basics
  • 2. LBS is ubiquitous but remains somehow a mystery let’s visit some of the basics
  • 3. query in geo-search: geotags
  • 4. geotag basics each location on earth is presented as lat/long pair relative to 180° along the Equator and 90° along the Meridian Examples 22.278146,114.185259 +22° 16′ N, 114° 11′ E +22° 16' 41.33", +114° 11' 6.93" - S/W + N/E
  • 5. geotagging photos gps trackers embed lat/long coordinates in the EXIF section of a photo
  • 6. geotagging the web as LBS takes off, movement to geotag the web and media follows suite flickr: ICBM, Geo Tag geoRSS: great for monitoring and scientific research
  • 7. geocoding as we don’t speak in coordinates 22.278146,114.185259 202.92.185.47 01558-6-3031 finds lat/long of a point of interest, given partial data such as an address, an IP or a phone number
  • 8. how address geocoding works step a: parse or rewrite the address
  • 9. how address geocoding works step b: locate corresponding map segment
  • 10. how address geocoding works 99 96 81 22.278146,114.185259 28 21 step c: interpolate address use other data like zip code, intersecting streets.etc. to improve accuracy
  • 11. reverse-geocoding does the opposite 22.278146,114.185259 sometimes we need to find non-geotagged points-of-interests near a location
  • 12. reverse-geocoding
  • 13. geocoding hong kong addresses lands department geo db google maps API commercial packages
  • 14. geo-searching most common use-cases: finding useful data about a location or finding points-of-interests near a location need a way to calculate distances between points-of-interests
  • 15. geo-searching: the algorithm challenge: calculation of distances between places is less straight forward as the world is not a flat surface
  • 16. geo-searching: the algorithm visualizing earth as a sphere, mathematicians derive the great circle between two points and then calculate the distance between them, using the radius of the sphere this has been used to help sea navigation routes planning for centuries
  • 17. geo-searching: the algorithm The haversine formula, given two locations (lat1,long1), (lat2,long2) and radius of the sphere: Δlat = lat2− lat1 Δlong = long2− long1 a = sin²(Δlat/2) + cos(lat1).cos(lat2).sin²(Δlong/2) c = 2.atan2(√a, √(1−a)) d = R.c other algorithms such as the spherical law of cosines and the Vincenty formulas are widely used as well
  • 18. geo-searching: the algorithm implementations of the haversine formula, in sql: SELECT id, ( 3959 * acos( cos( radians(inputLat) ) * cos( radians( lat ) ) * cos( radians( lng ) - radians(inputLong) ) + sin( radians(inputLat) ) * sin( radians( lat ) ) ) ) AS distance FROM markers HAVING distance < 10 ORDER BY distance; * expanded to perform a search for points of interests given a lat/long co-ordinates pair
  • 19. haversine in action server-side a. haversine sql lookup b. draw map with co- ordinates of points-of- interests friendsNearByMap.php upload location response
  • 20. that was just the beginning growing usages: location based search marketing more capable devices: iphone, smartphones, gps cameras
  • 21. references http://en.wikipedia.org/wiki/Geotagging http://www.uncorneredmarket.com/2008/02/geotagging-your-photos-importing-embedding/ http://www.codeproject.com/KB/scrapbook/ask_GoogleMap_Geocoder.aspx http://computer.howstuffworks.com/mapquest2.htm http://en.wikipedia.org/wiki/Great-circle_distance http://www.phpbites.com/2008/05/30/getting-to-the-point#more37 http://www.movable-type.co.uk/scripts/gis-faq-5.1.html http://en.wikipedia.org/wiki/Haversine_formula http://www.movable-type.co.uk/scripts/latlong.html http://code.google.com/apis/maps/articles/phpsqlsearch.html#findnearsql http://www.developer.com/lang/jscript/article.php/3615681 http://mathworld.wolfram.com/GreatCircle.html http://www.scribd.com/doc/2669666/Geo-Distance-Search-with-MySQL-Presentation
  • 22. friendsNearByMap.php <?php $mapHTML = <<<END_HTML <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> <script src="http://maps.google.com/maps? file=api&amp;v=2&amp;key=ABQIAAAAIyNua8PP_PzqZ7hTFF3NThR_fjc6V75Vk4buUDX2vYNSgRJ_LxQdsrhokMtHy8yClRqUkWyUUQy Ajg" type="text/javascript"></script> <script type="text/javascript"> function load() { if (GBrowserIsCompatible()) { var map = new GMap2(document.getElementById("map")); map.setCenter(new GLatLng($where), 16); map.addControl(new GSmallMapControl()); var tinyIcon = new GIcon(); tinyIcon.image = "http://labs.google.com/ridefinder/images/mm_20_red.png"; ... map.addOverlay(marker); END_HTML;
  • 23. friendsNearByMap.php (2) <?php // Get parameters from URL $centerLong = $_REQUEST['long']; $centerLat = $_REQUEST['lat']; // 10 miles $radius = 10; $query = sprintf("SELECT user_name, now, latitude, longitude, ( 3959 * acos( cos( radians('%s') ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians('%s') ) + sin( radians('%s') ) * sin( radians( latitude ) ) ) ) AS distance FROM plan HAVING distance < '%s' ORDER BY distance LIMIT 0 , 20", mysql_real_escape_string($centerLat), mysql_real_escape_string($centerLong), mysql_real_escape_string($centerLat), mysql_real_escape_string($radius)); $result = mysql_query($query);
  • 24. friendsNearByMap.php (3) // Iterate through the rows, print out details$i = 0; while ($row = @mysql_fetch_assoc($result)){ $nearbyUserName = $row['user_name']; $nearbyNow = $row['now']; $nearbyLatitude = $row['latitude']; $nearbyLongitude = $row['longitude']; $mapHTML = $mapHTML."n var latlng$i = new GLatLng($nearbyLatitude,$nearbyLongitude);"; $mapHTML = $mapHTML."n var marker$i = createMarker(latlng$i, '$nearbyUserName', '$nearbyNow');"; $mapHTML = $mapHTML."n map.addOverlay(marker$i);"; $i++; } ?> function createMarker(point, name, now) { var marker = new GMarker(point); var html = '<b>' + name + '</b> is now:<br/>' + now; GEvent.addListener(marker, 'click', function() { marker.openInfoWindowHtml(html); }); return marker; } </script></head> <body onload="load()" onunload="GUnload()"> <div id="map" style="width: 300px; height: 390px"></div> </body> </html>

×