Пример #1
0
 /**
  * Remove single series from route
  * @param enum $key
  */
 public function removeFromRoute($key)
 {
     $this->Route->set($key, array());
     if ($key == Model\Route\Object::ELEVATIONS_ORIGINAL || $key == Model\Route\Object::ELEVATIONS_CORRECTED) {
         $Calculator = new Calculator($this->Route);
         $Calculator->calculateElevation();
     }
 }
Пример #2
0
 /**
  * Tasks before insertion
  */
 protected function before()
 {
     parent::before();
     if ($this->hasChanged(Object::ELEVATIONS_ORIGINAL) || $this->hasChanged(Object::ELEVATIONS_CORRECTED)) {
         $Calculator = new Calculator($this->NewObject);
         $Calculator->calculateElevation();
     }
 }
Пример #3
0
 /**
  * Tasks before insertion
  */
 protected function before()
 {
     parent::before();
     $Calculator = new Calculator($this->Object);
     if (Configuration::ActivityForm()->correctElevation() && !$this->Object->hasCorrectedElevations()) {
         $Calculator->tryToCorrectElevation();
     }
     $Calculator->calculateElevation();
 }
Пример #4
0
 public function testCorrection()
 {
     $Route = new Route\Object(array(Route\Object::LATITUDES => array(49.44, 49.441, 49.442, 49.443, 49.444, 49.445, 49.446, 49.447, 49.448, 49.449, 49.45), Route\Object::LONGITUDES => array(7.76, 7.761, 7.762, 7.763, 7.764, 7.765, 7.766, 7.767, 7.768, 7.769, 7.77)));
     $Calc = new Calculator($Route);
     if ($Calc->tryToCorrectElevation()) {
         $this->assertEmpty($Route->elevationsOriginal());
         $this->assertNotEmpty($Route->elevationsCorrected());
         $this->assertNotEmpty($Route->get(Route\Object::ELEVATIONS_SOURCE));
     } else {
         $this->markTestSkipped('No elevation correction was not available.');
     }
 }
Пример #5
0
 /**
  * Tasks before insertion
  */
 protected function before()
 {
     parent::before();
     $Calculator = new Calculator($this->Object);
     if (Configuration::ActivityForm()->correctElevation() && !$this->Object->hasCorrectedElevations()) {
         try {
             $Calculator->tryToCorrectElevation();
         } catch (NoValidStrategyException $e) {
             // Well, obviously that did not work. Probably all API limits have been reached.
         }
     }
     $Calculator->calculateElevation();
 }
 */
require '../inc/class.Frontend.php';
use Runalyze\Context;
use Runalyze\Model\Activity;
use Runalyze\Model\Route;
use Runalyze\Calculation\Route\Calculator;
use Runalyze\View\Activity\Linker;
use Runalyze\Data\Elevation\Correction\NoValidStrategyException;
$Frontend = new Frontend();
$Factory = Context::Factory();
$Activity = $Factory->activity(Request::sendId());
$ActivityOld = clone $Activity;
$Route = $Factory->route($Activity->get(Activity\Object::ROUTEID));
$RouteOld = clone $Route;
try {
    $Calculator = new Calculator($Route);
    $result = $Calculator->tryToCorrectElevation(Request::param('strategy'));
} catch (NoValidStrategyException $Exception) {
    $result = false;
}
if ($result) {
    $Calculator->calculateElevation();
    $Activity->set(Activity\Object::ELEVATION, $Route->elevation());
    $UpdaterRoute = new Route\Updater(DB::getInstance(), $Route, $RouteOld);
    $UpdaterRoute->setAccountID(SessionAccountHandler::getId());
    $UpdaterRoute->update();
    $UpdaterActivity = new Activity\Updater(DB::getInstance(), $Activity, $ActivityOld);
    $UpdaterActivity->setAccountID(SessionAccountHandler::getId());
    $UpdaterActivity->update();
    echo __('Elevation data has been corrected.');
    Ajax::setReloadFlag(Ajax::$RELOAD_DATABROWSER_AND_TRAINING);
 * File for correction the elevation data of this training.
 * Call:   call/call.Training.elevationCorrection.php?id=
 */
require '../inc/class.Frontend.php';
use Runalyze\Context;
use Runalyze\Model\Activity;
use Runalyze\Model\Route;
use Runalyze\Calculation\Route\Calculator;
use Runalyze\View\Activity\Linker;
$Frontend = new Frontend();
$Factory = Context::Factory();
$Activity = $Factory->activity(Request::sendId());
$ActivityOld = clone $Activity;
$Route = $Factory->route($Activity->get(Activity\Object::ROUTEID));
$RouteOld = clone $Route;
$Calculator = new Calculator($Route);
if ($Calculator->tryToCorrectElevation()) {
    $Calculator->calculateElevation();
    $Activity->set(Activity\Object::ELEVATION, $Route->elevation());
    $UpdaterRoute = new Route\Updater(DB::getInstance(), $Route, $RouteOld);
    $UpdaterRoute->setAccountID(SessionAccountHandler::getId());
    $UpdaterRoute->update();
    $UpdaterActivity = new Activity\Updater(DB::getInstance(), $Activity, $ActivityOld);
    $UpdaterActivity->setAccountID(SessionAccountHandler::getId());
    $UpdaterActivity->update();
    echo __('Elevation data has been corrected.');
    Ajax::setReloadFlag(Ajax::$RELOAD_DATABROWSER_AND_TRAINING);
    echo Ajax::getReloadCommand();
    echo Ajax::wrapJS('if($("#ajax").is(":visible") && $("#training").length)Runalyze.Overlay.load(\'' . Linker::EDITOR_URL . '?id=' . Request::sendId() . '\')');
} else {
    echo __('Elevation data could not be retrieved.');