| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- <?php
- namespace Elastica\Query;
- /**
- * geo_shape query for provided shapes.
- *
- * Query provided shape definitions
- *
- * @author BennieKrijger <benniekrijger@gmail.com>
- *
- * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-shape-query.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 query.
- *
- * @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 query to array.
- *
- * @see \Elastica\Query\AbstractQuery::toArray()
- *
- * @return array
- */
- public function toArray()
- {
- return [
- 'geo_shape' => [
- $this->_path => [
- 'shape' => [
- 'type' => $this->_shapeType,
- 'coordinates' => $this->_coordinates,
- ],
- 'relation' => $this->_relation,
- ],
- ],
- ];
- }
- }
|