<slide>
<title>Aggregation: $geoNear example</title>

<iframe align="right" width="500" filename='examples/3angle/?l=pubsaggr&amp;zoom=16;&amp;lat=:-:lat:-:&amp;lon=:-:lon:-:'/>

<div effect="fade-out">
<example inline="1"><![CDATA[
res = db.poiConcat.aggregate( [ {
  '$geoNear' : { 
    'near' : {
      'type': 'Point',
      'coordinates' : [:-:lon:-:, :-:lat:-:]
    },
    'distanceField' : 'distance',
    'distanceMultiplier' : 1,
    'maxDistance' : 5000,
    'spherical' : true,
    'query' : { 
      '$or' : [
        { ts: 'amenity=pub' },
        { ts: 'amenity=bar' },
        { ts: 'amenity=restaurant' },
      ]     
    }   
  } 
} ] )
]]></example>
</div>

<div effect="fade-in-out stop">
<example inline="1"><![CDATA[
res = db.poiConcat.aggregate( [ {|
  |ff0000|'$geoNear' : { |
  |ff0000|  'near' : {|
  |ff0000|    'type': 'Point',|
  |ff0000|    'coordinates' : [:-:lon:-:, :-:lat:-:]|
  |ff0000|  },|
    'distanceField' : 'distance',
    'distanceMultiplier' : 1,
    'maxDistance' : 500,
    'spherical' : true,
    'query' : { 
      '$or' : [
        { ts: 'amenity=pub' },
        { ts: 'amenity=bar' },
        { ts: 'amenity=restaurant' },
      ]     
    }   
  } 
} ] )
]]></example>
</div>

<div effect="fade-in-out">
<example inline="1"><![CDATA[
res = db.poiConcat.aggregate( [ {
  '$geoNear' : { 
    'near' : {
      'type': 'Point',
      'coordinates' : [:-:lon:-:, :-:lat:-:]
    },
    'distanceField' : 'distance',
    'distanceMultiplier' : 1,
    'maxDistance' : 500,
    'spherical' : true,
|ff0000|    'query' : {|
|ff0000|      '$or' : [|
|ff0000|        { ts: 'amenity=pub' },|
|ff0000|        { ts: 'amenity=bar' },|
|ff0000|        { ts: 'amenity=restaurant' },|
|ff0000|      ]|
|ff0000|    }| 
  } 
} ] )
]]></example>
</div>

<div effect="fade-in">
<example inline="1"><![CDATA[
> res.result[0]
{
  "_id" : "n312156665",
  "ty" : NumberLong(1),
  "l" : {
    "type" : "Point",
    "coordinates" : [
      -0.121732,
      51.5145794
    ]
  },
  "ts" : [
    "amenity=pub",
    "name=The Prince of Wales",
    "toilets=yes",
    "toilets:access=customers"
  ],
  |ff0000|"distance" : 22.432289888830912|
}
]]></example>
</div>
</slide>
