Skip to main content

Point

View Markdown versionEdit this page on GitHub

Next version — This documentation describes a major version that is not yet the current stable release of spatial-types.

View the library roadmap

What is a Point?​

A Point represents a single location, described by coordinate ordinates such as X and Y. It has no child spatial objects.

Two separate Point examples; each dot represents one location.

Point — Supported representations​

Availability in the current version of Spatial Types:

Coordinate layoutGeometry MutableGeometry ImmutableGeography MutableGeography Immutable
XY✅✅✅✅
XYZ✅✅✅✅
XYM✅✅✅✅
XYZM✅✅✅✅

Creating the illustrated objects​

The examples recreate the labelled objects above using Geometry in XY. Composer’s autoloader must already be loaded. Variable names match the point letters in the illustration.

Immutable objects​

<?php

use LongitudeOne\SpatialTypes\Types\Dimension2\Geometry\PointImmutable;

// Immutable objects must be fully initialized through their constructors.

$a = new PointImmutable(16, 14.5);
$b = new PointImmutable(54, 9.5);

Mutable objects​

<?php

use LongitudeOne\SpatialTypes\Types\Dimension2\Point;

$a = new Point()->setX(16)->setY(14.5); // Using methods.
$b = new Point(54, 9.5); // Using the constructor.