You are here

function WKB::getMulti in geoPHP 7

Same name and namespace in other branches
  1. 8 geoPHP/lib/adapters/WKB.class.php \WKB::getMulti()
1 call to WKB::getMulti()
WKB::getGeometry in geoPHP/lib/adapters/WKB.class.php

File

geoPHP/lib/adapters/WKB.class.php, line 131

Class

WKB
PHP Geometry/WKB encoder/decoder

Code

function getMulti(&$mem, $type) {

  // Get the number of items expected in this multi out of the first 4 bytes
  $multi_length = unpack('L', fread($mem, 4));
  $components = array();
  $i = 1;
  while ($i <= $multi_length[1]) {
    $components[] = $this
      ->getGeometry($mem);
    $i++;
  }
  switch ($type) {
    case 'point':
      return new MultiPoint($components);
    case 'line':
      return new MultiLineString($components);
    case 'polygon':
      return new MultiPolygon($components);
    case 'geometry':
      return new GeometryCollection($components);
  }
}