GeometryCollection.class.php 950 B

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