You are here

public function KML::polygonToKML in geoPHP 7

Same name and namespace in other branches
  1. 8 geoPHP/lib/adapters/KML.class.php \KML::polygonToKML()
1 call to KML::polygonToKML()
KML::geometryToKML in geoPHP/lib/adapters/KML.class.php

File

geoPHP/lib/adapters/KML.class.php, line 248

Class

KML
PHP Geometry/KML encoder/decoder

Code

public function polygonToKML($geom) {
  $components = $geom
    ->getComponents();
  $str = '';
  if (!empty($components)) {
    $str = '<' . $this->nss . 'outerBoundaryIs>' . $this
      ->linestringToKML($components[0], 'LinearRing') . '</' . $this->nss . 'outerBoundaryIs>';
    foreach (array_slice($components, 1) as $comp) {
      $str .= '<' . $this->nss . 'innerBoundaryIs>' . $this
        ->linestringToKML($comp) . '</' . $this->nss . 'innerBoundaryIs>';
    }
  }
  return '<' . $this->nss . 'Polygon>' . $str . '</' . $this->nss . 'Polygon>';
}