Exemple #1
0
 public function indexAction()
 {
     $this->_initForms();
     $url = $this->getRequest()->getUserParam('url');
     if (isset($url)) {
         $this->view->geomform->setAction("");
         $pathMapper = new Syj_Model_PathMapper();
         $path = new Syj_Model_Path();
         if (!$pathMapper->findByUrl($url, $path)) {
             if (is_numeric($url) and $pathMapper->hasexisted($url)) {
                 $this->view->message = $this->view->translate("route has been deleted");
                 throw new Syj_Exception_NotFound('Gone', 410);
             } else {
                 $this->view->message = $this->view->translate("route does not exist");
                 throw new Syj_Exception_NotFound('Not Found', 404);
             }
         }
         if ($this->getRequest()->getQuery('format') == 'raw') {
             $this->rawmode($path);
             return;
         }
         $title = $path->displayTitle;
         $this->view->path = $path;
         $jsgeom = new phptojs\JsObject('gInitialGeom', array('data' => (string) $path->geom));
         $this->view->headScript()->prependScript((string) $jsgeom);
         $this->view->loginform->login_geom_id->setValue((string) $path->id);
         $this->view->geomform->geom_title->setValue($path->title);
         $this->view->profileActive = $this->_hasAltiProfile($path);
     } else {
         $this->_setInitialPos();
         $title = "Show your journey";
     }
     $this->_jsLoggedInfo(isset($url) ? $path : null);
     $this->_jsLocaleStrings();
     if (isset($url) and $path->creator) {
         $this->view->jslocales['geomAttribution'] = $this->view->translate('route by <strong>%s</strong>', (string) $path->creator->pseudo);
     }
     $this->view->headTitle($title);
     $this->view->headMeta()->appendName('description', $this->view->translate('website to share routes'));
     $this->view->loggedUser = $this->_helper->SyjUserManager->current();
 }
Exemple #2
0
 public function indexAction()
 {
     $url = $this->getRequest()->getUserParam('url');
     if (!isset($url)) {
         throw new Syj_Exception_NotFound('Not Found', 404);
     }
     $pathMapper = new Syj_Model_PathMapper();
     $path = new Syj_Model_Path();
     if (!$pathMapper->findByUrl($url, $path)) {
         if (is_numeric($url) and $pathMapper->hasexisted($url)) {
             throw new Syj_Exception_NotFound('Gone', 410);
         } else {
             throw new Syj_Exception_NotFound('Not Found', 404);
         }
     }
     $size = $this->getRequest()->getQuery('size', 'big');
     if ($size == 'small') {
         $width = 300;
         $height = 225;
     } else {
         $width = 800;
         $height = 600;
         $size = 'big';
     }
     $file = $path->getProfileCache($size);
     if (file_exists($file)) {
         if (filesize($file) == 0) {
             throw new Syj_Exception_NotImplemented("could not compute altitude profile");
         }
         $this->sendFile($file);
         return;
     }
     try {
         $service = $this->_helper->SyjAltiService->service();
         /* we accept 2% of invalid values in the profile */
         $profile = $path->getAltiProfile($service, 2 / 100);
     } catch (Syj_Exception_NotImplemented $e) {
         @touch($file);
         throw $e;
     }
     $canvas = $this->drawProfile($profile, $width, $height);
     $canvas->draw($file);
     $this->sendFile($file);
 }