public function GPX::geomFromText in geoPHP 7
Same name and namespace in other branches
- 8 geoPHP/lib/adapters/GPX.class.php \GPX::geomFromText()
1 call to GPX::geomFromText()
- GPX::read in geoPHP/
lib/ adapters/ GPX.class.php - Read GPX string into geometry objects
File
- geoPHP/
lib/ adapters/ GPX.class.php, line 45
Class
- GPX
- PHP Geometry/GPX encoder/decoder
Code
public function geomFromText($text) {
// Change to lower-case and strip all CDATA
$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 GPX: " . $text);
}
$this->xmlobj = $xmlobj;
try {
$geom = $this
->geomFromXML();
} catch (InvalidText $e) {
throw new Exception("Cannot Read Geometry From GPX: " . $text);
} catch (Exception $e) {
throw $e;
}
return $geom;
}