diff --git a/geoapi/utility/JsonManager.php b/geoapi/utility/JsonManager.php new file mode 100644 index 0000000..6874b8d --- /dev/null +++ b/geoapi/utility/JsonManager.php @@ -0,0 +1,135 @@ + $row[\database\SpsSqlManager::$placeId], + JsonManager::$parentIdName => $row[\database\SpsSqlManager::$parentId]); + array_push($places, $place); + } + return json_encode($places); + } + + /** + * Method convert an array to a response json for the pis service like + * + * @param array[num][assoc] $result + * @return json-string + */ + public static function arrayToPisJson($result) { + $actPlace = 0; + + $infos = array(); + foreach ($result as $row) { + + // fetch the place id of the row + $placeId = $row[\database\PisSqlManager::$placeId]; + + // if the id is new -> add new place item + if ($actPlace != $placeId) { + $actPlace = $placeId; + $place = array(JsonManager::$placeIdName => $placeId); + array_push($infos, $place); + } + + // add placeinformation item + $placeInfo = array(JsonManager::$placeInfoName => $row[\database\PisSqlManager::$infName], + JsonManager::$placeInfoValueName => utf8_encode($row[\database\PisSqlManager::$infValue])); + array_push($place, $placeInfo); + } + return json_encode($infos); + } + + /** + * Method convert an array to a response json for the pss service + * + * @param array[num][assoc] $result + * @return Json-string + */ + public static function arrayToPssJson($result) { + $actPlace = 0; + + $services = array(); + foreach ($result as $row) { + + // fetch the place id of the row + $placeId = $row[\database\PssSqlManager::$placeId]; + + // if the id is new -> add new place item + if ($actPlace != $placeId) { + $actPlace = $placeId; + $place = array(JsonManager::$placeIdName => $placeId); + array_push($services, $place); + } + + // add placeservice items + $placeSrv = array(JsonManager::$placeServiceName => $row[\database\PisSqlManager::$srvName], + JsonManager::$placeSapName => $row[\database\PisSqlManager::$srvSap], + JsonManager::$placeRequestName => $row[\database\PisSqlManager::$srvRequest]); + array_push($place, $placeSrv); + } + return json_encode($services); + } + +} + +?>