Skip to content

Commit e97f6b3

Browse files
committed
Adds shape type constants to GeoShapeQuery
Also updates associated unit test
1 parent b4c3c89 commit e97f6b3

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

Diff for: src/Query/Geo/GeoShapeQuery.php

+15
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,21 @@ class GeoShapeQuery implements BuilderInterface
2828
const WITHIN = 'within';
2929
const CONTAINS = 'contains';
3030

31+
/*
32+
* Available shape types for addShape() $type param.
33+
*
34+
* @link https://www.elastic.co/guide/en/elasticsearch/reference/current/geo-shape.html#input-structure
35+
*/
36+
const SHAPE_TYPE_POINT = 'point';
37+
const SHAPE_TYPE_LINESTRING = 'linestring';
38+
const SHAPE_TYPE_POLYGON = 'polygon';
39+
const SHAPE_TYPE_MULTIPOINT = 'multipoint';
40+
const SHAPE_TYPE_MULTILINESTRING = 'multilinestring';
41+
const SHAPE_TYPE_MULTIPOLYGON = 'multipolygon';
42+
const SHAPE_TYPE_GEOMETRYCOLLECTION = 'geometrycollection';
43+
const SHAPE_TYPE_ENVELOPE = 'envelope';
44+
const SHAPE_TYPE_CIRCLE = 'circle';
45+
3146
/**
3247
* @var array
3348
*/

Diff for: tests/Unit/Query/Geo/GeoShapeQueryTest.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,12 @@ class GeoShapeQueryTest extends \PHPUnit\Framework\TestCase
2121
public function testToArray()
2222
{
2323
$filter = new GeoShapeQuery(['param1' => 'value1']);
24-
$filter->addShape('location', 'envelope', [[13, 53], [14, 52]], GeoShapeQuery::INTERSECTS);
24+
$filter->addShape(
25+
'location',
26+
GeoShapeQuery::SHAPE_TYPE_ENVELOPE,
27+
[[13, 53], [14, 52]],
28+
GeoShapeQuery::INTERSECTS
29+
);
2530

2631
$expected = [
2732
'geo_shape' => [

0 commit comments

Comments
 (0)