$minx, "y" => $miny); } switch ($ajaxResponse->getMethod()) { case "transform" : if (!Mapbender::postgisAvailable()) { $ajaxResponse->setSuccess(false); $ajaxResponse->setMessage(_mb("PostGIS is not available. Please contact the administrator.")); $ajaxResponse->send(); } $fromSrs = $ajaxResponse->getParameter("fromSrs"); $toSrs = $ajaxResponse->getParameter("toSrs"); $x = $ajaxResponse->getParameter("x"); $y = $ajaxResponse->getParameter("y"); $bboxStr = $ajaxResponse->getParameter("bbox"); $bbox = explode(",", $bboxStr); $response = null; $oldEPSG = preg_replace("/EPSG:/","", $fromSrs); $newEPSG = preg_replace("/EPSG:/","", $toSrs); if (!is_null($bbox) && is_array($bbox) && count($bbox) === 4) { $response = array( "newSrs" => $toSrs, "points" => array() ); for ($i = 0; $i < count($bbox); $i+=2) { $pt = transform( floatval($bbox[$i]), floatval($bbox[$i+1]), $oldEPSG, $newEPSG ); if (!is_null($pt)) { $response["points"][]= array( "x" => $pt["x"], "y" => $pt["y"] ); } else { $response = null; break; } } } else { $pt = transform($x, $y, $oldEPSG, $newEPSG); if (!is_null($pt)) { $response = array( "newSrs" => $toSrs, "points" => array(array( "x" => $pt["x"], "y" => $pt["y"] )) ); } } if (is_null($response)) { $ajaxResponse->setSuccess(false); $ajaxResponse->setMessage(_mb("An unknown error occured.")); $ajaxResponse->send(); } else { $ajaxResponse->setSuccess(true); $ajaxResponse->setResult($response); } break; default : $ajaxResponse->setSuccess(false); $ajaxResponse->setMessage(_mb("An unknown error occured.")); break; } $ajaxResponse->send(); ?>