We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent eae31fa commit 0f94263Copy full SHA for 0f94263
src/Types/Geometry.php
@@ -70,14 +70,23 @@ public static function getWKTClass($value)
70
71
public static function fromWKB($wkb)
72
{
73
- // mysql adds 4 NUL bytes at the start of the binary
+ $srid = substr($wkb, 0, 4);
74
+ $srid = unpack('L', $srid)[1];
75
+
76
$wkb = substr($wkb, 4);
77
$parser = new Parser(new Factory());
78
- return $parser->parse($wkb);
79
+ /** @var Geometry $parsed */
80
+ $parsed = $parser->parse($wkb);
81
82
+ if ($srid >= 0 && $srid < 4000) {
83
+ $parsed->setSrid($srid);
84
+ }
85
86
+ return $parsed;
87
}
88
- public static function fromWKT($wkt, $srid = 0)
89
+ public static function fromWKT($wkt, $srid = null)
90
91
$wktArgument = static::getWKTArgument($wkt);
92
0 commit comments