Skip to content

Commit f74bc09

Browse files
using earth radius through a const
1 parent 32bf039 commit f74bc09

2 files changed

Lines changed: 2 additions & 1 deletion

File tree

‎src/Database/Adapter/MariaDB.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1396,7 +1396,7 @@ protected function handleDistanceSpatialQueries(Query $query, array &$binds, str
13961396
if ($wktType != Database::VAR_POINT || $attrType != Database::VAR_POINT) {
13971397
throw new QueryException('Distance in meters is not supported between '.$attrType . ' and '. $wktType);
13981398
}
1399-
return "ST_DISTANCE_SPHERE({$alias}.{$attribute}, " . $this->getSpatialGeomFromText(":{$placeholder}_0") . ", 6371000) {$operator} :{$placeholder}_1";
1399+
return "ST_DISTANCE_SPHERE({$alias}.{$attribute}, " . $this->getSpatialGeomFromText(":{$placeholder}_0") . ", " . Database::EARTH_RADIUS . ") {$operator} :{$placeholder}_1";
14001400
}
14011401
return "ST_Distance({$alias}.{$attribute}, " . $this->getSpatialGeomFromText(":{$placeholder}_0") . ") {$operator} :{$placeholder}_1";
14021402
}

‎src/Database/Database.php‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ class Database
5151

5252
// Global SRID for geographic coordinates (WGS84)
5353
public const SRID = 4326;
54+
public const EARTH_RADIUS = 6371000;
5455

5556
// Relationship Types
5657
public const VAR_RELATIONSHIP = 'relationship';

0 commit comments

Comments
 (0)