Search by

longitude-one / spatial-decoder

Alexandre-T

Decode spatial data from various representations into SpatialInterface objects.

Package info

github.com/longitude-one/spatial-decoder

pkg:composer/longitude-one/spatial-decoder

Fund package maintenance!

Ko Fi

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 2

1.0.0-RC.0 2026-11-25 17:08 UTC

This package is auto-updated.

Last update: 2026-12-03 20:52:58 UTC


README

Release PHP License CI Coverage Monthly downloads Documentation

Decode serialized spatial data into LongitudeOne spatial objects. Choose a strategy for the input format, then validate the resulting geometry explicitly when your application requires geometric validity.

Installation

composer require longitude-one/spatial-decoder:^1.0.0-RC.0

Requires PHP 8.4 or later and longitude-one/spatial-core ^1.4.0. Composer installs the compatible dependencies automatically.

Usage

use LongitudeOne\SpatialDecoder\Decoder;
use LongitudeOne\SpatialDecoder\Strategy\WktDecoderStrategy;

$decoder = new Decoder(new WktDecoderStrategy());
$point = $decoder->decode('POINT (1 2)');

// $point->toArray() === [1, 2]

Documentation

Read the official documentation.

See the decoding guide for EWKT, EWKB, WKB geometries, curves, dimensions and unsupported types.

Input formats

Built-in strategies decode WKT and EWKT, plus XY, XYZ, XYM and XYZM Points, LineStrings and Polygons, MultiPoint, MultiLineString, MultiPolygon, CircularString, CompoundCurve, Triangle and nested GeometryCollection in raw WKB (both byte orders), including EMPTY geometries. PolyhedralSurface supports XYZ and XYZM only. Other WKB geometry types are not yet supported. EWKB supports the same types and dimensions, with optional SRIDs at every geometry header; see EWKB decoding for its limits. MySQL internal binary is not supported.

Decoding and geometric validation

By default, WKT, EWKT, WKB and EWKB produce immutable Geometry objects, including collection members, independently of the shared factory's mutable/immutable mode. See Strategy configuration to select Geography or mutable output.

The decoder checks syntax, numeric ordinates, dimensions and supported types. It preserves geometrically invalid structures such as unclosed polygon rings; decoding success does not establish geometric validity. Malformed representations still raise an exception. See the validation boundary.

Contributing

See Contributing for development setup, checks and contribution guidelines.