소스 검색

added wfs GetFeature ogc:Filter from POST - fixed bug 414 too long url

Piotr Labudda 9 년 전
부모
커밋
68ccd0586d
2개의 변경된 파일41개의 추가작업 그리고 1개의 파일을 삭제
  1. 7 1
      SE/se-lib/Api/WfsDataServer.php
  2. 34 0
      SE/se-lib/Api/WfsServerBase.php

+ 7 - 1
SE/se-lib/Api/WfsDataServer.php

@@ -55,7 +55,13 @@ class Api_WfsDataServer extends Api_WfsServerBase {
 		$propertyName = trim($propertyName);
 		$srsname = V::get('SRSNAME', '', $_REQUEST);// eg. EPSG:4326
 		if (count($typeEx) == 2) {
-			return $this->getFeatures($typeEx[0], $typeEx[1], $maxFeatures, $srsname, $ogcFilter, $sortBy, $startIndex, $propertyName);
+			if (empty($ogcFilter)) {// read ogc:Filter from POST body if not defined in GET
+				$reqBody = Request::getRequestBody();
+				if (!empty($reqBody)) {
+					$ogcFilter = $this->convertOgcFilterFromRequestBody($reqBody);
+				}
+			}
+		return $this->getFeatures($typeEx[0], $typeEx[1], $maxFeatures, $srsname, $ogcFilter, $sortBy, $startIndex, $propertyName);
 		} else {
 			throw new HttpException("Wrong param TYPENAME", 400);
 		}

+ 34 - 0
SE/se-lib/Api/WfsServerBase.php

@@ -1549,4 +1549,38 @@ if($DBG){echo 'L.' . __LINE__ . ' $validateConvertedTransactionXsdString:';print
 		$this->_logger->DBG($reqLog, $lineNr, $funName, $className);
 	}
 
+	public function convertOgcFilterFromRequestBody($requestOgcFilter) {
+		$ogcFilter = '';
+		if (empty($requestOgcFilter)) return '';
+		{
+			$convertOgcFilterXslString .= <<<EOF
+<xsl:transform version="1.0"
+							 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+							 xmlns:wfs="http://www.opengis.net/wfs"
+							 xmlns:ogc="http://www.opengis.net/ogc"
+							 xmlns:gml="http://www.opengis.net/gml">
+	<xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/>
+	<xsl:template match="/">
+	<xsl:for-each select="//*[local-name() = 'GetFeature']">
+	  <xsl:copy-of select="ogc:Filter"/>
+	</xsl:for-each>
+	</xsl:template>
+</xsl:transform>
+EOF;
+
+			DBG::_('DBG_XML', '>2', "convertOgcFilterXslString", $convertOgcFilterXslString, __CLASS__, __FUNCTION__, __LINE__);
+			$convertTransactionXsl = new DOMDocument();
+			$convertTransactionXsl->loadXml($convertOgcFilterXslString);
+
+			$requestXml = new DOMDocument();
+			$requestXml->loadXml($requestOgcFilter);
+
+			$proc = new XSLTProcessor();
+			$proc->importStylesheet($convertTransactionXsl);
+			$ogcFilter = $proc->transformToXML($requestXml);
+			DBG::_('DBG_XML', '>2', "ogcFilter", $ogcFilter, __CLASS__, __FUNCTION__, __LINE__);
+		}
+		return $ogcFilter;
+	}
+
 }