1<?php
2/**
3 * GeometryCollection: A heterogenous collection of geometries
4 */
5class GeometryCollection extends Collection
6{
7  protected $geom_type = 'GeometryCollection';
8
9  // We need to override asArray. Because geometryCollections are heterogeneous
10  // we need to specify which type of geometries they contain. We need to do this
11  // because, for example, there would be no way to tell the difference between a
12  // MultiPoint or a LineString, since they share the same structure (collection
13  // of points). So we need to call out the type explicitly.
14  public function asArray() {
15    $array = array();
16    foreach ($this->components as $component) {
17      $array[] = array(
18        'type' => $component->geometryType(),
19        'components' => $component->asArray(),
20      );
21    }
22    return $array;
23  }
24
25  // Not valid for this geomettry
26  public function boundary() { return NULL; }
27  public function isSimple() { return NULL; }
28}
29
30