[Mapbender-commits] r3523 - branches/2.5/http/classes
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Tue Feb 10 10:51:43 EST 2009
Author: christoph
Date: 2009-02-10 10:51:43 -0500 (Tue, 10 Feb 2009)
New Revision: 3523
Modified:
branches/2.5/http/classes/class_map.php
branches/2.5/http/classes/class_wmc.php
branches/2.5/http/classes/class_wmcToXml.php
branches/2.5/http/classes/class_wms.php
Log:
selectability, global zoom
Modified: branches/2.5/http/classes/class_map.php
===================================================================
--- branches/2.5/http/classes/class_map.php 2009-02-08 17:33:13 UTC (rev 3522)
+++ branches/2.5/http/classes/class_map.php 2009-02-10 15:51:43 UTC (rev 3523)
@@ -11,6 +11,7 @@
private $frameName;
private $elementName = "maps";
private $extent;
+ private $zoomFullExtentArray = array();
private $isOverview = false;
private $wmsArray = array();
@@ -83,6 +84,14 @@
return $this->frameName;
}
+ public function addZoomFullExtent ($aMapbenderBbox) {
+ $e = new mb_exception("adding new box: " . $aMapbenderBbox);
+ array_push($this->zoomFullExtentArray, $aMapbenderBbox);
+ }
+
+ public function getZoomFullExtentArray () {
+ return $this->zoomFullExtentArray;
+ }
/**
* @param $value String
*/
@@ -106,6 +115,16 @@
return $this->extent->epsg;
}
+ public function getWms ($index) {
+ if (is_numeric($index)) {
+ $i = intval($index, 10);
+ if ($i < count($this->wmsArray) && count($this->wmsArray) > 0 && $i >= 0) {
+ return $this->wmsArray[$i];
+ }
+ }
+ return null;
+ }
+
/**
*
* @return
Modified: branches/2.5/http/classes/class_wmc.php
===================================================================
--- branches/2.5/http/classes/class_wmc.php 2009-02-08 17:33:13 UTC (rev 3522)
+++ branches/2.5/http/classes/class_wmc.php 2009-02-10 15:51:43 UTC (rev 3523)
@@ -86,7 +86,7 @@
var $monitoringIsOn = false;
var $saveWmcAsFile = false;
var $extensionNamespace = "mapbender";
- var $extensionNamespaceUrl = "http://www.mapbender.org";
+ var $extensionNamespaceUrl = "http://www.mapbender.org/context";
// set in constructor
var $wmc_id;
@@ -360,26 +360,17 @@
for ($i = 0; $i < count($ovWmsArray); $i++) {
for ($j = 0; $j < count($wmsArray); $j++) {
if ($ovWmsArray[$i]->equals($wmsArray[$j])) {
- $overviewWmsIndex = $j;
+ $overviewWmsIndex = $j;
+ $wmsIndexOverview = $i;
break;
}
}
}
}
-
-
// for all wms...
for ($i = 0; $i < count($wmsArray); $i++) {
- // ..use settings from ov if available
- if ($overviewWmsIndex !== null && $this->overviewMap !== null &&
- $overviewWmsIndex == $i && count($ovWmsArray) > $i) {
- array_push($wmcJsArray, $ovWmsArray[$i]->createJsObjFromWMS_());
- }
- else {
- // ..otherwise use data from mapframe1
- array_push($wmcJsArray, $wmsArray[$i]->createJsObjFromWMS_());
- }
+ array_push($wmcJsArray, $wmsArray[$i]->createJsObjFromWMS_());
}
// delete existing map objects...
@@ -393,16 +384,16 @@
// .. and add main map ..
$wmcJsArray = array_merge($wmcJsArray, $this->mainMap->toJavaScript(null));
- // set visibility of main map WMS (may be different from overview)
+ // set visibility of ov map WMS (may be different from main)
if ($this->overviewMap !== null) {
- for ($i = 0; $i < count($wmsArray[$overviewWmsIndex]->objLayer); $i++) {
- $visStr = "mb_mapObj[1].wms[" .$overviewWmsIndex . "].handleLayer(" .
- "'" . $wmsArray[$overviewWmsIndex]->objLayer[$i]->layer_name . "', " .
+ for ($i = 0; $i < count($ovWmsArray[$wmsIndexOverview]->objLayer); $i++) {
+ $visStr = "mb_mapObj[0].wms[" .$wmsIndexOverview . "].handleLayer(" .
+ "'" . $ovWmsArray[$wmsIndexOverview]->objLayer[$i]->layer_name . "', " .
"'visible', " .
- ($wmsArray[$overviewWmsIndex]->objLayer[$i]->gui_layer_visible ? 1 : 0) . ");";
+ ($ovWmsArray[$wmsIndexOverview]->objLayer[$i]->gui_layer_visible ? 1 : 0) . ");";
array_push($wmcJsArray, $visStr);
}
- array_push($wmcJsArray, "mb_mapObj[1].restateLayers(" . $wmsArray[$overviewWmsIndex]->wms_id . ");");
+ array_push($wmcJsArray, "mb_mapObj[0].restateLayers(" . $ovWmsArray[$wmsIndexOverview]->wms_id . ");");
}
@@ -650,7 +641,19 @@
$this->setMapData();
}
if ($generalExtension) {
- $this->generalExtensionArray[$tag] = $value;
+ if ($value !== "") {
+ if (isset($this->generalExtensionArray[$tag])) {
+ if (!is_array($this->generalExtensionArray[$tag])) {
+ $firstValue = $this->generalExtensionArray[$tag];
+ $this->generalExtensionArray[$tag] = array();
+ array_push($this->generalExtensionArray[$tag], $firstValue);
+ }
+ array_push($this->generalExtensionArray[$tag], $value);
+ }
+ else {
+ $this->generalExtensionArray[$tag] = $value;
+ }
+ }
}
if ($tag == "EXTENSION" && $type == "open") {
$generalExtension = true;
@@ -691,12 +694,12 @@
// we have all necessary information to CREATE
// a layer object and append it to the WMS object
//
- if ($currentLayer["extension"]["ISOVERVIEWLAYER"] == "1") {
+ if (isset($currentLayer["extension"]["OVERVIEWHIDDEN"])) {
array_push($layerlistArray["overview"], $currentLayer);
}
- else {
- array_push($layerlistArray["main"], $currentLayer);
- }
+ $modifiedLayer = $currentLayer;
+ unset($modifiedLayer["extension"]["OVERVIEWHIDDEN"]);
+ array_push($layerlistArray["main"], $modifiedLayer);
$layer = false;
}
if ($formatlist) {
@@ -856,6 +859,21 @@
$this->setLayerData($layerlistCompleteArray[$i]);
}
+ // set zoom full extent for root layer of first WMS
+ $firstWms = $this->mainMap->getWms(0);
+ $firstWms->objLayer[0]->layer_epsg = array();
+ $boxList = $this->mainMap->getZoomFullExtentArray();
+ for ($i = 0; $i < count($boxList); $i++) {
+ $currentBox = $boxList[$i];
+ array_push($firstWms->objLayer[0]->layer_epsg, array(
+ "epsg" => $currentBox->epsg,
+ "minx" => $currentBox->min->x,
+ "miny" => $currentBox->min->y,
+ "maxx" => $currentBox->max->x,
+ "maxy" => $currentBox->max->y
+ ));
+ }
+ new mb_exception("NEW LAYER EPSG: " . serialize($this->mainMap->getWms(0)->objLayer[0]->layer_epsg));
return true;
}
@@ -893,7 +911,7 @@
$currentMap = $this->mainMap;
$currentMapIsOverview = false;
- if ($currentLayer["extension"]["ISOVERVIEWLAYER"] == "1") {
+ if (isset($currentLayer["extension"]["OVERVIEWHIDDEN"])) {
$currentMap = $this->overviewMap;
$currentMapIsOverview = true;
}
@@ -989,7 +1007,7 @@
$wms->objLayer[0]->layer_maxscale = 0;
$wms->objLayer[0]->gui_layer_wms_id = $currentLayer["extension"]["WMS_ID"];
$wms->objLayer[0]->gui_layer_status = 1;
- $wms->objLayer[0]->gui_layer_selectable = 1;
+ $wms->objLayer[0]->gui_layer_selectable = $currentLayer["extension"]["WMS_SELECTABLE"];
$wms->objLayer[0]->gui_layer_visible = 1;
$wms->objLayer[0]->gui_layer_queryable = 0;
$wms->objLayer[0]->gui_layer_querylayer = 0;
@@ -1066,6 +1084,42 @@
$bbox = new Mapbender_bbox($this->generalExtensionArray["OV_MINX"], $this->generalExtensionArray["OV_MINY"], $this->generalExtensionArray["OV_MAXX"], $this->generalExtensionArray["OV_MAXY"], $this->generalExtensionArray["OV_SRS"]);
$this->overviewMap->setExtent($bbox);
}
+ if ($this->generalExtensionArray["EPSG"] &&
+ $this->generalExtensionArray["MINX"] &&
+ $this->generalExtensionArray["MINY"] &&
+ $this->generalExtensionArray["MAXX"] &&
+ $this->generalExtensionArray["MAXY"]) {
+
+ $mainEpsgArray = array();
+ $mainMinXArray = array();
+ $mainMinYArray = array();
+ $mainMaxXArray = array();
+ $mainMaxYArray = array();
+ if (!is_array($this->generalExtensionArray["EPSG"])) {
+ $mainEpsgArray[0] = $this->generalExtensionArray["EPSG"];
+ $mainMinXArray[0] = $this->generalExtensionArray["MINX"];
+ $mainMinYArray[0] = $this->generalExtensionArray["MINY"];
+ $mainMaxXArray[0] = $this->generalExtensionArray["MAXX"];
+ $mainMaxYArray[0] = $this->generalExtensionArray["MAXY"];
+ }
+ else {
+ $mainEpsgArray = $this->generalExtensionArray["EPSG"];
+ $mainMinXArray = $this->generalExtensionArray["MINX"];
+ $mainMinYArray = $this->generalExtensionArray["MINY"];
+ $mainMaxXArray = $this->generalExtensionArray["MAXX"];
+ $mainMaxYArray = $this->generalExtensionArray["MAXY"];
+ }
+
+ for ($i=0; $i < count($mainEpsgArray); $i++) {
+ $box = new Mapbender_bbox(
+ floatval($mainMinXArray[$i]), floatval($mainMinYArray[$i]),
+ floatval($mainMaxXArray[$i]), floatval($mainMaxYArray[$i]),
+ $mainEpsgArray[$i]
+ );
+ $this->mainMap->addZoomFullExtent($box);
+ }
+ }
+
if ($this->generalExtensionArray["MAIN_FRAMENAME"]) {
$this->mainMap->setFrameName($this->generalExtensionArray["MAIN_FRAMENAME"]);
}
Modified: branches/2.5/http/classes/class_wmcToXml.php
===================================================================
--- branches/2.5/http/classes/class_wmcToXml.php 2009-02-08 17:33:13 UTC (rev 3522)
+++ branches/2.5/http/classes/class_wmcToXml.php 2009-02-10 15:51:43 UTC (rev 3523)
@@ -56,12 +56,6 @@
private function toXml () {
- // add main map and overview (if exists) to $mapArray
- $mapArray = array($this->wmc->mainMap);
- if ($this->wmc->overviewMap !== null) {
- array_push($mapArray, $this->wmc->overviewMap);
- }
-
// generate XML
$this->doc = new DOMDocument("1.0", CHARSET);
$this->doc->preserveWhiteSpace = false;
@@ -70,10 +64,9 @@
$e_view_context = $this->doc->createElementNS("http://www.opengis.net/context", "ViewContext");
$e_view_context->setAttribute("version", "1.1.0");
$e_view_context->setAttribute("id", $this->wmc->wmc_id);
- $e_view_context->setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink");
+ $e_view_context->setAttribute("xsi:schemaLocation", "http://www.opengis.net/context http://schemas.opengis.net/context/1.1.0/context.xsd");
+ $e_view_context->setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
$e_view_context->setAttribute("xmlns:" . $this->wmc->extensionNamespace, $this->wmc->extensionNamespaceUrl);
- $e_view_context->setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
- $e_view_context->setAttribute("xsi:SchemaLocation", "http://schemas.opengis.net/context/1.0.0/context.xsd");
// General
$e_general = $this->createGeneralNode();
@@ -83,22 +76,46 @@
// Layerlist
$e_layer_list = $this->doc->createElement("LayerList");
- while (count($mapArray) > 0) {
+
+ // store overview layers
+ $overviewLayerArray = array();
+ if ($this->wmc->overviewMap !== null) {
+ $currentOverviewWmsArray = $this->wmc->overviewMap->getWmsArray();
+ for ($k = 0; $k < count($currentOverviewWmsArray); $k++) {
+ $currentOverviewWms = $currentOverviewWmsArray[$k];
+
+ for ($l = 0; $l < count($currentOverviewWms->objLayer); $l++) {
+ $currentOverviewLayer = $currentOverviewWms->objLayer[$l];
+ array_push($overviewLayerArray, $currentOverviewLayer);
+ }
+ }
+ }
+
+ $currentWmsArray = $this->wmc->mainMap->getWmsArray();
+ $currentMap = $this->wmc->mainMap;
+ for ($i = 0; $i < count($currentWmsArray); $i++) {
+ $currentWms = $currentWmsArray[$i];
- $currentMap = array_pop($mapArray);
- $currentWmsArray = $currentMap->getWmsArray();
-
- for ($i = 0; $i < count($currentWmsArray); $i++) {
- $currentWms = $currentWmsArray[$i];
+ for ($j = 0; $j < count($currentWms->objLayer); $j++) {
+ $currentLayer = $currentWms->objLayer[$j];
- for ($j = 0; $j < count($currentWms->objLayer); $j++) {
- $currentLayer = $currentWms->objLayer[$j];
+ $layerNode = null;
+ $found = false;
+ for ($k = 0; $k < count($overviewLayerArray); $k++) {
+ $currentOverviewLayer = $overviewLayerArray[$k];
+ if ($currentLayer->layer_uid == $currentOverviewLayer->layer_uid) {
+ $layerNode = $this->createLayerNode($currentMap, $currentWms, $currentLayer, $currentOverviewLayer);
+ $found = true;
+ break;
+ }
+ }
+ if (!$found) {
$layerNode = $this->createLayerNode($currentMap, $currentWms, $currentLayer);
- if ($layerNode !== null) {
- $e_layer_list->appendChild($layerNode);
- }
}
+ if ($layerNode !== null) {
+ $e_layer_list->appendChild($layerNode);
+ }
}
}
$e_view_context->appendChild($e_layer_list);
@@ -121,6 +138,15 @@
$extensionData["ov_height"] = $this->wmc->overviewMap->getHeight();
}
+ // store epsg and bbox of root layer of 0th WMS
+ $firstWms = $this->wmc->mainMap->getWms(0);
+ if ($firstWms !== null) {
+ for ($i = 0; $i < count($firstWms->objLayer[0]->layer_epsg); $i++) {
+ $currentLayerEpsg = $firstWms->objLayer[0]->layer_epsg[$i];
+ $extensionData["mainMapBox" . $i] = $currentLayerEpsg;
+ }
+ }
+
if ($this->wmc->mainMap !== null) {
$extensionData["main_framename"] = $this->wmc->mainMap->getFrameName();
}
@@ -146,21 +172,19 @@
$e_bbox->setAttribute("maxy", $mainExtent->max->y);
$e_general->appendChild($e_bbox);
- // Name
- $e_name = $this->doc->createElement("Name", $this->wmc->wmc_name);
- $e_general->appendChild($e_name);
-
// Title
$e_title = $this->doc->createElement("Title", $this->wmc->wmc_title);
$e_general->appendChild($e_title);
// Keywords
- $e_keyword_list = $this->doc->createElement("KeywordList");
- for ($i=0; $i < count($this->wmc->wmc_keyword); $i++) {
- $e_keyword = $this->doc->createElement("Keyword", $this->wmc->wmc_keyword[$i]);
- $e_keyword_list->appendChild($e_keyword);
+ if (count($this->wmc->wmc_keyword) > 0) {
+ $e_keyword_list = $this->doc->createElement("KeywordList");
+ for ($i=0; $i < count($this->wmc->wmc_keyword); $i++) {
+ $e_keyword = $this->doc->createElement("Keyword", $this->wmc->wmc_keyword[$i]);
+ $e_keyword_list->appendChild($e_keyword);
+ }
+ $e_general->appendChild($e_keyword_list);
}
- $e_general->appendChild($e_keyword_list);
// Abstract
if ($this->wmc->wmc_abstract) {
@@ -210,7 +234,7 @@
$e_extensionGeneral = $this->doc->createElement("Extension");
foreach ($extensionData as $keyExtensionData => $valueExtensionData) {
- $e_currentExtensionTag = $this->doc->createElement($this->wmc->extensionNamespace.":".$keyExtensionData, $valueExtensionData);
+ $e_currentExtensionTag = $this->addExtension($keyExtensionData, $valueExtensionData);
$e_extensionGeneral->appendChild($e_currentExtensionTag);
}
$e_general->appendChild($e_extensionGeneral);
@@ -218,7 +242,22 @@
return $e_general;
}
- private function createLayerNode ($currentMap, $currentWms, $currentLayer) {
+ private function createLayerNode () {
+ if (func_num_args() == 3) {
+ $currentMap = func_get_arg(0);
+ $currentWms = func_get_arg(1);
+ $currentLayer = func_get_arg(2);
+ $currentOverviewLayer = null;
+ }
+ else if (func_num_args() == 4) {
+ $currentMap = func_get_arg(0);
+ $currentWms = func_get_arg(1);
+ $currentLayer = func_get_arg(2);
+ $currentOverviewLayer = func_get_arg(3);
+ }
+ else {
+ return null;
+ }
if ($currentLayer->layer_parent != '') {
// Layer
@@ -254,12 +293,6 @@
$e_layer->appendChild($e_layer_abstract);
}
- // SRS
- $srsNode = $this->createSrsNode($currentMap, $currentWms);
- if ($srsNode !== null) {
- $e_layer->appendChild($srsNode);
- }
-
// Data URL
if ($currentLayer->layer_dataurl_href){
$e_layer_data_url = $this->doc->createElement("DataURL");
@@ -286,6 +319,12 @@
$e_layer->appendChild($e_layer_metadata_url);
}
+ // SRS
+ $srsNode = $this->createSrsNode($currentMap, $currentWms);
+ if ($srsNode !== null) {
+ $e_layer->appendChild($srsNode);
+ }
+
// Layer format
$formatListNode = $this->createLayerFormatListNode($currentWms);
if ($formatListNode !== null) {
@@ -299,11 +338,10 @@
}
// Extension
- $extensionNode = $this->createLayerExtensionNode($currentMap, $currentWms, $currentLayer);
+ $extensionNode = $this->createLayerExtensionNode($currentMap, $currentWms, $currentLayer, $currentOverviewLayer);
if ($extensionNode !== null) {
$e_layer->appendChild($extensionNode);
}
-
return $e_layer;
}
return null;
@@ -353,7 +391,7 @@
return $e_layer_format;
}
- private function createLayerExtensionNode ($currentMap, $currentWms, $currentLayer) {
+ private function createLayerExtensionNode ($currentMap, $currentWms, $currentLayer, $currentOverviewLayer) {
$layerExtensionData = array();
$layerExtensionData["wms_name"] = $currentWms->objLayer[0]->layer_name;
$layerExtensionData["minscale"] = $currentLayer->layer_minscale;
@@ -362,6 +400,7 @@
$layerExtensionData["gui_maxscale"] = $currentLayer->gui_layer_maxscale;
$layerExtensionData["layer_id"] = $currentLayer->layer_uid;
$layerExtensionData["wms_layer_id"] = $currentWms->objLayer[0]->layer_uid;
+ $layerExtensionData["wms_selectable"] = $currentWms->objLayer[0]->gui_layer_selectable;
$layerExtensionData["layer_pos"] = $currentLayer->layer_pos;
$layerExtensionData["layer_parent"] = $currentLayer->layer_parent;
$layerExtensionData["wms_id"] = $currentLayer->gui_layer_wms_id;
@@ -371,8 +410,8 @@
$layerExtensionData["gui_status"] = $currentLayer->gui_layer_status;
$layerExtensionData["layer_epsg"] = $currentLayer->layer_epsg;
- if ($currentMap->isOverview()) {
- $layerExtensionData["isOverviewLayer"] = 1;
+ if ($currentOverviewLayer != null) {
+ $layerExtensionData["overviewData"] = array("overviewHidden" => ($currentOverviewLayer->gui_layer_visible ? 0 : 1));
}
if ($currentLayer->gui_layer_wfs_featuretype) {
$layerExtensionData["wfsFeatureType"] = $currentLayer->gui_layer_wfs_featuretype;
@@ -395,6 +434,7 @@
if (is_numeric($key)) {
$key = "data" . $key;
}
+// $e_currentExtensionTag = $this->doc->createElementNS($this->wmc->extensionNamespaceUrl, $this->wmc->extensionNamespace.":".$key);
$e_currentExtensionTag = $this->doc->createElement($this->wmc->extensionNamespace.":".$key);
foreach ($value as $childKey => $childValue) {
$newNode = $this->addExtension($childKey, $childValue);
@@ -402,6 +442,7 @@
}
}
else {
+// $e_currentExtensionTag = $this->doc->createElementNS($this->wmc->extensionNamespaceUrl, $this->wmc->extensionNamespace.":".$key, $value);
$e_currentExtensionTag = $this->doc->createElement($this->wmc->extensionNamespace.":".$key, $value);
}
return $e_currentExtensionTag;
@@ -443,7 +484,7 @@
$e_layer_style->appendChild($e_layer_style_title);
- $e_layer_style_legendurl = $this->doc->createElement("LegendUrl");
+ $e_layer_style_legendurl = $this->doc->createElement("LegendURL");
//TODO: determine correct layer style entries
$layerStyle_legendUrl_width = ""; // To Do: add proper data
Modified: branches/2.5/http/classes/class_wms.php
===================================================================
--- branches/2.5/http/classes/class_wms.php 2009-02-08 17:33:13 UTC (rev 3522)
+++ branches/2.5/http/classes/class_wms.php 2009-02-10 15:51:43 UTC (rev 3523)
@@ -861,7 +861,12 @@
$newLayer->gui_layer_status = $currentLayer["extension"]["GUI_STATUS"];
$newLayer->gui_layer_style = ""; // TODO: Add correct data
$newLayer->gui_layer_selectable = $currentLayer["extension"]["GUI_SELECTABLE"];
- $newLayer->gui_layer_visible = $currentLayer["visible"];
+ if (isset($currentLayer["extension"]["OVERVIEWHIDDEN"])) {
+ $newLayer->gui_layer_visible = ($currentLayer["extension"]["OVERVIEWHIDDEN"] === "1") ? false : true;
+ }
+ else {
+ $newLayer->gui_layer_visible = $currentLayer["visible"];
+ }
$newLayer->gui_layer_queryable = $currentLayer["extension"]["GUI_QUERYABLE"];
$newLayer->gui_layer_querylayer = $currentLayer["extension"]["QUERYLAYER"];
$newLayer->gui_layer_minscale = $currentLayer["extension"]["GUI_MINSCALE"];
@@ -1896,7 +1901,7 @@
$res_style = db_prep_query($sql,$v,$t);
$count_layer_style = 0;
while($row2 = db_fetch_array($res_style)){
- $this->objLayer[$layer_cnt]->layer_style[$count_layer_style]["name"]=$row2["name"];
+ $this->objLayer[$layer_cnt]->layer_style[$count_layer_style]["name"] = $row2["name"] ? $row2["name"] : "default";
$this->objLayer[$layer_cnt]->layer_style[$count_layer_style]["title"]=$row2["title"];
if($wmsowsproxy != ""){
if($row2["legendurl"]!=''){
More information about the Mapbender_commits
mailing list