浏览代码

updated js wfs get feature - fixed p5:next link, added todo graphql query

Piotr Labudda 8 年之前
父节点
当前提交
37d04f6c78
共有 1 个文件被更改,包括 8 次插入2 次删除
  1. 8 2
      SE/static/p5WFS/GetFeature.js

+ 8 - 2
SE/static/p5WFS/GetFeature.js

@@ -1,5 +1,6 @@
 // @require WFS_URL
 if (!WFS_URL) throw "Missing WFS_URL"
+var DBG = DBG || false
 
 // wfsFeature json format:
 /*
@@ -26,9 +27,10 @@ function p5WFS_ParseFeatureFieldRecurse(tagNode) { // @returns object from xml e
 			// </p5:next>​</p5:links>​
 			for (var j = 0; j < fieldNode.children.length; j++) {
 				var p5LinkNode = fieldNode.children[j]
-				if ('p5:next') {
+				if ('p5:next' === p5LinkNode.tagName) {
 					var typeName = p5LinkNode.getAttribute('p5:typeName')
 					item[ typeName ].push( {
+						'type': 'next',
 						'@backRefNS': p5LinkNode.getAttribute('p5:backRefNS'),
 						'@backRefPK': p5LinkNode.getAttribute('p5:backRefPK'),
 						'@typeName': p5LinkNode.getAttribute('p5:typeName'),
@@ -36,7 +38,7 @@ function p5WFS_ParseFeatureFieldRecurse(tagNode) { // @returns object from xml e
 						'value': p5LinkNode.textContent
 					} )
 				} else {
-					// Not implemented
+					if (DBG) console.warn("Not implemented p5:links/" + p5LinkNode.tagName)
 				}
 			}
 		}
@@ -146,6 +148,10 @@ function p5WFS_GetFeature(typeName, query) { // @returns Promise
 			throw 'Error - wrong syntax ogc:Filter'
 		}
 	}
+	if ('graphql:query' in query && 'string' === typeof query['graphql:query']) { // TODO: http://graphql.org/learn/queries/
+		link += '&outputFormat=json'
+		postData = query['graphql:query']
+	}
 	if ('sortBy' in query) link += '&sortBy=' + query['sortBy']
 	if ('maxFeatures' in query) link += '&maxFeatures=' + query['maxFeatures']
 	if ('count' in query) link += '&count=' + query['count']