Skip to content

Commit be2d341

Browse files
committed
Adds shape type constants to GeoShapeQuery
1 parent b4c3c89 commit be2d341

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
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

+7-2
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,18 @@ 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' => [
2833
'location' => [
2934
'shape' => [
30-
'type' => 'envelope',
35+
'type' => GeoShapeQuery::SHAPE_TYPE_ENVELOPE,
3136
'coordinates' => [[13, 53], [14, 52]],
3237
],
3338
'relation' => 'intersects'

0 commit comments

Comments
 (0)