public function Geometry::envelope in geoPHP 7
Same name and namespace in other branches
- 8 geoPHP/lib/geometry/Geometry.class.php \Geometry::envelope()
File
- geoPHP/
lib/ geometry/ Geometry.class.php, line 59
Class
- Geometry
- Geometry abstract class
Code
public function envelope() {
if ($this
->isEmpty()) {
return new Polygon();
}
if ($this
->geos()) {
return geoPHP::geosToGeometry($this
->geos()
->envelope());
}
$bbox = $this
->getBBox();
$points = array(
new Point($bbox['maxx'], $bbox['miny']),
new Point($bbox['maxx'], $bbox['maxy']),
new Point($bbox['minx'], $bbox['maxy']),
new Point($bbox['minx'], $bbox['miny']),
new Point($bbox['maxx'], $bbox['miny']),
);
$outer_boundary = new LineString($points);
return new Polygon(array(
$outer_boundary,
));
}