refactored additional wp coord initialization

This commit is contained in:
following 2013-05-19 23:16:00 +02:00
parent bd01c96dfd
commit f54ac45292
4 changed files with 12 additions and 17 deletions

View File

@ -75,7 +75,7 @@ class ChildWp_Controller
{
$presenter = new ChildWp_AddPresenter($this->request, $this->translator);
/* set default waypoint coordinates to cache coordinates */
$presenter->initCoordinates( $childWpHandler->getCacheCoordinates( $cacheId ) );
$presenter->initCoordinate( Coordinate_Coordinate::getFromCache( $cacheId ) );
return $presenter;
}

View File

@ -85,20 +85,6 @@ class ChildWp_Handler
return $nameAndTypes;
}
public function getCacheCoordinates( $cacheid )
{
$rs = sql("SELECT latitude, longitude FROM caches WHERE cache_id = &1", $cacheid);
$r = sql_fetch_array($rs);
$ret = array();
$ret['latitude'] = $r['latitude'];
$ret['longitude'] = $r['longitude'];
mysql_free_result($rs);
return $ret;
}
private function recordToArray($r)
{
$ret = array();

View File

@ -63,9 +63,9 @@ abstract class ChildWp_Presenter
$this->typeImages = $childWpHandler->getChildNamesAndImages();
}
public function initCoordinates( $coords )
public function initCoordinate( $coords )
{
$this->coordinate->init( $coords['latitude'], $coords['longitude'] );
$this->coordinate->init( $coords->latitude(), $coords->longitude() );
}
public function initChildWp($childId, $childWp)

View File

@ -34,6 +34,15 @@ class Coordinate_Coordinate
return $hem ? $retval : -$retval;
}
static public function getFromCache($cacheid)
{
$rs = sql("SELECT latitude, longitude FROM caches WHERE cache_id = &1", $cacheid);
$r = sql_fetch_array($rs);
mysql_free_result($rs);
return new Coordinate_Coordinate($r['latitude'], $r['longitude']);
}
public function latitude()
{
return $this->latitude;