Open tw99 opened 2 years ago
This repo looks kind of abandoned/un-maintanied FYI, this has been embedded/fixed into this fork repo: https://github.com/itamair/geoPHP throughout this commit: https://github.com/itamair/geoPHP/commit/7de893d413447a0004dd1149c058c682ddd1cd98
Issue
When loading an empty point geometry encoded in one of the above formats, the coordinate doubles unpacked in
WKB.class#getPoint
are bothNAN
Because of the
NAN
values, the empty point is able to bypass the safeguards in thePoint.class
constructor.This results in an invalid
Point
object, where$point->isEmpty()
is false.Observations
Postgres seems to implicitly encode
POINT EMPTY
asPOINT(NAN, NAN)
, and by default returns the hexewkb representation.Postgres:
Verifying in PHP:
Problems
1. Reading the above empty point binary with
GeoPhp
:2. Empty Point binary output representation is invalid.
Solutions
is_nan
in thePoint.class
constructor and create an empty point in that case.*Note: this solution works for empty point geometries with different srid's as well.