com presentations: PHP NorthWest UG July 2013 slides.: phpnw-2013.xml slides/map/flat-sphere-flickr.xml slides/map/osm-xapi.xml
slides/mongodb/geo-aggregation2.xml slides/mongodb/geo-intersects.xml slides/mongodb/geo-near.xml slides/mongodb/geo-within.xml
templates/default/iframe.ezt

From: Date: Wed, 26 Jun 2013 12:59:57 +0000
Subject: com presentations: PHP NorthWest UG July 2013 slides.: phpnw-2013.xml slides/map/flat-sphere-flickr.xml slides/map/osm-xapi.xml
slides/mongodb/geo-aggregation2.xml slides/mongodb/geo-intersects.xml slides/mongodb/geo-near.xml slides/mongodb/geo-within.xml
templates/default/iframe.ezt
Groups: php.pres 
Request: Send a blank email to pres+get-1900@lists.php.net to get a copy of this message
Commit: d882220e8bd9b18baec0d8146e0dccda56b40dcd Author: Derick Rethans <github@derickrethans.nl> Wed, 26 Jun 2013 08:59:57 -0400 Parents: 10a3296abd4b03a5582377a0cabdb5d0b1206cba Branches: master Link: http://git.php.net/?p=presentations.git;a=commitdiff;h=d882220e8bd9b18baec0d8146e0dccda56b40dcd Log: PHP NorthWest UG July 2013 slides. Changed paths: A phpnw-2013.xml A slides/map/flat-sphere-flickr.xml M slides/map/osm-xapi.xml M slides/mongodb/geo-aggregation2.xml M slides/mongodb/geo-intersects.xml M slides/mongodb/geo-near.xml M slides/mongodb/geo-within.xml M templates/default/iframe.ezt

diff --git a/phpnw-2013.xml b/phpnw-2013.xml new file mode 100644 index 0000000..95e0c83 --- /dev/null +++ b/phpnw-2013.xml @@ -0,0 +1,169 @@ +<?xml version="1.0" encoding="utf-8"?> +<presentation css="10gen-strict.css"> +<topic>MongoDB</topic> +<title>Finding Pubs… (and other things)</title> +<event>PHP NorthWest July</event> +<location>Manchester, UK</location> +<lat>53.4810</lat><lon>-2.2333</lon> +<date>July 2nd, 2013</date> +<speaker>Derick Rethans</speaker> +<email>derick@10gen.com</email> +<twitter>derickr</twitter> +<joindin>http://derickrethans.nl/talks/phpnw-2013</joindin> + +<slide>slides/mongodb/title.xml</slide> + +<slide>slides/mongodb/closed-pub.xml</slide> +<!-- A few words about our dataset --> +<slide>slides/mongodb/few-words-about-osm.xml</slide> + +<slide>slides/mongodb/flat-vs-sphere.xml</slide> + +<slide>slides/map/flat-sphere-flickr.xml</slide> + +<!-- DATA STORAGE --> +<!-- + No more [ lon, lat ], but geojson instead + +SAY WHERE ELSE GeoJson is used +--> +<slide>slides/mongodb/geojson.xml</slide> + +<!-- + POINT: + show an image, and the GeoJson under +--> +<slide>slides/mongodb/geojson-point.xml</slide> +<!-- + LINESTRING: + show an image, and the GeoJson under +--> +<slide>slides/mongodb/geojson-linestring.xml</slide> +<!-- + POLYGON: + show an image, and the GeoJson under +--> +<slide>slides/mongodb/geojson-polygon.xml</slide> + +<!-- + CELLS, + We divide the surface of the earth into cells + A library called S2 from Google does the hard work + Cells have a level which define the size of the cell. + S2 provides 31 levels + The higher the level, the smaller the cell, and therefore the more needed to cover the earth + By default, we use all levels between 500m on a side and 100km on a side +--> +<slide>slides/mongodb/cells.xml</slide> +<!-- + Show grid of (part of) London: + - Point, Westminster palace + - Line, Oxford Street + - Polygon, Hyde Park +--> +<slide>slides/mongodb/cells-level10-example-london-1.xml</slide> +<slide>slides/mongodb/cells-level10-example-london-2.xml</slide> +<slide>slides/mongodb/cells-level10-example-london-3.xml</slide> + + +<!-- operators + $near + find stuff near a point + index required + $geoWithin + find stuff within a polygon/circle + index NOT required + $geoIntersects + find stuff that intersects with other stuff + index NOT required + +--> +<slide>slides/mongodb/geo-in-2.4.xml</slide> + +<!-- near + - Example with road and park + - slide with index/no index, and comparsion with 2.2? +--> +<!-- geoWithin + - Example with road and park + - slide with index/no index, and comparsion with 2.2? +--> +<!-- geoIntersects + - Example with road and park + - slide with index/no index, and comparsion with 2.2? +--> +<slide>slides/mongodb/geo-near.xml</slide> + +<!-- + NEAR + + Starts from a point + Looks at concentric donuts from that point + Want to look at documents within the donut + If distance from query point to document is within the donut, output + Adapts size of the donut as needed +--> +<slide>slides/mongodb/geo-near-explanation-0.xml</slide> +<slide>slides/mongodb/geo-near-explanation-1.xml</slide> +<slide>slides/mongodb/geo-near-explanation-2.xml</slide> +<slide>slides/mongodb/geo-near-explanation-3.xml</slide> +<slide>slides/mongodb/geo-near-explanation-4.xml</slide> +<slide>slides/mongodb/geo-near-explanation-5.xml</slide> +<slide>slides/mongodb/geo-near-explanation-6.xml</slide> +<slide>slides/mongodb/geo-near-explanation-7.xml</slide> + +<!-- + GeoWithin/GeoIntersecs + + Generate a covering for geometry in query + Look at all points in all overlapping cells + Cells may be larger or smaller than our covering + Must look at cells that contain our covering + Must look at cells that we contain + See if documents are within or intersect our query geometry + + Show examples of: + - within: The Palace of Westminster (point) in "City of Westminster" (polygon) + - intersect: thames (line) crossing London (polygon) +--> +<slide>slides/mongodb/geo-within.xml</slide> +<slide>slides/mongodb/geo-within-1.xml</slide> +<slide>slides/mongodb/geo-within-2.xml</slide> + +<slide>slides/mongodb/geo-intersects.xml</slide> + + +<!-- +Without index: + $near + Look at every point + Sort by distance + Very slow, so requires an index. + $geoWithin + Look at every document + Is it within the query polygon? + Order is arbitrary + $geoIntersects + Look at every document + Does it intersect with the query geometry? + Order is arbitrary +--> +<!-- AGGREGATION: + + - show tube stations per borough + - show pubs by borough + +http://docs.mongodb.org/manual/reference/aggregation/#stage._S_geoNear + +- distance is important +- $geoNear in aggregation can't deal with more than one 2dsphere index +- spherical option is *required* when using a 2dsphere index +--> +<slide>slides/mongodb/geo-aggregation.xml</slide> +<slide>slides/mongodb/geo-aggregation2.xml</slide> + +<slide>slides/map/osm-xapi.xml</slide> + +<slide>slides/mongodb/resources.xml</slide> + +</presentation> diff --git a/slides/map/flat-sphere-flickr.xml b/slides/map/flat-sphere-flickr.xml new file mode 100644 index 0000000..c6c2d66 --- /dev/null +++ b/slides/map/flat-sphere-flickr.xml @@ -0,0 +1,5 @@ +<slide> +<title>Flat vs. Sphere</title> + +<iframe filename='examples/3angle/?l=flickr&amp;zoom=12'/> +</slide> diff --git a/slides/map/osm-xapi.xml b/slides/map/osm-xapi.xml index 68f1ab0..2fca453 100644 --- a/slides/map/osm-xapi.xml +++ b/slides/map/osm-xapi.xml @@ -4,16 +4,17 @@ <div effect="fade-out stop"> <blurb>The whole planet (bad idea as it's 26GB):</blurb> <example>http://planet.openstreetmap.org/planet/planet-latest.osm.bz2</example> -<break/> <blurb>A whole country:</blurb> <example>http://download.geofabrik.de/openstreetmap/europe/great_britain/england.osm.bz2</example> -<blurb>Or pick a smaller country from<br/> -%http://download.geofabrik.de/openstreetmap/%</blurb> -<break/> +<blurb>Or pick a smaller country from</blurb> +<example>http://download.geofabrik.de/openstreetmap/</example> + +<blurb>A metro extract:</blurb> +<example>http://metro.teczno.com/#manchester</example> <blurb>XAPI (via Overpass):</blurb> -<example>http://www.overpass-api.de/api/xapi?*[bbox=7.1,51.2,7.2,51.3][amenity=restaurant]</example> +<example>http://www.overpass-api.de/api/xapi?*[bbox=7.1,51.2,7.2,51.3][amenity=pub]</example> </div> <div effect="fade-in"> @@ -28,8 +29,7 @@ $bb = '&lt;bbox-query e="0.334" n="51.691" s="51.286" w="-0.510"/>'; * &lt;query type="way">&lt;has-kv k="amenity" v="pub"/>$bb&lt;/query>* *&lt;/union>* *&lt;query type="node">* -* &lt;around radius="2"/>* -* &lt;has-kv k="highway" v="bus_stop"/>* +* &lt;has-kv k="real_cider" v="yes"/>* *&lt;/query>* *&lt;print/>* *ENDDATA;* diff --git a/slides/mongodb/geo-aggregation2.xml b/slides/mongodb/geo-aggregation2.xml index 1ac9248..fdcb80d 100644 --- a/slides/mongodb/geo-aggregation2.xml +++ b/slides/mongodb/geo-aggregation2.xml @@ -1,19 +1,19 @@ <slide> <title>Aggregation: $geoNear example</title> -<image filename="pubs-distance.png" align="right"/> +<iframe align="right" width="500" filename='examples/3angle/?l=pubsaggr&amp;zoom=17;&amp;lat=:-:lat:-:&amp;lon=:-:lon:-:'/> <div effect="fade-out"> <example inline="1"><![CDATA[ -maxDist = 500; -rEarth = 6371000; - res = db.poiConcat.aggregate( [ { '$geoNear' : { - 'near' : [ -0.122055, 51.514562 ], + 'near' : { + 'type': 'Point', + 'coordinates' : [:-:lon:-:, :-:lat:-:] + }, 'distanceField' : 'distance', - 'distanceMultiplier' : rEarth, - 'maxDistance' : maxDist / rEarth, + 'distanceMultiplier' : 1, + 'maxDistance' : 500, 'spherical' : true, 'query' : { '$or' : [ @@ -28,45 +28,45 @@ res = db.poiConcat.aggregate( [ { <div effect="fade-in-out"> <example inline="1"><![CDATA[ -maxDist = 500; -rEarth = 6371000; - -res = db.poiConcat.aggregate( [ { - |ff0000|'$geoNear' : {| - |ff0000|'near' : [ -0.122055, 51.514562 ],| +res = db.poiConcat.aggregate( [ {| + |ff0000|'$geoNear' : { | + |ff0000| 'near' : {| + |ff0000| 'type': 'Point',| + |ff0000| 'coordinates' : [:-:lon:-:, :-:lat:-:]| + |ff0000| },| 'distanceField' : 'distance', - 'distanceMultiplier' : rEarth, - 'maxDistance' : maxDist / rEarth, - |ff0000|'spherical' : true,| - |ff0000|'query' : {| - |ff0000|'$or' : [| - |ff0000|{ ts: 'amenity=pub' },| - |ff0000|{ ts: 'amenity=bar' },| - |ff0000|]| - |ff0000|}| - |ff0000|} | + 'distanceMultiplier' : 1, + 'maxDistance' : 500, + 'spherical' : true, + 'query' : { + '$or' : [ + { ts: 'amenity=pub' }, + { ts: 'amenity=bar' }, + ] + } + } } ] ) ]]></example> </div> <div effect="fade-in-out"> <example inline="1"><![CDATA[ -|ff0000|maxDist = 500;| -|ff0000|rEarth = 6371000;| - res = db.poiConcat.aggregate( [ { '$geoNear' : { - 'near' : [ -0.122055, 51.514562 ], - |ff0000|'distanceField' : 'distance',| - |ff0000|'distanceMultiplier' : rEarth,| - |ff0000|'maxDistance' : maxDist / rEarth,| + 'near' : { + 'type': 'Point', + 'coordinates' : [:-:lon:-:, :-:lat:-:] + }, + 'distanceField' : 'distance', + 'distanceMultiplier' : 1, + 'maxDistance' : 500, 'spherical' : true, - 'query' : { - '$or' : [ - { ts: 'amenity=pub' }, - { ts: 'amenity=bar' }, - ] - } +|ff0000| 'query' : {| +|ff0000| '$or' : [| +|ff0000| { ts: 'amenity=pub' },| +|ff0000| { ts: 'amenity=bar' },| +|ff0000| ]| +|ff0000| }| } } ] ) ]]></example> diff --git a/slides/mongodb/geo-intersects.xml b/slides/mongodb/geo-intersects.xml index d056466..79237d5 100644 --- a/slides/mongodb/geo-intersects.xml +++ b/slides/mongodb/geo-intersects.xml @@ -18,6 +18,7 @@ db.poiConcat.find( { $exists: true } } ); + </example> <example inline="1"> diff --git a/slides/mongodb/geo-near.xml b/slides/mongodb/geo-near.xml index a22113f..5a21375 100644 --- a/slides/mongodb/geo-near.xml +++ b/slides/mongodb/geo-near.xml @@ -1,7 +1,10 @@ <slide> <title>Example with $near</title> +<!-- <image filename="near-pub.png" align="right"/> +--> +<iframe align="right" width="500" filename='examples/3angle/?l=fivepubs&amp;zoom=14;&amp;lat=:-:lat:-:&amp;lon=:-:lon:-:'/> <example inline="1"> db.poiConcat.find( { diff --git a/slides/mongodb/geo-within.xml b/slides/mongodb/geo-within.xml index 13c4221..8320985 100644 --- a/slides/mongodb/geo-within.xml +++ b/slides/mongodb/geo-within.xml @@ -16,6 +16,7 @@ db.poiConcat.find( { *} },* ts: "amenity=cafe" } ); + </example> <example inline="1"> diff --git a/templates/default/iframe.ezt b/templates/default/iframe.ezt index 77680e4..5305ed8 100644 --- a/templates/default/iframe.ezt +++ b/templates/default/iframe.ezt @@ -1,14 +1,17 @@ {use $node, $pres, $inline = false} {var $align = get_attribute( $node, 'align' )} {var $attr = get_attribute( $node, 'attr' )} +{var $width = get_attribute( $node, 'width' )} {var $height = get_attribute( $node, 'height' )} {var $source = ''} +{if !$width}{$width = 1010}{/if} +{if !$height}{$height = 592}{/if} {if str_starts_with(get_attribute($node, 'filename'), 'http://')} {$source = get_attribute($node, 'filename')} {else} {$source = str_append($pres->base, get_attribute( $node, 'filename' ))} {/if} {if $attr}<div{if $align} align='{$align}'{/if}>{/if} -<iframe style="clear: both; background-color: #fff; margin-left: 9px;" scrolling="no" frameborder="0" width="1010" height="592" {if $inline}class='inline' {/if}{if $align}align='{$align}' {/if}src='{$source}'></iframe> +<iframe style="clear: both; background-color: #fff; margin-left: 9px;" scrolling="no" frameborder="0" width="{$width}" height="{$height}" {if $inline}class='inline' {/if}{if $align}align='{$align}' {/if}src='{$source}'></iframe> <img src="{$pres->base}{get_attribute( $node, 'image' )}"/> {if $attr}<span class='attribution'>{$attr}</span></div>{/if}
« previous php.pres (#1900) next »