GeohashCell.php 1.5 KB

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