X-Git-Url: https://dev.renevier.net/?p=syj.git;a=blobdiff_plain;f=application%2Fcontrollers%2FPathController.php;h=af9d104fb2efb3bb5e78d9d3dfc0ef8492d11e12;hp=7d7ae6af8cd2bb843fa707195671bd627a876f3b;hb=7504b7ccb77a798b20f4dbb003a90bcaee702124;hpb=0722c496ca63f30937427e3bf8fbdd5cfee2c83d diff --git a/application/controllers/PathController.php b/application/controllers/PathController.php index 7d7ae6a..af9d104 100644 --- a/application/controllers/PathController.php +++ b/application/controllers/PathController.php @@ -77,8 +77,20 @@ class PathController extends Zend_Controller_Action throw new Syj_Exception_InvalidGeomUpload(); } + // merge linestrings for gpx containting multiple trkseg elements. + if ($classname == 'gisconverter\\GPX' && $geom::name == 'GeometryCollection') { + $geomstring = ""; + foreach (array_filter($geom->components, function ($geom) { + return $geom::name == "LineString"; + }) as $linestring) { + $geomstring .= str_replace("", "", + str_replace("", "", $linestring->toGPX())); + } + $geom = $decoder->geomFromText("" . $geomstring . ""); + } + if ($geom::name != "LineString") { - throw new Syj_Exception_Request(); + throw new Syj_Exception_InvalidGeomUpload(); } $path->geom = $geom; @@ -90,20 +102,7 @@ class PathController extends Zend_Controller_Action /* now, saving !*/ $pathMapper = new Syj_Model_PathMapper(); - try { - $pathMapper->save ($path); - } catch(Zend_Db_Statement_Exception $e) { - if ($e->getCode() == 23505) { // 23505: Unique violation throw new Syj_Exception_Request(); - $message = $e->getMessage(); - if (strpos($message, 'paths_geom_key') !== false) { - throw new Syj_Exception_Request("uniquepath"); - } else { - throw $e; - } - } else { - throw $e; - } - } + $pathMapper->save ($path); } }