PHP Shapefile 3.3.0
Polygons/MultiPolygons rings orientation made simple
23 May 2020
After that last underwhelming (feature-wise) release, this new minor version comes with many new features and capabilities.
Lately I have received an interesting amount of feedback from users from a specific country who are dealing with some official shapefiles that are not compliant with ESRI specs, especially when it comes to Polygons/MultiPolygons orientation.
This new release is focused on this specific aspect, adding a number of new methods to check and manipulate Polygons/MultiPolygons rings and autosensing capabilities when reading shapefiles.
The result is more flexibility than ever, a wider out-of-the-box compatibility with different (and uncompliant…) shapefiles and a simpler yet more precise approach to ring orientation.
In order to have clearer idea of new default behaviour (which is no different than before in presence of a compliat shapefile of course) and capabilities, please read this note about Polygons orientation.
What’s new in Version 3.3.0
Shapefile\Geometry\Linestring
class counts with 4 new public methods:Shapefile\Geometry\Polygon
class counts with 5 new public methods:Shapefile\Geometry\MultiPolygon
class counts with 5 new public methods:Shapefile\Geometry\Polygon
andShapefile\Geometry\MultiPolygon
constructor parameter$flag_enforce_closed_rings
is now $closed_rings and acceptsShapefile::ACTION_IGNORE
,Shapefile::ACTION_CHECK
andShapefile::ACTION_FORCE
values.- New
Shapefile\Geometry\Polygon
andShapefile\Geometry\MultiPolygon
optional constructor parameter $force_orientation. - New
Shapefile\ShapefileReader
constructor options:Shapefile::OPTION_POLYGON_CLOSED_RINGS_ACTION
Shapefile::OPTION_POLYGON_ORIENTATION_READING_AUTOSENSE
Shapefile::OPTION_POLYGON_OUTPUT_ORIENTATION
- New action constants:
Shapefile::ACTION_IGNORE
Shapefile::ACTION_CHECK
Shapefile::ACTION_FORCE
- New Polygon and MultiPolygon orientation constants:
Shapefile::ORIENTATION_CLOCKWISE
Shapefile::ORIENTATION_COUNTERCLOCKWISE
Shapefile::ORIENTATION_UNCHANGED
- New error types constants:
Shapefile::ERR_GEOM_RING_AREA_TOO_SMALL
Shapefile::ERR_GEOM_RING_NOT_ENOUGH_VERTICES
- Other constants:
Shapefile::UNDEFINED
- Library implements a fluent interface that allows method chaining (Actually I am not a fan of this, but I reckon many developers like it, hence here it is).
- Code is now PSR-12 compliant
- Deprecated
Shapefile\ShapefileReader
constructor options that will disappear in the next releases:Shapefile::OPTION_ENFORCE_POLYGON_CLOSED_RINGS
. UseShapefile::OPTION_POLYGON_CLOSED_RINGS_ACTION
instead.Shapefile::OPTION_INVERT_POLYGONS_ORIENTATION
. UseShapefile::OPTION_POLYGON_OUTPUT_ORIENTATION
instead.
- Deprecated error constants that will disappear in the next releases:
Shapefile::ERR_GEOM_POLYGON_AREA_TOO_SMALL
. UseShapefile::ERR_GEOM_RING_AREA_TOO_SMALL
instead.Shapefile::ERR_GEOM_POLYGON_NOT_VALID
. UseShapefile::ERR_GEOM_POLYGON_WRONG_ORIENTATION
instead.
- Improved documentation navigation and format.
Download and documentation
Go to the Lab page: PHP Shapefile