Documentation

Point
in package

Read onlyYes

Point represents a point in 2D space with X and Y coordinates.

This is an immutable class that can be used to represent positions, vectors, or any other 2D data points.

Example usage: $point = new Point(52.2297, 21.0122); echo $point->toString(); // Output: "52.2297,21.0122" echo $point->toFormat("Lat: %F, Lng: %F"); // Output: "Lat: 52.229700, Lng: 21.012200"

Table of Contents

Properties

$latitude  : float
$longitude  : float

Methods

__construct()  : mixed
toFormat()  : string
Format the point coordinates according to the provided format string.
toPrepareSql()  : string
toSql()  : string
Returns the point in Well-Known Text (WKT) format for SQL databases
toString()  : string
Converts the point to a string representation

Properties

$latitude

public float $latitude

$longitude

public float $longitude

Methods

__construct()

public __construct(float $latitude, float $longitude) : mixed
Parameters
$latitude : float

Latitude coordinate

$longitude : float

Longitude coordinate

toFormat()

Format the point coordinates according to the provided format string.

public toFormat(string $format) : string
Parameters
$format : string

The format to use for formatting the coordinates. Should contain two %f or %F placeholders for latitude and longitude respectively.

Return values
string

The formatted string with coordinates.

toPrepareSql()

public toPrepareSql(string $xName, string $yName) : string
Parameters
$xName : string
$yName : string
Return values
string

toSql()

Returns the point in Well-Known Text (WKT) format for SQL databases

public toSql() : string
Return values
string

SQL POINT representation in format: POINT(lat long)

toString()

Converts the point to a string representation

public toString() : string
Return values
string

The string representation in "lat,lng" format

On this page

Search results