summaryrefslogtreecommitdiff
path: root/vendor/ruflin/elastica/lib/Elastica/Filter/GeoPolygon.php
blob: fa12c035f749623411805b4ef6e7dc66c943a0fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php

namespace Elastica\Filter;

use Elastica\Filter\AbstractFilter;

/**
 * Geo polygon filter
 *
 * @category Xodoa
 * @package Elastica
 * @author Michael Maclean <mgdm@php.net>
 * @link http://www.elasticsearch.org/guide/reference/query-dsl/geo-polygon-filter.html
 */
class GeoPolygon extends AbstractFilter
{
    /**
     * Key
     *
     * @var string Key
     */
    protected $_key = '';

    /**
     * Points making up polygon
     *
     * @var array Points making up polygon
     */
    protected $_points = array();

    /**
     * Construct polygon filter
     *
     * @param string $key    Key
     * @param array  $points Points making up polygon
     */
    public function __construct($key, array $points)
    {
        $this->_key = $key;
        $this->_points = $points;
    }

    /**
     * Converts filter to array
     *
     * @see \Elastica\Filter\AbstractFilter::toArray()
     * @return array
     */
    public function toArray()
    {
        return array(
            'geo_polygon' => array(
                $this->_key => array(
                    'points' => $this->_points
                ),
            )
        );
    }
}