[Mapbender-commits] r3576 - trunk/mapbender/http/extensions
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Wed Feb 18 12:40:12 EST 2009
Author: christoph
Date: 2009-02-18 12:40:12 -0500 (Wed, 18 Feb 2009)
New Revision: 3576
Modified:
trunk/mapbender/http/extensions/geom2wfst.php
Log:
changed interface w/ mod_digitize_tab.php
now uses WFS classes
Modified: trunk/mapbender/http/extensions/geom2wfst.php
===================================================================
--- trunk/mapbender/http/extensions/geom2wfst.php 2009-02-18 17:39:07 UTC (rev 3575)
+++ trunk/mapbender/http/extensions/geom2wfst.php 2009-02-18 17:40:12 UTC (rev 3576)
@@ -17,17 +17,16 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-/**
- * $_REQUEST["url"]
- * $_REQUEST["filter"]
- */
+$wfs_conf_id = $_POST["wfs_conf_id"];
+$method = $_POST["method"];
+$geoJson = stripslashes($_POST["geoJson"]);
-$wfs_conf_id = $_REQUEST["wfs_conf_id"];
-$featuretype_name = $_REQUEST["featuretype_name"];
-
require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
require_once(dirname(__FILE__)."/../classes/class_mb_exception.php");
require_once(dirname(__FILE__)."/../classes/class_json.php");
+require_once(dirname(__FILE__)."/../classes/class_universal_wfs_factory.php");
+require_once(dirname(__FILE__)."/../classes/class_universal_gml_factory.php");
+require_once(dirname(__FILE__)."/../classes/class_wfs_configuration.php");
function isValidVarName ($varname) {
if (preg_match("/[\$]{1}_[a-z]+\[\"[a-z_]+\"\]/i", $varname) != 0) {
@@ -100,43 +99,42 @@
}
-function sepNameSpace($s){
- $c = mb_strpos($s,":");
- if($c>0) return mb_substr($s,$c+1);
- return $s;
+function sendErrorMessage($data) {
+ $resObj = array();
+ $response = "error";
+ $resObj["errorMessage"] = $data;
+ $resObj["response"] = $response;
+
+ header("Content-Type:application/x-json");
+ $json = new Mapbender_JSON();
+ echo $json->encode($resObj);
+ die;
}
-function sendToHost($host,$port,$method,$path,$data){
- $buf = '';
- if (empty($method)) $method = 'POST';
- $method = mb_strtoupper($method);
- $fp = fsockopen($host, $port);
- fputs($fp, "$method $path HTTP/1.1\r\n");
- fputs($fp, "Host: $host\r\n");
- fputs($fp,"Content-type: application/xml\r\n");
- fputs($fp, "Content-length: " . strlen($data) . "\r\n");
- fputs($fp, "Connection: close\r\n\r\n");
- if ($method == 'POST') fputs($fp, $data);
- while (!feof($fp)) $buf .= fgets($fp,4096);
- fclose($fp);
- return $buf;
+
+
+$wfsConf = WfsConfiguration::createFromDb($wfs_conf_id);
+if (is_null($wfsConf)) {
+ sendErrorMessage("Invalid WFS conf: " . $wfs_conf_id);
}
-$result="";
-$error = false;
-$arURL = parse_url($_REQUEST["url"]);
-$host = $arURL["host"];
-$port = $arURL["port"];
-if($port == '') $port = 80;
+$myWfsFactory = new UniversalWfsFactory();
+$myWfs = $myWfsFactory->createFromDb($wfsConf->wfsId);
-$path = $arURL["path"];
-$method = "POST";
-$filter = stripslashes(addParameterToFilter($_REQUEST["filter"], $featuretype_name, $wfs_conf_id));
+if (is_null($myWfs)) {
+ sendErrorMessage("Invalid WFS: " . $wfsConf->wfsId);
+}
-$data = sendToHost($host,$port,$method,html_entity_decode($path),$filter);
+$gmlFactory = new UniversalGmlFactory();
+$gmlObj = $gmlFactory->createFromGeoJson($geoJson);
+$data = $myWfs->transaction($method, $wfsConf, $gmlObj);
+
+if (is_null($data)) {
+ sendErrorMessage("WFS didn't return any data.");
+}
+
$data = mb_eregi_replace("^[^<]*", "", $data);
$data = mb_eregi_replace("[^>]*$", "", $data);
-header('Content-type: text/html');
$resObj = array();
if (mb_strpos(mb_strtoupper($data), "SUCCESS") !== false) {
More information about the Mapbender_commits
mailing list