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\Linestringclass counts with 4 new public methods:Shapefile\Geometry\Polygonclass counts with 5 new public methods:Shapefile\Geometry\MultiPolygonclass counts with 5 new public methods:Shapefile\Geometry\PolygonandShapefile\Geometry\MultiPolygonconstructor parameter$flag_enforce_closed_ringsis now $closed_rings and acceptsShapefile::ACTION_IGNORE,Shapefile::ACTION_CHECKandShapefile::ACTION_FORCEvalues.- New
Shapefile\Geometry\PolygonandShapefile\Geometry\MultiPolygonoptional constructor parameter $force_orientation. - New
Shapefile\ShapefileReaderconstructor options:Shapefile::OPTION_POLYGON_CLOSED_RINGS_ACTIONShapefile::OPTION_POLYGON_ORIENTATION_READING_AUTOSENSEShapefile::OPTION_POLYGON_OUTPUT_ORIENTATION
- New action constants:
Shapefile::ACTION_IGNOREShapefile::ACTION_CHECKShapefile::ACTION_FORCE
- New Polygon and MultiPolygon orientation constants:
Shapefile::ORIENTATION_CLOCKWISEShapefile::ORIENTATION_COUNTERCLOCKWISEShapefile::ORIENTATION_UNCHANGED
- New error types constants:
Shapefile::ERR_GEOM_RING_AREA_TOO_SMALLShapefile::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\ShapefileReaderconstructor options that will disappear in the next releases:Shapefile::OPTION_ENFORCE_POLYGON_CLOSED_RINGS. UseShapefile::OPTION_POLYGON_CLOSED_RINGS_ACTIONinstead.Shapefile::OPTION_INVERT_POLYGONS_ORIENTATION. UseShapefile::OPTION_POLYGON_OUTPUT_ORIENTATIONinstead.
- Deprecated error constants that will disappear in the next releases:
Shapefile::ERR_GEOM_POLYGON_AREA_TOO_SMALL. UseShapefile::ERR_GEOM_RING_AREA_TOO_SMALLinstead.Shapefile::ERR_GEOM_POLYGON_NOT_VALID. UseShapefile::ERR_GEOM_POLYGON_WRONG_ORIENTATIONinstead.
- Improved documentation navigation and format.
Download and documentation
Go to the Lab page: PHP Shapefile