[Mapbender-commits] r9707 - trunk/mapbender/http/classes
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Wed Mar 22 06:04:57 PDT 2017
Author: armin11
Date: 2017-03-22 06:04:57 -0700 (Wed, 22 Mar 2017)
New Revision: 9707
Added:
trunk/mapbender/http/classes/class_owsPostQueryParser.php
Log:
First simple draft of class to parse ows post requests - needed for owsproxy
Added: trunk/mapbender/http/classes/class_owsPostQueryParser.php
===================================================================
--- trunk/mapbender/http/classes/class_owsPostQueryParser.php (rev 0)
+++ trunk/mapbender/http/classes/class_owsPostQueryParser.php 2017-03-22 13:04:57 UTC (rev 9707)
@@ -0,0 +1,77 @@
+<?php
+# $Id: class_owsPostQueryParser.php $
+# http://www.mapbender.org/index.php/class_owsPostQueryParser.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.
+
+require_once(dirname(__FILE__)."/../../core/globalSettings.php");
+
+/**
+ * An class to parse OWS Post queries to extract the relevant parameters
+ */
+ class OwsPostQueryParser {
+ var $serviceType; //string
+ var $serviceVersion; //string
+ var $serviceRequestType; //string
+ var $parsingSuccessful; //boolean
+ /**
+ * Constructor of the OwsPostQueryHandler
+ *
+ */
+ function __construct($postData){
+ //parse xml via dom
+ $this->parsingSuccessfull = false;
+ $queryDomObject = new DOMDocument();
+ libxml_use_internal_errors(true);
+ try {
+ $queryDomObject->loadXML($postData);
+ if ($queryDomObject === false) {
+ foreach(libxml_get_errors() as $error) {
+ $err = new mb_exception("class_owsPostQueryHandler.php: ".$error->message);
+ }
+ throw new Exception("class_owsPostQueryHandler.php: ".'Cannot parse post query with dom!');
+ }
+ }
+ catch (Exception $e) {
+ $err = new mb_exception("class_owsPostQueryHandler.php: ".$e->getMessage());
+ }
+ if ($queryDomObject !== false) {
+ $xpath = new DOMXPath($queryDomObject);
+ $rootNamespace = $queryDomObject->lookupNamespaceUri($queryDomObject->namespaceURI);
+ //$e = new mb_exception("class_owsPostQueryHandler.php: ".json_encode($rootNamespace));
+ switch ($rootNamespace) {
+ case "http://www.opengis.net/wfs/2.0":
+ $this->serviceType = "WFS";
+ break;
+ //maybe 1.1.0 or 1.0.0
+ case "http://www.opengis.net/wfs":
+ $this->serviceType = "WFS";
+ break;
+ //maybe 1.1.0 or 1.1.1 or 1.3.0 - does 1.1.0 and 1.1.1 support POST?
+ case "http://www.opengis.net/wms":
+ $this->serviceType = "WMS";
+ break;
+ }
+ //$xpath->registerNamespace('defaultns', $rootNamespace);
+ $this->serviceRequestType = $queryDomObject->documentElement->tagName;
+ $this->serviceVersion = $queryDomObject->documentElement->getAttribute("version");
+ //validate extracted parameters
+ }
+
+ }
+
+}
+?>
More information about the Mapbender_commits
mailing list