-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
514 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace GlaivePro\SF\MySQL; | ||
|
||
use GlaivePro\SF\Exceptions\MethodNotImplemented; | ||
use GlaivePro\SF\Expression; | ||
use GlaivePro\SF\OGC\Contracts\Curve as OGCCurve; | ||
|
||
/** | ||
* Curve model with MySQL-specific functions. | ||
*/ | ||
class Curve extends Geometry implements OGCCurve | ||
{ | ||
use \GlaivePro\SF\OGC\Traits\Curve; | ||
|
||
public function isRing(): Expression // Boolean-valued expression | ||
{ | ||
throw new MethodNotImplemented; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
namespace GlaivePro\SF\MySQL; | ||
|
||
use GlaivePro\SF\Exceptions\MethodNotImplemented; | ||
use GlaivePro\SF\Expression; | ||
use GlaivePro\SF\OGC\Geometry as OGCGeometry; | ||
|
||
/** | ||
* Geometry model with MySQL-specific functions. | ||
*/ | ||
class Geometry extends OGCGeometry | ||
{ | ||
protected const sfc = Sfc::class; | ||
|
||
public function setSRID(int $srid): static | ||
{ | ||
return static::fromMethod('ST_SRID', $this, $srid); | ||
} | ||
|
||
public function coordinateDimension(): Expression // Integer-valued expression | ||
{ | ||
throw new MethodNotImplemented; | ||
} | ||
|
||
public function is3D(): Expression // Boolean-valued expression | ||
{ | ||
throw new MethodNotImplemented; | ||
} | ||
|
||
public function isMeasured(): Expression // Boolean-valued expression | ||
{ | ||
throw new MethodNotImplemented; | ||
} | ||
|
||
public function boundary(): \GlaivePro\SF\OGC\Contracts\Geometry | ||
{ | ||
throw new MethodNotImplemented; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace GlaivePro\SF\MySQL; | ||
|
||
use GlaivePro\SF\OGC\Contracts\GeometryCollection as OGCGeometryCollection; | ||
|
||
/** | ||
* GeometryCollection model with MySQL-specific functions. | ||
*/ | ||
class GeometryCollection extends Geometry implements OGCGeometryCollection | ||
{ | ||
use \GlaivePro\SF\OGC\Traits\GeometryCollection; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace GlaivePro\SF\MySQL; | ||
|
||
use GlaivePro\SF\OGC\Contracts\LineString as OGCLineString; | ||
|
||
/** | ||
* LineString model with MySQL-specific functions. | ||
*/ | ||
class LineString extends Curve implements OGCLineString | ||
{ | ||
use \GlaivePro\SF\OGC\Traits\LineString; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace GlaivePro\SF\MySQL; | ||
|
||
use GlaivePro\SF\OGC\Contracts\MultiCurve as OGCMultiCurve; | ||
|
||
/** | ||
* MultiCurve model with MySQL-specific functions. | ||
*/ | ||
class MultiCurve extends GeometryCollection implements OGCMultiCurve | ||
{ | ||
use \GlaivePro\SF\OGC\Traits\CurveBasic; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace GlaivePro\SF\MySQL; | ||
|
||
use GlaivePro\SF\OGC\Contracts\MultiLineString as OGCMultiLineString; | ||
|
||
/** | ||
* MultiLineString model with MySQL-specific functions. | ||
*/ | ||
class MultiLineString extends MultiCurve implements OGCMultiLineString {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace GlaivePro\SF\MySQL; | ||
|
||
use GlaivePro\SF\OGC\Contracts\MultiPoint as OGCMultiPoint; | ||
|
||
/** | ||
* MultiPoint model with MySQL-specific functions. | ||
*/ | ||
class MultiPoint extends GeometryCollection implements OGCMultiPoint {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace GlaivePro\SF\MySQL; | ||
|
||
use GlaivePro\SF\OGC\Contracts\MultiPolygon as OGCMultiPolygon; | ||
|
||
/** | ||
* MultiPolygon model with MySQL-specific functions. | ||
*/ | ||
class MultiPolygon extends MultiSurface implements OGCMultiPolygon {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace GlaivePro\SF\MySQL; | ||
|
||
use GlaivePro\SF\Exceptions\MethodNotImplemented; | ||
use GlaivePro\SF\OGC\Contracts\MultiSurface as OGCMultiSurface; | ||
|
||
/** | ||
* MultiSurface model with MySQL-specific functions. | ||
*/ | ||
class MultiSurface extends GeometryCollection implements OGCMultiSurface | ||
{ | ||
use \GlaivePro\SF\OGC\Traits\SurfaceBasic; | ||
|
||
public function pointOnSurface(): \GlaivePro\SF\OGC\Contracts\Point | ||
{ | ||
throw new MethodNotImplemented(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace GlaivePro\SF\MySQL; | ||
|
||
use GlaivePro\SF\Exceptions\MethodNotImplemented; | ||
use GlaivePro\SF\Expression; | ||
use GlaivePro\SF\OGC\Contracts\Point as OGCPoint; | ||
|
||
/** | ||
* Point model with MySQL-specific functions. | ||
*/ | ||
class Point extends Geometry implements OGCPoint | ||
{ | ||
use \GlaivePro\SF\OGC\Traits\Point; | ||
|
||
public function Z(): Expression | ||
{ | ||
throw new MethodNotImplemented; | ||
} | ||
|
||
public function M(): Expression | ||
{ | ||
throw new MethodNotImplemented(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
namespace GlaivePro\SF\MySQL; | ||
|
||
use GlaivePro\SF\Expression; | ||
use GlaivePro\SF\OGC\Contracts\Polygon as OGCPolygon; | ||
|
||
/** | ||
* Polygon model with MySQL-specific functions. | ||
*/ | ||
class Polygon extends Surface implements OGCPolygon | ||
{ | ||
use \GlaivePro\SF\OGC\Traits\Polygon; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<?php | ||
|
||
namespace GlaivePro\SF\MySQL; | ||
|
||
use GlaivePro\SF\Exceptions\MethodNotImplemented; | ||
use GlaivePro\SF\Expression; | ||
use GlaivePro\SF\OGC\Sfc as OGCSfc; | ||
|
||
/** | ||
* Implements constructors available in MySQL. | ||
*/ | ||
class Sfc extends OGCSfc | ||
{ | ||
/** | ||
* Calls `fromMethod` on the desired class. | ||
* | ||
* We have to specify PostGIS-specific classes here. | ||
*/ | ||
protected static function callFromMethod(string $method, array $args): Geometry | ||
{ | ||
$class = match ($method) { | ||
'geometry' => Geometry::class, | ||
'geometryCollection' => GeometryCollection::class, | ||
'lineString' => LineString::class, | ||
'multiCurve' => MultiCurve::class, | ||
'multiLineString' => MultiLineString::class, | ||
'multiPoint' => MultiPoint::class, | ||
'multiPolygon' => MultiPolygon::class, | ||
'point' => Point::class, | ||
'polygon' => Polygon::class, | ||
}; | ||
|
||
return $class::fromMethod(...$args); | ||
} | ||
|
||
/** | ||
* Create a Point. | ||
* | ||
* Unlike POINT in MySQL, this also accepts POINT(x, y, srid) | ||
* and will set the SRID on the created POINT in such case. | ||
*/ | ||
public static function point(float $x, float $y, int $srid = null): Point | ||
{ | ||
$point = Point::fromMethod('Point', $x, $y); | ||
|
||
if (\is_null($srid)) | ||
return $point; | ||
|
||
return $point->setSRID($srid); | ||
} | ||
|
||
/** | ||
* Not implemented in MySQL. | ||
*/ | ||
public static function bdPolyFromWKB(string $WKBMultiLineString, int $SRID = null): Polygon | ||
{ | ||
throw new MethodNotImplemented; | ||
} | ||
|
||
/** | ||
* Not implemented in MySQL. | ||
*/ | ||
public static function bdPolyFromText(string $multiLineStringTaggedText, int $SRID = null): Polygon | ||
{ | ||
throw new MethodNotImplemented; | ||
} | ||
|
||
/** | ||
* Not implemented in MySQL. | ||
*/ | ||
public static function bdMPolyFromWKB(string $WKBMultiLineString, int $SRID = null): MultiPolygon | ||
{ | ||
throw new MethodNotImplemented; | ||
} | ||
|
||
/** | ||
* Not implemented in MySQL. | ||
*/ | ||
public static function bdMPolyFromText(string $multiLineStringTaggedText, int $SRID = null): MultiPolygon | ||
{ | ||
throw new MethodNotImplemented; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace GlaivePro\SF\MySQL; | ||
|
||
use GlaivePro\SF\Exceptions\MethodNotImplemented; | ||
use GlaivePro\SF\OGC\Contracts\Surface as OGCSurface; | ||
|
||
/** | ||
* Surface model with MySQL-specific functions. | ||
*/ | ||
class Surface extends Geometry implements OGCSurface | ||
{ | ||
use \GlaivePro\SF\OGC\Traits\Surface; | ||
|
||
public function pointOnSurface(): \GlaivePro\SF\OGC\Contracts\Point | ||
{ | ||
throw new MethodNotImplemented; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
namespace GlaivePro\SF\Tests\MySQL; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use GlaivePro\SF\MySQL\Sfc; | ||
|
||
class ConstructorTest extends TestCase | ||
{ | ||
public function testPointConstructors(): void | ||
{ | ||
$point = Sfc::point(1, 3); | ||
$this->assertSame( | ||
'Point(?, ?)', | ||
(string) $point, | ||
); | ||
$this->assertEquals([1, 3], $point->bindings); | ||
|
||
$pointWithSrid = Sfc::point(1, 3, 4326); | ||
$this->assertSame( | ||
'ST_SRID(Point(?, ?), ?)', | ||
(string) $pointWithSrid, | ||
); | ||
$this->assertEquals([1, 3, 4326], $pointWithSrid->bindings); | ||
} | ||
} |
Oops, something went wrong.