Reference documentation and code samples for the Google Cloud PHP shared dependency, providing functionality useful to all components. Client class GeoPoint.
Represents a geographical point.
Unless specified otherwise, this must conform to the WGS84 standard. Values must be within normalized ranges.
Example:
use Google\Cloud\Core\GeoPoint;
$point = new GeoPoint(37.423147, -122.085015);
Methods
__construct
Create a GeoPoint.
Ints will be converted to floats. Values not passing the is_numeric()
check will result in an exception.
latitude
float|int|null
The GeoPoint Latitude. Notethat null
is not a generally valid value, and will throw an InvalidArgumentException
unless $allowNull
is set to true
.
longitude
float|int|null
The GeoPoint Longitude. Notethat null
is not a generally valid value, and will throw an InvalidArgumentException
unless $allowNull
is set to true
.
allowNull
bool
[optional] If true, null values will be allowed
in the constructor only. This switch exists to handle a rare case
wherein a geopoint may be empty and is not intended for use from
outside the client. Defaults to false
.
latitude
Get the latitude
Example:
$latitude = $point->latitude();
float|null
setLatitude
Set the latitude
Non-numeric values will result in an exception
Example:
$point->setLatitude(42.279594);
latitude
int|float
The new latitude
longitude
Get the longitude
Example:
$longitude = $point->longitude();
float|null
setLongitude
Set the longitude
Non-numeric values will result in an exception.
Example:
$point->setLongitude(-83.732124);
longitude
float|int
The new longitude value
point
Return a GeoPoint
Example:
$point = $point->point();
array
jsonSerialize
Implement JsonSerializable by representing GeoPoint as a JSON-object:
{
latitude: 31.778333
longitude: 35.229722
}
object