Instantiable spatial types
Next version — This documentation describes a major version that is not yet the current stable release of spatial-types.
This reference documents the public, concrete spatial value types provided by
longitude-one/spatial-types. It covers their namespaces, direct constructors,
observable API, and mutation semantics.
Standards and model
The library follows the spatial-object model established by the
OGC Simple Features Access standard and
the ST_Geometry hierarchy of SQL/MM Spatial (ISO/IEC 13249-3). In practice,
that model supplies the instantiable Point, LineString, Polygon,
Triangle, PolyhedralSurface, MultiPoint, MultiLineString, MultiPolygon, and collection types.
GeometryTypeEnum implementation status
Use Implementation\SpatialTypeImplementationStatus::isFullyImplemented() to
query library support without depending on concrete class names or namespaces.
The API accepts a LongitudeOne\Core\Enum\GeometryTypeEnum and returns a
boolean for instantiable types. Instantiability is defined by
GeometryTypeEnum::isInstantiable() in spatial-core; implementation status
belongs to spatial-types.
use LongitudeOne\Core\Enum\GeometryTypeEnum;
use LongitudeOne\SpatialTypes\Exception\InvalidValueException;
use LongitudeOne\SpatialTypes\Implementation\SpatialTypeImplementationStatus;
SpatialTypeImplementationStatus::isFullyImplemented(GeometryTypeEnum::POINT); // true
SpatialTypeImplementationStatus::isFullyImplemented(GeometryTypeEnum::TIN); // false
SpatialTypeImplementationStatus::isFullyImplemented(GeometryTypeEnum::POLYHEDRALSURFACE); // true
try {
SpatialTypeImplementationStatus::isFullyImplemented(GeometryTypeEnum::GEOMETRY);
} catch (InvalidValueException $exception) {
// Implementation status is not applicable to non-instantiable GeometryTypeEnum::GEOMETRY.
}
The following matrix covers every current enum case. Not applicable means
that the request throws InvalidValueException, identifying the enum case and
its non-instantiable status. It never returns false for an abstract type.
No means that an instantiable type is not yet fully implemented.
If a future instantiable enum case has no explicit classification, the API throws
LongitudeOne\SpatialTypes\Exception\LogicException with the case name.
This exception extends PHP's LogicException and implements
SpatialTypeExceptionInterface; it identifies an incomplete library
classification, rather than an unsupported spatial type. A test iterates all
enum cases to ensure this exception is not raised for the current model.
GeometryTypeEnum | Instantiable | Fully implemented by spatial-types |
|---|---|---|
GEOMETRY | No | Not applicable |
POINT | Yes | Yes |
CURVE | No | Not applicable |
LINESTRING | Yes | Yes |
CIRCULARSTRING | Yes | Yes |
COMPOUNDCURVE | Yes | Yes |
SURFACE | No | Not applicable |
CURVEPOLYGON | Yes | No |
POLYGON | Yes | Yes |
TRIANGLE | Yes | Yes |
POLYHEDRALSURFACE | Yes | Yes |
TIN | Yes | No |
GEOMETRYCOLLECTION | Yes | Yes |
MULTIPOINT | Yes | Yes |
MULTICURVE | Yes | No |
MULTILINESTRING | Yes | Yes |
MULTISURFACE | Yes | No |
MULTIPOLYGON | Yes | Yes |
SOLID | No | Not applicable |
BREPSOLID | Yes | No |
CIRCLE | Yes | No |
CLOTHOID | Yes | No |
COMPOUNDSURFACE | Yes | No |
ELLIPTICALCURVE | Yes | No |
GEODESICSTRING | Yes | No |
NURBSCURVE | Yes | No |
SPIRALCURVE | Yes | No |
Full implementation is evaluated over the layouts applicable to the geometry
type, not over every layout in the library. POLYHEDRALSURFACE is fully
implemented for this API: both families provide XYZ and XYZM variants. This
does not add XY or XYM variants. The other eight implemented types are
available in both families for XY, XYZ, XYM and XYZM.
This API requires spatial-core 1.3 or newer within the 1.x series. The
library's minimum dependency has accordingly increased from 1.2 to 1.3.
The eight instantiable types added in spatial-core 1.3 are explicitly
classified as not yet implemented.
No existing spatial type or supported coordinate layout changes.
ST_SpatialRefSys is an SQL/MM spatial-reference-system metadata type rather
than a subtype of ST_Geometry; it is outside this value-type hierarchy. This
library identifies a reference with Reference\SpatialReference, which can
carry an authority and its integer identifier, without modelling a full
reference-system definition. The supplied ISO/IEC CD 13249-3:201x(E), section
8.5, names the polyhedral surface type ST_PolyhdrlSurface.
The Geography family is a library-level counterpart to the Geometry family;
it is not a separate ST_Geography branch in the SQL/MM hierarchy.
The library distinguishes two coordinate families:
- Geometry uses Cartesian
X, Ycoordinates. Numeric values are not range limited by this library. - Geography uses geodetic
longitude, latitudecoordinates, still ordered asX, Y. Longitude must be in[-180, 180]and latitude in[-90, 90].
The coordinate layouts are XY, XYZ, XYM, and XYZM; their tuple order is
always X, Y[, Z][, M]. Z is elevation and M is a measure. In particular,
an XYM tuple is [x, y, m], whereas an XYZ tuple is [x, y, z].
Every spatial object has a SpatialReference; getSrid() exposes its legacy
integer identifier. Constructors without a reference use identifier 0, as
prescribed for SQL/MM constructors without an SRID. Identifier 0 is a real
unnamed reference in this model, not a compatibility wildcard: every member of
an aggregate must have exactly the aggregate's spatial reference.
See Spatial reference systems for the ISO/IEC 13249-3 rationale and examples of valid and invalid aggregate membership. See Spatial validators for the constraints available through Symfony Validator, their constructor integration, and opt-in validation.
Class catalogue
All classes in the following matrix are concrete and instantiable. The class name is composed from the dimension, family, and type:
LongitudeOne\SpatialTypes\Types\<dimension>\<family>\<type>
| Dimension | Namespace segment | Coordinates |
|---|---|---|
| 2D | Dimension2 | X, Y |
| 3D with elevation | Dimension3z | X, Y, Z |
| 3D with measure | Dimension3m | X, Y, M |
| 4D | Dimension4zm | X, Y, Z, M |
For each dimension, both Geometry and Geography provide:
| Type | Geometry class | Geography class |
|---|---|---|
| Point | …\Geometry\Point | …\Geography\Point |
| Line string | …\Geometry\LineString | …\Geography\LineString |
| Polygon | …\Geometry\Polygon | …\Geography\Polygon |
| Triangle | …\Geometry\Triangle | …\Geography\Triangle |
| Multi-point | …\Geometry\MultiPoint | …\Geography\MultiPoint |
| Multi-line string | …\Geometry\MultiLineString | …\Geography\MultiLineString |
| Multi-polygon | …\Geometry\MultiPolygon | …\Geography\MultiPolygon |
| Heterogeneous collection | …\Geometry\GeometryCollection | |