diff --git a/geoapi/api/Api.php b/geoapi/api/Api.php index 9e02459..fa8abc2 100644 --- a/geoapi/api/Api.php +++ b/geoapi/api/Api.php @@ -23,9 +23,11 @@ abstract class Api extends \Slim\Slim { /** * Default-Constructor */ - public function __construct() { + public function __construct() { $this->connect(); parent::__construct(); + + // set content type td xml $this->contentType("Content-type: application/xml;charset=utf-8"); } @@ -33,6 +35,8 @@ abstract class Api extends \Slim\Slim { * Default-DeConstructor */ public function __destruct() { + + // destroy the sqlManager $this->sqlManager->closeConnection(); unset($this->sqlManager); $this->sqlManager = null; diff --git a/geoapi/api/PisApi.php b/geoapi/api/PisApi.php index ff072d2..7fa43e8 100644 --- a/geoapi/api/PisApi.php +++ b/geoapi/api/PisApi.php @@ -9,7 +9,7 @@ include_once PATH_UTILITTY . "/ArrayManager.php"; require_once PATH_API . "/Api.php"; /** - * This class provides some spezial SpsAPI methods + * This class provides some spezial PisAPI methods * @author stubbfel * @since 20.06.2013 */ diff --git a/geoapi/api/PssApi.php b/geoapi/api/PssApi.php index 3ffbcef..f35dcd8 100644 --- a/geoapi/api/PssApi.php +++ b/geoapi/api/PssApi.php @@ -9,7 +9,7 @@ include_once PATH_UTILITTY . "/ArrayManager.php"; require_once PATH_API . "/Api.php"; /** - * This class provides some spezial SpsAPI methods + * This class provides some spezial PssAPI methods * @author stubbfel * @since 20.06.2013 */ @@ -52,7 +52,6 @@ class PssApi extends Api { if (count($pidList) < $this->maxPid) { $result = $this->sqlManager->sendPssQuery($pidList); - return \utiliy\XmlManager::arrayToPssXml($result); } return NULL; diff --git a/geoapi/api/SpsApi.php b/geoapi/api/SpsApi.php index 955f5a2..65c53ff 100644 --- a/geoapi/api/SpsApi.php +++ b/geoapi/api/SpsApi.php @@ -21,7 +21,7 @@ class SpsApi extends Api { public static $routeParameterAlias = "/alias/:alias"; /** - * Route string for the alias paramter + * Route string for the domain paramter * @var string */ public static $routeParameterDomain = "/domain/:domain"; @@ -116,7 +116,6 @@ class SpsApi extends Api { public function __construct() { $this->sqlManager = new \database\SpsSqlManager(); parent::__construct(); - $this->contentType("Content-type: application/xml;charset=utf-8"); } /** @@ -142,6 +141,8 @@ class SpsApi extends Api { * @return querry result as xml */ public function sendSpsCoordinateQuery($queryArgs) { + + // check arguments of the query if (!array_key_exists(SpsApi::$keyLong, $queryArgs) || !array_key_exists(SpsApi::$keyLat, $queryArgs)) { return null; } @@ -152,7 +153,10 @@ class SpsApi extends Api { return null; } + // build a request polygon $queryArgs[SpsApi::$keyPoly] = $this->createPolygon($latitude, $longitude, $this->range); + + // send querry $result = $this->sqlManager->sendSpsCoordinateQuery($queryArgs); return \utiliy\XmlManager::arrayToSpsXml($result); } diff --git a/geoapi/config/config.db.php b/geoapi/config/config.db.php index 6dc498f..23aab87 100644 --- a/geoapi/config/config.db.php +++ b/geoapi/config/config.db.php @@ -4,6 +4,9 @@ namespace config; /** * This clas is an container for the DBConf + * + * @author stubbfel + * @since 20.06.2013 */ class DBConfig { diff --git a/geoapi/database/PisSqlManager.php b/geoapi/database/PisSqlManager.php index 97e9cb4..0ea9f49 100644 --- a/geoapi/database/PisSqlManager.php +++ b/geoapi/database/PisSqlManager.php @@ -7,7 +7,7 @@ include_once PATH_UTILITTY . "/StringManager.php"; require_once PATH_DATABASE . "/SqlManager.php"; /** - * Description of ZisSqlManager + * Description of PisSqlManager * * @author stubbfel * @since 20.06.2013 @@ -58,7 +58,7 @@ class PisSqlManager extends SQLManager { } /** - * Default-DEConstructor + * Default-DeConstructor */ public function __destruct() { parent::__destruct(); diff --git a/geoapi/database/PssSqlManager.php b/geoapi/database/PssSqlManager.php index 5fc243d..b55f325 100644 --- a/geoapi/database/PssSqlManager.php +++ b/geoapi/database/PssSqlManager.php @@ -7,7 +7,7 @@ include_once PATH_UTILITTY . "/ArrayManager.php"; require_once PATH_DATABASE . "/SqlManager.php"; /** - * Description of ZisSqlManager + * Description of PssSqlManager * * @author stubbfel * @since 20.06.2013 @@ -64,7 +64,7 @@ class PssSqlManager extends SQLManager { } /** - * Default-DEConstructor + * Default-DeConstructor */ public function __destruct() { parent::__destruct(); diff --git a/geoapi/database/SpsSqlManager.php b/geoapi/database/SpsSqlManager.php index 85c66b4..cb3c1ca 100644 --- a/geoapi/database/SpsSqlManager.php +++ b/geoapi/database/SpsSqlManager.php @@ -209,7 +209,8 @@ class SpsSqlManager extends SQLManager { * @return boolean */ private function validPolyString($poly) { - if (\utiliy\StringManager::validSQLString($poly) && \utiliy\StringManager::startsWith($poly, $this->polyStartStr) && \utiliy\StringManager::endsWith($poly, $this->polyEndStr)) { + if (\utiliy\StringManager::validSQLString($poly) && \utiliy\StringManager::startsWith($poly, $this->polyStartStr) + && \utiliy\StringManager::endsWith($poly, $this->polyEndStr)) { return TRUE; } return FALSE; diff --git a/geoapi/database/SqlManager.php b/geoapi/database/SqlManager.php index bc28073..c5a54a9 100644 --- a/geoapi/database/SqlManager.php +++ b/geoapi/database/SqlManager.php @@ -74,15 +74,15 @@ abstract class SqlManager { * Default-DEConstructor */ public function __destruct() { + + // close connection $this->closeConnection(); + + // delete connection parameter unset($this->serverAddress); unset($this->dbName); unset($this->userName); unset($this->userPW); - $this->serverAddress = null; - $this->dbName = null; - $this->userName = null; - $this->userPW = null; } /** @@ -116,17 +116,24 @@ abstract class SqlManager { * @return result[num][assoc] */ protected function query($query) { + + // send error $mysqlResult = mysql_query($query, $this->link); if (!$mysqlResult) { exit("Query error: " . mysql_error()); } + + // fetch result $rowNums = mysql_num_rows($mysqlResult); $result = array(); for ($i = 0; $i < $rowNums; $i++) { $row = mysql_fetch_assoc($mysqlResult); $result[$i] = $row; } + + // call gc mysql_free_result($mysqlResult); + return $result; } } diff --git a/geoapi/service/pis/index.php b/geoapi/service/pis/index.php index bed4a17..5d66718 100644 --- a/geoapi/service/pis/index.php +++ b/geoapi/service/pis/index.php @@ -6,6 +6,7 @@ require_once PATH_API . "/PisApi.php"; // instance a new api $app = new \api\PisApi(); +// HTTP-Get-Method $app->get(\api\PisApi::$routeParameterPids, function ($pid) use ($app) { echo $app->sendPisQuery($pid); }); diff --git a/geoapi/service/pss/index.php b/geoapi/service/pss/index.php index 0bf0278..61bcbab 100644 --- a/geoapi/service/pss/index.php +++ b/geoapi/service/pss/index.php @@ -6,9 +6,11 @@ require_once PATH_API . "/PssApi.php"; // instance a new api $app = new \api\PssApi(); +// HTTP-Get-Method $app->get(\api\PssApi::$routeParameterPids, function ($pid) use ($app) { echo $app->sendPssQuery($pid); }); $app->run(); + ?> diff --git a/geoapi/service/sps/index.php b/geoapi/service/sps/index.php index 8dddc5c..9e33d0f 100644 --- a/geoapi/service/sps/index.php +++ b/geoapi/service/sps/index.php @@ -6,8 +6,7 @@ require_once PATH_API . "/SpsApi.php"; // instance a new api $app = new \api\SpsApi(); -// declare the get-methods -// declare the get-methods +// HTTP-Get-Methods $app->get(\api\SpsApi::$routeParameterAlias, function ($alias) use ($app) { $args = array(); $args[\api\SpsApi::$keyAlias] = $alias; diff --git a/geoapi/utility/ArrayManager.php b/geoapi/utility/ArrayManager.php index ad18f21..dd25289 100644 --- a/geoapi/utility/ArrayManager.php +++ b/geoapi/utility/ArrayManager.php @@ -1,4 +1,5 @@ diff --git a/geoapi/utility/StringManager.php b/geoapi/utility/StringManager.php index f276d59..1312e1c 100644 --- a/geoapi/utility/StringManager.php +++ b/geoapi/utility/StringManager.php @@ -1,4 +1,5 @@ diff --git a/geoapi/utility/XmlManager.php b/geoapi/utility/XmlManager.php index 0b737c5..8465a44 100644 --- a/geoapi/utility/XmlManager.php +++ b/geoapi/utility/XmlManager.php @@ -36,34 +36,34 @@ class XmlManager { private static $placeServiceElementName = "placeService"; /** - * Name for the placesap element + * Name for the ssap element * @var string */ private static $placeSapElementName = "sap"; /** - * Name for the placerequest element + * Name for the request element * @var string */ private static $placeRequestElementName = "request"; /** - * Name for the placeInfoName attribute + * Name for the placeInfoName attribute * @var string */ - private static $placeInfoName = "placeInformationName"; + private static $placeInfoAttrName = "placeInformationName"; /** * Name for the placeServiceName attribute * @var string */ - private static $placeServiceName = "placeServiceName"; + private static $placeServiceAttrName = "placeServiceName"; /** * Name for the placeid attribute * @var string */ - private static $placeIdAttrName = "id"; + private static $placeIdAttrName = "id"; /** * Name for the parent attribute @@ -73,6 +73,8 @@ class XmlManager { /** * Method convert an array to a response xml for the sps service + * + * * @param array[num][assoc] $result * @return xml-string */ @@ -88,7 +90,11 @@ class XmlManager { } /** - * Method convert an array to a response xml for the pis service + * Method convert an array to a response xml for the pis service like + * + * Value + * + * * @param array[num][assoc] $result * @return xml-string */ @@ -110,13 +116,20 @@ class XmlManager { // add placeinformation elment $placeInfo = $place->addChild(XmlManager::$placeInfoElementName, utf8_encode($row[\database\PisSqlManager::$infValue])); - $placeInfo->addAttribute(XmlManager::$placeInfoName, $row[\database\PisSqlManager::$infName]); + $placeInfo->addAttribute(XmlManager::$placeInfoAttrName, $row[\database\PisSqlManager::$infName]); } return $xml->asXML(); } /** * Method convert an array to a response xml for the pss service + * + * + * sapValue + * reqVaule + * + * + * * @param array[num][assoc] $result * @return xml-string */ @@ -138,7 +151,7 @@ class XmlManager { // add placeservice elment $placeSrv = $place->addChild(XmlManager::$placeServiceElementName); - $placeSrv->addAttribute(XmlManager::$placeServiceName, $row[\database\PssSqlManager::$srvName]); + $placeSrv->addAttribute(XmlManager::$placeServiceAttrName, $row[\database\PssSqlManager::$srvName]); $placeSrv->addChild(XmlManager::$placeSapElementName, $row[\database\PssSqlManager::$srvSap]); $placeSrv->addChild(XmlManager::$placeRequestElementName, $row[\database\PssSqlManager::$srvRequest]); }