diff --git a/lib/classes/ChildWp/Controller.php b/lib/classes/ChildWp/Controller.php index fd31ce21..7e9ad947 100644 --- a/lib/classes/ChildWp/Controller.php +++ b/lib/classes/ChildWp/Controller.php @@ -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; } diff --git a/lib/classes/ChildWp/Handler.php b/lib/classes/ChildWp/Handler.php index 4c8f3c89..45df8aa0 100644 --- a/lib/classes/ChildWp/Handler.php +++ b/lib/classes/ChildWp/Handler.php @@ -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(); diff --git a/lib/classes/ChildWp/Presenter.php b/lib/classes/ChildWp/Presenter.php index 4f0235ff..d6c8e5f6 100644 --- a/lib/classes/ChildWp/Presenter.php +++ b/lib/classes/ChildWp/Presenter.php @@ -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) diff --git a/lib/classes/Coordinate/Coordinate.php b/lib/classes/Coordinate/Coordinate.php index 722c1730..2c4728bd 100644 --- a/lib/classes/Coordinate/Coordinate.php +++ b/lib/classes/Coordinate/Coordinate.php @@ -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;