diff options
author | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-05-01 15:30:47 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-05-01 15:30:47 -0400 |
commit | 7e85254903c7c0cb49e381f16b18441ea7b058cc (patch) | |
tree | b22328fcf4c8408fc25a7acb73d1cb1089cd82ac /vendor/ruflin/elastica/lib/Elastica/Filter/GeoDistance.php | |
parent | 1de335ad3f395ca6861085393ba366a9e3fb4a0d (diff) | |
parent | 1a365e77dfb8825136626202b1df462731b42060 (diff) |
Merge commit '1a365e'
Diffstat (limited to 'vendor/ruflin/elastica/lib/Elastica/Filter/GeoDistance.php')
-rw-r--r-- | vendor/ruflin/elastica/lib/Elastica/Filter/GeoDistance.php | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/GeoDistance.php b/vendor/ruflin/elastica/lib/Elastica/Filter/GeoDistance.php new file mode 100644 index 00000000..8e875365 --- /dev/null +++ b/vendor/ruflin/elastica/lib/Elastica/Filter/GeoDistance.php @@ -0,0 +1,73 @@ +<?php + +namespace Elastica\Filter; + +/** + * Geo distance filter + * + * @category Xodoa + * @package Elastica + * @author Nicolas Ruflin <spam@ruflin.com> + * @link http://www.elasticsearch.org/guide/reference/query-dsl/geo-distance-filter.html + */ +class GeoDistance extends AbstractGeoDistance +{ + const DISTANCE_TYPE_ARC = 'arc'; + const DISTANCE_TYPE_PLANE = 'plane'; + + const OPTIMIZE_BBOX_MEMORY = 'memory'; + const OPTIMIZE_BBOX_INDEXED = 'indexed'; + const OPTIMIZE_BBOX_NONE = 'none'; + + /** + * Create GeoDistance object + * + * @param string $key Key + * @param array|string $location Location as array or geohash: array('lat' => 48.86, 'lon' => 2.35) OR 'drm3btev3e86' + * @param string $distance Distance + * @throws \Elastica\Exception\InvalidException + */ + public function __construct($key, $location, $distance) + { + parent::__construct($key, $location); + + $this->setDistance($distance); + } + + /** + * @param string $distance + * @return \Elastica\Filter\GeoDistance current filter + */ + public function setDistance($distance) + { + $this->setParam('distance', $distance); + + return $this; + } + + /** + * See DISTANCE_TYPE_* constants + * + * @param string $distanceType + * @return \Elastica\Filter\GeoDistance current filter + */ + public function setDistanceType($distanceType) + { + $this->setParam('distance_type', $distanceType); + + return $this; + } + + /** + * See OPTIMIZE_BBOX_* constants + * + * @param string $optimizeBbox + * @return \Elastica\Filter\GeoDistance current filter + */ + public function setOptimizeBbox($optimizeBbox) + { + $this->setParam('optimize_bbox', $optimizeBbox); + + return $this; + } +} |