소스 검색

fixed bug in wfs performance - getFeature

Piotr Labudda 9 년 전
부모
커밋
c8ee1a309f
1개의 변경된 파일10개의 추가작업 그리고 4개의 파일을 삭제
  1. 10 4
      SE/se-lib/Api/WfsQgisServer.php

+ 10 - 4
SE/se-lib/Api/WfsQgisServer.php

@@ -80,12 +80,14 @@ class Api_WfsQgisServer extends Api_WfsServerBase {
 		$searchParams['limit'] = $maxFeatures;
 		$searchParams['order_by'] = $acl->getPrimaryKeyField();
 		$searchParams['order_dir'] = 'DESC';
+		$bbox = V::get('BBOX', '', $_GET);
+		// TODO: if (!empty($bbox)) $searchParams['f_the_geom'] = "BBOX:{$bbox}";
 		//if ($geomFld) $searchParams["f_{$geomFld}"] = 'IS NOT NULL';
 		//if ($geomFld) $searchParams["f_{$geomFld}"] = 'GeometryType=' . strtoupper($dbGeomType);
 		$geomType = strtoupper($dbGeomType);
 		if ($geomFld) $searchParams["ogc:Filter"] = <<<OGC_FILTER
 <ogc:Filter>
-	<ogc:Or>
+	<ogc:And>
 		<ogc:Not>
 			<ogc:PropertyIsNull>
 				<ogc:PropertyName>{$geomFld}</ogc:PropertyName>
@@ -97,7 +99,7 @@ class Api_WfsQgisServer extends Api_WfsServerBase {
 			</ogc:Function>
 			<ogc:Literal>{$geomType}</ogc:Literal>
 		</ogc:PropertyIsEqualTo>
-	</ogc:Or>
+	</ogc:And>
 </ogc:Filter>
 OGC_FILTER;
 if($DBG){echo 'getItems:';print_r($searchParams);echo "\n";}
@@ -109,6 +111,7 @@ if (true) {//1 == V::get('XML_WRITER', 0, $_GET, 'int')) {
 		header('Content-type: application/xml; charset=utf-8');
 		$xmlWriter = new XMLWriter();
 		$xmlWriter->openUri('php://output');
+		// $xmlWriter->openMemory();
 		$xmlWriter->setIndent(true);
 		if (!$xmlWriter) throw new HttpException("Error no XMLWriter", 404);
 		$xmlWriter->startDocument('1.0','UTF-8');
@@ -140,8 +143,9 @@ if($DBG){echo '(geomFld: '.$geomFld.'):';print_r($acl->getFieldType($geomFld));e
 			$items[0] = $fakeItem;
 		}
 		$dbgLoop = 0;
+		$this->DBG("before loop...", __LINE__, __FUNCTION__, __CLASS__);
 		foreach ($items as $itemKey => $item) {
-			if (0 == (++$dbgLoop) % 1000) $this->DBG("items loop:{$dbgLoop}", __LINE__, __FUNCTION__, __CLASS__);
+			if (0 == (++$dbgLoop) % 500) $this->DBG("items loop:{$dbgLoop}", __LINE__, __FUNCTION__, __CLASS__);
 if($DBG){echo 'item['.$itemKey.'] ('.$geomFld.')isEmpty('.empty($item->{$geomFld}).'):';print_r($item->{$geomFld});echo "\n";}
 			if ($geomFld) {
 				if (empty($item->{$geomFld})) {
@@ -152,7 +156,9 @@ if($DBG){echo 'item['.$itemKey.'] ('.$geomFld.')isEmpty('.empty($item->{$geomFld
 				$xmlWriter->startElement("{$wfsNs}:{$type}");
 					$xmlWriter->writeAttribute('fid', "{$type}.{$itemKey}");
 					foreach ($fldList as $fldName) {
-						if ($acl->isGeomField($fldName)) {
+						// if ($acl->isGeomField($fldName)) {// BUG: wolno
+						// if($fldName == 'the_geom'){// OK szybko
+						if ($geomFld != null && $fldName == $geomFld){
 							$xmlWriter->startElement("{$wfsNs}:{$fldName}");
 								$this->_typeConverter->createGmlFromWkt_xmlWriter($item->{$fldName}, $xmlWriter);
 							$xmlWriter->endElement();// {$wfsNs}:{$fldName}