예제 #1
0
 /**
  * Correct elevation data
  * 
  * This method does directly update the route object.
  * 
  * @return boolean false if correction did not work
  */
 public function tryToCorrectElevation()
 {
     if (!$this->Route->hasPositionData()) {
         return false;
     }
     $Corrector = new Corrector();
     $Corrector->correctElevation($this->Route->latitudes(), $this->Route->longitudes());
     $result = $Corrector->getCorrectedElevation();
     if (!empty($result)) {
         $this->Route->set(Route\Object::ELEVATIONS_CORRECTED, $result);
         $this->Route->set(Route\Object::ELEVATIONS_SOURCE, $Corrector->getNameOfUsedStrategy());
         return true;
     }
     return false;
 }
예제 #2
0
 public function testSimpleInsert()
 {
     $R = new Object(array(Object::NAME => 'Test route', Object::DISTANCE => 3.14, Object::LATITUDES => array(47.7, 47.8), Object::LONGITUDES => array(7.8, 7.7)));
     $I = new Inserter($this->PDO, $R);
     $I->setAccountID(0);
     $I->insert();
     $data = $this->PDO->query('SELECT * FROM `' . PREFIX . 'route` WHERE `accountid`=0')->fetch(PDO::FETCH_ASSOC);
     $N = new Object($data);
     $this->assertEquals(0, $data[Inserter::ACCOUNTID]);
     $this->assertEquals('Test route', $N->name());
     $this->assertTrue($N->hasID());
     $this->assertTrue($N->hasPositionData());
     $this->assertEquals(47.7, $N->get(Object::MIN_LATITUDE));
 }
예제 #3
0
 /**
  * Construct new route
  * @param string $id
  * @param \Runalyze\Model\Route\Object $route
  * @param \Runalyze\Model\Trackdata\Object $trackdata [optional]
  * @param bool $addIconsAndInfo [optional]
  * @throws \InvalidArgumentException
  */
 public function __construct($id, Route\Object $route, Trackdata\Object $trackdata = null, $addIconsAndInfo = true)
 {
     parent::__construct($id);
     if (!$route->hasPositionData()) {
         throw new \InvalidArgumentException('Route needs position data.');
     }
     $this->Route = $route;
     $this->Trackdata = $trackdata;
     $this->addIconsAndInfo = $addIconsAndInfo;
     $this->addOption('options', array('color' => Configuration::ActivityView()->RouteColor()));
     $this->createRoute();
 }