Skip to content

Commit

Permalink
fix setSRID()
Browse files Browse the repository at this point in the history
  • Loading branch information
Péter Báthory committed Aug 22, 2022
1 parent a4eb1bd commit 2cf5345
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/Geometry/Geometry.php
Original file line number Diff line number Diff line change
Expand Up @@ -394,9 +394,9 @@ public function getSRID(): ?int
*/
public function setSRID(?int $srid): void
{
if ($this->getGeos() && $srid !== null) {
if ($this->getGeos()) {
// @codeCoverageIgnoreStart
$this->getGeos()->setSRID($srid);
$this->getGeos()->setSRID($srid ?: 0);
// @codeCoverageIgnoreEnd
}
$this->srid = $srid;
Expand Down
4 changes: 1 addition & 3 deletions src/geoPHP.php
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,7 @@ public static function geosToGeometry(\GEOSGeometry $geos): ?Geometry

$wkbWriter = new \GEOSWKBWriter();
$wkbWriter->setOutputDimension($geos->coordinateDimension());
if ($geos->getSRID()) {
$wkbWriter->setIncludeSRID($geos->getSRID());
}
$wkbWriter->setIncludeSRID(true); // @phpstan-ignore-line

$wkb = $wkbWriter->writeHEX($geos);
return geoPHP::load($wkb, 'ewkb', true);
Expand Down

0 comments on commit 2cf5345

Please sign in to comment.