From 1a365e77dfb8825136626202b1df462731b42060 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sun, 16 Aug 2015 08:22:05 +0200 Subject: Update to MediaWiki 1.25.2 --- .../lib/Elastica/Aggregation/GeoDistance.php | 90 ++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 vendor/ruflin/elastica/lib/Elastica/Aggregation/GeoDistance.php (limited to 'vendor/ruflin/elastica/lib/Elastica/Aggregation/GeoDistance.php') diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/GeoDistance.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/GeoDistance.php new file mode 100644 index 00000000..76c871ea --- /dev/null +++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/GeoDistance.php @@ -0,0 +1,90 @@ +setField($field)->setOrigin($origin); + } + + /** + * Set the field for this aggregation + * @param string $field the name of the document field on which to perform this aggregation + * @return GeoDistance + */ + public function setField($field) + { + return $this->setParam('field', $field); + } + + /** + * Set the origin point from which distances will be calculated + * @param string|array $origin valid formats are array("lat" => 52.3760, "lon" => 4.894), "52.3760, 4.894", and array(4.894, 52.3760) + * @return GeoDistance + */ + public function setOrigin($origin) + { + return $this->setParam("origin", $origin); + } + + /** + * Add a distance range to this aggregation + * @param int $fromValue a distance + * @param int $toValue a distance + * @return GeoDistance + * @throws \Elastica\Exception\InvalidException + */ + public function addRange($fromValue = null, $toValue = null) + { + if (is_null($fromValue) && is_null($toValue)) { + throw new InvalidException("Either fromValue or toValue must be set. Both cannot be null."); + } + $range = array(); + if (!is_null($fromValue)) { + $range['from'] = $fromValue; + } + if (!is_null($toValue)) { + $range['to'] = $toValue; + } + return $this->addParam("ranges", $range); + } + + /** + * Set the unit of distance measure for this aggregation + * @param string $unit defaults to km + * @return GeoDistance + */ + public function setUnit($unit) + { + return $this->setParam("unit", $unit); + } + + /** + * Set the method by which distances will be calculated + * @param string $distanceType see DISTANCE_TYPE_* constants for options. Defaults to sloppy_arc. + * @return GeoDistance + */ + public function setDistanceType($distanceType) + { + return $this->setParam("distance_type", $distanceType); + } +} \ No newline at end of file -- cgit v1.2.2