From 1f75bb8d9a88b2883f3af9c17e2df27f506dfbbd Mon Sep 17 00:00:00 2001 From: Phil Kingston Date: Thu, 16 Nov 2017 15:23:01 +0000 Subject: [PATCH 1/5] Add ST_Distance_Sphere function for MySQL (since MySQL v5.7) --- .../ORM/Query/AST/Functions/MySql/SRID.php | 2 +- .../AST/Functions/MySql/STDistanceSphere.php | 40 +++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 lib/CrEOF/Spatial/ORM/Query/AST/Functions/MySql/STDistanceSphere.php diff --git a/lib/CrEOF/Spatial/ORM/Query/AST/Functions/MySql/SRID.php b/lib/CrEOF/Spatial/ORM/Query/AST/Functions/MySql/SRID.php index 99943e50..4e7ac99d 100644 --- a/lib/CrEOF/Spatial/ORM/Query/AST/Functions/MySql/SRID.php +++ b/lib/CrEOF/Spatial/ORM/Query/AST/Functions/MySql/SRID.php @@ -30,7 +30,7 @@ * SRID DQL function * * @author Mohammad Heydari - * @license http://mdhheydari.mit-license.org MIT + * @license https://philkingston.mit-license.org MIT */ class SRID extends AbstractSpatialDQLFunction { diff --git a/lib/CrEOF/Spatial/ORM/Query/AST/Functions/MySql/STDistanceSphere.php b/lib/CrEOF/Spatial/ORM/Query/AST/Functions/MySql/STDistanceSphere.php new file mode 100644 index 00000000..bfd543cb --- /dev/null +++ b/lib/CrEOF/Spatial/ORM/Query/AST/Functions/MySql/STDistanceSphere.php @@ -0,0 +1,40 @@ + + * @license http://dlambert.mit-license.org MIT + */ +class STDistanceSphere extends AbstractSpatialDQLFunction +{ + protected $platforms = array('mysql'); + protected $functionName = 'ST_Distance_Sphere'; + protected $minGeomExpr = 2; + protected $maxGeomExpr = 2; +} From f11d2ca7a3470e616ef7d905312b4be002b501e3 Mon Sep 17 00:00:00 2001 From: Phil Kingston Date: Thu, 16 Nov 2017 15:26:52 +0000 Subject: [PATCH 2/5] Fix comments --- lib/CrEOF/Spatial/ORM/Query/AST/Functions/MySql/SRID.php | 2 +- .../ORM/Query/AST/Functions/MySql/STDistanceSphere.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/CrEOF/Spatial/ORM/Query/AST/Functions/MySql/SRID.php b/lib/CrEOF/Spatial/ORM/Query/AST/Functions/MySql/SRID.php index 4e7ac99d..99943e50 100644 --- a/lib/CrEOF/Spatial/ORM/Query/AST/Functions/MySql/SRID.php +++ b/lib/CrEOF/Spatial/ORM/Query/AST/Functions/MySql/SRID.php @@ -30,7 +30,7 @@ * SRID DQL function * * @author Mohammad Heydari - * @license https://philkingston.mit-license.org MIT + * @license http://mdhheydari.mit-license.org MIT */ class SRID extends AbstractSpatialDQLFunction { diff --git a/lib/CrEOF/Spatial/ORM/Query/AST/Functions/MySql/STDistanceSphere.php b/lib/CrEOF/Spatial/ORM/Query/AST/Functions/MySql/STDistanceSphere.php index bfd543cb..fd0dd4b1 100644 --- a/lib/CrEOF/Spatial/ORM/Query/AST/Functions/MySql/STDistanceSphere.php +++ b/lib/CrEOF/Spatial/ORM/Query/AST/Functions/MySql/STDistanceSphere.php @@ -28,8 +28,8 @@ /** * ST_Distance_Sphere DQL function * - * @author Derek J. Lambert - * @license http://dlambert.mit-license.org MIT + * @author Phil Kingston + * @license https://philkingston.mit-license.org MIT */ class STDistanceSphere extends AbstractSpatialDQLFunction { From e5b17ec8380d02f361707715d27b8e44c5e34d5e Mon Sep 17 00:00:00 2001 From: Phil Kingston Date: Tue, 10 Sep 2024 22:13:11 +0100 Subject: [PATCH 3/5] Update AsBinary --- lib/CrEOF/Spatial/ORM/Query/AST/Functions/MySql/AsBinary.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/CrEOF/Spatial/ORM/Query/AST/Functions/MySql/AsBinary.php b/lib/CrEOF/Spatial/ORM/Query/AST/Functions/MySql/AsBinary.php index 2c1943d8..589f5f74 100644 --- a/lib/CrEOF/Spatial/ORM/Query/AST/Functions/MySql/AsBinary.php +++ b/lib/CrEOF/Spatial/ORM/Query/AST/Functions/MySql/AsBinary.php @@ -36,7 +36,7 @@ class AsBinary extends AbstractSpatialDQLFunction implements ReturnsGeometryInte { protected $platforms = array('mysql'); - protected $functionName = 'AsBinary'; + protected $functionName = 'ST_AsBinary'; protected $minGeomExpr = 1; From 53805e9bf02688bf6f7cd353b2a102d962b2609e Mon Sep 17 00:00:00 2001 From: Phil Kingston Date: Tue, 10 Sep 2024 22:36:12 +0100 Subject: [PATCH 4/5] Update package name --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index b5b179de..5f38a78c 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "creof/doctrine2-spatial", + "name": "philkingston/doctrine2-spatial", "type": "library", "description": "Doctrine2 multi-platform support for spatial types and functions", "keywords": ["orm", "dbal", "database", "postgresql", "mysql", "opengis", "postgis", "gis", "spatial", "geometry", "geography"], From 7b7f2f54695dab8ebc34338f3adc0c4d9096f054 Mon Sep 17 00:00:00 2001 From: Phil Kingston Date: Wed, 30 Oct 2024 15:50:57 +0000 Subject: [PATCH 5/5] Use ST_ versions of statements --- lib/CrEOF/Spatial/DBAL/Platform/MySql.php | 4 ++-- .../Spatial/ORM/Query/AST/Functions/MySql/GeomFromText.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/CrEOF/Spatial/DBAL/Platform/MySql.php b/lib/CrEOF/Spatial/DBAL/Platform/MySql.php index 4444fca4..7cf3ea2e 100644 --- a/lib/CrEOF/Spatial/DBAL/Platform/MySql.php +++ b/lib/CrEOF/Spatial/DBAL/Platform/MySql.php @@ -58,7 +58,7 @@ public function getSQLDeclaration(array $fieldDeclaration) */ public function convertToPHPValueSQL(AbstractSpatialType $type, $sqlExpr) { - return sprintf('AsBinary(%s)', $sqlExpr); + return sprintf('ST_AsBinary(%s)', $sqlExpr); } /** @@ -69,6 +69,6 @@ public function convertToPHPValueSQL(AbstractSpatialType $type, $sqlExpr) */ public function convertToDatabaseValueSQL(AbstractSpatialType $type, $sqlExpr) { - return sprintf('GeomFromText(%s)', $sqlExpr); + return sprintf('ST_GeomFromText(%s)', $sqlExpr); } } diff --git a/lib/CrEOF/Spatial/ORM/Query/AST/Functions/MySql/GeomFromText.php b/lib/CrEOF/Spatial/ORM/Query/AST/Functions/MySql/GeomFromText.php index 3eeb336c..ba7ffc14 100644 --- a/lib/CrEOF/Spatial/ORM/Query/AST/Functions/MySql/GeomFromText.php +++ b/lib/CrEOF/Spatial/ORM/Query/AST/Functions/MySql/GeomFromText.php @@ -35,7 +35,7 @@ class GeomFromText extends AbstractSpatialDQLFunction { protected $platforms = array('mysql'); - protected $functionName = 'GeomFromText'; + protected $functionName = 'ST_GeomFromText'; protected $minGeomExpr = 1;