Download the PHP package powlam/coordinates without Composer
On this page you can find all versions of the php package powlam/coordinates. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download powlam/coordinates
More information about powlam/coordinates
Files in powlam/coordinates
Package coordinates
Short Description A PHP package to work with coordinates
License MIT
Informations about the package coordinates
This package provides a handful of tools to work with coordinates the same way as Google Maps Javascript API does.
Requires PHP 8.3+
Classes
LatLng class
A LatLng is a point in geographic coordinates: latitude and longitude. Both parameters are of float type.
- Latitude ranges between -90 and 90 degrees inclusive. Values above or below this range will be clamped to the range [-90, 90]. This means that if the specified value is less than -90, it will be set to -90. And if the value is greater than 90, it will be set to 90.
- Longitude ranges between -180 and 180 degrees inclusive. Values above or below this range will be adjusted to fit within the range. For example, a value of -190 will become 170. A value of 190 will become -170. This reflects the fact that longitudes wrap around the globe.
LatLngAltitude class
A LatLngAltitude is a 3D point in geographic coordinates: latitude, longitude, and altitude.
- Altitude is measured in meters. Positive values indicate heights above ground level, and negative values indicate depths below the ground surface.
LatLngBounds class
A LatLngBounds instance represents a rectangle in geographical coordinates, including one that crosses the 180-degree longitudinal meridian.
Features
Movement
Both LatLng and LatLngAltitude points are movable, so they can be moved in any direction using the move method.
Note: Latitude movements stop when reaching the North or South Pole.
Moving areas
The LatLngBounds rectangles are also movable; the entire area is moved at once.
When moving a LatLngBounds rectangle towards east or west using meters or kilometers, the conversion between distance and degrees depends on the latitude. The corresponding degrees will be calculated based on the midpoint latitude of the area.
Interaction between bounds
LatLngBounds classes can interact with each other:
Also a LatLngBounds can interact with a LatLng point:
Unions and extensions are always done in the closest way possible. When talking about the longitude, usually there are 2 ways of making the join: towards west or towards east. This library selects the closest one or, in case of a tie, towards east.
Places
There is a list of geographical points, lines and areas into the Place enum.
Through the get() method you can retrieve the underlying LatLng, LatLngAltitude or LatLngBounds object that represents it.
Each of them can be used as any other LatLng, LatLngAltitude or LatLngBounds object.
Utils
Latitude and Longitude
These classes facilitate converting between degrees and meters or kilometers in both directions.
This is especially useful in the case of longitudes, because the ratio changes depending on the latitude.
FloatCompare
Testing floating point values for equality is problematic, due to the way that they are represented internally. To test floating point values for equality, an upper bound on the relative error due to rounding is used. This delta is the smallest acceptable difference in calculations.
The methods implemented into the FloatCompare class allow comparing float numbers due to an internal delta value.
📚 The full API of this library is available in this file.
Coordinates for PHP was created by Paul Albandoz under the MIT license.