PHP Class Location\Polygon

Author: Paul Vidal ([email protected])
Author: Marcus Jaschen ([email protected])
Inheritance: implements location\GeometryInterface
Mostrar archivo Open project: mjaschen/phpgeo Class Usage Examples

Protected Properties

Property Type Description
$points array

Public Methods

Method Description
addPoint ( Coordinate $point )
contains ( Coordinate $point ) : boolean Determine if given point is contained inside the polygon. Uses the PNPOLY algorithm by W. Randolph Franklin. Therfore some edge cases may not give the expected results, e. g. if the point resides on the polygon boundary.
containsGeometry ( location\GeometryInterface $geometry ) : boolean Determine if given geometry is contained inside the polygon. This is assumed to be true, if each point of the geometry is inside the polygon.
format ( Location\Formatter\Polygon\FormatterInterface $formatter ) : mixed
getArea ( ) : float Calculates the polygon area.
getLats ( ) : float[] Return all polygon point's latitudes.
getLngs ( ) : float[] Return all polygon point's longitudes.
getNumberOfPoints ( ) : integer
getPerimeter ( Location\Distance\DistanceInterface $calculator ) : float Calculates the polygon perimeter.
getPoints ( ) : array
getReverse ( ) : Polygon Create a new polygon with reversed order of points, i. e. reversed polygon direction.
getSegments ( ) : array

Method Details

addPoint() public method

public addPoint ( Coordinate $point )
$point Coordinate

contains() public method

Determine if given point is contained inside the polygon. Uses the PNPOLY algorithm by W. Randolph Franklin. Therfore some edge cases may not give the expected results, e. g. if the point resides on the polygon boundary.
See also: http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html For special cases this calculation leads to wrong results: - if the polygons spans over the longitude boundaries at 180/-180 degrees
public contains ( Coordinate $point ) : boolean
$point Coordinate
return boolean

containsGeometry() public method

Edge cases: - it's not detected when a line between two points is outside the polygon - @see contains() for more restrictions
public containsGeometry ( location\GeometryInterface $geometry ) : boolean
$geometry location\GeometryInterface
return boolean

format() public method

public format ( Location\Formatter\Polygon\FormatterInterface $formatter ) : mixed
$formatter Location\Formatter\Polygon\FormatterInterface
return mixed

getArea() public method

Calculates the polygon area.
public getArea ( ) : float
return float

getLats() public method

Return all polygon point's latitudes.
public getLats ( ) : float[]
return float[]

getLngs() public method

Return all polygon point's longitudes.
public getLngs ( ) : float[]
return float[]

getNumberOfPoints() public method

public getNumberOfPoints ( ) : integer
return integer

getPerimeter() public method

Calculates the polygon perimeter.
public getPerimeter ( Location\Distance\DistanceInterface $calculator ) : float
$calculator Location\Distance\DistanceInterface instance of distance calculation class
return float

getPoints() public method

public getPoints ( ) : array
return array

getReverse() public method

Create a new polygon with reversed order of points, i. e. reversed polygon direction.
public getReverse ( ) : Polygon
return Polygon

getSegments() public method

public getSegments ( ) : array
return array

Property Details

$points protected_oe property

protected array $points
return array