Search by

longitude-one / spatial-types

Alexandre-T

This library implements PHP spatial types: their interfaces and their geometric and geographic classes.

Package info

github.com/longitude-one/spatial-types

pkg:composer/longitude-one/spatial-types

Statistics

Installs: 642

Dependents: 1

Suggesters: 0

Stars: 0

Open Issues: 1

1.0.0-RC.1 2026-11-11 14:01 UTC

README

Release PHP License CI Coverage Monthly downloads Documentation

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.