Add more typedefs for return objects

This commit is contained in:
Bart van den Eijnden
2014-03-10 16:40:00 +01:00
parent 431a4d1725
commit 041479f1b7
3 changed files with 43 additions and 16 deletions
+4 -1
View File
@@ -328,7 +328,10 @@
/** /**
* @typedef {Object} olx.format.WFSOptions * @typedef {Object} olx.format.WFSOptions
* @property {string} featureNS The namespace URI used for features. * @property {string} featureNS The namespace URI used for features.
* @property {string} featureType * @property {string} featureType The feature type to parse. Only used for
* read operations.
* @property {string|undefined} schemaLocation Optional schemaLocation to use
* for serialization, this will override the default.
*/ */
/** /**
+3
View File
@@ -1,3 +1,6 @@
@exportSymbol ol.format.WFS @exportSymbol ol.format.WFS
@exportProperty ol.format.WFS.prototype.readFeatures
@exportProperty ol.format.WFS.prototype.readTransactionResponse
@exportProperty ol.format.WFS.prototype.readFeatureCollectionMetadata
@exportProperty ol.format.WFS.prototype.writeGetFeature @exportProperty ol.format.WFS.prototype.writeGetFeature
@exportProperty ol.format.WFS.prototype.writeTransaction @exportProperty ol.format.WFS.prototype.writeTransaction
+36 -15
View File
@@ -46,6 +46,22 @@ ol.format.WFS = function(opt_options) {
goog.inherits(ol.format.WFS, ol.format.XMLFeature); goog.inherits(ol.format.WFS, ol.format.XMLFeature);
/**
* @typedef {{numberOfFeatures: number,
* bounds: ol.Extent}}
*/
ol.format.WFS.FeatureCollectionMetadata;
/**
* @typedef {{totalDeleted: number,
* totalInserted: number,
totalUpdated: number,
insertIds: Array.<string>}}
*/
ol.format.WFS.TransactionResponse;
/** /**
* @const * @const
* @type {string} * @type {string}
@@ -74,7 +90,7 @@ ol.format.WFS.prototype.readFeaturesFromNode = function(node) {
/** /**
* @param {ArrayBuffer|Document|Node|Object|string} source Source. * @param {ArrayBuffer|Document|Node|Object|string} source Source.
* @return {Object|undefined} Transaction response. * @return {ol.format.WFS.TransactionResponse|undefined} Transaction response.
*/ */
ol.format.WFS.prototype.readTransactionResponse = function(source) { ol.format.WFS.prototype.readTransactionResponse = function(source) {
if (ol.xml.isDocument(source)) { if (ol.xml.isDocument(source)) {
@@ -87,14 +103,15 @@ ol.format.WFS.prototype.readTransactionResponse = function(source) {
return this.readTransactionResponseFromDocument(doc); return this.readTransactionResponseFromDocument(doc);
} else { } else {
goog.asserts.fail(); goog.asserts.fail();
return null; return undefined;
} }
}; };
/** /**
* @param {ArrayBuffer|Document|Node|Object|string} source Source. * @param {ArrayBuffer|Document|Node|Object|string} source Source.
* @return {Object|undefined} FeatureCollection metadata. * @return {ol.format.WFS.FeatureCollectionMetadata|undefined}
* FeatureCollection metadata.
*/ */
ol.format.WFS.prototype.readFeatureCollectionMetadata = function(source) { ol.format.WFS.prototype.readFeatureCollectionMetadata = function(source) {
if (ol.xml.isDocument(source)) { if (ol.xml.isDocument(source)) {
@@ -108,14 +125,15 @@ ol.format.WFS.prototype.readFeatureCollectionMetadata = function(source) {
return this.readFeatureCollectionMetadataFromDocument(doc); return this.readFeatureCollectionMetadataFromDocument(doc);
} else { } else {
goog.asserts.fail(); goog.asserts.fail();
return null; return undefined;
} }
}; };
/** /**
* @param {Document} doc Document. * @param {Document} doc Document.
* @return {Object|undefined} FeatureCollection metadata. * @return {ol.format.WFS.FeatureCollectionMetadata|undefined}
* FeatureCollection metadata.
*/ */
ol.format.WFS.prototype.readFeatureCollectionMetadataFromDocument = ol.format.WFS.prototype.readFeatureCollectionMetadataFromDocument =
function(doc) { function(doc) {
@@ -125,7 +143,7 @@ ol.format.WFS.prototype.readFeatureCollectionMetadataFromDocument =
return this.readFeatureCollectionMetadataFromNode(n); return this.readFeatureCollectionMetadataFromNode(n);
} }
} }
return null; return undefined;
}; };
@@ -144,7 +162,8 @@ ol.format.WFS.FEATURE_COLLECTION_PARSERS_ = {
/** /**
* @param {Node} node Node. * @param {Node} node Node.
* @return {Object|undefined} FeatureCollection metadata. * @return {ol.format.WFS.FeatureCollectionMetadata|undefined}
* FeatureCollection metadata.
*/ */
ol.format.WFS.prototype.readFeatureCollectionMetadataFromNode = function(node) { ol.format.WFS.prototype.readFeatureCollectionMetadataFromNode = function(node) {
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
@@ -154,7 +173,8 @@ ol.format.WFS.prototype.readFeatureCollectionMetadataFromNode = function(node) {
node.getAttribute('numberOfFeatures')); node.getAttribute('numberOfFeatures'));
goog.object.set(result, 'numberOfFeatures', value); goog.object.set(result, 'numberOfFeatures', value);
return ol.xml.pushParseAndPop( return ol.xml.pushParseAndPop(
result, ol.format.WFS.FEATURE_COLLECTION_PARSERS_, node, []); /** @type {ol.format.WFS.FeatureCollectionMetadata} */ (result),
ol.format.WFS.FEATURE_COLLECTION_PARSERS_, node, []);
}; };
@@ -226,7 +246,7 @@ ol.format.WFS.INSERT_RESULTS_PARSERS_ = {
/** /**
* @param {Node} node Node. * @param {Node} node Node.
* @param {Array.<*>} objectStack Object stack. * @param {Array.<*>} objectStack Object stack.
* @return {Object|undefined} Insert results. * @return {Array.<string>|undefined} Insert results.
* @private * @private
*/ */
ol.format.WFS.readInsertResults_ = function(node, objectStack) { ol.format.WFS.readInsertResults_ = function(node, objectStack) {
@@ -252,7 +272,7 @@ ol.format.WFS.TRANSACTION_RESPONSE_PARSERS_ = {
/** /**
* @param {Document} doc Document. * @param {Document} doc Document.
* @return {Object|undefined} Transaction response. * @return {ol.format.WFS.TransactionResponse|undefined} Transaction response.
*/ */
ol.format.WFS.prototype.readTransactionResponseFromDocument = function(doc) { ol.format.WFS.prototype.readTransactionResponseFromDocument = function(doc) {
goog.asserts.assert(doc.nodeType == goog.dom.NodeType.DOCUMENT); goog.asserts.assert(doc.nodeType == goog.dom.NodeType.DOCUMENT);
@@ -261,18 +281,19 @@ ol.format.WFS.prototype.readTransactionResponseFromDocument = function(doc) {
return this.readTransactionResponseFromNode(n); return this.readTransactionResponseFromNode(n);
} }
} }
return null; return undefined;
}; };
/** /**
* @param {Node} node Node. * @param {Node} node Node.
* @return {Object|undefined} Transaction response. * @return {ol.format.WFS.TransactionResponse|undefined} Transaction response.
*/ */
ol.format.WFS.prototype.readTransactionResponseFromNode = function(node) { ol.format.WFS.prototype.readTransactionResponseFromNode = function(node) {
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
goog.asserts.assert(node.localName == 'TransactionResponse'); goog.asserts.assert(node.localName == 'TransactionResponse');
return ol.xml.pushParseAndPop({}, return ol.xml.pushParseAndPop(
/** @type {ol.format.WFS.TransactionResponse} */({}),
ol.format.WFS.TRANSACTION_RESPONSE_PARSERS_, node, []); ol.format.WFS.TRANSACTION_RESPONSE_PARSERS_, node, []);
}; };
@@ -457,7 +478,7 @@ ol.format.WFS.writeQuery_ = function(node, featureType, objectStack) {
var bbox = goog.object.get(context, 'bbox'); var bbox = goog.object.get(context, 'bbox');
if (goog.isDef(bbox)) { if (goog.isDef(bbox)) {
var child = ol.xml.createElementNS('http://www.opengis.net/ogc', 'Filter'); var child = ol.xml.createElementNS('http://www.opengis.net/ogc', 'Filter');
ol.format.WFS.writeBBOX_(child, bbox, objectStack); ol.format.WFS.writeOgcBBOX_(child, bbox, objectStack);
node.appendChild(child); node.appendChild(child);
} }
}; };
@@ -483,7 +504,7 @@ ol.format.WFS.writeOgcPropertyName_ = function(node, value, objectStack) {
* @param {Array.<*>} objectStack Node stack. * @param {Array.<*>} objectStack Node stack.
* @private * @private
*/ */
ol.format.WFS.writeBBOX_ = function(node, bbox, objectStack) { ol.format.WFS.writeOgcBBOX_ = function(node, bbox, objectStack) {
var context = objectStack[objectStack.length - 1]; var context = objectStack[objectStack.length - 1];
goog.asserts.assert(goog.isObject(context)); goog.asserts.assert(goog.isObject(context));
var geometryName = goog.object.get(context, 'geometryName'); var geometryName = goog.object.get(context, 'geometryName');