The following links describe how MySQL interprets the coordinates of a POINT when a spatial reference identifier (SRID) is involved, making the type a "Geography" instead of a "Geometry":
MySQL follows the specification properly, but this is not the "de facto" standard (as used by this library), in summary:
All GIS implementations must do Point(x,y) for projected coordinates which is (long,lat). But, on geodetic coordinate systems there is some disagreement about what to do. MySQL (and SQL Server) do (lat,long) but PostGIS maintains (long,lat) everywhere.
This is the observed behavior:
no SRID isset / geometric types:
\CrEOF\Spatial\PHP\Types\Geometry\Point.x is populated with x: correct
\CrEOF\Spatial\PHP\Types\Geometry\Point.y is populated with y: correct
SRID is set / geographical types:
\CrEOF\Spatial\PHP\Types\Geography\Point.x is populated with latitude: incorrect
\CrEOF\Spatial\PHP\Types\Geography\Point.y is populated with longitude: incorrect
This behavior also propagates to LineStrings, Polygons, MultiPolygons, etc.
A simple way to check whether database table columns are configured/populated properly, is to load the table using MySQL Workbench and use the Spatial Viewer to browse the content of a table.
The following links describe how MySQL interprets the coordinates of a
POINT
when a spatial reference identifier (SRID) is involved, making the type a "Geography" instead of a "Geometry":MySQL follows the specification properly, but this is not the "de facto" standard (as used by this library), in summary:
This is the observed behavior:
\CrEOF\Spatial\PHP\Types\Geometry\Point.x
is populated with x: correct\CrEOF\Spatial\PHP\Types\Geometry\Point.y
is populated with y: correct\CrEOF\Spatial\PHP\Types\Geography\Point.x
is populated with latitude: incorrect\CrEOF\Spatial\PHP\Types\Geography\Point.y
is populated with longitude: incorrectThis behavior also propagates to LineStrings, Polygons, MultiPolygons, etc.
A simple way to check whether database table columns are configured/populated properly, is to load the table using MySQL Workbench and use the Spatial Viewer to browse the content of a table.
Possible solution
A possible solution might be to force the axis-order to
long-lat
which this library expects when loading and saving the data inCrEOF\Spatial\DBAL\Platform\Mysql
: