com presentations: Maps/Mongo talk for 4 developers: osm-4dev12.xml slides/map/finding-food-data-mongo.xml slides/map/finding-food-take2.xml
slides/map/leaflet.xml slides/map/openlayers-location-services.xml slides/map/openlayers-location.xml slides/map/osm-data-uses.xml
slides/map/osm-mapping-party1.xml slides/map/osm-mapping-party2.xml slides/map/osm-mapping-party3.xml slides/map/reverse-services.xml

From: Date: Mon, 16 Apr 2012 19:14:55 +0000
Subject: com presentations: Maps/Mongo talk for 4 developers: osm-4dev12.xml slides/map/finding-food-data-mongo.xml slides/map/finding-food-take2.xml
slides/map/leaflet.xml slides/map/openlayers-location-services.xml slides/map/openlayers-location.xml slides/map/osm-data-uses.xml
slides/map/osm-mapping-party1.xml slides/map/osm-mapping-party2.xml slides/map/osm-mapping-party3.xml slides/map/reverse-services.xml
Groups: php.pres 
Request: Send a blank email to pres+get-1795@lists.php.net to get a copy of this message
Commit: c1e32da97a4891f639c296f48c3f5b2d999b5c7b Author: Derick Rethans <github@derickrethans.nl> Mon, 16 Apr 2012 20:14:55 +0100 Parents: 9d80a41baf385b4e8db00f969e18df6a7d771329 Branches: master Link: http://git.php.net/?p=presentations.git;a=commitdiff;h=c1e32da97a4891f639c296f48c3f5b2d999b5c7b Log: Maps/Mongo talk for 4 developers Changed paths: A osm-4dev12.xml M slides/map/finding-food-data-mongo.xml M slides/map/finding-food-take2.xml M slides/map/leaflet.xml M slides/map/openlayers-location-services.xml M slides/map/openlayers-location.xml M slides/map/osm-data-uses.xml A slides/map/osm-mapping-party1.xml A slides/map/osm-mapping-party2.xml A slides/map/osm-mapping-party3.xml M slides/map/reverse-services.xml

diff --git a/osm-4dev12.xml b/osm-4dev12.xml new file mode 100644 index 0000000..41bdef5 --- /dev/null +++ b/osm-4dev12.xml @@ -0,0 +1,72 @@ +<?xml version="1.0" encoding="utf-8"?> +<presentation + template="css" + navmode="html" + navbarbackground="#4373b4" + navbartopiclinks="0" + navColor="#f1fbff" + logo1="" + backgroundfixed="1" > +<topic>Maps</topic> +<title>Geolocation and Maps with PHP and MongoDB</title> +<event>4developers</event> +<location>Poznán, Poland</location> +<date>April 18th, 2012</date> +<speaker>Derick Rethans</speaker> +<email>derick@derickrethans.nl</email> +<twitter>derickr</twitter> +<joindin></joindin> +<slide>slides/map/title.xml</slide> + +<!-- +In this talk I will be explaining the strong points of OpenStreetMap and why +using GoogleMaps for your websites is generally a bad idea. Contrary to popular +belief, GoogleMaps isn't as amazing as it looks and they are a lot more evil +than they look. OpenStreetMap's data is also easily accessible for use in PHP +applications and the generated tiles can easily be embedded into a Web 2.0 +application. Its open nature is a welcome and powerful geo database that can be +added to and used in whatever way imaginary. +--> + +<slide>slides/map/earth-not-a-sphere.xml</slide> +<slide>slides/map/earth-sphere-approximation.xml</slide> +<slide>slides/map/meridian.xml</slide> +<slide>slides/map/projections.xml</slide> + +<!-- +What is X? +--> +<slide>slides/map/osm-what.xml</slide> +<slide>slides/map/what-is-osm.xml</slide> +<slide>slides/map/what-is-googlemaps.xml</slide> +<slide>slides/map/terms-and-conditions.xml</slide> +<slide>slides/map/openlayers-simple.xml</slide> +<slide>slides/map/leaflet.xml</slide> + +<slide>slides/map/openlayers-location.xml</slide> +<slide>slides/map/openlayers-location-services.xml</slide> +<slide>slides/map/reverse.xml</slide> +<slide>slides/map/reverse-services.xml</slide> + +<slide>slides/map/html-location-services.xml</slide> + +<slide>slides/map/osm-data.xml</slide> + +<slide>slides/map/osm-tags-edit.xml</slide> + + +<slide>slides/map/osm-mapping-party1.xml</slide> +<slide>slides/map/osm-mapping-party2.xml</slide> +<slide>slides/map/osm-editors.xml</slide> +<slide>slides/map/osm-data-uses.xml</slide> + +<slide>slides/map/osm-parse-into-db.xml</slide> +<slide>slides/map/osm-xapi.xml</slide> + +<slide>slides/map/finding-food-import-mongo.xml</slide> +<slide>slides/map/finding-food-data-mongo.xml</slide> +<slide>slides/map/finding-food-take2.xml</slide> + +<slide>slides/mongodb/resources.xml</slide> + +</presentation> diff --git a/slides/map/finding-food-data-mongo.xml b/slides/map/finding-food-data-mongo.xml index da27d51..2f31e57 100644 --- a/slides/map/finding-food-data-mongo.xml +++ b/slides/map/finding-food-data-mongo.xml @@ -6,10 +6,14 @@ header('Content-type: text/plain'); $m = new Mongo( 'mongodb://localhost:27017' ); $d = $m->selectDb( 'poi' ); - +$d->ensureIndex( array( 'poi' => '2d' ) ); +]]></example> +</div> +<div effect="fade-in-out"> +<example><![CDATA[ $wantedD = isset($_GET['d']) ? $_GET['d']: 1; - $query = array( 'tags_indexed.k' => 'cuisine', 'tags_indexed.v' => $_GET['cuisine'] ); + if ( $_GET['cuisine'] == 'all' ) { $query = array( 'tags_indexed.k' => 'amenity', 'tags_indexed.v' => 'restaurant' ); @@ -18,45 +22,67 @@ if ( $_GET['cuisine'] == 'all' ) $s = $d->command( array( 'geoNear' => 'poi', - 'spherical' => true, - 'near' => array( $_GET['lat'], $_GET['lon'] ), + 'spherical' => true, + 'near' => array( + (float) $_GET['lon'], + (float) $_GET['lat'] + ), 'num' => 1000, - 'maxDistance' => $wantedD / 6371.01, // km to ° + 'maxDistance' => $wantedD / 6371.01, 'query' => $query, ) ); -echo "lat\tlon\ttitle\tdescription\r\n"; -foreach( $s['results'] as $res) { - if (isset($res['obj']['name'] ) ) - { - echo $res['obj']['loc'][0], "\t", $res['obj']['loc'][1], "\t", - $res['obj']['name'], "\t", - sprintf('real: %.4f mongo: %.4f', - $e, - $res['dis'] * 6371.01 - ), " km away\r\n"; + +]]></example> +</div> +<div effect="fade-in-out"> +<example><![CDATA[ +foreach( $s['results'] as $res) +{ + $o = $res['obj']; + if (!isset($o['name'])) { + continue; + } + $ret = array( + 'type' => 'Feature', + 'properties' => array( + 'name' => $o['name'], + 'popupContent' => $o['name'], + ) + ); + if ($o['type'] == 1) { + $ret['geometry'] = array( + 'type' => "Point", + 'coordinates' => $o['loc'] + ); } + if ($o['type'] == 2) { + $ret['geometry'] = array( + 'type' => "Polygon", + 'coordinates' => array($o['loc']), + ); + } + $rets[] = $ret; } +echo json_encode( $rets, JSON_PRETTY_PRINT ); ]]></example> </div> -<div effect="fade-in-out"> -<blurb>MongoDB's 2D index</blurb> +<div effect="fade-in"> <example><![CDATA[ -db.poi.ensureIndex( { poi : '2d' } ); - -$s = $d->command( - array( - 'geoNear' => 'poi', - 'spherical' => true, - 'near' => array( $_GET['lon'], $_GET['lat'] ), - 'num' => 10000, - 'maxDistance' => $wantedD / 6371.01, // km to radians - 'query' => $query, - ) -); +{ + "type": "Feature", + "properties": { + "name": "La Ballerina", + "popupContent": "<b>La Ballerina<\/b><br\/>addr:housenumber: 7-8\n<br\/>addr:street: Bow street\n<br\/>amenity: restaurant\n<br\/>cuisine: italian\n<br\/>phone: +442073796659\n" + }, + "geometry": { + "type": "Point", + "coordinates": [ + -0.122713, + 51.513472 + ] + } +}, ]]></example> -<list> - <bullet>%spherical => true,% for spherical Earth calculations</bullet> -</list> </div> </slide> diff --git a/slides/map/finding-food-take2.xml b/slides/map/finding-food-take2.xml index 16ff71e..72ef0a7 100644 --- a/slides/map/finding-food-take2.xml +++ b/slides/map/finding-food-take2.xml @@ -1,5 +1,5 @@ <slide> <title>Finding Food</title> -<iframe filename='examples/find-poi-mongo.php'/> +<iframe filename='examples/find-poi-mongo2.php'/> </slide> diff --git a/slides/map/leaflet.xml b/slides/map/leaflet.xml index 10fd2cd..f7607ea 100644 --- a/slides/map/leaflet.xml +++ b/slides/map/leaflet.xml @@ -22,12 +22,10 @@ var map = new L.Map('map'); var osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', - osmAttrib = 'Map data &copy; 2011 OpenStreetMap contributors', - osm = new L.TileLayer(osmUrl, {maxZoom: 18, attribution: osmAttrib}); + osmAttrib = 'Map data &copy; 2011 OpenStreetMap contributors', + osm = new L.TileLayer(osmUrl, {maxZoom: 18, attribution: osmAttrib}); map.setView(new L.LatLng(51.5179, -0.12), 13).addLayer(osm); - - var popup = new L.Popup(); </script> </body> </html>]]></example> diff --git a/slides/map/openlayers-location-services.xml b/slides/map/openlayers-location-services.xml index 5b9b0a5..5646bfa 100644 --- a/slides/map/openlayers-location-services.xml +++ b/slides/map/openlayers-location-services.xml @@ -4,6 +4,6 @@ <list> <bullet>*Nominatim:*<br/>http://nominatim.openstreetmap.org/search?format=json&amp;limit=1&amp;q=London</bullet> - <bullet>*Yahoo:*<br/>http://where.yahooapis.com/geocode?flags=GJT&amp;appid=[yourappidhere]&amp;q=London</bullet> + <bullet>?</bullet> </list> </slide> diff --git a/slides/map/openlayers-location.xml b/slides/map/openlayers-location.xml index 7c7275a..7de1a34 100644 --- a/slides/map/openlayers-location.xml +++ b/slides/map/openlayers-location.xml @@ -6,16 +6,13 @@ <div effect="fade-in"> <example result="1"><![CDATA[ <?php +$baseUrl = 'http://nominatim.openstreetmap.org/search?format=json&limit=1'; $name = urlencode( ':-:location:-:' ); -$baseUrl = 'http://nominatim.openstreetmap.org/search?format=json&q='; -$data = file_get_contents( "{$baseUrl}{$name}&limit=1" ); +$data = file_get_contents( "{$baseUrl}&q={$name}" ); $json = json_decode( $data ); -$lat = $json[0]->lat; -$lon = $json[0]->lon; + +var_dump( $json[0] ); ?> -var lat=<?php printf( '%0.3f', $lat ); ?> -var lon=<?php printf( '%0.3f', $lon ); ?> -<?php var_dump( $json[0] ); ?> ]]></example> </div> </slide> diff --git a/slides/map/osm-data-uses.xml b/slides/map/osm-data-uses.xml index a85ec37..c1ce913 100644 --- a/slides/map/osm-data-uses.xml +++ b/slides/map/osm-data-uses.xml @@ -1,14 +1,8 @@ <slide> -<title>Using data</title> -<div effect="fade-out"> -<list> - <bullet>Quering data (API, XAPI/JXAPI, Nominatim)</bullet> - <bullet>Render and display what ever you want from it</bullet> -</list> -</div> -<div effect="fade-in-out"><image filename='style-cycle.jpg'/></div> +<title>Different visualisations of the data</title> +<div effect="fade-out"><image filename='style-cycle.jpg'/></div> <div effect="fade-in-out"><image filename='style-sea.jpg'/></div> <div effect="fade-in-out"><image filename='style-transport.jpg'/></div> <div effect="fade-in-out"><image filename='style-piste.jpg'/></div> -<div effect="fade-in-out"><image filename='style-wheel.jpg'/></div> +<div effect="fade-in"><image filename='style-wheel.jpg'/></div> </slide> diff --git a/slides/map/osm-mapping-party1.xml b/slides/map/osm-mapping-party1.xml new file mode 100644 index 0000000..a66be82 --- /dev/null +++ b/slides/map/osm-mapping-party1.xml @@ -0,0 +1,13 @@ +<slide> +<title>Mapping parties</title> +<div> +<blurb>As OSM's main purpose is creating a database of free map data:</blurb> +<list> + <bullet>data needs to be generated (surveyed), which is best done by hand</bullet> + <bullet>data needs to be added to the database: Potlatch, JOSM</bullet> + <bullet>surveying is more fun if you're not alone</bullet> + <bullet>why not do it in a group?</bullet> +</list> +<image filename='postbox.png'/> +</div> +</slide> diff --git a/slides/map/osm-mapping-party2.xml b/slides/map/osm-mapping-party2.xml new file mode 100644 index 0000000..626dddc --- /dev/null +++ b/slides/map/osm-mapping-party2.xml @@ -0,0 +1,6 @@ +<slide> +<title>Mapping parties</title> +<div> +<image filename='mapping-party.jpg'/> +</div> +</slide> diff --git a/slides/map/osm-mapping-party3.xml b/slides/map/osm-mapping-party3.xml new file mode 100644 index 0000000..bad6740 --- /dev/null +++ b/slides/map/osm-mapping-party3.xml @@ -0,0 +1,6 @@ +<slide> +<title>Mapping parties</title> +<div> +<iframe filename='http://player.vimeo.com/video/37255594?title=0&amp;byline=0&amp;portrait=0'/> +</div> +</slide> diff --git a/slides/map/reverse-services.xml b/slides/map/reverse-services.xml index 9764c8a..a48b4f3 100644 --- a/slides/map/reverse-services.xml +++ b/slides/map/reverse-services.xml @@ -5,6 +5,5 @@ <list> <bullet>*Geonames:*<br/>http://ws.geonames.org/findNearbyPlaceNameJSON?username=derick&amp;style=full&amp;lat={$lat}&amp;lng={$lon}</bullet> <bullet>*Nominatim:*<br/>http://nominatim.openstreetmap.org/reverse?format=json&amp;lat={$lat}&amp;lon={$lon}&amp;zoom={$z}</bullet> - <bullet>*Yahoo:*<br/>http://where.yahooapis.com/geocode?gflags=R&amp;flags=GJQT&amp;q={$lat},{$lon}</bullet> </list> </slide>
« previous php.pres (#1795) next »