Ver código fonte

added docs for fetch nested object in WFS API

Piotr Labudda 8 anos atrás
pai
commit
f6ca276813

+ 1 - 1
SE/se-lib/AclQueryFeatures.php

@@ -521,7 +521,7 @@ class AclQueryFeatures {
 						'fieldName' => $fieldName,
 						'fieldName' => $fieldName,
 					]
 					]
 				])->getItems();
 				])->getItems();
-				DBG::log($items, 'array', "TODO: add remote items '{$fieldName}' \$items");
+				DBG::log($items, 'array', "add remote items '{$fieldName}' \$items");
 				$row[$fieldName] = $items;
 				$row[$fieldName] = $items;
 			} else { // TODO: field is not ref
 			} else { // TODO: field is not ref
 				DBG::log($items, 'array', "NotImplemented - add remote items for non ref field \$items[{$primaryKey}][{$fieldName}]?");
 				DBG::log($items, 'array', "NotImplemented - add remote items for non ref field \$items[{$primaryKey}][{$fieldName}]?");

+ 8 - 10
SE/se-lib/Api/Wfs/GetFeature.php

@@ -82,12 +82,17 @@ class Api_Wfs_GetFeature {
 	// TODO: add $contextAcl and context xpath to check for special perms by contextAcl
 	// TODO: add $contextAcl and context xpath to check for special perms by contextAcl
 	public static function printXmlFeatureRecurse($xmlWriter, $acl, $item, $showFields, $tagName, $attrs = [], $showAdvancedAttrs = false, $schemaCache = [], $printedFidLog = []) {
 	public static function printXmlFeatureRecurse($xmlWriter, $acl, $item, $showFields, $tagName, $attrs = [], $showAdvancedAttrs = false, $schemaCache = [], $printedFidLog = []) {
 		$dbgFid = V::get('fid', 0, $attrs);
 		$dbgFid = V::get('fid', 0, $attrs);
-		if ($dbgFid) $printedFidLog[] = $dbgFid;
 		if(V::get('DBG_XML', '', $_GET))$xmlWriter->writeComment("DBG: print Xml Feature Recurse... '{$tagName}'" . ( $dbgFid ? " fid='{$dbgFid}'" : "" )); // TODO: DBG
 		if(V::get('DBG_XML', '', $_GET))$xmlWriter->writeComment("DBG: print Xml Feature Recurse... '{$tagName}'" . ( $dbgFid ? " fid='{$dbgFid}'" : "" )); // TODO: DBG
 		DBG::log($acl, 'array', "DBG: print Xml Feature Recurse( ... {$tagName}, \$acl)" . ( $dbgFid ? " fid='{$dbgFid}'" : "" ) . " \$acl");
 		DBG::log($acl, 'array', "DBG: print Xml Feature Recurse( ... {$tagName}, \$acl)" . ( $dbgFid ? " fid='{$dbgFid}'" : "" ) . " \$acl");
 		DBG::log($item, 'array', "DBG: print Xml Feature Recurse( ... {$tagName}, \$item)" . ( $dbgFid ? " fid='{$dbgFid}'" : "" ) . " \$item");
 		DBG::log($item, 'array', "DBG: print Xml Feature Recurse( ... {$tagName}, \$item)" . ( $dbgFid ? " fid='{$dbgFid}'" : "" ) . " \$item");
 		DBG::log($showFields, 'array', "DBG: print Xml Feature Recurse( ... {$tagName}, \$item)" . ( $dbgFid ? " fid='{$dbgFid}'" : "" ) . " \$showFields");
 		DBG::log($showFields, 'array', "DBG: print Xml Feature Recurse( ... {$tagName}, \$item)" . ( $dbgFid ? " fid='{$dbgFid}'" : "" ) . " \$showFields");
 		DBG::log([$attrs, $showAdvancedAttrs, array_keys($schemaCache), $printedFidLog], 'array', "DBG: print Xml Feature Recurse( ... {$tagName}, \$attrs, \$showAdvancedAttrs, keys(\$schemaCache), \$printedFidLog)");
 		DBG::log([$attrs, $showAdvancedAttrs, array_keys($schemaCache), $printedFidLog], 'array', "DBG: print Xml Feature Recurse( ... {$tagName}, \$attrs, \$showAdvancedAttrs, keys(\$schemaCache), \$printedFidLog)");
+		if ($dbgFid) {
+			if (in_array($dbgFid, $printedFidLog)) {
+				DBG::log("TODO: in_array({$dbgFid}, \$printedFidLog)");
+			}
+		}
+		if ($dbgFid) $printedFidLog[] = $dbgFid;
 		// $rootWfsNs = 'p5';
 		// $rootWfsNs = 'p5';
 		list($itemPrefix, $localName) = explode(':', $tagName);
 		list($itemPrefix, $localName) = explode(':', $tagName);
 
 
@@ -96,14 +101,7 @@ class Api_Wfs_GetFeature {
 			$xlink = $item['xlink'];
 			$xlink = $item['xlink'];
 			list($xlinkUrl, $xlinkFid) = explode('#', $xlink);
 			list($xlinkUrl, $xlinkFid) = explode('#', $xlink);
 
 
-			// } else if (1 == count($item[$fldName]) && !empty($item[$fldName][0]['xlink'])) {
-			// $xmlWriter->writeComment("TODO: xlinks for '{$fldName}'"); // TODO: DBG
-			DBG::log($item[$fldName], 'array', "TODO: xlinks for '{$tagName}'");
-			// $xlink = $item[$fldName][0]['xlink'];
-			// $xlinkParts = explode(':', $xlink);
-			// if (2 != count($xlinkParts)) throw new Exception("Error Processing Request - wrong xlink format for ".$acl->getName().".{$itemKey}/{$fldName}");
-			// $xlinkParts[0] = Api_WfsNs::getNsUri($xlinkParts[0]);
-			// $xlink = implode('#', $xlinkParts);
+			DBG::log($item[$fldName], 'array', "xlinks for '{$tagName}'");
 			$xmlWriter->startElement($tagName);
 			$xmlWriter->startElement($tagName);
 				foreach ($attrs as $name => $value) {
 				foreach ($attrs as $name => $value) {
 					$xmlWriter->writeAttribute($name, $value);
 					$xmlWriter->writeAttribute($name, $value);
@@ -182,7 +180,7 @@ class Api_Wfs_GetFeature {
 							if(V::get('DBG_XML', '', $_GET))$xmlWriter->writeComment("Error Processing Request - field is not ref or missing acl ".$acl->getName().".{$itemKey}/{$fldName}");
 							if(V::get('DBG_XML', '', $_GET))$xmlWriter->writeComment("Error Processing Request - field is not ref or missing acl ".$acl->getName().".{$itemKey}/{$fldName}");
 						}
 						}
 					} else {
 					} else {
-						DBG::log($schemaCache[$fieldNs], 'array', "TODO: xxxxxxx ".$acl->getName().".{$itemKey}/{$fldName}");
+						DBG::log($schemaCache[$fieldNs], 'array', "fetch child acl ".$acl->getName().".{$itemKey}/{$fldName}");
 						$childAcl = Core_AclHelper::getAclByNamespace($schemaCache[$fieldNs]['namespace'], false, $schemaCache[$fieldNs]);
 						$childAcl = Core_AclHelper::getAclByNamespace($schemaCache[$fieldNs]['namespace'], false, $schemaCache[$fieldNs]);
 						$childName = $schemaCache[$fieldNs]['name'];
 						$childName = $schemaCache[$fieldNs]['name'];
 						foreach ($item[$fldName] as $childItem) {
 						foreach ($item[$fldName] as $childItem) {

+ 19 - 0
SE/se-lib/ParseOgcFilter.php

@@ -3,6 +3,25 @@
 Lib::loadClass('SqlQueryWhereBuilder');
 Lib::loadClass('SqlQueryWhereBuilder');
 Lib::loadClass('Api_WfsException');
 Lib::loadClass('Api_WfsException');
 
 
+// WFS 1.1 - traverseXlinkDepth, traverseXlinkExpiry  http://docs.opengeospatial.org/is/04-094r1/04-094r1.html#50
+// WFS 2.0 - resolve, resolveDepth, resolveTimeout    http://docs.opengeospatial.org/is/09-025r2/09-025r2.html#57
+
+// WFS 1.1   traverseXlinkDepth   type="string" ('*' or int > 0) - recurse limit ('*' - no limit)
+// WFS 1.1   traverseXlinkExpiry  type="xsd:positiveInteger"     - timeOut in minutes
+// WFS 1.1 Note: traverse used in wfs:GetFeature or inside wfs:Query tag wfs:XlinkPropertyName (same like wfs:PropertyName but with @traverse* attributes)
+
+// WFS 2.0   resolve         type="wfs:ResolveValueType"         default="none"  (enum: 'local', 'remote', 'all', 'none')
+//           - resolve="local"   - operation shall only resolve local references
+//           - resolve="remote"  - operation shall only resolve remote resource references
+//           - resolve="all"     - means that an operation shall resolve all resource references
+//           - resolve="none"    - means that an operation shall not resolve any resource references
+// WFS 2.0   resolveDepth    type="wfs:positiveIntegerWithStar" default="*" ('*' or int > 0)   - recurse limit ('*' - no limit)
+// WFW 2.0   resolveTimeout  type="xsd:positiveInteger"         default="300"  - timeOut in seconds
+// WFS 2.0 Note: resolve used in wfs:GetFeature or inside wfs:Query tag wfs:PropertyName
+//               in wfs:PropertyName may use resolvePath - @see http://docs.opengeospatial.org/is/09-025r2/09-025r2.html#103
+
+// WFS 2.0 resolve, resolveDepth example http://grepcode.com/file/repo1.maven.org/maven2/org.jvnet.ogc/ogc-schemas/2.2.0/ogc/wfs/2.0/examples/GetFeature/GetFeature_12.xml
+
 /**
 /**
  * @see wfs 1.0 wfs:GetFeature schema: http://schemas.opengis.net/wfs/1.0.0/WFS-basic.xsd
  * @see wfs 1.0 wfs:GetFeature schema: http://schemas.opengis.net/wfs/1.0.0/WFS-basic.xsd
  * @see docs wfs 1.1 http://docs.opengeospatial.org/is/04-094r1/04-094r1.html
  * @see docs wfs 1.1 http://docs.opengeospatial.org/is/04-094r1/04-094r1.html

+ 30 - 1
SE/se-lib/Route/WfsJsRequestPanel.php

@@ -107,7 +107,36 @@ class Route_WfsJsRequestPanel extends RouteBase {
 			echo UI::h('textarea', [ 'id' => 'wfsRequestBody', 'style' => "width:100%; height:300px" ], htmlspecialchars($exampleWfsRequestBody));
 			echo UI::h('textarea', [ 'id' => 'wfsRequestBody', 'style' => "width:100%; height:300px" ], htmlspecialchars($exampleWfsRequestBody));
 			echo UI::h('button', [ 'class' => "btn btn-primary", 'onClick' => "return sendWfsRequest(this)" ], "Wyslij");
 			echo UI::h('button', [ 'class' => "btn btn-primary", 'onClick' => "return sendWfsRequest(this)" ], "Wyslij");
 			echo UI::h('div', [ 'style' => "display:inline", 'id' => "wfs-example-btns" ]);
 			echo UI::h('div', [ 'style' => "display:inline", 'id' => "wfs-example-btns" ]);
-			echo UI::h('pre', [ 'id' => 'wfsResponse' ], 'loading...');
+			echo UI::h('details', [ 'style' => "padding:6px; background-color:#333; color:#fff", 'open' => "open" ], [
+				UI::h('summary', [ 'style' => "padding:0 3px; outline:none; cursor:pointer" ], "WFS Response"),
+				UI::h('pre', [ 'id' => 'wfsResponse', 'style' => "margin:0; font-size:x-small; border-radius:0" ], 'loading...'),
+			]);
+			echo UI::h('details', [ 'style' => "padding:6px; background-color:#68cbfd; color:#fff" ], [
+				UI::h('summary', [ 'style' => "padding:0 3px; outline:none; cursor:pointer" ], [
+					UI::h('i',[ 'class' => "glyphicon glyphicon-question-sign" ]),
+					" WFS 1.1, 2.0 fetch nested objects (traverse, resolve)",
+				]),
+				UI::h('pre', ['style' => "margin:0; font-size:x-small; border-radius:0"], implode("\n", [
+					"WFS 1.1 - traverseXlinkDepth, traverseXlinkExpiry  " . UI::h('a', ['href'=>"http://docs.opengeospatial.org/is/04-094r1/04-094r1.html#50"], "http://docs.opengeospatial.org/is/04-094r1/04-094r1.html#50"),
+					"WFS 2.0 - resolve, resolveDepth, resolveTimeout    " . UI::h('a', ['href'=>"http://docs.opengeospatial.org/is/09-025r2/09-025r2.html#57"], "http://docs.opengeospatial.org/is/09-025r2/09-025r2.html#57"),
+					"",
+					"WFS 1.1   traverseXlinkDepth   type=\"string\" ('*' or int > 0) - recurse limit ('*' - no limit)",
+					"WFS 1.1   traverseXlinkExpiry  type=\"xsd:positiveInteger\"     - timeOut in minutes",
+					"WFS 1.1 Note: traverse used in wfs:GetFeature or inside wfs:Query tag wfs:XlinkPropertyName (same like wfs:PropertyName but with @traverse* attributes)",
+					"",
+					"WFS 2.0   resolve         type=\"wfs:ResolveValueType\"         default=\"none\"  (enum: 'local', 'remote', 'all', 'none')",
+					"          - resolve=\"local\"   - operation shall only resolve local references",
+					"          - resolve=\"remote\"  - operation shall only resolve remote resource references",
+					"          - resolve=\"all\"     - means that an operation shall resolve all resource references",
+					"          - resolve=\"none\"    - means that an operation shall not resolve any resource references",
+					"WFS 2.0   resolveDepth    type=\"wfs:positiveIntegerWithStar\" default=\"*\" ('*' or int > 0)   - recurse limit ('*' - no limit)",
+					"WFW 2.0   resolveTimeout  type=\"xsd:positiveInteger\"         default=\"300\"  - timeOut in seconds",
+					"WFS 2.0 Note: resolve used in wfs:GetFeature or inside wfs:Query tag wfs:PropertyName",
+					"              in wfs:PropertyName may use resolvePath - @see " . UI::h('a', ['href'=>"http://docs.opengeospatial.org/is/09-025r2/09-025r2.html#103"], "http://docs.opengeospatial.org/is/09-025r2/09-025r2.html#103"),
+					"",
+					"WFS 2.0 resolve, resolveDepth example " . UI::h('a', ['href'=>"http://grepcode.com/file/repo1.maven.org/maven2/org.jvnet.ogc/ogc-schemas/2.2.0/ogc/wfs/2.0/examples/GetFeature/GetFeature_12.xml"], "http://grepcode.com/file/repo1.maven.org/maven2/org.jvnet.ogc/ogc-schemas/2.2.0/ogc/wfs/2.0/examples/GetFeature/GetFeature_12.xml"),
+				])),
+			]);
 			UI::endContainer();
 			UI::endContainer();
 			$examples = array_map(function ($props) use ($exampleFltr) {
 			$examples = array_map(function ($props) use ($exampleFltr) {
 				return "<wfs:Query>" . implode("\n", array_merge($props, $exampleFltr)) . "</wfs:Query>";
 				return "<wfs:Query>" . implode("\n", array_merge($props, $exampleFltr)) . "</wfs:Query>";