[Mapbender-commits] r6966 - in trunk/mapbender/http: classes
javascripts
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Wed Sep 29 09:11:50 EDT 2010
Author: christoph
Date: 2010-09-29 13:11:49 +0000 (Wed, 29 Sep 2010)
New Revision: 6966
Added:
trunk/mapbender/http/classes/class_wmc_factory.php
Modified:
trunk/mapbender/http/javascripts/initWmcObj.php
Log:
load WMC from Get API, see http://www.mapbender.org/GET-Parameter#WMC
Added: trunk/mapbender/http/classes/class_wmc_factory.php
===================================================================
--- trunk/mapbender/http/classes/class_wmc_factory.php (rev 0)
+++ trunk/mapbender/http/classes/class_wmc_factory.php 2010-09-29 13:11:49 UTC (rev 6966)
@@ -0,0 +1,53 @@
+<?php
+# License:
+# Copyright (c) 2009, Open Source Geospatial Foundation
+# This program is dual licensed under the GNU General Public License
+# and Simplified BSD license.
+# http://svn.osgeo.org/mapbender/trunk/mapbender/license/license.txt
+
+require_once dirname(__FILE__) . "/../../core/globalSettings.php";
+require_once dirname(__FILE__) . "/../classes/class_ows_factory.php";
+require_once dirname(__FILE__) . "/../classes/class_wmc.php";
+require_once dirname(__FILE__) . "/../classes/class_connector.php";
+require_once dirname(__FILE__) . "/../classes/class_administration.php";
+
+/**
+ * Creates WMC 1.1.0 objects.
+ *
+ * @return wmc
+ */
+class WmcFactory extends OwsFactory {
+
+ /**
+ * Creates WMC 1.1.0 objects from an XML document.
+ *
+ * @return wmc
+ * @param $xml String
+ */
+ public function createFromXml ($xml) {
+ try {
+ $wmc = new wmc();
+ $wmc->createFromXml($xml);
+ }
+ catch (Exception $e) {
+ throw new Exception("Could not create WMC from XML.");
+ }
+ return $wmc;
+ }
+
+ public function createFromDb ($id) {
+ try {
+ $wmc = new wmc();
+ $res = $wmc->createFromDb($id);
+ if ($res === false) {
+ throw new Exception("Could not create WMC from DB.");
+ }
+ }
+ catch (Exception $e) {
+ throw new Exception("Could not create WMC from DB.");
+ }
+ return $wmc;
+ }
+
+}
+?>
\ No newline at end of file
Modified: trunk/mapbender/http/javascripts/initWmcObj.php
===================================================================
--- trunk/mapbender/http/javascripts/initWmcObj.php 2010-09-29 12:56:54 UTC (rev 6965)
+++ trunk/mapbender/http/javascripts/initWmcObj.php 2010-09-29 13:11:49 UTC (rev 6966)
@@ -4,6 +4,7 @@
//
require_once dirname(__FILE__)."/../php/mb_validateSession.php";
require_once dirname(__FILE__)."/../classes/class_wmc.php";
+require_once dirname(__FILE__)."/../classes/class_wmc_factory.php";
require_once dirname(__FILE__)."/../classes/class_administration.php";
require_once dirname(__FILE__)."/../../lib/class_GetApi.php";
require_once dirname(__FILE__)."/../classes/class_elementVar.php";
@@ -54,12 +55,27 @@
}
$getParams = array(
+ "WMC" => getConfiguration("WMC"),
"WMS" => getConfiguration("WMS"),
"LAYER" => getConfiguration("LAYER"),
"FEATURETYPE" => getConfiguration("FEATURETYPE")
);
$getApi = new GetApi($getParams);
+
+$inputWmcArray = $getApi->getWmc();
+if ($inputWmcArray) {
+ foreach ($inputWmcArray as $input) {
+ // just make it work for a single Wmc
+ try {
+ $wmc = WmcFactory::createFromDb($input["id"]);
+ }
+ catch (Exception $e) {
+ new mb_exception("Failed to load WMC from DB. Keeping original WMC.");
+ }
+ }
+}
+
if ($getParams['WMS']) {
// WMS param given as array
if (is_array($getParams['WMS'])) {
More information about the Mapbender_commits
mailing list