[Mapbender-commits] r2862 - branches/nimix_dev/http/classes
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Mon Aug 18 10:47:14 EDT 2008
Author: nimix
Date: 2008-08-18 10:47:14 -0400 (Mon, 18 Aug 2008)
New Revision: 2862
Added:
branches/nimix_dev/http/classes/class_wmcToXml.php
Modified:
branches/nimix_dev/http/classes/class_point.php
branches/nimix_dev/http/classes/class_wfs_conf.php
Log:
merge
Modified: branches/nimix_dev/http/classes/class_point.php
===================================================================
--- branches/nimix_dev/http/classes/class_point.php 2008-08-18 14:45:42 UTC (rev 2861)
+++ branches/nimix_dev/http/classes/class_point.php 2008-08-18 14:47:14 UTC (rev 2862)
@@ -151,6 +151,26 @@
}
}
+ function toHtml () {
+ $str = "";
+
+ $xArray = explode(".", strval($this->x));
+ $str .= $xArray[0] . "°";
+ if ($xArray[1]) {
+ $str .= $xArray[1] . "'";
+ }
+ $str .= " O / ";
+
+ $yArray = explode(".", strval($this->y));
+ $str .= $yArray[0] . "°";
+ if ($yArray[1]) {
+ $str .= $yArray[1] . "'";
+ }
+ $str .= " N";
+ return $str;
+
+ }
+
function __toString() {
return (string) "(" . $this->x . "," . $this->y . "," . $this->epsg . ")";
}
Modified: branches/nimix_dev/http/classes/class_wfs_conf.php
===================================================================
--- branches/nimix_dev/http/classes/class_wfs_conf.php 2008-08-18 14:45:42 UTC (rev 2861)
+++ branches/nimix_dev/http/classes/class_wfs_conf.php 2008-08-18 14:47:14 UTC (rev 2862)
@@ -18,8 +18,9 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
require_once(dirname(__FILE__)."/class_mb_exception.php");
+require_once(dirname(__FILE__)."/class_user.php");
require_once(dirname(__FILE__)."/class_administration.php");
-require_once(dirname(__FILE__)."/../extensions/JSON.php");
+require_once(dirname(__FILE__)."/../classes/class_json.php");
class WfsConf {
var $confArray = array();
@@ -31,54 +32,66 @@
}
+ function __toString () {
+ $json = new Mapbender_JSON();
+ return $json->encode($this->confArray);
+ }
+
+ /**
+ * Loads WFS conf data from the database
+ *
+ * @return Object WFS conf data.
+ * @param $idOrIdArray Object May be an integer or an array of integers representing WFS conf IDs.
+ */
public function load ($idOrIdArray) {
- /*
- * Check parameter and set idArray
- */
+ // Check parameter and set idArray
if (isset($idOrIdArray)){
// parameter is a number
if (!is_array($idOrIdArray) && is_numeric($idOrIdArray)) {
- $this->getWfsConfFromDB(array(intval($idOrIdArray)), $_SESSION["mb_user_id"]);
+ $idArray = array(intval($idOrIdArray));
}
// parameter is an array of numbers
- else if (is_array($idOrIdArray)) {
+ if (is_array($idOrIdArray)) {
$idArray = array();
for ($i=0; $i < count($idOrIdArray); $i++) {
if (!is_numeric($idOrIdArray[$i])) {
$e = new mb_exception("Wfs_conf: constructor: wrong parameter: ".$idOrIdArray[$i]." is not a number.");
- return null;
+ return array();
}
array_push($idArray, intval($idOrIdArray[$i]));
}
- $this->getWfsConfFromDB($idArray, $_SESSION["mb_user_id"]);
+
+ // If a user ID is given, remove the ones the user has no access to
+ if ($_SESSION["mb_user_id"]) {
+ $user = new User($_SESSION["mb_user_id"]);
+ $idArray = array_intersect($idArray, $user->getWfsConfByPermission());
}
+
+ return $this->getWfsConfFromDB($idArray);
+ }
// parameter is invalid
else {
$e = new mb_exception("Wfs_conf: constructor: parameter must be number or an array of numbers.");
- return null;
+ return array();
}
}
else {
$e = new mb_exception("Wfs_conf: constructor: parameter is not valid");
+ return null;
}
}
+
+ // --------------------------- private -----------------------------------
+
/**
- * get WFS conf data from database
+ * Gets the database content for a number of WFS configurations given by their IDs.
+ *
+ * @return Array
+ * @param $idArray Array an array of integer values representing WFS conf IDs.
*/
- private function getWfsConfFromDB ($idArray, $userId) {
- /*
- * If a user ID is given, remove the ones the user has no access to
- */
- if ($userId) {
- $idArray = array_intersect($idArray, WfsConf::getWfsConfByPermission($userId));
- }
-
- if (count($idArray) > 0) {
- /*
- * Get WFS configurations
- */
+ private static function getWfsConfFromDbByArray ($idArray) {
$sql = "SELECT * FROM wfs_conf ";
$sql .= "JOIN wfs ON wfs_conf.fkey_wfs_id = wfs.wfs_id ";
$sql .= "WHERE wfs_conf.wfs_conf_id IN (";
@@ -95,123 +108,133 @@
$res = db_prep_query($sql, $v, $t);
+ $rowArray = array();
while ($row = db_fetch_array($res)) {
+ array_push($rowArray, $row);
+ }
+ return $rowArray;
+ }
-
- /*
- * Get WFS conf elements
+ /**
+ * Gets the database content of a WFS conf element given by a WFS conf ID.
+ *
+ * @return Array
+ * @param $id Integer the WFS conf ID.
*/
- $id = $row["wfs_conf_id"];
-
- $sql_conf_element = "SELECT * FROM wfs_conf_element ";
- $sql_conf_element .= "JOIN wfs_element ON wfs_conf_element.f_id = wfs_element.element_id ";
- $sql_conf_element .= "WHERE wfs_conf_element.fkey_wfs_conf_id = $1 ";
-#filtered on client side
-# $sql_conf_element .= "AND wfs_conf_element.f_search = 1 ";
- $sql_conf_element .= "ORDER BY wfs_conf_element.f_pos";
- $v_conf_element = array($id);
- $t_conf_element = array('i');
- $res_conf_element = db_prep_query($sql_conf_element, $v_conf_element, $t_conf_element);
+ private static function getWfsConfElementFromDb ($id) {
+ $sql = "SELECT * FROM wfs_conf_element ";
+ $sql .= "JOIN wfs_element ON wfs_conf_element.f_id = wfs_element.element_id ";
+ $sql .= "WHERE wfs_conf_element.fkey_wfs_conf_id = $1 ";
+ #filtered on client side
+ #$sql .= "AND wfs_conf_element.f_search = 1 ";
+ $sql .= "ORDER BY wfs_conf_element.f_pos";
+ $v = array($id);
+ $t = array('i');
+ $res = db_prep_query($sql, $v, $t);
- $elementArray = array();
- while ($row_conf_element = db_fetch_array($res_conf_element)) {
-
-
- $currentElement = array("f_search" => $row_conf_element["f_search"],
- "f_style_id" => $row_conf_element["f_style_id"],
- "f_toupper" => $row_conf_element["f_toupper"],
- "f_label" => $row_conf_element["f_label"],
- "f_label_id" => $row_conf_element["f_label_id"],
- "f_geom" => $row_conf_element["f_geom"],
- "f_show" => $row_conf_element["f_show"],
- "f_respos" => $row_conf_element["f_respos"],
- "f_form_element_html" => $row_conf_element["f_form_element_html"],
- "f_show_detail" => $row_conf_element["f_show_detail"],
- "element_name" => $row_conf_element["element_name"],
- "element_type" => $row_conf_element["element_type"]
+ $elementArray = array();
+ while ($row = db_fetch_array($res)) {
+ $currentElement = array("element_name" => $row["element_name"],
+ "element_type" => $row["element_type"],
+ "f_search" => $row["f_search"],
+ "f_style_id" => $row["f_style_id"],
+ "f_toupper" => $row["f_toupper"],
+ "f_label" => $row["f_label"],
+ "f_label_id" => $row["f_label_id"],
+ "f_geom" => $row["f_geom"],
+ "f_show" => $row["f_show"],
+ "f_mandatory" => $row_conf_element["f_mandatory"],
+ "f_respos" => $row_conf_element["f_respos"],
+ "f_min_input" => $row_conf_element["f_min_input"],
+ "f_form_element_html" => $row_conf_element["f_form_element_html"],
+ "f_show_detail" => $row_conf_element["f_show_detail"],
+ "f_detailpos" => $row_conf_element["f_detailpos"],
+ "f_operator" => $row_conf_element["f_operator"],
+ "f_show_detail" => $row["f_show_detail"]
);
array_push($elementArray, $currentElement);
}
+ return $elementArray;
+ }
- /*
- * Get WFS featuretype
+ /**
+ * Gets the database content of a WFS feature type given by a WFS ID and a featuretype ID.
+ *
+ * @return Array
+ * @param $wfsId Integer the WFS ID.
+ * @param $featuretypeId Integer the WFS featuretype ID.
*/
- $sql_feature_type = "SELECT * FROM wfs_featuretype WHERE fkey_wfs_id = $1 AND featuretype_id = $2";
- $v_feature_type = array($row["fkey_wfs_id"], $row["fkey_featuretype_id"]);
- $t_feature_type = array("i", "i");
+ private static function getWfsFeatureTypeFromDb($wfsId, $featuretypeId) {
+ $sql = "SELECT * FROM wfs_featuretype WHERE fkey_wfs_id = $1 AND featuretype_id = $2";
+ $v = array($wfsId, $featuretypeId);
+ $t = array("i", "i");
- $res_feature_type = db_prep_query($sql_feature_type, $v_feature_type, $t_feature_type);
- if($row_feature_type = db_fetch_array($res_feature_type)){
- $featuretype_name = $row_feature_type["featuretype_name"];
- $featuretype_srs = $row_feature_type["featuretype_srs"];
- }
+ $res = db_prep_query($sql, $v, $t);
- $currentRow = array("g_label" => $row["g_label"],
- "g_label_id" => $row["g_label_id"],
- "g_style" => $row["g_style"],
- "g_button" => $row["g_button"],
- "g_button_id" => $row["g_button_id"],
- "g_buffer" => $row["g_buffer"],
- "g_res_style" => $row["g_res_style"],
- "g_use_wzgraphics" => $row["g_use_wzgraphics"],
- "wfs_id" => $row["fkey_wfs_id"],
- "featuretype_id" => $row["fkey_featuretype_id"],
- "featuretype_name" => $featuretype_name,
- "featuretype_srs" => $featuretype_srs,
- "wfs_getfeature" => $row["wfs_getfeature"],
- "wfs_describefeaturetype" => $row["wfs_describefeaturetype"],
- "wfs_transaction" => $row["wfs_transaction"],
- "element" => $elementArray
- );
+ $currentRow = array();
- $this->confArray[$id] = $currentRow;
+ if($row = db_fetch_array($res)){
+ $currentRow["featuretype_name"] = $row["featuretype_name"];
+ $currentRow["featuretype_srs"] = $row["featuretype_srs"];
}
+
+ return $currentRow;
}
- else {
- $e = new mb_warning("class_wfs_conf.php: getWfsConfFromDB: You don't have access to any WFS confs. Check EDIT WFS.");
- }
- }
- /** identifies the Conf-FeatureServices where the current user is owner
- *
- * @param integer userid the user-ID of the current user
- * @return integer[] the IDs of the wfs_conf-table
+ /**
+ * get WFS conf data from database
*/
- public static function getWfsConfByPermission($userid){
- $guisByPer = array();
-// 1.
- $adm = new administration();
- $guisByPer = $adm->getGuisByPermission($userid, true);
-// 2.
- if(count($guisByPer)>0){
- $v = array();
- $t = array();
- $sql = "SELECT wfs_conf.wfs_conf_id FROM gui_wfs_conf, wfs_conf " .
- "where wfs_conf.wfs_conf_id = gui_wfs_conf.fkey_wfs_conf_id " .
- "and gui_wfs_conf.fkey_gui_id IN(";
- for($i=0; $i<count($guisByPer); $i++){
- if($i>0){ $sql .= ",";}
- $sql .= "$".strval($i+1);
+ private function getWfsConfFromDB ($idArray) {
- array_push($v, $guisByPer[$i]);
- array_push($t, "s");
- }
- $sql .= ") GROUP BY wfs_conf.wfs_conf_id ORDER BY wfs_conf.wfs_conf_id";
+ // if a user has access to some WFS confs...
+ if (count($idArray) > 0) {
- $res = db_prep_query($sql,$v,$t);
- $ownWFSconfs = array();
- $i=0;
- while($row = db_fetch_array($res)){
+ // get WFS conf data from DB
+ $rowArray = self::getWfsConfFromDbByArray($idArray);
- $ownWFSconfs[$i] = $row['wfs_conf_id'];
- $i++;
+ for ($i=0; $i < count($rowArray); $i++) {
+
+ // WFS conf data
+ $currentRow = array("g_label" => $rowArray[$i]["g_label"],
+ "g_label_id" => $rowArray[$i]["g_label_id"],
+ "g_style" => $rowArray[$i]["g_style"],
+ "g_button" => $rowArray[$i]["g_button"],
+ "g_button_id" => $rowArray[$i]["g_button_id"],
+ "g_buffer" => $rowArray[$i]["g_buffer"],
+ "g_res_style" => $rowArray[$i]["g_res_style"],
+ "g_use_wzgraphics" => $rowArray[$i]["g_use_wzgraphics"],
+ "wfs_id" => $rowArray[$i]["fkey_wfs_id"],
+ "featuretype_id" => $rowArray[$i]["fkey_featuretype_id"],
+ "wfs_getfeature" => $rowArray[$i]["wfs_getfeature"],
+ "wfs_describefeaturetype" => $rowArray[$i]["wfs_describefeaturetype"],
+ "wfs_transaction" => $rowArray[$i]["wfs_transaction"],
+ "element" => $elementArray
+ );
+
+ // get WFS conf element data of current WFS conf
+ $id = $rowArray[$i]["wfs_conf_id"];
+ $currentRow["element"] = self::getWfsConfElementFromDb($id);
+
+ // get WFS featuretype data of current WFS conf
+ $wfsId = $rowArray[$i]["fkey_wfs_id"];
+ $featuretypeId = $rowArray[$i]["fkey_featuretype_id"];
+ $currentRow = array_merge($currentRow , self::getWfsFeatureTypeFromDb($wfsId, $featuretypeId));
+
+ $this->confArray[$id] = $currentRow;
}
+ return $this->confArray;
}
- return $ownWFSconfs;
+ else {
+ $e = new mb_warning("class_wfs_conf.php: getWfsConfFromDB: You don't have access to any WFS confs. Check EDIT WFS.");
+ return array();
}
}
+}
+/**
+ * @deprecated
+ */
class wfs_conf{
var $wfs_id;
Copied: branches/nimix_dev/http/classes/class_wmcToXml.php (from rev 2653, trunk/mapbender/http/classes/class_wmcToXml.php)
===================================================================
--- branches/nimix_dev/http/classes/class_wmcToXml.php (rev 0)
+++ branches/nimix_dev/http/classes/class_wmcToXml.php 2008-08-18 14:47:14 UTC (rev 2862)
@@ -0,0 +1,536 @@
+<?php
+# $Id: class_wmc.php 2466 2008-05-20 08:55:03Z christoph $
+# http://www.mapbender.org/index.php/class_wmc.php
+# Copyright (C) 2002 CCGIS
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# 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.
+
+/**
+ * The XML representation of a WMC object.
+ *
+ * Usage:
+ *
+ * $wmcToXml = new WmcToXml($wmc);
+ * $xml = $wmcToXml->getXml();
+ *
+ */
+class WmcToXml {
+
+ private $wmc = null;
+ private $doc;
+ private $xml = "";
+
+ /**
+ * Constructor. Computes the XML of the WMC object given as parameter.
+ *
+ * @param $someWmc wmc
+ */
+ public function __construct ($someWmc) {
+ $this->wmc = $someWmc;
+ $this->toXml();
+ }
+
+ // ---------------------------------------------------------------------
+ // public functions
+ // ---------------------------------------------------------------------
+
+ public function getXml () {
+ return $this->xml;
+ }
+
+ // ---------------------------------------------------------------------
+ // private functions
+ // ---------------------------------------------------------------------
+
+ 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;
+
+ // ViewContext
+ $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("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();
+ if ($e_general !== null) {
+ $e_view_context->appendChild($e_general);
+ }
+
+ // Layerlist
+ $e_layer_list = $this->doc->createElement("LayerList");
+ while (count($mapArray) > 0) {
+
+ $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];
+
+ $layerNode = $this->createLayerNode($currentMap, $currentWms, $currentLayer);
+ if ($layerNode !== null) {
+ $e_layer_list->appendChild($layerNode);
+ }
+ }
+ }
+ }
+ $e_view_context->appendChild($e_layer_list);
+
+ $this->doc->appendChild($e_view_context);
+ $this->xml = $this->doc->saveXML();
+ }
+
+ private function createGeneralNode () {
+ if ($this->wmc->overviewMap !== null) {
+ $ovExtent = $this->wmc->overviewMap->getExtent();
+ $extensionData->ov_minx = $ovExtent->min->x;
+ $extensionData->ov_miny = $ovExtent->min->y;
+ $extensionData->ov_maxx = $ovExtent->max->x;
+ $extensionData->ov_maxy = $ovExtent->max->y;
+ $extensionData->ov_srs = $ovExtent->epsg;
+ $extensionData->ov_framename = $this->wmc->overviewMap->getFrameName();
+ $extensionData->ov_width = $this->wmc->overviewMap->getWidth();
+ $extensionData->ov_height = $this->wmc->overviewMap->getHeight();
+ }
+
+ // General
+ $e_general = $this->doc->createElement("General");
+
+ // Window
+ $e_window = $this->doc->createElement("Window");
+ if ($this->wmc->mainMap->getWidth() && $this->wmc->mainMap->getHeight()) {
+ $e_window->setAttribute("width", $this->wmc->mainMap->getWidth());
+ $e_window->setAttribute("height", $this->wmc->mainMap->getHeight());
+ }
+ $e_general->appendChild($e_window);
+
+ // BoundingBox
+ $mainExtent = $this->wmc->mainMap->getExtent();
+ $e_bbox = $this->doc->createElement("BoundingBox");
+ $e_bbox->setAttribute("SRS", $mainExtent->epsg);
+ $e_bbox->setAttribute("minx", $mainExtent->min->x);
+ $e_bbox->setAttribute("miny", $mainExtent->min->y);
+ $e_bbox->setAttribute("maxx", $mainExtent->max->x);
+ $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);
+ }
+ $e_general->appendChild($e_keyword_list);
+
+ // Abstract
+ if ($this->wmc->wmc_abstract) {
+ $e_abstract = $this->doc->createElement("Abstract", $this->wmc->wmc_abstract);
+ $e_general->appendChild($e_abstract);
+ }
+
+ // Logo URL
+ if ($this->wmc->wmc_logourl_width && $this->wmc->wmc_logourl_height &&
+ $this->wmc->wmc_logourl_format && $this->wmc->wmc_logourl){
+
+ $e_logo_url = $this->doc->createElement("LogoURL");
+ $e_logo_url->setAttribute("width", $this->wmc->wmc_logourl_width);
+ $e_logo_url->setAttribute("height", $this->wmc->wmc_logourl_height);
+ $e_logo_url->setAttribute("format", $this->wmc->wmc_logourl_format);
+
+ $e_logo_url_or = $this->doc->createElement("OnlineResource");
+ $e_logo_url_or->setAttributeNS("http://www.opengis.net/context", "xmlns:xlink", "http://www.w3.org/1999/xlink");
+ $e_logo_url_or->setAttribute("xlink:type", "simple");
+ $e_logo_url_or->setAttribute("xlink:href", $this->wmc->wmc_logourl);
+ $e_logo_url->appendChild($e_logo_url_or);
+
+ $e_general->appendChild($e_logo_url);
+ }
+
+ // Description URL
+ if ($this->wmc->wmc_descriptionurl){
+ $e_description_url = $this->doc->createElement("DescriptionURL");
+
+ $e_description_url_or = $this->doc->createElement("OnlineResource");
+ $e_description_url_or->setAttributeNS("http://www.opengis.net/context", "xmlns:xlink", "http://www.w3.org/1999/xlink");
+ $e_description_url_or->setAttribute("xlink:type", "simple");
+ $e_description_url_or->setAttribute("xlink:href", $this->wmc->wmc_descriptionurl);
+ $e_description_url->appendChild($e_description_url_or);
+
+ $e_general->appendChild($e_description_url);
+ }
+
+ // Contact information
+ $e_contact = $this->createContactInformationNode();
+ if ($e_contact !== null) {
+ $e_general->appendChild($e_contact);
+ }
+
+ // Extension data
+ if (count($extensionData) > 0) {
+ $e_extensionGeneral = $this->doc->createElement("Extension");
+
+ foreach ($extensionData as $keyExtensionData => $valueExtensionData) {
+ $e_currentExtensionTag = $this->doc->createElement($this->wmc->extensionNamespace.":".$keyExtensionData, $valueExtensionData);
+ $e_extensionGeneral->appendChild($e_currentExtensionTag);
+ }
+ $e_general->appendChild($e_extensionGeneral);
+ }
+ return $e_general;
+ }
+
+ private function createLayerNode ($currentMap, $currentWms, $currentLayer) {
+ if ($currentLayer->layer_parent != '') {
+
+ // Layer
+ $e_layer = $this->doc->createElement("Layer");
+ $e_layer->setAttribute("queryable", $currentLayer->layer_queryable);
+ $e_layer->setAttribute("hidden", ($currentLayer->gui_layer_visible ? 0 : 1));
+
+ // Server
+ $e_service = $this->doc->createElement("Server");
+ $e_service->setAttribute("service", "OGC:WMS");
+ $e_service->setAttribute("version", $currentWms->wms_version);
+ $e_service->setAttribute("title", $currentWms->wms_title);
+
+ // Online resource
+ $e_service_or = $this->doc->createElement("OnlineResource");
+ $e_service_or->setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink");
+ $e_service_or->setAttribute("xlink:type", "simple");
+ $e_service_or->setAttribute("xlink:href", $currentWms->wms_getmap);
+ $e_service->appendChild($e_service_or);
+ $e_layer->appendChild($e_service);
+
+ // Name
+ $e_layer_name = $this->doc->createElement("Name", $currentLayer->layer_name);
+ $e_layer->appendChild($e_layer_name);
+
+ // Title
+ $e_layer_title = $this->doc->createElement("Title", $currentLayer->layer_title);
+ $e_layer->appendChild($e_layer_title);
+
+ // Abstract
+ if ($currentWms->wms_abstract){
+ $e_layer_abstract = $this->doc->createElement("Abstract", $currentWms->wms_abstract);
+ $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");
+
+ $e_layer_data_url_or = $this->doc->createElement("OnlineResource");
+ $e_layer_data_url_or->setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink");
+ $e_layer_data_url_or->setAttribute("xlink:type", "simple");
+ $e_layer_data_url_or->setAttribute("xlink:href", $currentLayer->layer_dataurl_href);
+
+ $e_layer_data_url->appendChild($e_layer_data_url_or);
+ $e_layer->appendChild($e_layer_data_url);
+ }
+
+ // Metadata URL
+ if ($currentLayer->layer_metadataurl){
+ $e_layer_metadata_url = $this->doc->createElement("MetadataURL");
+
+ // Metadata URL online resource
+ $e_layer_metadata_url_or = $this->doc->createElement("OnlineResource");
+ $e_layer_metadata_url_or->setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink");
+ $e_layer_metadata_url_or->setAttribute("xlink:type", "simple");
+ $e_layer_metadata_url_or->setAttribute("xlink:href", $currentLayer->layer_metadataurl);
+ $e_layer_metadata_url->appendChild($e_layer_metadata_url_or);
+ $e_layer->appendChild($e_layer_metadata_url);
+ }
+
+ // Layer format
+ $formatListNode = $this->createLayerFormatListNode($currentWms);
+ if ($formatListNode !== null) {
+ $e_layer->appendChild($formatListNode);
+ }
+
+ // Layer style
+ $layerStyleListNode = $this->createLayerStyleNode($currentWms, $currentLayer);
+ if ($layerStyleListNode !== null) {
+ $e_layer->appendChild($layerStyleListNode);
+ }
+
+ // Extension
+ $extensionNode = $this->createLayerExtensionNode($currentMap, $currentWms, $currentLayer);
+ if ($extensionNode !== null) {
+ $e_layer->appendChild($extensionNode);
+ }
+
+ return $e_layer;
+ }
+ return null;
+ }
+
+ private function createSrsNode ($currentMap, $currentWms) {
+ $wms_epsg = array();
+ $wms_epsg[0] = $currentMap->getEpsg();
+
+ if ($currentWms->gui_wms_epsg != $currentMap->getEpsg()) {
+ $wms_epsg[1] = $currentWms->gui_wms_epsg;
+ }
+
+ for ($j = 0; $j < count($currentWms->gui_epsg); $j++) {
+ if (!in_array($currentWms->gui_epsg[$j], $wms_epsg)){
+ array_push($wms_epsg, $currentWms->gui_epsg[$j]);
+ }
+ }
+
+ $e_layer_srs = $this->doc->createElement("SRS", implode(" ", $wms_epsg));
+ return $e_layer_srs;
+ }
+
+ private function createLayerFormatListNode ($currentWms) {
+ $e_layer_format = $this->doc->createElement("FormatList");
+
+ $data_format_current = false;
+
+ for ($k = 0; $k < count($currentWms->data_format); $k++){
+
+ if ($currentWms->data_type[$k] == "map") {
+ $layerFormat = $currentWms->data_format[$k];
+
+ $e_format = $this->doc->createElement("Format", $layerFormat);
+
+ if ($data_format_current === false && (
+ $currentWms->data_format[$k] == $currentWms->gui_wms_mapformat ||
+ $k == (count($currentWms->data_format)-1)
+ )){
+
+ $e_format->setAttribute("current", "1");
+ $data_format_current = true;
+ }
+ $e_layer_format->appendChild($e_format);
+ }
+ }
+ return $e_layer_format;
+ }
+
+ private function createLayerExtensionNode ($currentMap, $currentWms, $currentLayer) {
+ $layerExtensionData = array();
+ $layerExtensionData["wms_name"] = $currentWms->objLayer[0]->layer_name;
+ $layerExtensionData["minscale"] = $currentLayer->layer_minscale;
+ $layerExtensionData["maxscale"] = $currentLayer->layer_maxscale;
+ $layerExtensionData["gui_minscale"] = $currentLayer->gui_layer_minscale;
+ $layerExtensionData["gui_maxscale"] = $currentLayer->gui_layer_maxscale;
+ $layerExtensionData["layer_id"] = $currentLayer->layer_uid;
+ $layerExtensionData["wms_layer_id"] = $currentWms->objLayer[0]->layer_uid;
+ $layerExtensionData["layer_pos"] = $currentLayer->layer_pos;
+ $layerExtensionData["layer_parent"] = $currentLayer->layer_parent;
+ $layerExtensionData["wms_id"] = $currentWms->wms_id;
+ $layerExtensionData["querylayer"] = $currentLayer->gui_layer_querylayer;
+ $layerExtensionData["gui_selectable"] = $currentLayer->gui_layer_selectable;
+ $layerExtensionData["gui_queryable"] = $currentLayer->gui_layer_queryable;
+ $layerExtensionData["gui_status"] = $currentLayer->gui_layer_status;
+ if ($currentMap->isOverview()) {
+ $layerExtensionData["isOverviewLayer"] = 1;
+ }
+ if ($currentLayer->gui_layer_wfs_featuretype) {
+ $layerExtensionData["wfsFeatureType"] = $currentLayer->gui_layer_wfs_featuretype;
+ }
+
+ if (count($layerExtensionData) > 0) {
+ $e_extension = $this->doc->createElement("Extension");
+
+ foreach ($layerExtensionData as $keyExtensionData => $valueExtensionData) {
+ $e_currentExtensionTag = $this->doc->createElement($this->wmc->extensionNamespace.":".$keyExtensionData, $valueExtensionData);
+ $e_extension->appendChild($e_currentExtensionTag);
+ }
+ return $e_extension;
+ }
+ return null;
+ }
+
+ private function createLayerStyleNode ($currentWms, $currentLayer) {
+ $e_layer_stylelist = $this->doc->createElement("StyleList");
+
+ for ($k = 0; $k < count($currentLayer->layer_style); $k++) {
+
+ $currentStyle = $currentLayer->layer_style[$k];
+
+ $layerStyle_current = 0;
+ if ($k === 0){
+ $layerStyle_current = 1; // To do: insert proper data
+ }
+
+ $e_layer_style = $this->doc->createElement("Style");
+
+ $layerStyleSLD = "";
+
+ if ($layerStyleSLD) {
+ $e_layer_style_or = $this->doc->createElement("OnlineResource");
+ $e_layer_style_or->setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink");
+ $e_layer_style_or->setAttribute("xlink:type", "simple");
+ $e_layer_style_or->setAttribute("xlink:href", $currentWms->gui_wms_sldurl);
+ $e_layer_style->appendChild($e_layer_style_or);
+ }
+ else{
+
+ if ($layerStyle_current == 1){
+ $e_layer_style->setAttribute("current", "1");
+ }
+
+ $e_layer_style_name = $this->doc->createElement("Name", $currentStyle->name);
+ $e_layer_style->appendChild($e_layer_style_name);
+
+ $e_layer_style_title = $this->doc->createElement("Title", $currentStyle->title);
+ $e_layer_style->appendChild($e_layer_style_title);
+
+
+ $e_layer_style_legendurl = $this->doc->createElement("LegendUrl");
+
+ //TODO: determine correct layer style entries
+ $layerStyle_legendUrl_width = ""; // To Do: add proper data
+ $layerStyle_legendUrl_height = ""; // To Do: add proper data
+ $layerStyle_legendUrl_format = ""; // To Do: add proper data
+ $e_layer_style_legendurl->setAttribute("width", $layerStyle_legendUrl_width);
+ $e_layer_style_legendurl->setAttribute("height", $layerStyle_legendUrl_height);
+ $e_layer_style_legendurl->setAttribute("format", $layerStyle_legendUrl_format);
+
+ $e_layer_style_legendurl_or = $this->doc->createElement("OnlineResource");
+ $e_layer_style_legendurl_or->setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink");
+ $e_layer_style_legendurl_or->setAttribute("xlink:type", "simple");
+ $e_layer_style_legendurl_or->setAttribute("xlink:href", $currentWms->wms_getlegendurl);
+ $e_layer_style_legendurl->appendChild($e_layer_style_legendurl_or);
+ $e_layer_style->appendChild($e_layer_style_legendurl);
+ }
+ $e_layer_stylelist->appendChild($e_layer_style);
+ }
+ return $e_layer_stylelist;
+ }
+
+ /**
+ *
+ * @return
+ */
+ private function createContactInformationNode () {
+
+ if ($this->wmc->wmc_contactemail || $this->wmc->wmc_contactorganization ||
+ $this->wmc->wmc_contactperson || $this->wmc->wmc_contactposition ||
+ $this->wmc->wmc_contactaddresstype || $this->wmc->wmc_contactaddress ||
+ $this->wmc->wmc_contactcity || $this->wmc->wmc_contactstateorprovince ||
+ $this->wmc->wmc_contactpostcode || $this->wmc->wmc_contactcountry ||
+ $this->wmc->wmc_contactvoicetelephone || $this->wmc->wmc_contactfacsimiletelephone) {
+
+ $e_contact = $this->doc->createElement("ContactInformation");
+ $e_contact_person_primary = $this->wmc->createContactPersonPrimaryNode();
+ if ($e_contact_person_primary !== null) {
+ $e_contact->appendChild($e_contact_person_primary);
+ }
+
+ if ($this->wmc->wmc_contactposition){
+ $e_contact_position = $this->doc->createElement("ContactPosition", $this->wmc->wmc_contactposition);
+ $e_contact->appendChild($e_contact_position);
+ }
+
+ if ($this->wmc->wmc_contactaddresstype || $this->wmc->wmc_contactaddress ||
+ $this->wmc->wmc_contactcity || $this->wmc->wmc_contactstateorprovince ||
+ $this->wmc->wmc_contactpostcode || $this->wmc->wmc_contactcountry) {
+
+ $e_contact_address = $this->doc->createElement("ContactAddress");
+
+ if ($this->wmc->wmc_contactaddresstype){
+ $e_address_type = $this->doc->createElement("AddressType", $this->wmc->wmc_contactaddresstype);
+ $e_contact_address->appendChild($e_address_type);
+ }
+ if ($this->wmc->wmc_contactaddress){
+ $e_address = $this->doc->createElement("Address", $this->wmc->wmc_contactaddress);
+ $e_contact_address->appendChild($e_address);
+ }
+ if ($this->wmc->wmc_contactcity){
+ $e_city = $this->doc->createElement("City", $this->wmc->wmc_contactcity);
+ $e_contact_address->appendChild($e_city);
+ }
+ if ($this->wmc->wmc_contactstateorprovince){
+ $e_state = $this->doc->createElement("StateOrProvince", $this->wmc->wmc_contactstateorprovince);
+ $e_contact_address->appendChild($e_state);
+ }
+ if ($this->wmc->wmc_contactpostcode){
+ $e_postcode = $this->doc->createElement("PostCode", $this->wmc->wmc_contactpostcode);
+ $e_contact_address->appendChild($e_postcode);
+ }
+ if ($this->wmc->wmc_contactcountry){
+ $e_country = $this->doc->createElement("Country", $this->wmc->wmc_contactcountry);
+ $e_contact_address->appendChild($e_country);
+ }
+ $e_contact->appendChild($e_contact_address);
+ }
+
+ if ($this->wmc->wmc_contactvoicetelephone){
+ $e_voice_telephone = $this->doc->createElement("ContactVoiceTelephone", $this->wmc->wmc_contactvoicetelephone);
+ $e_contact->appendChild($e_voice_telephone);
+ }
+ if ($this->wmc->wmc_contactfacsimiletelephone){
+ $e_facsimile_telephone = $this->doc->createElement("ContactFacsimileTelephone", $this->wmc->wmc_contactfacsimiletelephone);
+ $e_contact->appendChild($e_facsimile_telephone);
+ }
+ if ($this->wmc->wmc_contactemail){
+ $e_email = $this->doc->createElement("ContactElectronicMailAddress", $this->wmc->wmc_contactemail);
+ $e_contact->appendChild($e_email);
+ }
+ return $e_contact;
+ }
+ return null;
+ }
+
+ private function createContactPersonPrimaryNode () {
+ if ($this->wmc->wmc_contactperson || $this->wmc->wmc_contactorganization){
+ $e_contact_person_primary = $this->doc->createElement("ContactPersonPrimary");
+
+ if ($this->wmc->wmc_contactperson){
+ $e_contact_person = $this->doc->createElement("ContactPerson", $this->wmc->wmc_contactperson);
+ $e_contact_person_primary->appendChild($e_contact_person);
+ }
+ if ($this->wmc->wmc_contactorganization){
+ $e_contact_organization = $this->doc->createElement("ContactOrganization", $this->wmc->wmc_contactorganization);
+ $e_contact_person_primary->appendChild($e_contact_organization);
+ }
+ return $e_contact_person_primary;
+ }
+ return null;
+ }
+
+}
+?>
\ No newline at end of file
More information about the Mapbender_commits
mailing list