Point(float $latitude, float $longitude, int $srid = 0)
- MySQL PointMultiPoint(Point[] | Collection<Point> $geometries, int $srid = 0)
- MySQL MultiPointLineString(Point[] | Collection<Point> $geometries, int $srid = 0)
- MySQL LineStringMultiLineString(LineString[] | Collection<LineString> $geometries, int $srid = 0)
- MySQL MultiLineStringPolygon(LineString[] | Collection<LineString> $geometries, int $srid = 0)
- MySQL PolygonMultiPolygon(Polygon[] | Collection<Polygon> $geometries, int $srid = 0)
- MySQL MultiPolygonGeometryCollection(Geometry[] | Collection<Geometry> $geometries, int $srid = 0)
- MySQL GeometryCollectionGeometry classes can be also created by these static methods:
fromArray(array $geometry)
- Creates a geometry object from a GeoJSON array.fromJson(string $geoJson, int $srid = 0)
- Creates a geometry object from a GeoJSON string.fromWkt(string $wkt, int $srid = 0)
- Creates a geometry object from a WKT.fromWkb(string $wkb, int $srid = 0)
- Creates a geometry object from a WKB.toArray()
- Serializes the geometry object into a GeoJSON associative array.toJson()
- Serializes the geometry object into an GeoJSON string.toFeatureCollectionJson()
- Serializes the geometry object into an GeoJSON’s FeatureCollection string.toWkt()
- Serializes the geometry object into a WKT.toWkb()
- Serializes the geometry object into a WKB.getCoordinates()
- Returns the coordinates of the geometry object.toSqlExpression(ConnectionInterface $connection)
- Serializes the geometry object into an SQL query.
In addition, GeometryCollection
also has these functions:
getGeometries()
- Returns a geometry array. Can be used with ArrayAccess
as well.$geometryCollection = new GeometryCollection([
new Polygon([
new LineString([
new Point(0, 180),
new Point(1, 179),
new Point(2, 178),
new Point(3, 177),
new Point(0, 180),
]),
]),
new Point(0, 180),
]),
]);
echo $geometryCollection->getGeometries()[1]->latitude; // 0
// or access as an array:
echo $geometryCollection[1]->latitude; // 0
Spatial reference identifiers (SRID) identify the type of coordinate system to use.
An enum is provided with the following values:
Identifier | Value | Description |
---|---|---|
Srid::WGS84 |
4326 |
Geographic coordinate system |
Srid::WEB_MERCATOR |
3857 |
Mercator coordinate system |
Retrieves the distance between 2 geometry objects. Uses ST_Distance.
parameter name | type | default |
---|---|---|
$column |
Geometry \ string |
|
$geometryOrColumn |
Geometry \ string |
|
$alias |
string |
'distance' |
Filters records by distance. Uses ST_Distance.
parameter name | type |
---|---|
$column |
Geometry \ string |
$geometryOrColumn |
Geometry \ string |
$operator |
string |
$value |
int \ float |
Orders records by distance. Uses ST_Distance.
parameter name | type | default |
---|---|---|
$column |
Geometry \ string |
|
$geometryOrColumn |
Geometry \ string |
|
$direction |
string |
'asc' |
Retrieves the spherical distance between 2 geometry objects. Uses ST_Distance_Sphere.
parameter name | type | default |
---|---|---|
$column |
Geometry \ string |
|
$geometryOrColumn |
Geometry \ string |
|
$alias |
string |
'distance' |
Filters records by spherical distance. Uses ST_Distance_Sphere.
parameter name | type |
---|---|
$column |
Geometry \ string |
$geometryOrColumn |
Geometry \ string |
$operator |
string |
$value |
int \ float |
Orders records by spherical distance. Uses ST_Distance_Sphere.
parameter name | type | default |
---|---|---|
$column |
Geometry \ string |
|
$geometryOrColumn |
Geometry \ string |
|
$direction |
string |
'asc' |
Filters records by the ST_Within function.
parameter name | type |
---|---|
$column |
Geometry \ string |
$geometryOrColumn |
Geometry \ string |
Filters records by the ST_Within function.
parameter name | type |
---|---|
$column |
Geometry \ string |
$geometryOrColumn |
Geometry \ string |
Filters records by the ST_Contains function.
parameter name | type |
---|---|
$column |
Geometry \ string |
$geometryOrColumn |
Geometry \ string |
Filters records by the ST_Contains function.
parameter name | type |
---|---|
$column |
Geometry \ string |
$geometryOrColumn |
Geometry \ string |
Filters records by the ST_Touches function.
parameter name | type |
---|---|
$column |
Geometry \ string |
$geometryOrColumn |
Geometry \ string |
Filters records by the ST_Intersects function.
parameter name | type |
---|---|
$column |
Geometry \ string |
$geometryOrColumn |
Geometry \ string |
Filters records by the ST_Crosses function.
parameter name | type |
---|---|
$column |
Geometry \ string |
$geometryOrColumn |
Geometry \ string |
Filters records by the ST_Disjoint function.
parameter name | type |
---|---|
$column |
Geometry \ string |
$geometryOrColumn |
Geometry \ string |
Filters records by the ST_Equal function.
parameter name | type |
---|---|
$column |
Geometry \ string |
$geometryOrColumn |
Geometry \ string |
Filters records by the ST_Srid function.
parameter name | type |
---|---|
$column |
Geometry \ string |
$operator |
string |
$value |
int |