2017 © Pedro Peláez
 

library pip

The Polygon class

image

hannesvdvreken/pip

The Polygon class

  • Friday, February 6, 2015
  • by hannesvdvreken
  • Repository
  • 2 Watchers
  • 10 Stars
  • 11,784 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 1 Open issues
  • 3 Versions
  • 6 % Grown

The README.md

Polygon tools

Build Status, (*1)

A point-in-polygon algorithm, centroid and orientation calculation, written in PHP. Figure out (pun) if a point is actually inside a convex or concave polygon., (*2)

Usage

Initiate a Polygon object with coordinates as specified in the GeoJSON Format. An array of latitude, longitude pairs., (*3)

$coords = [
    [51.046945330263, 3.7388005491447],
    [50.884119340619, 4.7054353759129],
    [51.260385196697, 4.3696193284848],
];

$poly = new \Geometry\Polygon($coords);

$coords = $poly->getOutline();
$poly->setOutline($coords);

$centroid = $poly->centroid();
echo "the centroid of the polygon is ($centroid[0], $centroid[1]).\n";

if ($poly->isValid()) {
    echo "the polygon was succesfully created.\n";
}

if (!$poly->isClockwise()) {
    echo "the points define a counter-clockwise polygon.\n";
}

if ($poly->pip($x, $y)) {
    echo "the polygon includes ($x,$y).\n";
}

Origin

Written during Apps For Ghent, 2012., (*4)

License

MIT, (*5)

The Versions

06/02 2015

dev-master

9999999-dev

The Polygon class

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

geo geometry geojson polygon pip point-in-polygon

13/11 2014

1.0.0

1.0.0.0

The Polygon class

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

geo geometry geojson polygon pip point-in-polygon

08/09 2013

v0.0.2

0.0.2.0

The Polygon class

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

geo geometry geojson polygon pip point-in-polygon