[Mapbender-commits] r2453 - in branches/beck_dev/mapbender/http:
classes javascripts php
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Thu May 15 05:06:07 EDT 2008
Author: christoph
Date: 2008-05-15 05:06:04 -0400 (Thu, 15 May 2008)
New Revision: 2453
Modified:
branches/beck_dev/mapbender/http/classes/class_administration.php
branches/beck_dev/mapbender/http/classes/class_map.php
branches/beck_dev/mapbender/http/classes/class_wmc.php
branches/beck_dev/mapbender/http/classes/class_wms.php
branches/beck_dev/mapbender/http/javascripts/mod_loadwmc.js
branches/beck_dev/mapbender/http/php/mod_insertWmcIntoDb.php
Log:
WMC updates for PortalU
Modified: branches/beck_dev/mapbender/http/classes/class_administration.php
===================================================================
--- branches/beck_dev/mapbender/http/classes/class_administration.php 2008-05-15 09:02:56 UTC (rev 2452)
+++ branches/beck_dev/mapbender/http/classes/class_administration.php 2008-05-15 09:06:04 UTC (rev 2453)
@@ -19,6 +19,7 @@
require_once(dirname(__FILE__)."/../../conf/mapbender.conf");
require_once(dirname(__FILE__)."/class_mb_exception.php");
require_once(dirname(__FILE__)."/class_user.php");
+
$con = db_connect(DBSERVER,OWNER,PW);
db_select_db(DB,$con);
@@ -28,8 +29,8 @@
* class to wrap administration methods
*
* @uses phpmailer
- */
-class administration{
+ */
+class administration {
/**
* checks whether the passed email-address is valid / following a pattern
* @todo is this an exact representation of the RFC 2822?
@@ -109,6 +110,54 @@
}
}
+ /**
+ * Removes the namespace from a tag name
+ * @return String like "gml"
+ * @param $s String like "ogc:gml"
+ */
+ public static function sepNameSpace($s) {
+ $c = strpos($s,":");
+ if ($c > 0) {
+ return substr($s,$c+1);
+ }
+ return $s;
+ }
+
+ /**
+ * Parses an XML with PHP XML parser, see
+ * http://de2.php.net/manual/de/book.xml.php
+ *
+ * @return Array an associative array of tags, values, attributes and types
+ * @param $someXml String The actual XML as string.
+ */
+ public static function parseXml ($someXml) {
+ $values = null;
+ $tags = null;
+
+ $parser = xml_parser_create(CHARSET);
+
+ // set parsing options
+ xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
+ xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
+ xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, CHARSET);
+
+ // this is the actual parsing process
+ xml_parse_into_struct($parser, $someXml, $values, $tags);
+
+ // check if an error occured
+ $code = xml_get_error_code ($parser);
+ if ($code) {
+ // report error
+ $line = xml_get_current_line_number($parser);
+ $errorMessage = xml_error_string($code) . " in line " . $line;
+ $mb_exception = new mb_exception($errorMessage);
+ return false;
+ }
+ xml_parser_free($parser);
+
+ return $values;
+ }
+
/**
* returns a random password with numbers and chars both lowercase and uppercase (0-9a-zA-Z)
*
Modified: branches/beck_dev/mapbender/http/classes/class_map.php
===================================================================
--- branches/beck_dev/mapbender/http/classes/class_map.php 2008-05-15 09:02:56 UTC (rev 2452)
+++ branches/beck_dev/mapbender/http/classes/class_map.php 2008-05-15 09:06:04 UTC (rev 2453)
@@ -1,6 +1,5 @@
<?php
-ini_set("display_errors","on");
-
+require_once(dirname(__FILE__)."/../classes/class_bbox.php");
/**
* Representing a map object, identical to the JS object in javascripts/map.js
* @class
@@ -11,15 +10,8 @@
var $height;
var $frameName;
var $elementName = "maps";
- var $layers = array();
- var $querylayers = array();
- var $styles = array();
- var $geom = "";
- var $gml = "";
- var $wms = array();
- var $epsg;
var $extent;
- var $mapURL = array();
+ var $overviewLayerIndex;
/**
* @constructor
@@ -28,7 +20,6 @@
function __construct() {
}
-
/**
* @param $value Integer
*/
@@ -53,59 +44,66 @@
/**
* @param $value String
*/
- public function setEpsg ($value) {
- $this->epsg = $value;
+ public function setExtent ($aMapbenderBbox) {
+ $this->extent = $aMapbenderBbox;
}
/**
- * @param $value String
- */
- public function setExtent ($value) {
- $this->extent = $value;
- }
-
- /**
* @param $value Object
*/
- public function pushWms ($value) {
+ public function addWms ($value) {
array_push($this->wms, $value);
}
/**
- * @param $value Object
+ *
+ * @return String EPSG code of the map.
*/
- public function pushMapUrl ($value) {
- array_push($this->mapURL, $value);
- }
-
+ public function getEpsg () {
+ return $this->extent->epsg;
+ }
+
/**
- * @param $value Object
+ *
+ * @return Mapbender_bbox
*/
- public function pushWms ($value) {
- array_push($this->wms, $value);
- }
-
+ public function getExtent () {
+ return $this->extent;
+ }
+
/**
- * @param $value Object
+ *
+ * @return String
*/
- public function pushLayer ($value) {
- array_push($this->layers, $value);
- }
-
+ public function getFrameName () {
+ return $this->frameName;
+ }
+
/**
- * @param $value Object
+ * Returns an array of string, which are JS statements.
+ * @return String[]
*/
- public function pushQueryLayer ($value) {
- array_push($this->querylayers, $value);
- }
+ public function createJsObj () {
+ $jsCodeArray = array();
+ $registerMapString = "mb_registerMapObj('" .
+ $this->frameName . "', " .
+ "'maps', " .
+ (isset($this->overviewLayerIndex)?$this->overviewLayerIndex:"null") . ", " .
+ $this->width . ", " .
+ $this->height . ");";
+ array_push($jsCodeArray, $registerMapString);
+ $calcExtentString = "mb_calculateExtent('" .
+ $this->frameName . "', " .
+ $this->extent->min->x . ", " .
+ $this->extent->min->y . ", " .
+ $this->extent->max->x . ", " .
+ $this->extent->max->y . ");";
+ array_push($jsCodeArray, $calcExtentString);
+ return $jsCodeArray;
+ }
+
/**
- * @param $value Object
- */
- public function pushStyle ($value) {
- array_push($this->styles, $value);
- }
- /**
* @destructor
* @param
*/
Modified: branches/beck_dev/mapbender/http/classes/class_wmc.php
===================================================================
--- branches/beck_dev/mapbender/http/classes/class_wmc.php 2008-05-15 09:02:56 UTC (rev 2452)
+++ branches/beck_dev/mapbender/http/classes/class_wmc.php 2008-05-15 09:06:04 UTC (rev 2453)
@@ -16,31 +16,15 @@
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-require_once(dirname(__FILE__) . "/../../conf/mapbender.conf");
+
require_once(dirname(__FILE__) . "/../classes/class_wms.php");
-require_once(dirname(__FILE__) . "/../classes/class_mb_exception.php");
require_once(dirname(__FILE__) . "/../classes/class_layer_monitor.php");
require_once(dirname(__FILE__) . "/../classes/class_point.php");
require_once(dirname(__FILE__) . "/../classes/class_bbox.php");
require_once(dirname(__FILE__) . "/../classes/class_json.php");
+require_once(dirname(__FILE__) . "/../classes/class_map.php");
+require_once(dirname(__FILE__) . "/../classes/class_administration.php");
-$con = db_connect(DBSERVER,OWNER,PW);
-db_select_db(DB,$con);
-
-function mb_utf8_encode ($str) {
- if(CHARSET=="UTF-8") return utf8_encode($str);
- return $str;
-}
-function mb_utf8_decode ($str) {
- if(CHARSET=="UTF-8") return utf8_decode($str);
- return $str;
-}
-function sepNameSpace($s){
- $c = strpos($s,":");
- if($c>0)return substr($s,$c+1);
- return $s;
-}
-
/**
* Implementation of a Web Map Context Document, WMC 1.1.0
*/
@@ -48,27 +32,19 @@
var $xml;
+ var $mainMap;
+ var $overviewMap;
+ var $wmsArray = array();
+ var $generalExtensionArray = array();
+
+ var $monitoringIsOn = false;
+ var $saveWmcAsFile = false;
+
var $wmc_id;
var $wmc_version;
- var $wmc_windowWidth;
- var $wmc_windowHeight;
- var $wmc_bBox_SRS;
- var $wmc_bBox_minx;
- var $wmc_bBox_maxx;
- var $wmc_bBox_miny;
- var $wmc_bBox_maxy;
var $wmc_name;
var $wmc_title;
var $wmc_abstract;
- var $wmc_general_extension = array();
- var $wmc_logourl;
- var $wmc_logourl_format;
- var $wmc_logourl_type;
- var $wmc_logourl_width;
- var $wmc_logourl_height;
- var $wmc_descriptionurl;
- var $wmc_descriptionurl_format;
- var $wmc_descriptionurl_type;
var $wmc_keyword = array();
var $wmc_contactposition;
var $wmc_contactvoicetelephone;
@@ -82,63 +58,16 @@
var $wmc_contactstateorprovince;
var $wmc_contactpostcode;
var $wmc_contactcountry;
-
-
- var $wmc_wms_title = array();
- var $wmc_layer_queryable = array();
- var $wmc_layer_hidden = array();
- var $wmc_wms_id = array();
- var $wmc_wms_service = array();
- var $wmc_wms_version = array();
- var $wmc_wms_layer_id = array();
- var $wmc_layer_wfs_featuretype = array();
- var $wmc_layer_id = array();
- var $wmc_layer_pos = array();
- var $wmc_layer_parent = array();
- var $wmc_layer_querylayer = array();
- var $wmc_layer_title = array();
- var $wmc_layer_name = array();
- var $wmc_layer_abstract = array();
- var $wmc_layer_srs = array();
- var $wmc_wms_serviceURL = array();
- var $wmc_layer_format_current = array();
- var $wmc_layer_dataurl = array();
- var $wmc_layer_metadataurl = array();
- var $wmc_layer_minscale = array();
- var $wmc_layer_maxscale = array();
- var $wmc_gui_layer_minscale = array();
- var $wmc_gui_layer_maxscale = array();
- var $wmc_layer_format = array();
- var $wmc_layer_style_current = array();
- var $wmc_layer_style_name = array();
- var $wmc_layer_style_title = array();
- var $wmc_layer_style_legendurl = array();
- var $wmc_layer_style_legendurl_width = array();
- var $wmc_layer_style_legendurl_height = array();
- var $wmc_layer_style_legendurl_format = array();
- var $wmc_layer_style_legendurl_type = array();
- var $wmc_layer_style_sld_url = array();
- var $wmc_layer_style_sld_type = array();
- var $wmc_layer_style_sld_title = array();
-
- var $wmc_wms_count = 0;
-
- /*
- var $data_type = array();
- var $data_format = array();
-
- var $objLayer = array();
-
- var $gui_wms_mapformat;
- var $gui_wms_featureinfoformat;
- var $gui_wms_exceptionformat;
- var $gui_wms_epsg;
-
- var $default_epsg = 0;
- */
- var $monitoringIsOn = false;
-
- function wmc() {
+ var $wmc_logourl;
+ var $wmc_logourl_format;
+ var $wmc_logourl_type;
+ var $wmc_logourl_width;
+ var $wmc_logourl_height;
+ var $wmc_descriptionurl;
+ var $wmc_descriptionurl_format;
+ var $wmc_descriptionurl_type;
+
+ public function __construct () {
}
/**
@@ -149,8 +78,8 @@
* @param string the wmc_id
* @return boolean Did the query run successful?
*/
- function delete ($wmcId, $userId) {
- if ($userId == null) {
+ public function delete ($wmcId, $userId) {
+ if (!isset($userId) || $userId == null) {
$userId = $_SESSION["mb_user_id"];
}
@@ -172,7 +101,7 @@
* @return String|boolean The document if it exists; else false
* @param $id String the WMC id
*/
- function getDocument ($id) {
+ public function getDocument ($id) {
$sql = "SELECT wmc FROM mb_user_wmc WHERE wmc_id = $1 ";
$v = array($id);
$t = array('s');
@@ -187,41 +116,14 @@
}
/**
- * Saves the current WMC in the log folder.
- *
- * @return string the filename of the WMC document.
- */
- function saveAsFile() {
- $filename = "wmc_" . date("Y_m_d_H_i_s") . ".log";
- $logfile = "../../log/" . $filename;
-
- if($h = fopen($logfile,"a")){
- $content = $this->xml;
- if(!fwrite($h,$content)){
- $e = new mb_exception("class_wmc.php: failed to write wmc.");
- return false;
- }
- fclose($h);
- }
- return $filename;
- }
-
- /**
* @return string the title of the WMC.
*/
- function getTitle() {
+ public function getTitle() {
return $this->wmc_title;
}
/**
- * @return Integer the number of (unique?) WMS contained in this WMC.
- */
- function getNumberOfWms () {
- return $this->wmc_wms_count;
- }
-
- /**
- * Creates a WMC object from a JS map object {@see map.js}
+ * Creates a WMC object from a JS map object {@see map_obj.js}
*
* @param object $mapObject a map object
* @param integer $user_id the ID of the current user
@@ -229,7 +131,7 @@
* @param object $extensionData data exclusive to Mapbender, which will be
* mapped into the extension part of the WMC
*/
- function createWMCFromObj($mapObject, $user_id, $generalTitle, $extensionData) {
+ public function createWmcFromJs($mapObject, $user_id, $generalTitle, $extensionData) {
$extension_namespace = "mapbender";
@@ -288,6 +190,8 @@
$extensionData->ov_miny = floatval($arrayBBox[1]);
$extensionData->ov_maxx = floatval($arrayBBox[2]);
$extensionData->ov_maxy = floatval($arrayBBox[3]);
+ $extensionData->ov_srs = $mapObject[$i]->epsg;
+ $extensionData->ov_framename = $mapObject[$i]->frameName;
}
}
@@ -444,9 +348,7 @@
$e_general->appendChild($e_contact);
}
-
if (count($extensionData) > 0) {
- //$e = new mb_exception("writing wmc...");
$e_extensionGeneral = $doc->createElement("Extension");
foreach ($extensionData as $keyExtensionData => $valueExtensionData) {
@@ -589,16 +491,18 @@
$e_extension = $doc->createElement("Extension");
- $e_scalehint = $doc->createElement($extension_namespace.":ScaleHint");
- $e_scalehint->setAttribute("min", $layerMinscale);
- $e_scalehint->setAttribute("max", $layerMaxscale);
- $e_extension->appendChild($e_scalehint);
+ $e_minscalehint = $doc->createElement($extension_namespace.":minscale", $layerMinscale);
+ $e_extension->appendChild($e_minscalehint);
- $e_gui_scalehint = $doc->createElement($extension_namespace.":guiScaleHint");
- $e_gui_scalehint->setAttribute("min", $guiLayerMinscale);
- $e_gui_scalehint->setAttribute("max", $guiLayerMaxscale);
- $e_extension->appendChild($e_gui_scalehint);
+ $e_maxscalehint = $doc->createElement($extension_namespace.":maxscale", $layerMaxscale);
+ $e_extension->appendChild($e_maxscalehint);
+ $e_gui_minscalehint = $doc->createElement($extension_namespace.":gui_minscale", $guiLayerMinscale);
+ $e_extension->appendChild($e_gui_minscalehint);
+
+ $e_gui_maxscalehint = $doc->createElement($extension_namespace.":gui_maxscale", $guiLayerMaxscale);
+ $e_extension->appendChild($e_gui_maxscalehint);
+
$e_layer_id = $doc->createElement($extension_namespace.":layer_id", $layerId);
$e_extension->appendChild($e_layer_id);
@@ -725,12 +629,7 @@
$doc->appendChild($e_view_context);
$this->xml = $doc->saveXML();
- // for debugging: saving WMC as file
- // (comment when no longer needed)
- # $filename = $this->saveAsFile();
- # if ($filename) {
- # $e = new mb_notice("class_wmc: saving WMC as file " . $filename);
- # }
+ $filename = $this->saveAsFile();
}
/**
@@ -747,389 +646,368 @@
/**
* Loads a WMC from an actual WMC XML document.
+ * Uses WMS class.
*
* @param string $data the data from the XML file
*/
function createObjFromWMC_xml($data){
- # $data = str_replace("&", "&", $data);
-
// store xml
$this->xml = $data;
// for debugging: saving WMC as file
// (comment when no longer needed)
- $filename = $this->saveAsFile();
- if ($filename) {
- $e = new mb_notice("class_wmc: saving WMC as file " . $filename);
- }
+# $filename = $this->saveAsFile();
+# if ($filename) {
+# $e = new mb_notice("class_wmc: saving WMC as file " . $filename);
+# }
-
-
- $values = NULL;
- $tags = NULL;
- $parser = xml_parser_create(CHARSET);
- xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0);
- xml_parser_set_option($parser,XML_OPTION_SKIP_WHITE,1);
- xml_parser_set_option($parser,XML_OPTION_TARGET_ENCODING,CHARSET);
- xml_parse_into_struct($parser,$data,$values,$tags);
- $code = xml_get_error_code ($parser);
- if ($code) {
- $line = xml_get_current_line_number($parser);
- $mb_exception = new mb_exception(xml_error_string($code) . " in line " . $line);
- return false;
- }
- xml_parser_free($parser);
-
- $section = NULL;
- $format = NULL;
- $cnt_format = 0;
- $parent = array();
- $myParent = array();
- $cnt_layer = -1;
- $request = NULL;
- $layer_style = array();
- $extension = false;
-
- $general = false;
- $layerlist = false;
- $layer = false;
- $formatlist = false;
- $dataurl = false;
- $metadataurl = false;
- $stylelist = false;
- $cnt_style = -1;
+ $values = administration::parseXml($data);
+ //
+ // Local variables that indicate which section of the WMC
+ // is currently parsed.
+ //
+ $extension = false; $general = false; $layerlist = false;
+ $layer = false; $formatlist = false; $dataurl = false;
+ $metadataurl = false; $stylelist = false;
+
+ //
+ // reset WMC data
+ //
+ $this->mainMap = new Map();
+ $this->overviewMap = null;
+ $this->wmsArray = array();
+ $this->generalExtensionArray = array();
foreach ($values as $element) {
- $verbose .= ".";
- if(strtoupper($element[tag]) == "VIEWCONTEXT" && $element[type] == "open"){
- $this->wmc_id = $element[attributes]["id"];
- $this->wmc_version = $element[attributes]["version"];
+ $tag = strtoupper(administration::sepNameSpace($element[tag]));
+ $tagLowerCase = administration::sepNameSpace($element[tag]);
+ $type = $element[type];
+ $attributes = $element[attributes];
+ $value = mb_utf8_decode(html_entity_decode($element[value])); // TODO: not sure if utf decoding is necessary
+
+ if ($tag == "VIEWCONTEXT" && $type == "open") {
+ $this->wmc_id = $attributes["id"];
+ $this->wmc_version = $attributes["version"];
}
- if(strtoupper($element[tag]) == "GENERAL" && $element[type] == "open"){
- $general = true;
+ if ($tag == "GENERAL" && $type == "open") {
+ $general = true;
}
- if(strtoupper($element[tag]) == "LAYERLIST" && $element[type] == "open"){
- $layerlist = true;
+ if ($tag == "LAYERLIST" && $type == "open") {
+ $layerlist = true;
}
if ($general) {
- if(strtoupper($element[tag]) == "WINDOW"){
- $this->wmc_windowWidth = $element[attributes]["width"];
- $this->wmc_windowHeight = $element[attributes]["height"];
+ if ($tag == "WINDOW") {
+ $this->mainMap->setWidth($attributes["width"]);
+ $this->mainMap->setHeight($attributes["height"]);
}
- if(strtoupper($element[tag]) == "BOUNDINGBOX"){
- $this->wmc_bBox_SRS = $element[attributes]["SRS"];
- $this->wmc_bBox_minx = $element[attributes]["minx"];
- $this->wmc_bBox_miny = $element[attributes]["miny"];
- $this->wmc_bBox_maxx = $element[attributes]["maxx"];
- $this->wmc_bBox_maxy = $element[attributes]["maxy"];
+ if ($tag == "BOUNDINGBOX") {
+ $bbox = new Mapbender_bbox($attributes["minx"], $attributes["miny"], $attributes["maxx"], $attributes["maxy"], $attributes["SRS"]);
+ $this->mainMap->setExtent($bbox);
}
- if(strtoupper($element[tag]) == "NAME"){
- $this->wmc_name = mb_utf8_decode(html_entity_decode($element[value]));
+ if ($tag == "NAME") {
+ $this->wmc_name = $value;
}
- if(strtoupper($element[tag]) == "TITLE"){
- $this->wmc_title = mb_utf8_decode(html_entity_decode($element[value]));
+ if ($tag == "TITLE") {
+ $this->wmc_title = $value;
}
- if(strtoupper($element[tag]) == "ABSTRACT"){
- $this->wmc_abstract = mb_utf8_decode(html_entity_decode($element[value]));
+ if ($tag == "ABSTRACT") {
+ $this->wmc_abstract = $value;
}
- if(strtoupper($element[tag]) == "CONTACTINFORMATION" && $element['type'] == "open"){
- $contactinformation = true;
+ if ($tag == "CONTACTINFORMATION" && $type == "open") {
+ $contactinformation = true;
}
if ($contactinformation) {
- if(strtoupper($element[tag]) == "CONTACTPOSITION"){
- $this->wmc_contactposition = mb_utf8_decode(html_entity_decode($element[value]));
+ if ($tag == "CONTACTPOSITION") {
+ $this->wmc_contactposition = $value;
}
- if(strtoupper($element[tag]) == "CONTACTVOICETELEPHONE"){
- $this->wmc_contactvoicetelephone = $element[value];
+ if ($tag == "CONTACTVOICETELEPHONE") {
+ $this->wmc_contactvoicetelephone = $value;
}
- if(strtoupper($element[tag]) == "CONTACTFACSIMILETELEPHONE"){
- $this->wmc_contactfacsimiletelephone = $element[value];
+ if ($tag == "CONTACTFACSIMILETELEPHONE") {
+ $this->wmc_contactfacsimiletelephone = $value;
}
- if(strtoupper($element[tag]) == "CONTACTELECTRONICMAILADDRESS"){
- $this->wmc_contactemail = mb_utf8_decode(html_entity_decode($element[value]));
+ if ($tag == "CONTACTELECTRONICMAILADDRESS") {
+ $this->wmc_contactemail = $value;
}
- if(strtoupper($element[tag]) == "CONTACTPERSONPRIMARY" && $element['type'] == "open"){
- $contactpersonprimary = true;
+ if ($tag == "CONTACTPERSONPRIMARY" && $type == "open") {
+ $contactpersonprimary = true;
}
if ($contactpersonprimary) {
- if(strtoupper($element[tag]) == "CONTACTPERSON"){
- $this->wmc_contactperson = mb_utf8_decode(html_entity_decode($element[value]));
+ if ($tag == "CONTACTPERSON") {
+ $this->wmc_contactperson = $value;
}
- if(strtoupper($element[tag]) == "CONTACTORGANIZATION"){
- $this->wmc_contactorganization = mb_utf8_decode(html_entity_decode($element[value]));
+ if ($tag == "CONTACTORGANIZATION") {
+ $this->wmc_contactorganization = $value;;
}
- if(strtoupper($element[tag]) == "CONTACTPERSONPRIMARY" && $element['type'] == "close"){
- $contactpersonprimary = false;
+ if ($tag == "CONTACTPERSONPRIMARY" && $type == "close") {
+ $contactpersonprimary = false;
}
}
- if(strtoupper($element[tag]) == "CONTACTADDRESS" && $element['type'] == "open"){
- $contactaddress = true;
+ if ($tag == "CONTACTADDRESS" && $type == "open") {
+ $contactaddress = true;
}
if ($contactaddress) {
- if(strtoupper($element[tag]) == "ADDRESSTYPE"){
- $this->wmc_contactaddresstype = mb_utf8_decode(html_entity_decode($element[value]));
+ if ($tag == "ADDRESSTYPE") {
+ $this->wmc_contactaddresstype = $value;
}
- if(strtoupper($element[tag]) == "ADDRESS"){
- $this->wmc_contactaddress = mb_utf8_decode(html_entity_decode($element[value]));
+ if ($tag == "ADDRESS") {
+ $this->wmc_contactaddress = $value;
}
- if(strtoupper($element[tag]) == "CITY"){
- $this->wmc_contactcity = mb_utf8_decode(html_entity_decode($element[value]));
+ if ($tag == "CITY") {
+ $this->wmc_contactcity = $value;
}
- if(strtoupper($element[tag]) == "STATEORPROVINCE"){
- $this->wmc_contactstateorprovince = mb_utf8_decode(html_entity_decode($element[value]));
+ if ($tag == "STATEORPROVINCE") {
+ $this->wmc_contactstateorprovince = $value;
}
- if(strtoupper($element[tag]) == "POSTCODE"){
- $this->wmc_contactpostcode = $element[value];
+ if ($tag == "POSTCODE"){
+ $this->wmc_contactpostcode = $value;
}
- if(strtoupper($element[tag]) == "COUNTRY"){
- $this->wmc_contactcountry = mb_utf8_decode(html_entity_decode($element[value]));
+ if ($tag == "COUNTRY") {
+ $this->wmc_contactcountry = $value;
}
- if(strtoupper($element[tag]) == "CONTACTADDRESS" && $element['type'] == "close"){
- $contactaddress = false;
+ if ($tag == "CONTACTADDRESS" && $type == "close") {
+ $contactaddress = false;
}
}
}
- if(strtoupper($element[tag]) == "LOGOURL" && $element['type'] == "open"){
+ if ($tag == "LOGOURL" && $type == "open") {
$logourl = true;
- $this->wmc_logourl_width = $element[attributes]["width"];
- $this->wmc_logourl_height = $element[attributes]["height"];
- $this->wmc_logourl_format = $element[attributes]["format"];
+ $this->wmc_logourl_width = $attributes["width"];
+ $this->wmc_logourl_height = $attributes["height"];
+ $this->wmc_logourl_format = $attributes["format"];
}
if ($logourl) {
- if(strtoupper($element[tag]) == "LOGOURL" && $element['type'] == "close"){
- $logourl = false;
+ if ($tag == "LOGOURL" && $type == "close") {
+ $logourl = false;
}
- if(strtoupper($element[tag]) == "ONLINERESOURCE"){
- $this->wmc_logourl_type = $element[attributes]["xlink:type"];
- $this->wmc_logourl = $element[attributes]["xlink:href"];
+ if ($tag == "ONLINERESOURCE") {
+ $this->wmc_logourl_type = $attributes["xlink:type"];
+ $this->wmc_logourl = $attributes["xlink:href"];
}
}
- if(strtoupper($element[tag]) == "DESCRIPTIONURL" && $element['type'] == "open"){
+ if ($tag == "DESCRIPTIONURL" && $type == "open") {
$descriptionurl = true;
- $this->wmc_descriptionurl_format = $element[attributes]["format"];
+ $this->wmc_descriptionurl_format = $attributes["format"];
}
if ($descriptionurl) {
- if(strtoupper($element[tag]) == "DESCRIPTIONURL" && $element['type'] == "close"){
- $descriptionurl = false;
+ if ($tag == "DESCRIPTIONURL" && $type == "close"){
+ $descriptionurl = false;
}
- if(strtoupper($element[tag]) == "ONLINERESOURCE"){
- $this->wmc_descriptionurl_type = $element[attributes]["xlink:type"];
- $this->wmc_descriptionurl = $element[attributes]["xlink:href"];
+ if ($tag == "ONLINERESOURCE") {
+ $this->wmc_descriptionurl_type = $attributes["xlink:type"];
+ $this->wmc_descriptionurl = $attributes["xlink:href"];
}
}
- if(strtoupper($element[tag]) == "KEYWORDLIST" && $element['type'] == "open"){
- $keywordlist = true;
+ if ($tag == "KEYWORDLIST" && $type == "open") {
+ $keywordlist = true;
}
if ($keywordlist) {
- if(strtoupper($element[tag]) == "KEYWORDLIST" && $element['type'] == "close"){
- $keywordlist = false;
- $cnt_keyword = -1;
+ if ($tag == "KEYWORDLIST" && $type == "close") {
+ $keywordlist = false;
+ $cnt_keyword = -1;
}
- if(strtoupper($element[tag]) == "KEYWORD"){
+ if ($tag == "KEYWORD") {
$cnt_keyword++;
- $this->wmc_keyword[$cnt_keyword] = mb_utf8_decode(html_entity_decode($element[value]));
+ $this->wmc_keyword[$cnt_keyword] = $value;
}
}
- if(strtoupper($element[tag]) == "EXTENSION" && $element['type'] == "close"){
+ if ($tag == "EXTENSION" && $type == "close") {
$generalExtension = false;
+ //
+ // After the general extension tag is closed,
+ // we have all necessary information to CREATE
+ // the map objects that are contained in this
+ // WMC.
+ //
+ $this->setMapData();
}
if ($generalExtension) {
- $this->wmc_general_extension[sepNameSpace($element[tag])] = $element[value];
-// $e = new mb_exception("WMC: " . $element[tag] . ": " . $element[value]);
+ $this->generalExtensionArray[$tag] = $value;
}
- if(strtoupper($element[tag]) == "EXTENSION" && $element['type'] == "open"){
+ if ($tag == "EXTENSION" && $type == "open") {
$generalExtension = true;
}
-
- if(strtoupper($element[tag]) == "GENERAL" && $element['type'] == "close"){
+ if ($tag == "GENERAL" && $type == "close") {
$general = false;
}
- }
- if ($layerlist) {
- if(strtoupper($element[tag]) == "LAYERLIST" && $element['type'] == "close"){
+ }
+ if ($layerlist) {
+ if ($tag == "LAYERLIST" && $type == "close") {
$layerlist = false;
}
- if(strtoupper($element[tag]) == "LAYER" && $element[type] == "open"){
- $cnt_layer++;
- $this->wmc_layer_queryable[$cnt_layer] = $element[attributes]["queryable"];
- $this->wmc_layer_hidden[$cnt_layer] = $element[attributes]["hidden"];
- $layer = true;
- $cnt_epsg = 0;
+ if ($tag == "LAYER" && $type == "open") {
+ //
+ // The associative array currentLayer holds all
+ // data of the currently processed layer.
+ // The data will be set in the classes' WMS
+ // object when the layer tag is closed.
+ //
+ $currentLayer = array();
+
+ $currentLayer["queryable"] = $attributes["queryable"];
+ if ($attributes["hidden"] == "1") {
+ $currentLayer["visible"] = 0;
+ }
+ else {
+ $currentLayer["visible"] = 1;
+ }
+ $currentLayer["format"] = array();
+ $currentLayer["style"] = array();
+ $layer = true;
}
if ($layer) {
- if(strtoupper($element[tag]) == "LAYER" && $element[type] == "close"){
- $layer = false;
- }
- if ($formatlist) {
- if(strtoupper($element[tag]) == "FORMAT"){
- $cnt_format++;
- $this->wmc_layer_format_current[$cnt_layer][$cnt_format] = $element[attributes]["current"];
- $this->wmc_layer_format[$cnt_layer][$cnt_format] = $element[value];
+ if ($tag == "LAYER" && $type == "close") {
+
+ //
+ // After a layer tag is closed,
+ // we have all necessary information to CREATE
+ // a layer object and append it to the WMS object
+ //
+ $this->setLayerData($currentLayer);
+
+ $layer = false;
+ }
+ if ($formatlist) {
+ if ($tag == "FORMAT") {
+ array_push($currentLayer["format"], array("current" => $attributes["current"], "name" => $value));
+ if ($attributes["current"] == "1") {
+ $currentLayer["formatIndex"] = count($currentLayer["format"]) - 1;
+ }
}
- if(strtoupper($element[tag]) == "FORMATLIST" && $element[type] == "close"){
+ if ($tag == "FORMATLIST" && $type == "close") {
$formatlist = false;
}
}
elseif ($metadataurl) {
- if(strtoupper($element[tag]) == "ONLINERESOURCE"){
- $this->wmc_layer_metadataurl[$cnt_layer] = $element[attributes]["xlink:href"];
- }
- if(strtoupper($element[tag]) == "METADATAURL" && $element[type] == "close"){
- $metadataurl = false;
- }
+ if ($tag == "ONLINERESOURCE") {
+ $currentLayer["metadataurl"] = $attributes["xlink:href"];
+ }
+ if ($tag == "METADATAURL" && $type == "close") {
+ $metadataurl = false;
+ }
}
elseif ($dataurl) {
- if(strtoupper($element[tag]) == "ONLINERESOURCE"){
- $this->wmc_layer_dataurl[$cnt_layer] = $element[attributes]["xlink:href"];
+ if ($tag == "ONLINERESOURCE") {
+ $currentLayer["dataurl"] = $attributes["xlink:href"];
+ }
+ if ($tag == "DATAURL" && $type == "close") {
+ $dataurl = false;
}
- if(strtoupper($element[tag]) == "DATAURL" && $element[type] == "close"){
- $dataurl = false;
- }
}
elseif ($stylelist) {
- if(strtoupper($element[tag]) == "STYLE" && $element[type] == "open"){
- $cnt_style++;
+ if ($tag == "STYLE" && $type == "open") {
$style = true;
- $this->wmc_layer_style_current[$cnt_layer][$cnt_style] = $element[attributes]["current"];
+ array_push($currentLayer["style"], array("current" => $attributes["current"]));
+ if ($attributes["current"] == "1") {
+ $currentLayer["styleIndex"] = count($currentLayer) - 1;
+ }
}
if ($style) {
- if(strtoupper($element[tag]) == "STYLE" && $element[type] == "close"){
- $style = false;
- }
- if(strtoupper($element[tag]) == "SLD" && $element[type] == "open"){
- $sld = true;
- }
- if ($sld) {
- if(strtoupper($element[tag]) == "SLD" && $element[type] == "close"){
- $sld = false;
- }
- if(strtoupper($element[tag]) == "ONLINERESOURCE"){
- $this->wmc_layer_style_sld_type[$cnt_layer][$cnt_style] = $element[attributes]["xlink:type"];
- $this->wmc_layer_style_sld_url[$cnt_layer][$cnt_style] = $element[attributes]["xlink:href"];
- }
- if(strtoupper($element[tag]) == "TITLE"){
- $this->wmc_layer_style_sld_title[$cnt_layer][$cnt_style] = mb_utf8_decode(html_entity_decode($element[value]));
- }
- }
- else {
- if(strtoupper($element[tag]) == "NAME"){
- $this->wmc_layer_style_name[$cnt_layer][$cnt_style] = mb_utf8_decode(html_entity_decode($element[value]));
- }
- if(strtoupper($element[tag]) == "TITLE"){
- $this->wmc_layer_style_title[$cnt_layer][$cnt_style] = $element[value];
- }
- if(strtoupper($element[tag]) == "LEGENDURL" && $element[type] == "open"){
+ $index = count($currentLayer["style"]) - 1;
+ if ($tag == "STYLE" && $type == "close") {
+ $style = false;
+ }
+ if ($tag == "SLD" && $type == "open") {
+ $sld = true;
+ }
+ if ($sld) {
+ if ($tag == "SLD" && $type == "close") {
+ $sld = false;
+ }
+ if ($tag == "ONLINERESOURCE") {
+ $currentLayer["style"][$index]["sld_type"] = $attributes["xlink:type"];
+ $currentLayer["style"][$index]["sld_url"] = $attributes["xlink:href"];
+ }
+ if ($tag == "TITLE") {
+ $currentLayer["style"][$index]["sld_title"] = $value;
+ }
+ }
+ else {
+ if ($tag == "NAME"){
+ $currentLayer["style"][$index]["name"] = $value;
+ }
+ if ($tag == "TITLE") {
+ $currentLayer["style"][$index]["title"] = $value;
+ }
+ if ($tag == "LEGENDURL" && $type == "open") {
$legendurl = true;
- $this->wmc_layer_style_legendurl_width[$cnt_layer][$cnt_style] = $element[attributes]["width"];
- $this->wmc_layer_style_legendurl_height[$cnt_layer][$cnt_style] = $element[attributes]["height"];
- $this->wmc_layer_style_legendurl_format[$cnt_layer][$cnt_style] = $element[attributes]["format"];
- }
- if ($legendurl) {
- if(strtoupper($element[tag]) == "LEGENDURL" && $element[type] == "close"){
- $legendurl = false;
- }
- if(strtoupper($element[tag]) == "ONLINERESOURCE"){
- $this->wmc_layer_style_legendurl_type[$cnt_layer][$cnt_style] = $element[attributes]["xlink:type"];
- $this->wmc_layer_style_legendurl[$cnt_layer][$cnt_style] = $element[attributes]["xlink:href"];
- }
- }
- }
- }
- if(strtoupper($element[tag]) == "STYLELIST" && $element[type] == "close"){
- $stylelist = false;
- }
- }
- else {
- if(strtoupper($element[tag]) == "SERVER" && $element[type] == "open"){
- $server = true;
- $this->wmc_wms_service[$cnt_layer] = $element[attributes]["service"];
- $this->wmc_wms_version[$cnt_layer] = $element[attributes]["version"];
- $this->wmc_wms_title[$cnt_layer] = mb_utf8_decode(html_entity_decode($element[attributes]["title"]));
- }
- if ($server) {
- if(strtoupper($element[tag]) == "SERVER" && $element[type] == "close"){
- $server = false;
- }
- if(strtoupper($element[tag]) == "ONLINERESOURCE"){
- $this->wmc_wms_serviceURL[$cnt_layer] = $element[attributes]["xlink:href"];
- }
- }
- if(strtoupper($element[tag]) == "NAME"){
- $this->wmc_layer_name[$cnt_layer] = mb_utf8_decode(html_entity_decode($element[value]));
- }
- if(strtoupper($element[tag]) == "TITLE"){
- $this->wmc_layer_title[$cnt_layer] = mb_utf8_decode(html_entity_decode($element[value]));
- }
- if(strtoupper($element[tag]) == "ABSTRACT"){
- $this->wmc_layer_abstract[$cnt_layer] = mb_utf8_decode(html_entity_decode($element[value]));
- }
- if(strtoupper($element[tag]) == "SRS"){
- $epsgArray = explode(" ", $element[value]);
-
- for ($c = 0 ; $c < count($epsgArray) ; $c ++) {
- $this->wmc_layer_srs[$cnt_layer][$cnt_epsg] = $epsgArray[$c];
- $cnt_epsg++;
- }
- }
- if (strtoupper($element[tag]) == "EXTENSION" && $element[type] == "open") {
- $extension = true;
- }
- if (strtoupper($element[tag]) == "EXTENSION" && $element[type] == "close") {
- $extension = false;
- }
- if($extension == true && strtoupper(sepNameSpace($element[tag])) == "SCALEHINT"){
- $this->wmc_layer_minscale[$cnt_layer] = $element[attributes]["min"];
- $this->wmc_layer_maxscale[$cnt_layer] = $element[attributes]["max"];
- }
- if($extension == true && strtoupper(sepNameSpace($element[tag])) == "GUISCALEHINT"){
- $this->wmc_gui_layer_minscale[$cnt_layer] = $element[attributes]["min"];
- $this->wmc_gui_layer_maxscale[$cnt_layer] = $element[attributes]["max"];
- }
- if($extension == true && strtoupper(sepNameSpace($element[tag])) == "LAYER_ID"){
- $this->wmc_layer_id[$cnt_layer] = $element[value];
- }
- if($extension == true && strtoupper(sepNameSpace($element[tag])) == "WMS_LAYER_ID"){
- $this->wmc_wms_layer_id[$cnt_layer] = $element[value];
- }
- if($extension == true && strtoupper(sepNameSpace($element[tag])) == "LAYER_POS"){
- $this->wmc_layer_pos[$cnt_layer] = $element[value];
- }
- if($extension == true && strtoupper(sepNameSpace($element[tag])) == "LAYER_PARENT"){
- $this->wmc_layer_parent[$cnt_layer] = $element[value];
- }
- if($extension == true && strtoupper(sepNameSpace($element[tag])) == "QUERYLAYER"){
- $this->wmc_layer_querylayer[$cnt_layer] = $element[value];
- }
- if($extension == true && strtoupper(sepNameSpace($element[tag])) == "WMS_ID"){
- $this->wmc_wms_id[$cnt_layer] = $element[value];
- }
- if($extension == true && strtoupper(sepNameSpace($element[tag])) == "WFSFEATURETYPE"){
- $this->wmc_layer_wfs_featuretype[$cnt_layer] = $element[value];
- }
- if(strtoupper($element[tag]) == "METADATAURL" && $element[type] == "open"){
- $metadataurl = true;
- }
- if(strtoupper($element[tag]) == "DATAURL" && $element[type] == "open"){
- $dataurl = true;
- }
- if(strtoupper($element[tag]) == "FORMATLIST" && $element[type] == "open"){
- $formatlist = true;
- $cnt_format = -1;
- }
- if(strtoupper($element[tag]) == "STYLELIST" && $element[type] == "open"){
- $stylelist = true;
- $cnt_style = -1;
- }
- }
+ $currentLayer["style"][$index]["legendurl_width"] = $attributes["width"];
+ $currentLayer["style"][$index]["legendurl_height"] = $attributes["height"];
+ $currentLayer["style"][$index]["legendurl_format"] = $attributes["format"];
+ }
+ if ($legendurl) {
+ if ($tag == "LEGENDURL" && $type == "close") {
+ $legendurl = false;
+ }
+ if ($tag == "ONLINERESOURCE") {
+ $currentLayer["style"][$index]["legendurl_type"] = $attributes["xlink:type"];
+ $currentLayer["style"][$index]["legendurl"] = $attributes["xlink:href"];
+ }
+ }
+ }
+ }
+ if ($tag == "STYLELIST" && $type == "close") {
+ $stylelist = false;
+ }
+ }
+ else {
+ if ($tag == "SERVER" && $type == "open") {
+ $server = true;
+ $currentLayer["service"] = $attributes["service"];
+ $currentLayer["version"] = $attributes["version"];
+ $currentLayer["wms_title"] = $attributes["title"];
+ }
+ if ($server) {
+ if ($tag == "SERVER" && $type == "close") {
+ $server = false;
+ }
+ if ($tag == "ONLINERESOURCE") {
+ $currentLayer["url"] = $attributes["xlink:href"];
+ }
+ }
+ if ($tag == "NAME") {
+ $currentLayer["name"] = $value;
+ }
+ if ($tag == "TITLE") {
+ $currentLayer["title"] = $value;
+ }
+ if ($tag == "ABSTRACT") {
+ $currentLayer["abstract"] = $value;
+ }
+ if ($tag == "SRS") {
+ $currentLayer["epsg"] = explode(" ", $value);
+ }
+ if ($tag == "EXTENSION" && $type == "close") {
+ $extension = false;
+ }
+ if ($extension == true){
+ $currentLayer["extension"][$tag] = $value;
+ }
+ if ($tag == "EXTENSION" && $type == "open") {
+ $currentLayer["extension"] = array();
+ $extension = true;
+ }
+ if ($tag == "METADATAURL" && $type == "open") {
+ $metadataurl = true;
+ }
+ if ($tag == "DATAURL" && $type == "open") {
+ $dataurl = true;
+ }
+ if ($tag == "FORMATLIST" && $type == "open") {
+ $formatlist = true;
+ }
+ if ($tag == "STYLELIST" && $type == "open") {
+ $stylelist = true;
+ }
+ }
}
}
}
return true;
- //return $verbose;
}
- function load ($wmcId) {
+ public function load ($wmcId) {
$this->createObjFromWMC_id($wmcId);
// counts how often a layer has been loaded
@@ -1142,70 +1020,26 @@
// will contain the JS code to create the maps
// representing the state stored in this WMC
- $wmc_string = "";
+ $wmcJsArray = array();
+ array_push($wmcJsArray, "wms = [];");
// general extension
if (count($this->wmc_general_extension) > 0) {
$json = new Mapbender_JSON();
- $wmc_string .= "restoredWmcExtensionData = " . $json->encode($this->wmc_general_extension) . ";";
+ array_push($wmcJsArray, "restoredWmcExtensionData = " . $json->encode($this->generalExtensionArray) . ";");
}
- $foundWmsArray = array();
-
- // for all layers in wmc, find individual wms...
- for ($i = 0; $i < count($this->wmc_layer_title); $i++) {
- $currentWms = $this->wmc_wms_serviceURL[$i];
-
- // skip this WMS if it has been found before
- if (in_array($currentWms , $foundWmsArray)) {
- continue;
- }
-
- // mark this WMS as found
- array_push($foundWmsArray, $currentWms);
-
+ // for all wms...
+ for ($i = 0; $i < count($this->wmsArray); $i++) {
// add wms
- $wmc_string .= $this->getJsCodeAddWms($i);
-
- // add epsg
- $wmc_string .= $this->createJsCodeAddWmsSrs();
-
- $layerlist = "";
- $querylayerlist = "";
- $numberOfLayers = 0;
-
- // find other layers belonging to this layer
- for ($ii = $i; $ii < count($this->wmc_layer_title); $ii++) {
- if ($currentWms != $this->wmc_wms_serviceURL[$ii]) {
- continue;
- }
-
- // add root layer
- if ($numberOfLayers == 0) {
- $wmc_string .= $this->getJsCodeAddRootLayer($i);
- }
- $numberOfLayers++;
-
- // add other layers
- $wmc_string .= $this->getJsCodeAddLayer ($numberOfLayers, $i, $ii);
-
- // add layer style
- $wmc_string .= $this->getJsCodeAddLayerStyle ($numberOfLayers, $ii);
-
- // add layer format (FIXME: is this working?)
- $wmc_string .= $this->getJsCodeAddLayerDataFormat($ii);
-
-
- }
+ array_push($wmcJsArray, $this->this->wmsArray[$i]->createJsObjFromWMS_());
}
- $wmc_string = "mb_mapObj = null;";
- $wmc_string = "wms = null;";
- $wmc_string .= "mb_registerMapObj('mapframe1', 'maps', null, " . $this->wmc_windowWidth . ", " . $this->wmc_windowHeight . ");";
- $wmc_string .= "mb_calculateExtent('mapframe1', " .
- $this->wmc_bBox_minx .",".$this->wmc_bBox_miny ."," .
- $this->wmc_bBox_maxx .",".$this->wmc_bBox_maxy.");";
- $wmc_string .= "setMapRequest('mapframe1');";
+ array_push($wmcJsArray, "mb_mapObj = [];");
+ $wmcJsArray = array_merge($wmcJsArray, $this->mainMap->createJsObj());
+ $wmcJsArray = array_merge($wmcJsArray, $this->overviewMap->createJsObj());
+
+/*
$ov_bbox = array();
// box for mapframe
@@ -1232,17 +1066,12 @@
array_push($ov_bbox, $unionBox->min->y);
array_push($ov_bbox, $unionBox->max->x);
array_push($ov_bbox, $unionBox->max->y);
-
+*/
- $wmc_string .= "mb_registerMapObj('overview', 'maps', 0, " . $this->wmc_windowWidth . ", " . $this->wmc_windowHeight . ");";
-
- $wmc_string .= "mb_calculateExtent('overview', " .
- $ov_bbox[0] .",".$ov_bbox[1] ."," .
- $ov_bbox[2] .",".$ov_bbox[3] .");";
-
- $wmc_string .= "setMapRequest('overview');\n";
-// $wmc_string .= $target . "mb_execloadWmsSubFunctions();";
- return $wmc_string;
+ // Finally, request maps
+ array_push($wmcJsArray, "setMapRequest('" . $this->mainMap->getFrameName() . "');");
+ array_push($wmcJsArray, "setMapRequest('" . $this->overviewMap->getFrameName() . "');");
+ return $wmcJsArray;
}
function append ($wmcId) {
@@ -1255,115 +1084,6 @@
$this->createJsObjFromWMC("", "", "merge");
}
- private function getJsCodeAddWms ($i) {
- // get the last data format of this WMS
- for($j=0; $j < count($this->wmc_layer_format[$i]); $j++){
- if ($this->wmc_layer_format_current[$i][$j] == 1) {
- $wms_data_format = $this->wmc_layer_format[$i][$j];
- }
- }
- // add wms
- $wmc_addWMS_string = "add_wms(" .
- "'" . $this->wmc_wms_id[$i] . "'," .
- "'" . $this->wmc_wms_version[$i] ."'," .
- "'" . $this->wmc_wms_title[$i] ."'," .
- "'" . $this->wmc_layer_abstract[$i] ."'," .
- "'" . $this->wmc_wms_serviceURL[$i] ."'," .
- "'" . $this->wmc_wms_serviceURL[$i] ."'," .
- "'" . $this->wmc_layer_style_legendurl[$i][0] ."'," .
- "''," .
- $wms_data_format ."'," .
- "'text/html'," .
- "'application/vnd.ogc.se_xml'," .
- "'" . $this->wmc_bBox_SRS . "'," .
- "'1'," .
- "'100'," .
- "'');";
- return $wmc_addWMS_string;
- }
-
- private function createJsCodeAddWmsSrs () {
- return "wms_addSRS(" .
- "'" . $this->wmc_bBox_SRS . "'," .
- "'" . $this->wmc_bBox_minx . "'," .
- "'" . $this->wmc_bBox_miny . "'," .
- "'" . $this->wmc_bBox_maxx . "'," .
- "'" . $this->wmc_bBox_maxy . "');";
- }
-
- private function getJsCodeAddLayerDataFormat($ii) {
- $z = count($this->wmc_layer_format[$ii]);
- for($j=0; $j < $z; $j++){
- $wmc_string .= "wms_add_data_type_format(" .
- "'map'," .
- "'" . $this->wmc_layer_format[$ii][$j] ."');";
- }
- }
-
- private function getJsCodeAddRootLayer ($i) {
- return "wms_add_layer(" .
- "''," .
- "'" . $this->wmc_wms_layer_id[$i] . "'," .
- "''," .
- "'" . $this->wmc_wms_title[$i] . "'," .
- "''," .
- "'0'," .
- "'0'," .
- "'0'," .
- "'0'," .
- "''," .
- "'" . $this->wmc_wms_id[$i] . "'," .
- "'1'," .
- "''," .
- "'1'," .
- "'1'," .
- "'0'," .
- "'0'," .
- "'0'," .
- "'0'," .
- "'');";
- }
-
- private function getJsCodeAddLayerStyle ($cnt_layers, $ii) {
- $str = "";
- for ($j = 0; $j < count($this->wmc_layer_style_name[$ii]); $j++){
- $str .= "wms_addLayerStyle(" .
- "'" . $this->wmc_layer_style_name[$ii][$j] . "'," .
- "'" . $this->wmc_layer_style_title[$ii][$j] ."'," .
- "'" . $j."'," .
- "'" . $cnt_layers."'," .
- "'" . $this->wmc_layer_style_legendurl[$ii][$j] . "'," .
- "'" . $this->wmc_layer_style_legendurl_format[$ii][$j] . "');";
- }
- return $str;
- }
-
- private function getJsCodeAddLayer ($cnt_layers, $i, $ii) {
- return "\twms_add_layer(" .
- "'" . ($this->wmc_layer_parent[$ii]!=""?$this->wmc_layer_parent[$ii]:"0") . "'," .
- "'" . $this->wmc_layer_id[$ii] . "'," .
- "'" . $this->wmc_layer_name[$ii] . "'," .
- "'" . $this->wmc_layer_title[$ii] ."'," .
- "'" . $this->wmc_layer_dataurl[$ii] . "'," .
- "'" . ($this->wmc_layer_pos[$ii]!=""?$this->wmc_layer_pos[$ii]:intval($cnt_layers)) ."'," .
- "'" . $this->wmc_layer_queryable[$ii] . "'," .
- "'" . $this->wmc_layer_minscale[$ii] . "'," .
- "'" . $this->wmc_layer_maxscale[$ii] . "'," .
- "'" . $this->wmc_layer_metadataurl[$ii] . "'," .
- "'" . $this->wmc_wms_id[$i] ."'," .
- "'1'," .
- "''," .
- "'1'," .
- "'" . intval(!$this->wmc_layer_hidden[$ii]) ."'," .
- "'" . $this->wmc_layer_queryable[$ii] . "'," .
- "'" . ($this->wmc_layer_querylayer[$ii]!=""?$this->wmc_layer_querylayer[$ii]:$this->wmc_layer_queryable[$ii]) ."'," .
- "'" . ($this->wmc_gui_layer_minscale[$ii]!=""?$this->wmc_gui_layer_minscale[$ii]:$this->wmc_layer_minscale[$ii]) ."'," .
- "'" . ($this->wmc_gui_layer_maxscale[$ii]!=""?$this->wmc_gui_layer_maxscale[$ii]:$this->wmc_layer_maxscale[$ii]) ."'," .
- "'" . $this->wmc_layer_wfs_featuretype[$ii] . "'" .
- ");";
-
- }
-
/**
* Creates JS code manipulating the map and wms objects,
* by this displaying the WMC
@@ -1650,6 +1370,213 @@
$wmc_string .= $target . "mb_execloadWmsSubFunctions();\n";
return $wmc_string;
}
+
+// ---------------------------------------------------------------------------
+// private functions
+// ---------------------------------------------------------------------------
+
+ /**
+ * Saves the current WMC in the log folder.
+ *
+ * @return string the filename of the WMC document.
+ */
+ private function saveAsFile() {
+ if ($this->saveWmcAsFile) {
+ $filename = "wmc_" . date("Y_m_d_H_i_s") . ".log";
+ $logfile = "../../log/" . $filename;
+
+ if($h = fopen($logfile,"a")){
+ $content = $this->xml;
+ if(!fwrite($h,$content)){
+ $e = new mb_exception("class_wmc.php: failed to write wmc.");
+ return false;
+ }
+ fclose($h);
+ }
+ $e = new mb_notice("class_wmc: saving WMC as file " . $filename . "; You can turn this behaviour off in class_wmc.php");
+ return $filename;
+ }
+ return null;
+ }
+
+ /**
+ * Called during WMC parsing; sets the data of a single layer.
+ *
+ * @return
+ * @param $currentLayer Array an associative array with layer data
+ */
+ private function setLayerData ($currentLayer) {
+ // check if current layer belongs to an existing WMS...
+ $wmsIndex = null;
+ for ($i = 0; $i < count($this->wmsArray); $i++) {
+ if (isset($currentLayer["url"]) &&
+ $currentLayer["url"] == $this->wmsArray[$i]->wms_getmap) {
+
+ $wmsIndex = $i;
+ }
+ }
+
+ // if yes, create a new WMS ...
+ if ($wmsIndex === null) {
+ $wmsIndex = 0;
+ $wms = new wms();
+
+ //
+ // set WMS data
+ //
+ $wms->wms_id = $currentLayer["extension"]["WMS_ID"]; // TO DO: how about WMS without ID?
+ $wms->wms_version = $currentLayer["version"];
+ $wms->wms_title = $currentLayer["wms_title"];
+ $wms->wms_abstract = $currentLayer["abstract"];
+ $wms->wms_getmap = $currentLayer["url"];
+ $wms->wms_getfeatureinfo = $currentLayer["url"]; // TODO : Add correct data
+
+ $styleIndex = $currentLayer["styleIndex"];
+ $wms->wms_getlegendurl = $currentLayer["style"][$styleIndex]["legendurl"];
+
+ $wms->wms_filter = ""; // TODO : Add correct data
+
+ $formatIndex = $currentLayer["formatIndex"];
+ $wms->gui_wms_mapformat = $currentLayer["format"][$formatIndex]["name"];
+
+ $wms->gui_wms_featureinfoformat = "text/html"; // TODO : Add correct data
+ $wms->gui_wms_exceptionformat = "application/vnd.ogc.se_xml"; // TODO : Add correct data
+ $wms->gui_wms_epsg = $this->mainMap->getEpsg();
+ $wms->gui_wms_visible = 1; // TODO : Add correct data
+ $wms->gui_wms_opacity = 100; // TODO : Add correct data
+ $wms->gui_wms_sldurl = $currentLayer["style"][$styleIndex]["sld_url"];
+
+ //
+ // set data formats
+ //
+ for ($i = 0; $i < count($currentLayer["format"]); $i++) {
+ array_push($wms->data_type, "map");
+ array_push($wms->data_format, $currentLayer["format"][$i]["name"]);
+ }
+
+ //
+ // set wms epsg
+ //
+ $layerEpsgIndex = count($newLayer->objLayer[$i]->layer_epsg) - 1;
+ $currentLayerEpsg = $newLayer->objLayer[$i]->layer_epsg[$layerEpsgIndex];
+ $currentLayerEpsg["epsg"] = $this->mainMap->getEpsg();
+ $mainMapExtent = $this->mainMap->getExtent();
+ $currentLayerEpsg["minx"] = $mainMapExtent->min->x;
+ $currentLayerEpsg["miny"] = $mainMapExtent->min->y;
+ $currentLayerEpsg["maxx"] = $mainMapExtent->max->x;
+ $currentLayerEpsg["maxy"] = $mainMapExtent->max->y;
+
+ array_push($this->wmsArray, $wms);
+
+ if ($currentLayer["extension"]["ISOVERVIEWLAYER"] == "1") {
+ $this->overviewMap->overviewLayerIndex = count($this->wmsArray) - 1;
+ }
+ }
+ // add layer to existing WMS ...
+ $currentWms = $this->wmsArray[$wmsIndex];
+ $pos = $currentLayer["extension"]["LAYER_POS"];
+ $parent = $currentLayer["extension"]["LAYER_PARENT"];
+ $currentWms->addLayer($pos, $parent); // TO DO: how about WMC from other sources
+
+ // set layer data
+ $layerIndex = count($currentWms->objLayer) - 1;
+ $newLayer = $currentWms->objLayer[$layerIndex];
+ $newLayer->layer_uid = $currentLayer["extension"]["LAYER_ID"];
+ $newLayer->layer_name = $currentLayer["name"];
+ $newLayer->layer_title = $currentLayer["title"];
+ $newLayer->layer_dataurl_href = $currentLayer["dataurl"];
+ $newLayer->layer_pos = $currentLayer["extension"]["LAYER_POS"];
+ $newLayer->layer_queryable = $currentLayer["queryable"];
+ $newLayer->layer_minscale = $currentLayer["extension"]["MINSCALE"];
+ $newLayer->layer_maxscale = $currentLayer["extension"]["MAXSCALE"];
+ $newLayer->layer_metadataurl = $currentLayer["metadataurl"];
+ $newLayer->gui_layer_wms_id = $currentLayer["extension"]["WMS_LAYER_ID"];
+ $newLayer->gui_layer_status = 1; // TODO: Add correct data
+ $newLayer->gui_layer_style = ""; // TODO: Add correct data
+ $newLayer->gui_layer_selectable = ""; // TODO: Add correct data
+ $newLayer->gui_layer_visible = $currentLayer["visible"];
+ $newLayer->gui_layer_queryable = ""; // TODO: Add correct data
+ $newLayer->gui_layer_querylayer = ""; // TODO: Add correct data
+ $newLayer->gui_layer_minscale = $currentLayer["extension"]["GUI_MINSCALE"];
+ $newLayer->gui_layer_maxscale = $currentLayer["extension"]["GUI_MAXSCALE"];
+ $newLayer->gui_layer_wfs_featuretype = ""; // TODO: Add correct data
+ $newLayer->layer_abstract = $currentLayer["abstract"];
+
+ //
+ // set layer epsg
+ //
+ $layerEpsgIndex = count($newLayer->objLayer[$i]->layer_epsg) - 1;
+
+ $currentLayerEpsg = $newLayer->objLayer[$i]->layer_epsg[$layerEpsgIndex];
+ $currentLayerEpsg["epsg"] = $this->mainMap->getEpsg();
+
+ $mainMapExtent = $this->mainMap->getExtent();
+ $currentLayerEpsg["minx"] = $mainMapExtent->min->x;
+ $currentLayerEpsg["miny"] = $mainMapExtent->min->y;
+ $currentLayerEpsg["maxx"] = $mainMapExtent->max->x;
+ $currentLayerEpsg["maxy"] = $mainMapExtent->max->y;
+
+ //
+ // set layer style
+ //
+ for ($i = 0; $i < count($currentLayer["format"]); $i++) {
+ $layerStyleIndex = count($newLayer->gui_layer_style) - 1;
+ $newLayer->layer_style[$layerStyleIndex] = array();
+ $currentStyle = $newLayer->layer_style[$layerStyleIndex];
+ $currentStyle["name"] = $currentLayer["style"][$i]["name"];
+ $currentStyle["title"] = $currentLayer["style"][$i]["title"];
+ $currentStyle["legendurl"] = $currentLayer["style"][$i]["legendurl"];
+ $currentStyle["legendurl_format"] = $currentLayer["style"][$i]["legendurl_type"];
+ }
+ return true;
+ }
+
+ /**
+ * Called during WMC parsing; sets the maps within a WMC.
+ *
+ * @return
+ */
+ private function setMapData () {
+ if ($this->generalExtensionArray["OV_WIDTH"] &&
+ $this->generalExtensionArray["OV_HEIGHT"] &&
+ $this->generalExtensionArray["OV_FRAMENAME"] &&
+ $this->generalExtensionArray["OV_MINX"] &&
+ $this->generalExtensionArray["OV_MINY"] &&
+ $this->generalExtensionArray["OV_MAXX"] &&
+ $this->generalExtensionArray["OV_MAXY"] &&
+ $this->generalExtensionArray["OV_SRS"]) {
+
+ $this->overviewMap = new Map();
+ $this->overviewMap->setWidth($this->generalExtensionArray["OV_WIDTH"]);
+ $this->overviewMap->setHeight($this->generalExtensionArray["OV_HEIGHT"]);
+ $this->overviewMap->setFrameName($this->generalExtensionArray["OV_FRAMENAME"]);
+
+ $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["MAIN_FRAMENAME"]) {
+ $this->mainMap->setFrameName($this->generalExtensionArray["MAIN_FRAMENAME"]);
+ }
+ else {
+ $this->mainMap->setFrameName("mapframe1");
+ }
+ return true;
+ }
}
-// end class
-?>
+
+/**
+ * @deprecated
+ */
+function mb_utf8_encode ($str) {
+ if(CHARSET=="UTF-8") return utf8_encode($str);
+ return $str;
+}
+
+/**
+ * @deprecated
+ */
+function mb_utf8_decode ($str) {
+ if(CHARSET=="UTF-8") return utf8_decode($str);
+ return $str;
+}
+?>
\ No newline at end of file
Modified: branches/beck_dev/mapbender/http/classes/class_wms.php
===================================================================
--- branches/beck_dev/mapbender/http/classes/class_wms.php 2008-05-15 09:02:56 UTC (rev 2452)
+++ branches/beck_dev/mapbender/http/classes/class_wms.php 2008-05-15 09:06:04 UTC (rev 2453)
@@ -681,13 +681,17 @@
function stripEndlineAndCarriageReturn($string) {
return preg_replace("/\n/", "", preg_replace("/\r/", " ", $string));
}
- function createJsObjFromWMS($parent=0){
+ function createJsObjFromWMS($parent=0){
+ echo $this->createJsObjFromWMS_();
+ }
+ function createJsObjFromWMS_($parent=0){
+ $str = "";
if(!$this->wms_title || $this->wms_title == ""){
- echo "alert('Error: no valid capabilities-document !!');";
+ $str .= "alert('Error: no valid capabilities-document !!');";
die; exit;
}
if($parent){
- echo "parent.";
+ $str .= "parent.";
}
// wms_title and abstract have previously been urlencoded
// this solution may not yet be the ultimate one
@@ -709,19 +713,19 @@
"'" . $this->gui_wms_opacity ."'," .
"'" . $this->gui_wms_sldurl ."" .
"');";
- echo $add_wms_string;
+ $str .= $add_wms_string;
for($i=0;$i<count($this->data_format);$i++){
if($parent){
- echo "parent.";
+ $str .= "parent.";
}
- echo "wms_add_data_type_format('". $this->data_type[$i] ."','". $this->data_format[$i] ."');\n";
+ $str .= "wms_add_data_type_format('". $this->data_type[$i] ."','". $this->data_format[$i] ."');\n";
}
for($i=0; $i<count($this->objLayer); $i++){
if($parent){
- echo "parent.";
+ $str .= "parent.";
}
- print ("wms_add_layer('".
+ $str .= "wms_add_layer('".
$this->objLayer[$i]->layer_parent ."','".
$this->objLayer[$i]->layer_uid ."','".
addslashes($this->objLayer[$i]->layer_name) . "','".
@@ -741,37 +745,43 @@
$this->objLayer[$i]->gui_layer_querylayer ."','".
$this->objLayer[$i]->gui_layer_minscale ."','".
$this->objLayer[$i]->gui_layer_maxscale ."','".
- $this->objLayer[$i]->gui_layer_wfs_featuretype ."');\n");
+ $this->objLayer[$i]->gui_layer_wfs_featuretype ."');\n";
for($j=0; $j<count($this->objLayer[$i]->layer_epsg);$j++){
if($i==0){
if($parent){
- echo "parent.";
+ $str .= "parent.";
}
- print("wms_addSRS('".
+ $str .= "wms_addSRS('".
$this->objLayer[$i]->layer_epsg[$j]["epsg"] ."','".
$this->objLayer[$i]->layer_epsg[$j]["minx"] ."','".
$this->objLayer[$i]->layer_epsg[$j]["miny"] ."','".
$this->objLayer[$i]->layer_epsg[$j]["maxx"] ."','".
- $this->objLayer[$i]->layer_epsg[$j]["maxy"] ."');\n");
+ $this->objLayer[$i]->layer_epsg[$j]["maxy"] ."');\n";
}
if($parent){
- echo "parent.";
+ $str .= "parent.";
}
- print("layer_addEpsg('".
+ $str .= "layer_addEpsg('".
$this->objLayer[$i]->layer_epsg[$j]["epsg"] ."','".
$this->objLayer[$i]->layer_epsg[$j]["minx"] ."','".
$this->objLayer[$i]->layer_epsg[$j]["miny"] ."','".
$this->objLayer[$i]->layer_epsg[$j]["maxx"] ."','".
- $this->objLayer[$i]->layer_epsg[$j]["maxy"] ."');\n");
+ $this->objLayer[$i]->layer_epsg[$j]["maxy"] ."');\n";
}
for($j=0; $j<count($this->objLayer[$i]->layer_style);$j++){
if($parent){
- echo "parent.";
+ $str .= "parent.";
}
- print("wms_addLayerStyle('".$this->objLayer[$i]->layer_style[$j]["name"]."', '".$this->objLayer[$i]->layer_style[$j]["title"]."', ".$j.",".$i.",'".$this->objLayer[$i]->layer_style[$j]["legendurl"]."', '".$this->objLayer[$i]->layer_style[$j]["legendformat"]."');\n");
+ $str .= "wms_addLayerStyle('".$this->objLayer[$i]->layer_style[$j]["name"].
+ "', '".$this->objLayer[$i]->layer_style[$j]["title"].
+ "', ".$j.
+ ",".$i.
+ ",'".$this->objLayer[$i]->layer_style[$j]["legendurl"].
+ "', '".$this->objLayer[$i]->layer_style[$j]["legendformat"]."');\n";
}
}
+ return $str;
}
function createJsLayerObjFromWMS($parent=0, $layer_name){
Modified: branches/beck_dev/mapbender/http/javascripts/mod_loadwmc.js
===================================================================
--- branches/beck_dev/mapbender/http/javascripts/mod_loadwmc.js 2008-05-15 09:02:56 UTC (rev 2452)
+++ branches/beck_dev/mapbender/http/javascripts/mod_loadwmc.js 2008-05-15 09:06:04 UTC (rev 2453)
@@ -92,8 +92,11 @@
if (json && status == "success") {
var resultObj = eval("(" + json + ")");
try {
- if (resultObj.javascript) {
- eval(resultObj.javascript);
+ if (resultObj.javascript && typeof(resultObj.javascript) == "object") {
+ for (var j=0; j < resultObj.javascript.length; j++) {
+ console.log("%s", resultObj.javascript[j]);
+ eval(resultObj.javascript[j]);
+ }
}
}
catch (e) {
@@ -102,7 +105,7 @@
}
}
if (loadWmcError) {
- alert("An error has occured while deleting this WMC.");
+ alert("An error has occured while loading this WMC.");
}
});
});
Modified: branches/beck_dev/mapbender/http/php/mod_insertWmcIntoDb.php
===================================================================
--- branches/beck_dev/mapbender/http/php/mod_insertWmcIntoDb.php 2008-05-15 09:02:56 UTC (rev 2452)
+++ branches/beck_dev/mapbender/http/php/mod_insertWmcIntoDb.php 2008-05-15 09:06:04 UTC (rev 2453)
@@ -31,7 +31,7 @@
$extensionData = $json->decode(stripslashes($_POST["extensionData"]));
$wmc = new wmc();
-$wmc->createWMCFromObj($mapObject, $user_id, $generalTitle, $extensionData);
+$wmc->createWmcFromJs($mapObject, $user_id, $generalTitle, $extensionData);
if ($save_in_session) {
$_SESSION["mb_wmc"] = $wmc->xml;
More information about the Mapbender_commits
mailing list