Example #1
0
 /**
  * Parse boundary.
  * @param DOMNode $element
  * @return IdmlBoundary
  */
 public static function parseBoundary(DOMNode $element)
 {
     $points = array();
     $xpath = new DOMXPath($element->ownerDocument);
     // Get four <PathPointType> tags which define the objects corners (or more than four,
     // for complex polygons, which we treat as rectangles anyway)
     $corners = $xpath->query('Properties/PathGeometry/GeometryPathType/PathPointArray//PathPointType', $element);
     foreach ($corners as $corner) {
         $attributes = $corner->attributes;
         $anchor = $attributes->getNamedItem('Anchor')->value;
         $parts = explode(' ', $anchor);
         assert(count($parts) == 2);
         $points[] = array('x' => (double) $parts[0], 'y' => (double) $parts[1]);
     }
     return IdmlBoundary::createFromCornerPoints($points);
 }