diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2015-12-17 09:15:42 +0100 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2015-12-17 09:44:51 +0100 |
commit | a1789ddde42033f1b05cc4929491214ee6e79383 (patch) | |
tree | 63615735c4ddffaaabf2428946bb26f90899f7bf /vendor/ruflin/elastica/lib/Elastica/Filter/GeoShapeProvided.php | |
parent | 9e06a62f265e3a2aaabecc598d4bc617e06fa32d (diff) |
Update to MediaWiki 1.26.0
Diffstat (limited to 'vendor/ruflin/elastica/lib/Elastica/Filter/GeoShapeProvided.php')
-rw-r--r-- | vendor/ruflin/elastica/lib/Elastica/Filter/GeoShapeProvided.php | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/GeoShapeProvided.php b/vendor/ruflin/elastica/lib/Elastica/Filter/GeoShapeProvided.php new file mode 100644 index 00000000..0f25beeb --- /dev/null +++ b/vendor/ruflin/elastica/lib/Elastica/Filter/GeoShapeProvided.php @@ -0,0 +1,73 @@ +<?php +namespace Elastica\Filter; + +/** + * geo_shape filter or provided shapes. + * + * Filter provided shape definitions + * + * @author BennieKrijger <benniekrijger@gmail.com> + * + * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-shape-filter.html + */ +class GeoShapeProvided extends AbstractGeoShape +{ + const TYPE_ENVELOPE = 'envelope'; + const TYPE_MULTIPOINT = 'multipoint'; + const TYPE_POINT = 'point'; + const TYPE_MULTIPOLYGON = 'multipolygon'; + const TYPE_LINESTRING = 'linestring'; + const TYPE_POLYGON = 'polygon'; + + /** + * Type of the geo_shape. + * + * @var string + */ + protected $_shapeType; + + /** + * Coordinates making up geo_shape. + * + * @var array Coordinates making up geo_shape + */ + protected $_coordinates; + + /** + * Construct geo_shape filter. + * + * @param string $path The path/field of the shape searched + * @param array $coordinates Points making up the shape + * @param string $shapeType Type of the geo_shape: + * point, envelope, linestring, polygon, + * multipoint or multipolygon + */ + public function __construct($path, array $coordinates, $shapeType = self::TYPE_ENVELOPE) + { + $this->_path = $path; + $this->_shapeType = $shapeType; + $this->_coordinates = $coordinates; + } + + /** + * Converts filter to array. + * + * @see \Elastica\Filter\AbstractFilter::toArray() + * + * @return array + */ + public function toArray() + { + return array( + 'geo_shape' => array( + $this->_path => array( + 'shape' => array( + 'type' => $this->_shapeType, + 'coordinates' => $this->_coordinates, + ), + 'relation' => $this->_relation, + ), + ), + ); + } +} |