longitude-one / spatial-types
This library implements PHP spatial types: their interfaces and their geometric and geographic classes.
Requires
- php: ^8.4
- longitude-one/geo-parser: ^4.1
- longitude-one/spatial-core: ^1.3
Requires (Dev)
- ext-pcov: *
- phpunit/phpunit: ^13
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-15 12:15:10 UTC
README
Create and manipulate spatial objects such as points, lines and polygons in PHP. The library provides mutable and immutable types for geometric and geographic data; use spatial-validator when you need explicit geometric validation.
Installation
composer require longitude-one/spatial-types:^1.0.0-RC.1
Usage
Immutable point
use LongitudeOne\SpatialTypes\Types\Dimension2\Geometry\PointImmutable; $point = new PointImmutable(1, 2);
Mutable point
use LongitudeOne\SpatialTypes\Types\Dimension2\Point; $point = new Point(1, 2);
Documentation
Read the official documentation.
Geometry and Geography
Geometry and Geography are distinct spatial families. Immutable types use separate
Geometry and Geography namespaces. Mutable types share the dimension namespace;
select Geography with the family constructor argument.
XY, XYZ, XYM and XYZM types live in Dimension2, Dimension3z, Dimension3m
and Dimension4zm, respectively. Declaring a spatial reference does not transform coordinates.
Contributing
See Contributing for development setup, checks and contribution guidelines.