Download the PHP package brianfp/geometry-library without Composer
On this page you can find all versions of the php package brianfp/geometry-library. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download brianfp/geometry-library
More information about brianfp/geometry-library
Files in brianfp/geometry-library
Package geometry-library
Short Description PHP Geometry library provides utility functions for the computation of geometric data on the surface of the Earth.
License MIT
Homepage https://alexpechkarev.github.io/geometry-library/
Informations about the package geometry-library
Geometry Library Google Maps API V3
PHP Geometry Library provides utility functions for the computation of geometric data on the surface of the Earth. Code ported from Google Maps Android API.
Features
- Spherical contains spherical geometry utilities allowing you to compute angles, distances and areas from latitudes and longitudes.
- Poly utility functions for computations involving polygons and polylines.
- Encoding utilities for polyline encoding and decoding.
Dependency
Installation
Issue following command:
Alternatively edit composer.json by adding following line and run composer update
Usage
Here is an example of using GeometryLibrary:
Available methods
PolyUtil class
containsLocation($point, $polygon, $geodesic = false)
isLocationOnEdge($point, $polygon, $tolerance = self::DEFAULT_TOLERANCE, $geodesic = true)
isLocationOnPath($point, $polyline, $tolerance = self::DEFAULT_TOLERANCE, $geodesic = true)
distanceToLine($p, $start, $end)
decode($encodedPath)
encode($path)
SphericalUtil class
computeHeading($from, $to)
computeOffset($from, $distance, $heading)
computeOffsetOrigin($to, $distance, $heading)
interpolate($from, $to, $fraction)
computeDistanceBetween( $from, $to)
computeLength($path)
computeArea($path)
computeSignedArea($path)
containsLocation( $point, $polygon, $geodesic = false )
- To find whether a given point falls within a polygon
$point
- ['lat' => 38.5, 'lng' => -120.2 ]$polygon
- [ ['lat' => 38.5, 'lng' => -120.2], ['lat' => 40.7, 'lng' => -120.95], ['lat' => 43.252, 'lng' => -126.453]]$geodesic
- boolean
Returns boolean
isLocationOnEdge( $point, $polygon, $tolerance = self::DEFAULT_TOLERANCE, $geodesic = true )
- To determine whether a point falls on or near a polyline, or on or near the edge of a polygon, within a specified tolerance in meters.
$point
- ['lat' => 25.774, 'lng' => -80.190 ]$polygon
- [ ['lat' => 38.5, 'lng' => -120.2], ['lat' => 40.7, 'lng' => -120.95], ['lat' => 43.252, 'lng' => -126.453]]$tolerance
- tolerance value in degrees$geodesic
- boolean
Returns boolean
isLocationOnPath( $point, $polygon, $tolerance = self::DEFAULT_TOLERANCE, $geodesic = true )
- To determine whether a point falls on or near a polyline, within a specified tolerance in meters
$point
- ['lat' => 25.774, 'lng' => -80.190 ]$polygon
- [ ['lat' => 38.5, 'lng' => -120.2], ['lat' => 40.7, 'lng' => -120.95], ['lat' => 43.252, 'lng' => -126.453]]$tolerance
- tolerance value in degrees$geodesic
- boolean
Returns boolean
distanceToLine( $p, $start, $end )
- To calculate distance from a point to line start->end on sphere.
$p
- ['lat' => 61.387002, 'lng' => 23.890636]$start
- ['lat' => 61.487002, 'lng' => 23.790636]$end
- ['lat' => 60.48047, 'lng' => 22.052754]
Returns distance from a point to line
decode( $encodedPath )
- Decodes an encoded path string into a sequence of LatLngs.
$encodedPath
- string '_p~iF~ps|U_ulLnnqC_mqNvxq`@'
Returns array
encode( $path )
- Encodes a sequence of LatLngs into an encoded path string.
$path
- [ ['lat' => 38.5, 'lng' => -120.2], ['lat' => 40.7, 'lng' => -120.95], ['lat' => 43.252, 'lng' => -126.453] ]
Returns string
computeHeading( $from, $to )
- Returns the heading from one LatLng to another LatLng.
$from
- ['lat' => 38.5, 'lng' => -120.2]$to
- ['lat' => 40.7, 'lng' => -120.95]
Returns int
computeOffset( $from, $distance, $heading )
- Returns the LatLng resulting from moving a distance from an origin in the specified heading.
$from
- ['lat' => 38.5, 'lng' => -120.2]$distance
- number, the distance to travel$heading
- number, the heading in degrees clockwise from north
Returns array
computeOffsetOrigin( $from, $distance, $heading )
- Returns the location of origin when provided with a LatLng destination, meters travelled and original heading. Headings are expressed in degrees clockwise from North.
$from
- ['lat' => 38.5, 'lng' => -120.2]$distance
- number, the distance to travel$heading
- number, the heading in degrees clockwise from north
Returns array
interpolate( $from, $to, $fraction )
- Returns the LatLng which lies the given fraction of the way between the origin LatLng and the destination LatLng.
$from
- ['lat' => 38.5, 'lng' => -120.2]$to
- ['lat' => 38.5, 'lng' => -120.2]$fraction
- number, a fraction of the distance to travel
Returns array
computeDistanceBetween( $from, $to )
- Returns the distance, in meters, between two LatLngs. You can optionally specify a custom radius. The radius defaults to the radius of the Earth.
$from
- ['lat' => 38.5, 'lng' => -120.2]$to
- ['lat' => 38.5, 'lng' => -120.2]
Returns float
computeLength( $path )
- Returns the length of the given path, in meters, on Earth.
$path
- [ ['lat' => 38.5, 'lng' => -120.2], ['lat' => 40.7, 'lng' => -120.95], ['lat' => 43.252, 'lng' => -126.453] ]
Returns float
computeArea( $path )
- Returns the area of a closed path.
$path
- [ ['lat' => 38.5, 'lng' => -120.2], ['lat' => 40.7, 'lng' => -120.95], ['lat' => 43.252, 'lng' => -126.453] ]
Returns float
computeSignedArea( $path )
- Returns the signed area of a closed path.
$path
- [ ['lat' => 38.5, 'lng' => -120.2], ['lat' => 40.7, 'lng' => -120.95], ['lat' => 43.252, 'lng' => -126.453] ]
Returns float
Support
Please open an issue on GitHub
License
Geometry Library Google Maps API V3 is released under the MIT License. See the bundled LICENSE file for details.