Skip to content
Snippets Groups Projects
Unverified Commit 025da8ee authored by Simonas Šerlinskas's avatar Simonas Šerlinskas
Browse files

Merge remote-tracking branch 'remotes/upstream/5.x' into 6.x

# Conflicts:
#	.travis.yml
#	composer.json
#	tests/Unit/Aggregation/Bucketing/DateRangeAggregationTest.php
parents a5729780 ce0875f1
No related branches found
No related tags found
No related merge requests found
......@@ -11,15 +11,14 @@
}
],
"require": {
"php": ">=7.0",
"symfony/serializer": "~3.0|~4.0",
"paragonie/random_compat": "^2.0",
"elasticsearch/elasticsearch": "~6.0"
"php": "^7.0",
"symfony/serializer": "^3.0|^4.0",
"paragonie/random_compat": "^1.0|^2.0"
},
"require-dev": {
"phpunit/phpunit": "~6.0",
"squizlabs/php_codesniffer": "~3.0",
"satooshi/php-coveralls": "~2.0"
"phpunit/phpunit": "^6.0",
"squizlabs/php_codesniffer": "^3.0",
"satooshi/php-coveralls": "^2.0"
},
"autoload": {
"psr-4": {
......
......@@ -23,6 +23,11 @@ class GeoShapeQuery implements BuilderInterface
{
use ParametersTrait;
const INTERSECTS = 'intersects';
const DISJOINT = 'disjoint';
const WITHIN = 'within';
const CONTAINS = 'contains';
/**
* @var array
*/
......@@ -50,10 +55,18 @@ class GeoShapeQuery implements BuilderInterface
* @param string $field Field name.
* @param string $type Shape type.
* @param array $coordinates Shape coordinates.
* @param string $relation Spatial relation.
* @param array $parameters Additional parameters.
*/
public function addShape($field, $type, array $coordinates, array $parameters = [])
public function addShape($field, $type, array $coordinates, $relation = self::INTERSECTS, array $parameters = [])
{
// TODO: remove this in the next major version
if (is_array($relation)) {
$parameters = $relation;
$relation = self::INTERSECTS;
trigger_error('$parameters as parameter 4 in addShape is deprecated', E_USER_DEPRECATED);
}
$filter = array_merge(
$parameters,
[
......@@ -62,7 +75,10 @@ class GeoShapeQuery implements BuilderInterface
]
);
$this->fields[$field]['shape'] = $filter;
$this->fields[$field] = [
'shape' => $filter,
'relation' => $relation,
];
}
/**
......
......@@ -21,7 +21,7 @@ class GeoShapeQueryTest extends \PHPUnit\Framework\TestCase
public function testToArray()
{
$filter = new GeoShapeQuery(['param1' => 'value1']);
$filter->addShape('location', 'envelope', [[13, 53], [14, 52]]);
$filter->addShape('location', 'envelope', [[13, 53], [14, 52]], GeoShapeQuery::INTERSECTS);
$expected = [
'geo_shape' => [
......@@ -30,6 +30,7 @@ class GeoShapeQueryTest extends \PHPUnit\Framework\TestCase
'type' => 'envelope',
'coordinates' => [[13, 53], [14, 52]],
],
'relation' => 'intersects'
],
'param1' => 'value1',
],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment