Skip to content

Releases: gasparesganga/php-shapefile

v3.1.0

30 Oct 09:06
Compare
Choose a tag to compare

Added

  • Writing buffer in ShapefileWriter. It allows up to a 50% reduction in writing time
  • ShapefileWriter::flushBuffer() method
  • Shapefile::OPTION_BUFFERED_RECORDS constructor option for ShapefileWriter class
  • Capability to append records to existing Shapefiles
  • Shapefile::OPTION_EXISTING_FILES_MODE constructor option for ShapefileWriter class
  • Shapefile::MODE_PRESERVE, Shapefile::MODE_APPEND, Shapefile::MODE_OVERWRITE constants
  • isZ(), isM() and getFieldsNames() methods for both ShapefileReader and ShapefileWriter classes
  • ShapefileWriter expose getShapeType(), getBoundingBox(), getPRJ(), getCharset(), setCharset(), getFieldsNames(), getField(), getFieldType(), getFieldSize(), getFieldDecimals(), getFields() and getTotRecords() public methods like ShapefileReader
  • Sanitize and accept conflicting and duplicated field names
  • Other minor code and performance improvements across the library

Changed

  • Improved GeometryCollection::getBoundingBox() method for better performance
  • Improved ShapefileWriter::encodeFieldValue() method for better performance, relying on PHP number_format() for non-textual numeric input
  • Field name sanitization is always carried out in all ShapefileWriter field-adding methods
  • Shapefile::ERR_DBF_FIELD_NAME_NOT_VALID error type is now defined as "Too many field names conflicting"
  • Default c+b file access mode for ShapefileWriter class

Fixed

  • Convert field names to uppercase for Geometry data when Shapefile::OPTION_DBF_FORCE_ALL_CAPS is enabled
  • Decoupling field names sanitization and Shapefile::OPTION_DBF_FORCE_ALL_CAPS option
  • Shapefile::ERR_GEOM_MISSING_FIELD exception was erroneously raised when a field had an explicit null value and Shapefile::OPTION_ENFORCE_GEOMETRY_DATA_STRUCTURE was enabled
  • Suppress PHP warnings in fread() and fwrite() calls: a ShapefileException is thrown anyways
  • Bug causing a corrupted DBF file when a Shapefile::ERR_GEOM_MISSING_FIELD is raised
  • Bug causing wrong record number to be written in SHP record headers (count starts from 1, not from 0)
  • Corner case bug affecting ShapefileWriter destructor when no record has been written yet

Removed

  • $flag_sanitize_name parameter from all field-adding methods
  • Shapefile::OPTION_OVERWRITE_EXISTING_FILES constructor option for ShapefileWriter class
  • Shapefile::ERR_DBF_FIELD_NAME_NOT_UNIQUE error type

See release notes

v3.0.2

23 Sep 09:18
Compare
Choose a tag to compare

Fixed

  • A Declaration of X must be compatible with Y PHP7 Warning thrown for Polygon and MultiPolygon addGeometry protected methods.

See release notes

v3.0.1

31 Aug 10:45
Compare
Choose a tag to compare

A tiny bugfix release to correct a couple of typos that went unnoticed in v3.0.0.

Fixed

  • A typo in a variable name introduced with a late code clean-up before final release that was causing a PHP Notice when reading Shapefiles with Memo fields.
  • Year in the release date of v3 in CHANGELOG file.

See release notes

v3.0.0

30 Aug 09:33
Compare
Choose a tag to compare

See v3 RELEASE NOTES

Added

  • Complete OOP style refactoring
  • Shapefile writing capabilities
  • PHPDoc style comments
  • Shapefile\Geometry namespace with Point, MultiPoint, Linestring, MultiLinestring, Polygon and MultiPolygon classes
  • ShapefileReader and ShapefileWriter classes
  • Shapefile, Geometry and GeometryCollection abstract classes
  • Custom DBF charset support
  • Support for emulated null values in DBF files
  • Reading and writing optional DBT files (support for MEMO fields)
  • Reading and writing optional CPG files
  • ShapefileException::getDetails() method
  • Constructor options constants:
    • Shapefile::OPTION_CPG_ENABLE_FOR_DEFAULT_CHARSET
    • Shapefile::OPTION_DBF_CONVERT_TO_UTF8
    • Shapefile::OPTION_DBF_FORCE_ALL_CAPS
    • Shapefile::OPTION_DBF_IGNORED_FIELDS
    • Shapefile::OPTION_DBF_NULL_PADDING_CHAR
    • Shapefile::OPTION_DBF_NULLIFY_INVALID_DATES
    • Shapefile::OPTION_DBF_RETURN_DATES_AS_OBJECTS
    • Shapefile::OPTION_DELETE_EMPTY_FILES
    • Shapefile::OPTION_ENFORCE_GEOMETRY_DATA_STRUCTURE
    • Shapefile::OPTION_ENFORCE_POLYGON_CLOSED_RINGS
    • Shapefile::OPTION_FORCE_MULTIPART_GEOMETRIES
    • Shapefile::OPTION_IGNORE_GEOMETRIES_BBOXES
    • Shapefile::OPTION_IGNORE_SHAPEFILE_BBOX
    • Shapefile::OPTION_INVERT_POLYGONS_ORIENTATION
    • Shapefile::OPTION_OVERWRITE_EXISTING_FILES
    • Shapefile::OPTION_SUPPRESS_M
    • Shapefile::OPTION_SUPPRESS_Z
  • File types constants:
    • Shapefile::FILE_SHP
    • Shapefile::FILE_SHX
    • Shapefile::FILE_DBF
    • Shapefile::FILE_DBT
    • Shapefile::FILE_PRJ
    • Shapefile::FILE_CPG
  • Shape types constants:
    • Shapefile::SHAPE_TYPE_NULL
    • Shapefile::SHAPE_TYPE_POINT
    • Shapefile::SHAPE_TYPE_POLYLINE
    • Shapefile::SHAPE_TYPE_POLYGON
    • Shapefile::SHAPE_TYPE_MULTIPOINT
    • Shapefile::SHAPE_TYPE_POINTZ
    • Shapefile::SHAPE_TYPE_POLYLINEZ
    • Shapefile::SHAPE_TYPE_POLYGONZ
    • Shapefile::SHAPE_TYPE_MULTIPOINTZ
    • Shapefile::SHAPE_TYPE_POINTM
    • Shapefile::SHAPE_TYPE_POLYLINEM
    • Shapefile::SHAPE_TYPE_POLYGONM
    • Shapefile::SHAPE_TYPE_MULTIPOINTM
  • DBF fields types constants:
    • Shapefile::DBF_TYPE_CHAR
    • Shapefile::DBF_TYPE_DATE
    • Shapefile::DBF_TYPE_LOGICAL
    • Shapefile::DBF_TYPE_MEMO
    • Shapefile::DBF_TYPE_NUMERIC
    • Shapefile::DBF_TYPE_FLOAT
  • Error types constants:
    • Shapefile::ERR_UNDEFINED
    • Shapefile::ERR_FILE_MISSING
    • Shapefile::ERR_FILE_EXISTS
    • Shapefile::ERR_FILE_INVALID_RESOURCE
    • Shapefile::ERR_FILE_OPEN
    • Shapefile::ERR_FILE_READING
    • Shapefile::ERR_FILE_WRITING
    • Shapefile::ERR_SHP_TYPE_NOT_SUPPORTED
    • Shapefile::ERR_SHP_TYPE_NOT_SET
    • Shapefile::ERR_SHP_TYPE_ALREADY_SET
    • Shapefile::ERR_SHP_GEOMETRY_TYPE_NOT_COMPATIBLE
    • Shapefile::ERR_SHP_MISMATCHED_BBOX
    • Shapefile::ERR_SHP_FILE_ALREADY_INITIALIZED
    • Shapefile::ERR_SHP_WRONG_RECORD_TYPE
    • Shapefile::ERR_DBF_FILE_NOT_VALID
    • Shapefile::ERR_DBF_MISMATCHED_FILE
    • Shapefile::ERR_DBF_EOF_REACHED
    • Shapefile::ERR_DBF_MAX_FIELD_COUNT_REACHED
    • Shapefile::ERR_DBF_FIELD_NAME_NOT_UNIQUE
    • Shapefile::ERR_DBF_FIELD_NAME_NOT_VALID
    • Shapefile::ERR_DBF_FIELD_TYPE_NOT_VALID
    • Shapefile::ERR_DBF_FIELD_SIZE_NOT_VALID
    • Shapefile::ERR_DBF_FIELD_DECIMALS_NOT_VALID
    • Shapefile::ERR_DBF_CHARSET_CONVERSION
    • Shapefile::ERR_DBT_EOF_REACHED
    • Shapefile::ERR_GEOM_NOT_EMPTY
    • Shapefile::ERR_GEOM_COORD_VALUE_NOT_VALID
    • Shapefile::ERR_GEOM_MISMATCHED_DIMENSIONS
    • Shapefile::ERR_GEOM_MISMATCHED_BBOX
    • Shapefile::ERR_GEOM_MISSING_FIELD
    • Shapefile::ERR_GEOM_POINT_NOT_VALID
    • Shapefile::ERR_GEOM_POLYGON_OPEN_RING
    • Shapefile::ERR_GEOM_POLYGON_AREA_TOO_SMALL
    • Shapefile::ERR_GEOM_POLYGON_NOT_VALID
    • Shapefile::ERR_INPUT_RECORD_NOT_FOUND
    • Shapefile::ERR_INPUT_FIELD_NOT_FOUND
    • Shapefile::ERR_INPUT_GEOMETRY_TYPE_NOT_VALID
    • Shapefile::ERR_INPUT_GEOMETRY_INDEX_NOT_VALID
    • Shapefile::ERR_INPUT_ARRAY_NOT_VALID
    • Shapefile::ERR_INPUT_WKT_NOT_VALID
    • Shapefile::ERR_INPUT_GEOJSON_NOT_VALID
    • Shapefile::ERR_INPUT_NUMERIC_VALUE_OVERFLOW

Changed

  • Folder structure under src/ reflects namespaces hierarchy
  • Namespace and class names case normalized
  • Bitwise constructor flags replaced by associative array
  • Default output polygons orientation is now opposite to ESRI Shapefile specs and compliant to OGC Simple Features
  • Use of iconv() instead of utf8_encode() for charset conversion
  • ShapefileException::getErrorType() method returns one of Shapefile::ERR_* constant values
  • ShapefileReader::fetchRecord() method replaces ShapefileReader::getRecord() and returns an object
  • Order of bounding boxes associative arrays elements

Fixed

  • Stricter invalid date format detection
  • Logical (bool) not initialized values (null) detection in DBF files

Removed

  • ShapefileReader public methods:
    • setDefaultGeometryFormat()
    • readRecord()
  • ShapefileReader protected method init()
  • Shapefile constants:
    • Shapefile::FLAG_SUPPRESS_Z
    • Shapefile::FLAG_SUPPRESS_M
    • Shapefile::GEOMETRY_ARRAY
    • Shapefile::GEOMETRY_WKT
    • Shapefile::GEOMETRY_GEOJSON_GEOMETRY
    • Shapefile::GEOMETRY_GEOJSON_FEATURE
    • Shapefile::GEOMETRY_BOTH
  • Shapefile numeric error codes

See release notes

v2.4.3

07 Apr 07:52
Compare
Choose a tag to compare
  • Fixed bug in binary reading function causing issues with DBF fields size

See release notes

v2.4.2

06 Dec 15:14
Compare
Choose a tag to compare
  • Reversed the orientation of inner and outer rings in GeoJSON output of Polygons and MultiPolygons, complying to section 3.1.6 of RFC 7946

See release notes

v2.4.1

29 Nov 23:20
Compare
Choose a tag to compare
  • Fixed composer.json file: PHP 5.4+ required

See release notes

v2.4.0

20 Nov 15:42
Compare
Choose a tag to compare
  • Public method setDefaultGeometryFormat()
  • GeoJSON output format
  • Changes to getRecord() public method
  • Deprecated ShapeFile::GEOMETRY_BOTH output format

See release notes

v2.3.0

14 Sep 12:04
Compare
Choose a tag to compare
  • Protected method init() allows the main ShapeFile class to be easily extended using a custom constructor
  • Some minor code abbelishments to better comply to PSR-2

See release notes

v2.2.0

23 Nov 16:36
Compare
Choose a tag to compare
  • SHX file is now required
  • Capability to randomly access the shapefile records
  • Implements the Iterator interface
  • Method getTotRecords()
  • Method setCurrentRecord()
  • Method getCurrentRecord()

See release notes