Skip to content

Commit 7d710a1

Browse files
committed
Core spatial types implementation
Add geometry and geography types for spatial data Introduces new spatial data types for handling geometric and geographic data in database applications. GeometryType handles planar coordinates while GeographyType handles spherical earth coordinates, both using Well-Known Text (WKT) format. This provides foundation for spatial data operations across database platforms that support spatial extensions.
1 parent af03149 commit 7d710a1

13 files changed

+583
-0
lines changed

src/Platforms/AbstractMySQLPlatform.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use Doctrine\DBAL\Connection;
88
use Doctrine\DBAL\Exception\InvalidColumnType\ColumnValuesRequired;
9+
use Doctrine\DBAL\Platforms\Exception\NotSupported;
910
use Doctrine\DBAL\Platforms\Keywords\KeywordList;
1011
use Doctrine\DBAL\Platforms\Keywords\MySQLKeywords;
1112
use Doctrine\DBAL\Schema\ForeignKeyConstraint;
@@ -217,6 +218,42 @@ public function getBooleanTypeDeclarationSQL(array $column): string
217218
return 'TINYINT(1)';
218219
}
219220

221+
/**
222+
* {@inheritDoc}
223+
*/
224+
public function getGeometryTypeDeclarationSQL(array $column): string
225+
{
226+
throw NotSupported::new(__METHOD__);
227+
}
228+
229+
public function getGeometryFromTextSQL(string $sqlExpr): string
230+
{
231+
throw NotSupported::new(__METHOD__);
232+
}
233+
234+
public function getGeometryAsTextSQL(string $sqlExpr): string
235+
{
236+
throw NotSupported::new(__METHOD__);
237+
}
238+
239+
/**
240+
* {@inheritDoc}
241+
*/
242+
public function getGeographyTypeDeclarationSQL(array $column): string
243+
{
244+
throw NotSupported::new(__METHOD__);
245+
}
246+
247+
public function getGeographyFromTextSQL(string $sqlExpr): string
248+
{
249+
throw NotSupported::new(__METHOD__);
250+
}
251+
252+
public function getGeographyAsTextSQL(string $sqlExpr): string
253+
{
254+
throw NotSupported::new(__METHOD__);
255+
}
256+
220257
/**
221258
* {@inheritDoc}
222259
*

src/Platforms/AbstractPlatform.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,40 @@ abstract public function getClobTypeDeclarationSQL(array $column): string;
384384
*/
385385
abstract public function getBlobTypeDeclarationSQL(array $column): string;
386386

387+
/**
388+
* Gets the SQL declaration snippet for a geometry column.
389+
*
390+
* @param array<string, mixed> $column
391+
*/
392+
abstract public function getGeometryTypeDeclarationSQL(array $column): string;
393+
394+
/**
395+
* Gets the SQL snippet to convert a geometry value from text format to the database's internal geometry format.
396+
*/
397+
abstract public function getGeometryFromTextSQL(string $sqlExpr): string;
398+
399+
/**
400+
* Gets the SQL snippet to convert a geometry value from the database's internal format to text format.
401+
*/
402+
abstract public function getGeometryAsTextSQL(string $sqlExpr): string;
403+
404+
/**
405+
* Gets the SQL declaration snippet for a geography column.
406+
*
407+
* @param array<string, mixed> $column
408+
*/
409+
abstract public function getGeographyTypeDeclarationSQL(array $column): string;
410+
411+
/**
412+
* Gets the SQL snippet to convert a geography value from text format to the database's internal geography format.
413+
*/
414+
abstract public function getGeographyFromTextSQL(string $sqlExpr): string;
415+
416+
/**
417+
* Gets the SQL snippet to convert a geography value from the database's internal format to text format.
418+
*/
419+
abstract public function getGeographyAsTextSQL(string $sqlExpr): string;
420+
387421
/**
388422
* Registers a doctrine type to be used in conjunction with a column type of this platform.
389423
*

src/Platforms/DB2Platform.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,42 @@ public function getTimeTypeDeclarationSQL(array $column): string
202202
return 'TIME';
203203
}
204204

205+
/**
206+
* {@inheritDoc}
207+
*/
208+
public function getGeometryTypeDeclarationSQL(array $column): string
209+
{
210+
throw NotSupported::new(__METHOD__);
211+
}
212+
213+
public function getGeometryFromTextSQL(string $sqlExpr): string
214+
{
215+
throw NotSupported::new(__METHOD__);
216+
}
217+
218+
public function getGeometryAsTextSQL(string $sqlExpr): string
219+
{
220+
throw NotSupported::new(__METHOD__);
221+
}
222+
223+
/**
224+
* {@inheritDoc}
225+
*/
226+
public function getGeographyTypeDeclarationSQL(array $column): string
227+
{
228+
throw NotSupported::new(__METHOD__);
229+
}
230+
231+
public function getGeographyFromTextSQL(string $sqlExpr): string
232+
{
233+
throw NotSupported::new(__METHOD__);
234+
}
235+
236+
public function getGeographyAsTextSQL(string $sqlExpr): string
237+
{
238+
throw NotSupported::new(__METHOD__);
239+
}
240+
205241
public function getTruncateTableSQL(string $tableName, bool $cascade = false): string
206242
{
207243
$tableIdentifier = new Identifier($tableName);

src/Platforms/OraclePlatform.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use Doctrine\DBAL\Connection;
88
use Doctrine\DBAL\Exception\InvalidColumnType\ColumnLengthRequired;
9+
use Doctrine\DBAL\Platforms\Exception\NotSupported;
910
use Doctrine\DBAL\Platforms\Keywords\KeywordList;
1011
use Doctrine\DBAL\Platforms\Keywords\OracleKeywords;
1112
use Doctrine\DBAL\Schema\ForeignKeyConstraint;
@@ -269,6 +270,42 @@ public function getTimeTypeDeclarationSQL(array $column): string
269270
return 'DATE';
270271
}
271272

273+
/**
274+
* {@inheritDoc}
275+
*/
276+
public function getGeometryTypeDeclarationSQL(array $column): string
277+
{
278+
throw NotSupported::new(__METHOD__);
279+
}
280+
281+
public function getGeometryFromTextSQL(string $sqlExpr): string
282+
{
283+
throw NotSupported::new(__METHOD__);
284+
}
285+
286+
public function getGeometryAsTextSQL(string $sqlExpr): string
287+
{
288+
throw NotSupported::new(__METHOD__);
289+
}
290+
291+
/**
292+
* {@inheritDoc}
293+
*/
294+
public function getGeographyTypeDeclarationSQL(array $column): string
295+
{
296+
throw NotSupported::new(__METHOD__);
297+
}
298+
299+
public function getGeographyFromTextSQL(string $sqlExpr): string
300+
{
301+
throw NotSupported::new(__METHOD__);
302+
}
303+
304+
public function getGeographyAsTextSQL(string $sqlExpr): string
305+
{
306+
throw NotSupported::new(__METHOD__);
307+
}
308+
272309
/**
273310
* {@inheritDoc}
274311
*/

src/Platforms/PostgreSQLPlatform.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Doctrine\DBAL\Platforms;
66

77
use Doctrine\DBAL\Connection;
8+
use Doctrine\DBAL\Platforms\Exception\NotSupported;
89
use Doctrine\DBAL\Platforms\Keywords\KeywordList;
910
use Doctrine\DBAL\Platforms\Keywords\PostgreSQLKeywords;
1011
use Doctrine\DBAL\Schema\Column;
@@ -822,6 +823,42 @@ public function getJsonbTypeDeclarationSQL(array $column): string
822823
return 'JSONB';
823824
}
824825

826+
/**
827+
* {@inheritDoc}
828+
*/
829+
public function getGeometryTypeDeclarationSQL(array $column): string
830+
{
831+
throw NotSupported::new(__METHOD__);
832+
}
833+
834+
public function getGeometryFromTextSQL(string $sqlExpr): string
835+
{
836+
throw NotSupported::new(__METHOD__);
837+
}
838+
839+
public function getGeometryAsTextSQL(string $sqlExpr): string
840+
{
841+
throw NotSupported::new(__METHOD__);
842+
}
843+
844+
/**
845+
* {@inheritDoc}
846+
*/
847+
public function getGeographyTypeDeclarationSQL(array $column): string
848+
{
849+
throw NotSupported::new(__METHOD__);
850+
}
851+
852+
public function getGeographyFromTextSQL(string $sqlExpr): string
853+
{
854+
throw NotSupported::new(__METHOD__);
855+
}
856+
857+
public function getGeographyAsTextSQL(string $sqlExpr): string
858+
{
859+
throw NotSupported::new(__METHOD__);
860+
}
861+
825862
public function createSchemaManager(Connection $connection): PostgreSQLSchemaManager
826863
{
827864
return new PostgreSQLSchemaManager($connection, $this);

src/Platforms/SQLServerPlatform.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Doctrine\DBAL\Connection;
88
use Doctrine\DBAL\Exception\InvalidColumnType\ColumnLengthRequired;
99
use Doctrine\DBAL\LockMode;
10+
use Doctrine\DBAL\Platforms\Exception\NotSupported;
1011
use Doctrine\DBAL\Platforms\Keywords\KeywordList;
1112
use Doctrine\DBAL\Platforms\Keywords\SQLServerKeywords;
1213
use Doctrine\DBAL\Platforms\SQLServer\SQL\Builder\SQLServerSelectSQLBuilder;
@@ -1042,6 +1043,42 @@ public function getBooleanTypeDeclarationSQL(array $column): string
10421043
return 'BIT';
10431044
}
10441045

1046+
/**
1047+
* {@inheritDoc}
1048+
*/
1049+
public function getGeometryTypeDeclarationSQL(array $column): string
1050+
{
1051+
throw NotSupported::new(__METHOD__);
1052+
}
1053+
1054+
public function getGeometryFromTextSQL(string $sqlExpr): string
1055+
{
1056+
throw NotSupported::new(__METHOD__);
1057+
}
1058+
1059+
public function getGeometryAsTextSQL(string $sqlExpr): string
1060+
{
1061+
throw NotSupported::new(__METHOD__);
1062+
}
1063+
1064+
/**
1065+
* {@inheritDoc}
1066+
*/
1067+
public function getGeographyTypeDeclarationSQL(array $column): string
1068+
{
1069+
throw NotSupported::new(__METHOD__);
1070+
}
1071+
1072+
public function getGeographyFromTextSQL(string $sqlExpr): string
1073+
{
1074+
throw NotSupported::new(__METHOD__);
1075+
}
1076+
1077+
public function getGeographyAsTextSQL(string $sqlExpr): string
1078+
{
1079+
throw NotSupported::new(__METHOD__);
1080+
}
1081+
10451082
protected function doModifyLimitQuery(string $query, ?int $limit, int $offset): string
10461083
{
10471084
if ($limit === null && $offset <= 0) {

src/Platforms/SQLitePlatform.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,42 @@ public function getClobTypeDeclarationSQL(array $column): string
374374
return 'CLOB';
375375
}
376376

377+
/**
378+
* {@inheritDoc}
379+
*/
380+
public function getGeometryTypeDeclarationSQL(array $column): string
381+
{
382+
throw NotSupported::new(__METHOD__);
383+
}
384+
385+
public function getGeometryFromTextSQL(string $sqlExpr): string
386+
{
387+
throw NotSupported::new(__METHOD__);
388+
}
389+
390+
public function getGeometryAsTextSQL(string $sqlExpr): string
391+
{
392+
throw NotSupported::new(__METHOD__);
393+
}
394+
395+
/**
396+
* {@inheritDoc}
397+
*/
398+
public function getGeographyTypeDeclarationSQL(array $column): string
399+
{
400+
throw NotSupported::new(__METHOD__);
401+
}
402+
403+
public function getGeographyFromTextSQL(string $sqlExpr): string
404+
{
405+
throw NotSupported::new(__METHOD__);
406+
}
407+
408+
public function getGeographyAsTextSQL(string $sqlExpr): string
409+
{
410+
throw NotSupported::new(__METHOD__);
411+
}
412+
377413
/** @internal The method should be only used from within the {@see AbstractSchemaManager} class hierarchy. */
378414
public function getListViewsSQL(string $database): string
379415
{

0 commit comments

Comments
 (0)