Skip to content

Commit 653e19d

Browse files
authored
Merge pull request #673 from ArnabChatterjee20k/spatial-attribute-support
updated distance query handling
2 parents 0c91b97 + 966c3cd commit 653e19d

File tree

2 files changed

+109
-62
lines changed

2 files changed

+109
-62
lines changed

src/Database/Query.php

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,8 @@ public static function isMethod(string $value): bool
263263
self::TYPE_NOT_CROSSES,
264264
self::TYPE_DISTANCE_EQUAL,
265265
self::TYPE_DISTANCE_NOT_EQUAL,
266+
self::TYPE_DISTANCE_GREATER_THAN,
267+
self::TYPE_DISTANCE_LESS_THAN,
266268
self::TYPE_INTERSECTS,
267269
self::TYPE_NOT_INTERSECTS,
268270
self::TYPE_OVERLAPS,
@@ -900,47 +902,51 @@ public function setOnArray(bool $bool): void
900902
*
901903
* @param string $attribute
902904
* @param array<mixed> $values
905+
* @param int|float $distance
903906
* @return Query
904907
*/
905-
public static function distanceEqual(string $attribute, array $values): self
908+
public static function distanceEqual(string $attribute, array $values, int|float $distance): self
906909
{
907-
return new self(self::TYPE_DISTANCE_EQUAL, $attribute, $values);
910+
return new self(self::TYPE_DISTANCE_EQUAL, $attribute, [[$values,$distance]]);
908911
}
909912

910913
/**
911914
* Helper method to create Query with distanceNotEqual method
912915
*
913916
* @param string $attribute
914917
* @param array<mixed> $values
918+
* @param int|float $distance
915919
* @return Query
916920
*/
917-
public static function distanceNotEqual(string $attribute, array $values): self
921+
public static function distanceNotEqual(string $attribute, array $values, int|float $distance): self
918922
{
919-
return new self(self::TYPE_DISTANCE_NOT_EQUAL, $attribute, $values);
923+
return new self(self::TYPE_DISTANCE_NOT_EQUAL, $attribute, [[$values,$distance]]);
920924
}
921925

922926
/**
923927
* Helper method to create Query with distanceGreaterThan method
924928
*
925929
* @param string $attribute
926930
* @param array<mixed> $values
931+
* @param int|float $distance
927932
* @return Query
928933
*/
929-
public static function distanceGreaterThan(string $attribute, array $values): self
934+
public static function distanceGreaterThan(string $attribute, array $values, int|float $distance): self
930935
{
931-
return new self(self::TYPE_DISTANCE_GREATER_THAN, $attribute, $values);
936+
return new self(self::TYPE_DISTANCE_GREATER_THAN, $attribute, [[$values,$distance]]);
932937
}
933938

934939
/**
935940
* Helper method to create Query with distanceLessThan method
936941
*
937942
* @param string $attribute
938943
* @param array<mixed> $values
944+
* @param int|float $distance
939945
* @return Query
940946
*/
941-
public static function distanceLessThan(string $attribute, array $values): self
947+
public static function distanceLessThan(string $attribute, array $values, int|float $distance): self
942948
{
943-
return new self(self::TYPE_DISTANCE_LESS_THAN, $attribute, $values);
949+
return new self(self::TYPE_DISTANCE_LESS_THAN, $attribute, [[$values,$distance]]);
944950
}
945951

946952
/**

0 commit comments

Comments
 (0)