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

<image filename="pubs-distance.png" align="right"/>

<div effect="fade-out">
<example inline="1"><![CDATA[
$center = new GeoJSONPoint(
  (float) $_GET['lon'],
  (float) $_GET['lat']
);
$maxDist =     500; // in meters
$rEarth  = 6371000;

$res = $c->aggregate( [
  '$geoNear' => [
    'near' => $center->p,
    'distanceField' => 'distance',
    'distanceMultiplier' => $rEarth,
    'maxDistance' => $maxDist / $rEarth,
    'spherical' => true,
    'query' => [
      '$or' => [
        [ TAGS => 'amenity=pub' ],
        [ TAGS => 'amenity=bar' ]
      ]
    ],
  ]
] );
]]></example>
</div>

<div effect="fade-in-out">
<example inline="1"><![CDATA[
$center = new GeoJSONPoint(
  (float) $_GET['lon'],
  (float) $_GET['lat']
);
$maxDist =     500; // in meters
$rEarth  = 6371000;

$res = $c->aggregate( [
  |ff0000|'$geoNear' => [|
    |ff0000|'near' => $center->p,|
    'distanceField' => 'distance',
    'distanceMultiplier' => $rEarth,
    'maxDistance' => $maxDist / $rEarth,
    |ff0000|'spherical' => true,|
    |ff0000|'query' => [|
      |ff0000|'$or' => [|
        |ff0000|[ TAGS => 'amenity=pub' ],|
        |ff0000|[ TAGS => 'amenity=bar' ]|
      |ff0000|]|
    |ff0000|],|
  |ff0000|]|
] );
]]></example>
</div>

<div effect="fade-in-out">
<example inline="1"><![CDATA[
$center = new GeoJSONPoint(
  (float) $_GET['lon'],
  (float) $_GET['lat']
);

|ff0000|$maxDist =     500; // in meters|
|ff0000|$rEarth  = 6371000;|

$res = $c->aggregate( [
  '$geoNear' => [
    'near' => $center->p,
    |ff0000|'distanceField' => 'distance',|
    |ff0000|'distanceMultiplier' => $rEarth,|
    |ff0000|'maxDistance' => $maxDist / $rEarth,|
    'spherical' => true,
    'query' => [
      '$or' => [
        [ TAGS => 'amenity=pub' ],
        [ TAGS => 'amenity=bar' ]
      ]
    ],
  ]
] );
]]></example>
</div>

<div effect="fade-in-out">
<example inline="1"><![CDATA[
]]></example>
</div>
</slide>
