1<?php
2
3namespace Elastica\Query;
4
5\trigger_error('Elastica\Query\GeohashCell is deprecated.', E_USER_DEPRECATED);
6
7/**
8 * Class GeohashCell.
9 *
10 * @see https://www.elastic.co/guide/en/elasticsearch/reference/2.4/query-dsl-geohash-cell-query.html
11 */
12class GeohashCell extends AbstractGeoDistance
13{
14    /**
15     * @param string       $key       The field on which to query
16     * @param array|string $location  Location as coordinates array or geohash string ['lat' => 40.3, 'lon' => 45.2]
17     * @param string|int   $precision Integer length of geohash prefix or distance (3, or "50m")
18     * @param bool         $neighbors if true, queries cells next to the given cell
19     */
20    public function __construct(string $key, $location, $precision = -1, bool $neighbors = false)
21    {
22        parent::__construct($key, $location);
23        $this->setPrecision($precision);
24        $this->setNeighbors($neighbors);
25    }
26
27    /**
28     * Set the precision for this query.
29     *
30     * @param string|int $precision Integer length of geohash prefix or distance (3, or "50m")
31     *
32     * @return $this
33     */
34    public function setPrecision($precision): self
35    {
36        return $this->setParam('precision', $precision);
37    }
38
39    /**
40     * Set the neighbours option for this query.
41     *
42     * @param bool $neighbours if true, queries cells next to the given cell
43     *
44     * @return $this
45     */
46    public function setNeighbors(bool $neighbours): self
47    {
48        return $this->setParam('neighbors', $neighbours);
49    }
50}
51