1<?php
2
3namespace Elastica\Query;
4
5/**
6 * geo_shape query.
7 *
8 * @author Bennie Krijger <benniekrijger@gmail.com>
9 *
10 * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-shape-query.html
11 */
12abstract class AbstractGeoShape extends AbstractQuery
13{
14    /** Return all documents whose geo_shape field intersects the query geometry. (default behavior) */
15    const RELATION_INTERSECT = 'intersects';
16
17    /** Return all documents whose geo_shape field has nothing in common with the query geometry. */
18    const RELATION_DISJOINT = 'disjoint';
19
20    /** Return all documents whose geo_shape field is within the query geometry. */
21    const RELATION_WITHIN = 'within';
22
23    /** Return all documents whose geo_shape field contains the query geometry. */
24    const RELATION_CONTAINS = 'contains';
25
26    /**
27     * Elasticsearch path of the geo_shape field.
28     *
29     * @var string
30     */
31    protected $_path;
32
33    /**
34     * @var string
35     */
36    protected $_relation = self::RELATION_INTERSECT;
37
38    /**
39     * Sets the relation of the geo_shape field and the query geometry.
40     *
41     * Possible values: intersects, disjoint, within, contains (see constants).
42     *
43     * @param string $relation
44     *
45     * @return $this
46     */
47    public function setRelation(string $relation): self
48    {
49        $this->_relation = $relation;
50
51        return $this;
52    }
53
54    /**
55     * Gets the relation of the geo_shape field and the query geometry.
56     *
57     * @return string
58     */
59    public function getRelation(): string
60    {
61        return $this->_relation;
62    }
63}
64