private static function selectByApplication($appId, $frameName) { // find the mapframe in the application elements... $sql = "SELECT * FROM gui_element WHERE fkey_gui_id = \$1 AND " . "e_id = \$2 AND e_public = 1 LIMIT 1"; $v = array($appId, $frameName); $t = array('s', 's'); $res = db_prep_query($sql, $v, $t); $row = db_fetch_array($res); // if found... if ($row) { $currentMap = new Map(); // use settings from database $currentMap->setWidth($row["e_width"]); $currentMap->setHeight($row["e_height"]); $currentMap->setFrameName($row["e_id"]); // get the WMS $wmsArray = wms::selectMyWmsByApplication($appId); // $e = new mb_notice("WMS in this map: " . implode(",", $wmsArray)); // if this is the overview, find the WMS index and // reset the WMS array // BEWARE, SUPER UGLY CODE AHEAD!! // (BUT THERE IS NO OTHER WAY TO DO IT) if (strpos($row["e_js_file"], "mb_overview.js") !== false) { // $e = new mb_exception("guess this is the OV"); $ov_sql = "SELECT var_value FROM gui_element_vars WHERE " . "var_name = 'overview_wms' AND fkey_e_id = \$1 AND " . "fkey_gui_id = \$2"; $ov_v = array($frameName, $appId); $ov_t = array('s', 's'); $ov_res = db_prep_query($ov_sql, $ov_v, $ov_t); $ov_row = db_fetch_array($ov_res); if ($ov_row) { $ovIndex = intval($ov_row["var_value"]); } // $e = new mb_exception("OV index: " . $ovIndex); if (!isset($ovIndex)) { $ovIndex = 0; } $wmsArray = array($wmsArray[$ovIndex]); // $e = new mb_notice("WMS in this map (corrected): " . implode(",", $wmsArray)); } else { // $e = new mb_exception("guess this is NOT the OV"); } $currentMap->wmsArray = $wmsArray; // EXTENT $sql = "SELECT gui_wms_epsg FROM gui_wms WHERE gui_wms_position = 0 AND fkey_gui_id = \$1"; $v = array($appId); $t = array('s'); $res = db_prep_query($sql, $v, $t); $row = db_fetch_array($res); $epsg = $row["gui_wms_epsg"]; $layer_epsg = $wmsArray[0]->objLayer[0]->layer_epsg; $j = 0; for ($i = 0; $i < count($layer_epsg); $i++) { if ($layer_epsg[$i]["epsg"] === $epsg) { $j = $i; break; } } $minx = $wmsArray[0]->objLayer[0]->layer_epsg[$j]["minx"]; $miny = $wmsArray[0]->objLayer[0]->layer_epsg[$j]["miny"]; $maxx = $wmsArray[0]->objLayer[0]->layer_epsg[$j]["maxx"]; $maxy = $wmsArray[0]->objLayer[0]->layer_epsg[$j]["maxy"]; $epsg = $wmsArray[0]->objLayer[0]->layer_epsg[$j]["epsg"]; $mapExtent = new Mapbender_bbox($minx, $miny, $maxx, $maxy, $epsg); $currentMap->setExtent($mapExtent); return $currentMap; } else { return null; } }
<?php // // Load WMS // require_once dirname(__FILE__) . "/../php/mb_validateSession.php"; require_once dirname(__FILE__) . "/../classes/class_wms.php"; require_once dirname(__FILE__) . "/../classes/class_administration.php"; $wmsArray = wms::selectMyWmsByApplication($gui_id); for ($i = 0; $i < count($wmsArray); $i++) { $currentWms = $wmsArray[$i]; $output = $currentWms->createJsObjFromWMS_(); echo administration::convertOutgoingString($output); unset($output); }