You are here

public function GeoRSS::geomFromText in geoPHP 8

Same name and namespace in other branches
  1. 7 geoPHP/lib/adapters/GeoRSS.class.php \GeoRSS::geomFromText()
1 call to GeoRSS::geomFromText()
GeoRSS::read in geoPHP/lib/adapters/GeoRSS.class.php
Read GeoRSS string into geometry objects

File

geoPHP/lib/adapters/GeoRSS.class.php, line 44

Class

GeoRSS
PHP Geometry/GeoRSS encoder/decoder

Code

public function geomFromText($text) {

  // Change to lower-case, strip all CDATA, and de-namespace
  $text = strtolower($text);
  $text = preg_replace('/<!\\[cdata\\[(.*?)\\]\\]>/s', '', $text);

  // Load into DOMDOcument
  $xmlobj = new DOMDocument();
  @$xmlobj
    ->loadXML($text);
  if ($xmlobj === false) {
    throw new Exception("Invalid GeoRSS: " . $text);
  }
  $this->xmlobj = $xmlobj;
  try {
    $geom = $this
      ->geomFromXML();
  } catch (InvalidText $e) {
    throw new Exception("Cannot Read Geometry From GeoRSS: " . $text);
  } catch (Exception $e) {
    throw $e;
  }
  return $geom;
}