From fe2bee1577de21db57da9e5ee85f2ae212b18dba Mon Sep 17 00:00:00 2001 From: Hadrien Tulipe Date: Sun, 16 Mar 2014 19:47:13 +0100 Subject: [PATCH 1/5] Add basic reading support for OWS Capabilities document. --- src/ol/format/owscapabilitiesformat.js | 511 ++++++++++++++++++ .../ol/format/owscapabilitiesformat.test.js | 154 ++++++ 2 files changed, 665 insertions(+) create mode 100644 src/ol/format/owscapabilitiesformat.js create mode 100644 test/spec/ol/format/owscapabilitiesformat.test.js diff --git a/src/ol/format/owscapabilitiesformat.js b/src/ol/format/owscapabilitiesformat.js new file mode 100644 index 0000000000..c525bd6aa2 --- /dev/null +++ b/src/ol/format/owscapabilitiesformat.js @@ -0,0 +1,511 @@ +goog.provide('ol.format.OWSCapabilities'); + +goog.require('goog.asserts'); +goog.require('goog.dom.NodeType'); +goog.require('goog.object'); +goog.require('ol.format.XLink'); +goog.require('ol.format.XML'); +goog.require('ol.format.XSD'); +goog.require('ol.xml'); + + + +/** + * @constructor + * @extends {ol.format.XML} + */ +ol.format.OWSCapabilities = function() { + goog.base(this); +}; +goog.inherits(ol.format.OWSCapabilities, ol.format.XML); + + +/** + * @param {Document} doc Document. + * @return {Object} OWS object. + */ +ol.format.OWSCapabilities.prototype.readFromDocument = function(doc) { + goog.asserts.assert(doc.nodeType == goog.dom.NodeType.DOCUMENT); + for (var n = doc.firstChild; !goog.isNull(n); n = n.nextSibling) { + if (n.nodeType == goog.dom.NodeType.ELEMENT) { + return this.readFromNode(n); + } + } + return null; +}; + + +/** + * @param {Node} node Node. + * @return {Object} OWS object. + */ +ol.format.OWSCapabilities.prototype.readFromNode = function(node) { + goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); + var owsObject = ol.xml.pushParseAndPop({}, + ol.format.OWSCapabilities.PARSERS_, node, []); + return goog.isDef(owsObject) ? owsObject : null; +}; + + +/** + * @param {Node} node Node. + * @param {Array.<*>} objectStack Object stack. + * @private + * @return {Object|undefined} + */ +ol.format.OWSCapabilities.readAddress_ = function(node, objectStack) { + goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); + goog.asserts.assert(node.localName == 'Address'); + return ol.xml.pushParseAndPop({}, + ol.format.OWSCapabilities.ADDRESS_PARSERS_, node, objectStack); +}; + + +/** + * @param {Node} node Node. + * @param {Array.<*>} objectStack Object stack. + * @private + * @return {Object|undefined} + */ +ol.format.OWSCapabilities.readAllowedValues_ = function(node, objectStack) { + goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); + goog.asserts.assert(node.localName == 'AllowedValues'); + return ol.xml.pushParseAndPop({}, + ol.format.OWSCapabilities.ALLOWED_VALUES_PARSERS_, node, objectStack); +}; + + +/** + * @param {Node} node Node. + * @param {Array.<*>} objectStack Object stack. + * @private + * @return {Object|undefined} + */ +ol.format.OWSCapabilities.readConstraint_ = function(node, objectStack) { + goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); + goog.asserts.assert(node.localName == 'Constraint'); + var object = objectStack[objectStack.length - 1]; + goog.asserts.assert(goog.isObject(object)); + var name = node.getAttribute('name'); + var value = ol.xml.pushParseAndPop({}, + ol.format.OWSCapabilities.CONSTRAINT_PARSERS_, node, + objectStack); + if (!goog.isDef(object.constraints)) { + object.constraints = {}; + } + object.constraints[name] = value; + +}; + + +/** + * @param {Node} node Node. + * @param {Array.<*>} objectStack Object stack. + * @private + * @return {Object|undefined} + */ +ol.format.OWSCapabilities.readContactInfo_ = function(node, objectStack) { + goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); + goog.asserts.assert(node.localName == 'ContactInfo'); + return ol.xml.pushParseAndPop({}, + ol.format.OWSCapabilities.CONTACT_INFO_PARSERS_, node, objectStack); +}; + + +/** + * @param {Node} node Node. + * @param {Array.<*>} objectStack Object stack. + * @private + * @return {Object|undefined} + */ +ol.format.OWSCapabilities.readDcp_ = function(node, objectStack) { + goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); + goog.asserts.assert(node.localName == 'DCP'); + return ol.xml.pushParseAndPop({}, + ol.format.OWSCapabilities.DCP_PARSERS_, node, objectStack); +}; + + +/** + * @param {Node} node Node. + * @param {Array.<*>} objectStack Object stack. + * @private + * @return {Object|undefined} + */ +ol.format.OWSCapabilities.readGet_ = function(node, objectStack) { + goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); + goog.asserts.assert(node.localName == 'Get'); + var object = objectStack[objectStack.length - 1]; + var url = ol.format.XLink.readHref(node); + goog.asserts.assert(goog.isObject(object)); + var value = ol.xml.pushParseAndPop({'url': url}, + ol.format.OWSCapabilities.REQUEST_METHOD_PARSERS_, node, objectStack); + if (!goog.isDef(object.get)) { + goog.object.set(object, 'get', [value]); + }else { + goog.asserts.assert(goog.isArray(object.get)); + object.get.push(value); + } + +}; + + +/** + * @param {Node} node Node. + * @param {Array.<*>} objectStack Object stack. + * @private + * @return {Object|undefined} + */ +ol.format.OWSCapabilities.readHttp_ = function(node, objectStack) { + goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); + goog.asserts.assert(node.localName == 'HTTP'); + /*var rawArray = ol.xml.pushParseAndPop([], + ol.format.OWSCapabilities.HTTP_PARSERS_, node, objectStack); + var object = {}; + goog.array.forEach(rawArray,function(item){ + if(goog.isDef(object[item.method])){ + object[item.method].push(item.url); + } else { + object[item.method] = [item.url]; + } + });*/ + return ol.xml.pushParseAndPop({}, ol.format.OWSCapabilities.HTTP_PARSERS_, + node, objectStack); +}; + + +/** + * @param {Node} node Node. + * @param {Array.<*>} objectStack Object stack. + * @private + * @return {Object|undefined} + */ +ol.format.OWSCapabilities.readOperation_ = function(node, objectStack) { + goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); + goog.asserts.assert(node.localName == 'Operation'); + var name = node.getAttribute('name'); + var value = ol.xml.pushParseAndPop({}, + ol.format.OWSCapabilities.OPERATION_PARSERS_, node, objectStack); + var object = /** @type {Object} */ + (objectStack[objectStack.length - 1]); + goog.asserts.assert(goog.isObject(object)); + goog.object.set(object, name, value); + +}; + + +/** + * @param {Node} node Node. + * @param {Array.<*>} objectStack Object stack. + * @private + * @return {Object|undefined} + */ +ol.format.OWSCapabilities.readOperationsMetadata_ = function(node, + objectStack) { + goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); + goog.asserts.assert(node.localName == 'OperationsMetadata'); + return ol.xml.pushParseAndPop({}, + ol.format.OWSCapabilities.OPERATIONS_METADATA_PARSERS_, node, + objectStack); +}; + + +/** + * @param {Node} node Node. + * @param {Array.<*>} objectStack Object stack. + * @private + * @return {Object|undefined} + */ +ol.format.OWSCapabilities.readPhone_ = function(node, objectStack) { + goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); + goog.asserts.assert(node.localName == 'Phone'); + return ol.xml.pushParseAndPop({}, + ol.format.OWSCapabilities.PHONE_PARSERS_, node, objectStack); +}; + + +/** + * @param {Node} node Node. + * @param {Array.<*>} objectStack Object stack. + * @private + * @return {Object|undefined} + */ +ol.format.OWSCapabilities.readServiceIdentification_ = function(node, + objectStack) { + goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); + goog.asserts.assert(node.localName == 'ServiceIdentification'); + return ol.xml.pushParseAndPop( + {}, ol.format.OWSCapabilities.SERVICE_IDENTIFICATION_PARSERS_, node, + objectStack); +}; + + +/** + * @param {Node} node Node. + * @param {Array.<*>} objectStack Object stack. + * @private + * @return {Object|undefined} + */ +ol.format.OWSCapabilities.readServiceContact_ = function(node, objectStack) { + goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); + goog.asserts.assert(node.localName == 'ServiceContact'); + return ol.xml.pushParseAndPop( + {}, ol.format.OWSCapabilities.SERVICE_CONTACT_PARSERS_, node, + objectStack); +}; + + +/** + * @param {Node} node Node. + * @param {Array.<*>} objectStack Object stack. + * @private + * @return {Object|undefined} + */ +ol.format.OWSCapabilities.readServiceProvider_ = function(node, objectStack) { + goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); + goog.asserts.assert(node.localName == 'ServiceProvider'); + return ol.xml.pushParseAndPop( + {}, ol.format.OWSCapabilities.SERVICE_PROVIDER_PARSERS_, node, + objectStack); +}; + + +/** + * @param {Node} node Node. + * @param {Array.<*>} objectStack Object stack. + * @private + * @return {Object|undefined} + */ +ol.format.OWSCapabilities.readValue_ = function(node, objectStack) { + goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); + goog.asserts.assert(node.localName == 'Value'); + var object = objectStack[objectStack.length - 1]; + goog.asserts.assert(goog.isObject(object)); + var key = /** @type {string} */ (ol.format.XSD.readString(node)); + goog.object.set(object, key, true); +}; + + +/** + * @const + * @type {Array.} + * @private + */ +ol.format.OWSCapabilities.NAMESPACE_URIS_ = [ + null, + 'http://www.opengis.net/ows/1.1' +]; + + +/** + * @const + * @type {Object.>} + * @private + */ +ol.format.OWSCapabilities.PARSERS_ = ol.xml.makeParsersNS( + ol.format.OWSCapabilities.NAMESPACE_URIS_, { + 'ServiceIdentification' : ol.xml.makeObjectPropertySetter( + ol.format.OWSCapabilities.readServiceIdentification_, + 'serviceIdentification'), + 'ServiceProvider' : ol.xml.makeObjectPropertySetter( + ol.format.OWSCapabilities.readServiceProvider_, + 'serviceProvider'), + 'OperationsMetadata': ol.xml.makeObjectPropertySetter( + ol.format.OWSCapabilities.readOperationsMetadata_, + 'operationsMetadata') + } + ); + + +/** + * @const + * @type {Object.>} + * @private + */ +ol.format.OWSCapabilities.ADDRESS_PARSERS_ = ol.xml.makeParsersNS( + ol.format.OWSCapabilities.NAMESPACE_URIS_, { + 'DeliveryPoint' : ol.xml.makeObjectPropertySetter( + ol.format.XSD.readString, 'deliveryPoint'), + 'City' : ol.xml.makeObjectPropertySetter(ol.format.XSD.readString, + 'city'), + 'AdministrativeArea' : ol.xml.makeObjectPropertySetter( + ol.format.XSD.readString, 'administrativeArea'), + 'PostalCode' : ol.xml.makeObjectPropertySetter(ol.format.XSD.readString, + 'postalCode'), + 'Country' : ol.xml.makeObjectPropertySetter( + ol.format.XSD.readString, 'country'), + 'ElectronicMailAddress' : ol.xml.makeObjectPropertySetter( + ol.format.XSD.readString, 'electronicMailAddress') + } + ); + + +/** + * @const + * @type {Object.>} + * @private + */ +ol.format.OWSCapabilities.ALLOWED_VALUES_PARSERS_ = ol.xml.makeParsersNS( + ol.format.OWSCapabilities.NAMESPACE_URIS_, { + 'Value': ol.format.OWSCapabilities.readValue_ + } + ); + + +/** + * @const + * @type {Object.>} + * @private + */ +ol.format.OWSCapabilities.CONSTRAINT_PARSERS_ = ol.xml.makeParsersNS( + ol.format.OWSCapabilities.NAMESPACE_URIS_, { + 'AllowedValues': ol.xml.makeObjectPropertySetter( + ol.format.OWSCapabilities.readAllowedValues_, 'allowedValues' + ) + } + ); + + +/** + * @const + * @type {Object.>} + * @private + */ +ol.format.OWSCapabilities.CONTACT_INFO_PARSERS_ = ol.xml.makeParsersNS( + ol.format.OWSCapabilities.NAMESPACE_URIS_, { + 'Phone' : ol.xml.makeObjectPropertySetter( + ol.format.OWSCapabilities.readPhone_, 'phone'), + 'Address' : ol.xml.makeObjectPropertySetter( + ol.format.OWSCapabilities.readAddress_, 'address') + } + ); + + +/** + * @const + * @type {Object.>} + * @private + */ +ol.format.OWSCapabilities.DCP_PARSERS_ = ol.xml.makeParsersNS( + ol.format.OWSCapabilities.NAMESPACE_URIS_, { + 'HTTP' : ol.xml.makeObjectPropertySetter( + ol.format.OWSCapabilities.readHttp_, 'http') + } + ); + + +/** + * @const + * @type {Object.>} + * @private + */ +ol.format.OWSCapabilities.HTTP_PARSERS_ = ol.xml.makeParsersNS( + ol.format.OWSCapabilities.NAMESPACE_URIS_, { + 'Get': ol.format.OWSCapabilities.readGet_, + 'Post': undefined // TODO + } + ); + + +/** + * @const + * @type {Object.>} + * @private + */ +ol.format.OWSCapabilities.OPERATION_PARSERS_ = ol.xml.makeParsersNS( + ol.format.OWSCapabilities.NAMESPACE_URIS_, { + 'DCP' : ol.xml.makeObjectPropertySetter( + ol.format.OWSCapabilities.readDcp_, 'dcp') + } + ); + + +/** + * @const + * @type {Object.>} + * @private + */ +ol.format.OWSCapabilities.OPERATIONS_METADATA_PARSERS_ = ol.xml.makeParsersNS( + ol.format.OWSCapabilities.NAMESPACE_URIS_, { + 'Operation' : ol.format.OWSCapabilities.readOperation_ + } + ); + + +/** + * @const + * @type {Object.>} + * @private + */ +ol.format.OWSCapabilities.PHONE_PARSERS_ = ol.xml.makeParsersNS( + ol.format.OWSCapabilities.NAMESPACE_URIS_, { + 'Voice' : ol.xml.makeObjectPropertySetter(ol.format.XSD.readString, + 'voice'), + 'Facsimile' : ol.xml.makeObjectPropertySetter(ol.format.XSD.readString, + 'facsimile') + } + ); + + +/** + * @const + * @type {Object.>} + * @private + */ +ol.format.OWSCapabilities.REQUEST_METHOD_PARSERS_ = ol.xml.makeParsersNS( + ol.format.OWSCapabilities.NAMESPACE_URIS_, { + 'Constraint': ol.format.OWSCapabilities.readConstraint_ + }); + + +/** + * @const + * @type {Object.>} + * @private + */ +ol.format.OWSCapabilities.SERVICE_CONTACT_PARSERS_ = + ol.xml.makeParsersNS( + ol.format.OWSCapabilities.NAMESPACE_URIS_, { + 'IndividualName' : ol.xml.makeObjectPropertySetter( + ol.format.XSD.readString, 'individualName'), + 'PositionName' : ol.xml.makeObjectPropertySetter(ol.format.XSD.readString, + 'positionName'), + 'ContactInfo' : ol.xml.makeObjectPropertySetter( + ol.format.OWSCapabilities.readContactInfo_, 'contactInfo') + } + ); + + +/** + * @const + * @type {Object.>} + * @private + */ +ol.format.OWSCapabilities.SERVICE_IDENTIFICATION_PARSERS_ = + ol.xml.makeParsersNS( + ol.format.OWSCapabilities.NAMESPACE_URIS_, { + 'Title' : ol.xml.makeObjectPropertySetter(ol.format.XSD.readString, + 'title'), + 'ServiceTypeVersion' : ol.xml.makeObjectPropertySetter( + ol.format.XSD.readString, 'serviceTypeVersion'), + 'ServiceType' : ol.xml.makeObjectPropertySetter( + ol.format.XSD.readString, 'serviceType') + }); + + +/** + * @const + * @type {Object.>} + * @private + */ +ol.format.OWSCapabilities.SERVICE_PROVIDER_PARSERS_ = + ol.xml.makeParsersNS( + ol.format.OWSCapabilities.NAMESPACE_URIS_, { + 'ProviderName' : ol.xml.makeObjectPropertySetter(ol.format.XSD.readString, + 'providerName'), + 'ProviderSite' : ol.xml.makeObjectPropertySetter(ol.format.XLink.readHref, + 'providerSite'), + 'ServiceContact' : ol.xml.makeObjectPropertySetter( + ol.format.OWSCapabilities.readServiceContact_, 'serviceContact') + } + ); diff --git a/test/spec/ol/format/owscapabilitiesformat.test.js b/test/spec/ol/format/owscapabilitiesformat.test.js new file mode 100644 index 0000000000..d0db568d13 --- /dev/null +++ b/test/spec/ol/format/owscapabilitiesformat.test.js @@ -0,0 +1,154 @@ +goog.provide('ol.test.format.OWSCapabilities'); + +goog.require('ol.xml'); + +describe('ol.format.OWSCapabilities 1.1', function() { + + var parser = new ol.format.OWSCapabilities(); + + it('should read ServiceProvider tag properly', function() { + var doc = ol.xml.load( + '' + + '' + + 'MiraMon' + + '' + + '' + + 'Joan Maso Pau' + + '' + + 'Senior Software Engineer' + + '' + + '' + + '' + + '+34 93 581 1312' + + '+34 93 581 4151' + + '' + + '' + + '' + + 'Fac Ciencies UAB' + + '' + + 'Bellaterra' + + 'Barcelona' + + '' + + '08193' + + 'Spain' + + 'joan.maso@uab.es' + + '' + + '' + + '' + + '' + + '' + + '' + ); + + var obj = parser.read(doc); + expect(obj).to.be.ok(); + var serviceProvider = obj.serviceProvider; + expect(serviceProvider).to.be.ok(); + expect(serviceProvider.providerName).to.eql('MiraMon'); + var url = 'http://www.creaf.uab.es/miramon'; + expect(serviceProvider.providerSite).to.eql(url); + var name = 'Joan Maso Pau'; + expect(serviceProvider.serviceContact.individualName).to.eql(name); + var position = 'Senior Software Engineer'; + expect(serviceProvider.serviceContact.positionName).to.eql(position); + }); + + it('should read ServiceIdentification tag properly', function() { + var doc = ol.xml.load( + '' + + '' + + 'Web Map Tile Service' + + 'Service that contrains the map access interface ' + + 'to some TileMatrixSets' + + '' + + 'tile' + + 'tile matrix set' + + 'map' + + '' + + 'OGC WMTS' + + '1.0.0' + + 'none' + + 'none' + + '' + + '' + ); + var obj = parser.readFromNode(doc.firstChild); + expect(obj).to.be.ok(); + + var serviceIdentification = obj.serviceIdentification; + expect(serviceIdentification).to.be.ok(); + expect(serviceIdentification.title).to.eql('Web Map Tile Service'); + expect(serviceIdentification.serviceTypeVersion).to.eql('1.0.0'); + expect(serviceIdentification.serviceType).to.eql('OGC WMTS'); + }); + + it('should read OperationsMetadata tag properly', function() { + var doc = ol.xml.load( + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + 'KVP' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + ); + var obj = parser.readFromNode(doc.firstChild); + expect(obj).to.be.ok(); + + var operationsMetadata = obj.operationsMetadata; + expect(operationsMetadata).to.be.ok(); + var dcp = operationsMetadata.GetCapabilities.dcp; + var url = 'http://www.miramon.uab.es/cgi-bin/MiraMon5_0.cgi?'; + expect(dcp.http.get[0].url).to.eql(url); + dcp = operationsMetadata.GetCapabilities.dcp; + expect(dcp.http.get[0].constraints.GetEncoding.allowedValues).to.eql( + {'KVP': true}); + url = 'http://www.miramon.uab.es/cgi-bin/MiraMon5_0.cgi?'; + dcp = operationsMetadata.GetFeatureInfo.dcp; + expect(dcp.http.get[0].url).to.eql(url); + dcp = operationsMetadata.GetFeatureInfo.dcp; + expect(dcp.http.get[0].constraints).to.be(undefined); + url = 'http://www.miramon.uab.es/cgi-bin/MiraMon5_0.cgi?'; + expect(operationsMetadata.GetTile.dcp.http.get[0].url).to.eql(url); + dcp = operationsMetadata.GetTile.dcp; + expect(dcp.http.get[0].constraints).to.be(undefined); + }); + +}); + +goog.require('ol.format.OWSCapabilities'); From 00da1405b6b4bc20f2f52d698ae52ffe417a8e94 Mon Sep 17 00:00:00 2001 From: Hadrien Tulipe Date: Sun, 16 Mar 2014 20:18:14 +0100 Subject: [PATCH 2/5] Remove commented code --- src/ol/format/owscapabilitiesformat.js | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/ol/format/owscapabilitiesformat.js b/src/ol/format/owscapabilitiesformat.js index c525bd6aa2..9f3bfeaca4 100644 --- a/src/ol/format/owscapabilitiesformat.js +++ b/src/ol/format/owscapabilitiesformat.js @@ -159,16 +159,6 @@ ol.format.OWSCapabilities.readGet_ = function(node, objectStack) { ol.format.OWSCapabilities.readHttp_ = function(node, objectStack) { goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); goog.asserts.assert(node.localName == 'HTTP'); - /*var rawArray = ol.xml.pushParseAndPop([], - ol.format.OWSCapabilities.HTTP_PARSERS_, node, objectStack); - var object = {}; - goog.array.forEach(rawArray,function(item){ - if(goog.isDef(object[item.method])){ - object[item.method].push(item.url); - } else { - object[item.method] = [item.url]; - } - });*/ return ol.xml.pushParseAndPop({}, ol.format.OWSCapabilities.HTTP_PARSERS_, node, objectStack); }; From 149e5c9068e4d418830c1a54d5dfd4075f9c1929 Mon Sep 17 00:00:00 2001 From: Hadrien Tulipe Date: Mon, 17 Mar 2014 21:03:41 +0100 Subject: [PATCH 3/5] Fix syntax and private functions return values for OWS format --- src/ol/format/owscapabilitiesformat.js | 72 +++++++++++++++----------- 1 file changed, 42 insertions(+), 30 deletions(-) diff --git a/src/ol/format/owscapabilitiesformat.js b/src/ol/format/owscapabilitiesformat.js index 9f3bfeaca4..8ff4b4eb2e 100644 --- a/src/ol/format/owscapabilitiesformat.js +++ b/src/ol/format/owscapabilitiesformat.js @@ -90,6 +90,9 @@ ol.format.OWSCapabilities.readConstraint_ = function(node, objectStack) { var value = ol.xml.pushParseAndPop({}, ol.format.OWSCapabilities.CONSTRAINT_PARSERS_, node, objectStack); + if (!goog.isDef(value)) { + return undefined; + } if (!goog.isDef(object.constraints)) { object.constraints = {}; } @@ -140,11 +143,15 @@ ol.format.OWSCapabilities.readGet_ = function(node, objectStack) { goog.asserts.assert(goog.isObject(object)); var value = ol.xml.pushParseAndPop({'url': url}, ol.format.OWSCapabilities.REQUEST_METHOD_PARSERS_, node, objectStack); - if (!goog.isDef(object.get)) { + if (!goog.isDef(value)) { + return undefined; + } + var get = goog.object.get(object, 'get'); + if (!goog.isDef(get)) { goog.object.set(object, 'get', [value]); }else { - goog.asserts.assert(goog.isArray(object.get)); - object.get.push(value); + goog.asserts.assert(goog.isArray(get)); + get.push(value); } }; @@ -176,6 +183,9 @@ ol.format.OWSCapabilities.readOperation_ = function(node, objectStack) { var name = node.getAttribute('name'); var value = ol.xml.pushParseAndPop({}, ol.format.OWSCapabilities.OPERATION_PARSERS_, node, objectStack); + if (!goog.isDef(value)) { + return undefined; + } var object = /** @type {Object} */ (objectStack[objectStack.length - 1]); goog.asserts.assert(goog.isObject(object)); @@ -271,7 +281,10 @@ ol.format.OWSCapabilities.readValue_ = function(node, objectStack) { goog.asserts.assert(node.localName == 'Value'); var object = objectStack[objectStack.length - 1]; goog.asserts.assert(goog.isObject(object)); - var key = /** @type {string} */ (ol.format.XSD.readString(node)); + var key = ol.format.XSD.readString(node); + if (!goog.isDef(key)) { + return undefined; + } goog.object.set(object, key, true); }; @@ -294,17 +307,16 @@ ol.format.OWSCapabilities.NAMESPACE_URIS_ = [ */ ol.format.OWSCapabilities.PARSERS_ = ol.xml.makeParsersNS( ol.format.OWSCapabilities.NAMESPACE_URIS_, { - 'ServiceIdentification' : ol.xml.makeObjectPropertySetter( + 'ServiceIdentification': ol.xml.makeObjectPropertySetter( ol.format.OWSCapabilities.readServiceIdentification_, 'serviceIdentification'), - 'ServiceProvider' : ol.xml.makeObjectPropertySetter( + 'ServiceProvider': ol.xml.makeObjectPropertySetter( ol.format.OWSCapabilities.readServiceProvider_, 'serviceProvider'), 'OperationsMetadata': ol.xml.makeObjectPropertySetter( ol.format.OWSCapabilities.readOperationsMetadata_, 'operationsMetadata') - } - ); + }); /** @@ -314,17 +326,17 @@ ol.format.OWSCapabilities.PARSERS_ = ol.xml.makeParsersNS( */ ol.format.OWSCapabilities.ADDRESS_PARSERS_ = ol.xml.makeParsersNS( ol.format.OWSCapabilities.NAMESPACE_URIS_, { - 'DeliveryPoint' : ol.xml.makeObjectPropertySetter( + 'DeliveryPoint': ol.xml.makeObjectPropertySetter( ol.format.XSD.readString, 'deliveryPoint'), - 'City' : ol.xml.makeObjectPropertySetter(ol.format.XSD.readString, + 'City': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString, 'city'), - 'AdministrativeArea' : ol.xml.makeObjectPropertySetter( + 'AdministrativeArea': ol.xml.makeObjectPropertySetter( ol.format.XSD.readString, 'administrativeArea'), - 'PostalCode' : ol.xml.makeObjectPropertySetter(ol.format.XSD.readString, + 'PostalCode': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString, 'postalCode'), - 'Country' : ol.xml.makeObjectPropertySetter( + 'Country': ol.xml.makeObjectPropertySetter( ol.format.XSD.readString, 'country'), - 'ElectronicMailAddress' : ol.xml.makeObjectPropertySetter( + 'ElectronicMailAddress': ol.xml.makeObjectPropertySetter( ol.format.XSD.readString, 'electronicMailAddress') } ); @@ -363,9 +375,9 @@ ol.format.OWSCapabilities.CONSTRAINT_PARSERS_ = ol.xml.makeParsersNS( */ ol.format.OWSCapabilities.CONTACT_INFO_PARSERS_ = ol.xml.makeParsersNS( ol.format.OWSCapabilities.NAMESPACE_URIS_, { - 'Phone' : ol.xml.makeObjectPropertySetter( + 'Phone': ol.xml.makeObjectPropertySetter( ol.format.OWSCapabilities.readPhone_, 'phone'), - 'Address' : ol.xml.makeObjectPropertySetter( + 'Address': ol.xml.makeObjectPropertySetter( ol.format.OWSCapabilities.readAddress_, 'address') } ); @@ -378,7 +390,7 @@ ol.format.OWSCapabilities.CONTACT_INFO_PARSERS_ = ol.xml.makeParsersNS( */ ol.format.OWSCapabilities.DCP_PARSERS_ = ol.xml.makeParsersNS( ol.format.OWSCapabilities.NAMESPACE_URIS_, { - 'HTTP' : ol.xml.makeObjectPropertySetter( + 'HTTP': ol.xml.makeObjectPropertySetter( ol.format.OWSCapabilities.readHttp_, 'http') } ); @@ -404,7 +416,7 @@ ol.format.OWSCapabilities.HTTP_PARSERS_ = ol.xml.makeParsersNS( */ ol.format.OWSCapabilities.OPERATION_PARSERS_ = ol.xml.makeParsersNS( ol.format.OWSCapabilities.NAMESPACE_URIS_, { - 'DCP' : ol.xml.makeObjectPropertySetter( + 'DCP': ol.xml.makeObjectPropertySetter( ol.format.OWSCapabilities.readDcp_, 'dcp') } ); @@ -417,7 +429,7 @@ ol.format.OWSCapabilities.OPERATION_PARSERS_ = ol.xml.makeParsersNS( */ ol.format.OWSCapabilities.OPERATIONS_METADATA_PARSERS_ = ol.xml.makeParsersNS( ol.format.OWSCapabilities.NAMESPACE_URIS_, { - 'Operation' : ol.format.OWSCapabilities.readOperation_ + 'Operation': ol.format.OWSCapabilities.readOperation_ } ); @@ -429,9 +441,9 @@ ol.format.OWSCapabilities.OPERATIONS_METADATA_PARSERS_ = ol.xml.makeParsersNS( */ ol.format.OWSCapabilities.PHONE_PARSERS_ = ol.xml.makeParsersNS( ol.format.OWSCapabilities.NAMESPACE_URIS_, { - 'Voice' : ol.xml.makeObjectPropertySetter(ol.format.XSD.readString, + 'Voice': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString, 'voice'), - 'Facsimile' : ol.xml.makeObjectPropertySetter(ol.format.XSD.readString, + 'Facsimile': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString, 'facsimile') } ); @@ -456,11 +468,11 @@ ol.format.OWSCapabilities.REQUEST_METHOD_PARSERS_ = ol.xml.makeParsersNS( ol.format.OWSCapabilities.SERVICE_CONTACT_PARSERS_ = ol.xml.makeParsersNS( ol.format.OWSCapabilities.NAMESPACE_URIS_, { - 'IndividualName' : ol.xml.makeObjectPropertySetter( + 'IndividualName': ol.xml.makeObjectPropertySetter( ol.format.XSD.readString, 'individualName'), - 'PositionName' : ol.xml.makeObjectPropertySetter(ol.format.XSD.readString, + 'PositionName': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString, 'positionName'), - 'ContactInfo' : ol.xml.makeObjectPropertySetter( + 'ContactInfo': ol.xml.makeObjectPropertySetter( ol.format.OWSCapabilities.readContactInfo_, 'contactInfo') } ); @@ -474,11 +486,11 @@ ol.format.OWSCapabilities.SERVICE_CONTACT_PARSERS_ = ol.format.OWSCapabilities.SERVICE_IDENTIFICATION_PARSERS_ = ol.xml.makeParsersNS( ol.format.OWSCapabilities.NAMESPACE_URIS_, { - 'Title' : ol.xml.makeObjectPropertySetter(ol.format.XSD.readString, + 'Title': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString, 'title'), - 'ServiceTypeVersion' : ol.xml.makeObjectPropertySetter( + 'ServiceTypeVersion': ol.xml.makeObjectPropertySetter( ol.format.XSD.readString, 'serviceTypeVersion'), - 'ServiceType' : ol.xml.makeObjectPropertySetter( + 'ServiceType': ol.xml.makeObjectPropertySetter( ol.format.XSD.readString, 'serviceType') }); @@ -491,11 +503,11 @@ ol.format.OWSCapabilities.SERVICE_IDENTIFICATION_PARSERS_ = ol.format.OWSCapabilities.SERVICE_PROVIDER_PARSERS_ = ol.xml.makeParsersNS( ol.format.OWSCapabilities.NAMESPACE_URIS_, { - 'ProviderName' : ol.xml.makeObjectPropertySetter(ol.format.XSD.readString, + 'ProviderName': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString, 'providerName'), - 'ProviderSite' : ol.xml.makeObjectPropertySetter(ol.format.XLink.readHref, + 'ProviderSite': ol.xml.makeObjectPropertySetter(ol.format.XLink.readHref, 'providerSite'), - 'ServiceContact' : ol.xml.makeObjectPropertySetter( + 'ServiceContact': ol.xml.makeObjectPropertySetter( ol.format.OWSCapabilities.readServiceContact_, 'serviceContact') } ); From 58e74229d2a41c96a8e15f687c16188596bb066d Mon Sep 17 00:00:00 2001 From: Hadrien Tulipe Date: Mon, 17 Mar 2014 21:10:47 +0100 Subject: [PATCH 4/5] Rename ol.format.OWSCapabilities to ol.format.OWS --- ...{owscapabilitiesformat.js => owsformat.js} | 152 +++++++++--------- ...litiesformat.test.js => owsformat.test.js} | 8 +- 2 files changed, 80 insertions(+), 80 deletions(-) rename src/ol/format/{owscapabilitiesformat.js => owsformat.js} (67%) rename test/spec/ol/format/{owscapabilitiesformat.test.js => owsformat.test.js} (97%) diff --git a/src/ol/format/owscapabilitiesformat.js b/src/ol/format/owsformat.js similarity index 67% rename from src/ol/format/owscapabilitiesformat.js rename to src/ol/format/owsformat.js index 8ff4b4eb2e..0c120e5bd7 100644 --- a/src/ol/format/owscapabilitiesformat.js +++ b/src/ol/format/owsformat.js @@ -1,4 +1,4 @@ -goog.provide('ol.format.OWSCapabilities'); +goog.provide('ol.format.OWS'); goog.require('goog.asserts'); goog.require('goog.dom.NodeType'); @@ -14,17 +14,17 @@ goog.require('ol.xml'); * @constructor * @extends {ol.format.XML} */ -ol.format.OWSCapabilities = function() { +ol.format.OWS = function() { goog.base(this); }; -goog.inherits(ol.format.OWSCapabilities, ol.format.XML); +goog.inherits(ol.format.OWS, ol.format.XML); /** * @param {Document} doc Document. * @return {Object} OWS object. */ -ol.format.OWSCapabilities.prototype.readFromDocument = function(doc) { +ol.format.OWS.prototype.readFromDocument = function(doc) { goog.asserts.assert(doc.nodeType == goog.dom.NodeType.DOCUMENT); for (var n = doc.firstChild; !goog.isNull(n); n = n.nextSibling) { if (n.nodeType == goog.dom.NodeType.ELEMENT) { @@ -39,10 +39,10 @@ ol.format.OWSCapabilities.prototype.readFromDocument = function(doc) { * @param {Node} node Node. * @return {Object} OWS object. */ -ol.format.OWSCapabilities.prototype.readFromNode = function(node) { +ol.format.OWS.prototype.readFromNode = function(node) { goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); var owsObject = ol.xml.pushParseAndPop({}, - ol.format.OWSCapabilities.PARSERS_, node, []); + ol.format.OWS.PARSERS_, node, []); return goog.isDef(owsObject) ? owsObject : null; }; @@ -53,11 +53,11 @@ ol.format.OWSCapabilities.prototype.readFromNode = function(node) { * @private * @return {Object|undefined} */ -ol.format.OWSCapabilities.readAddress_ = function(node, objectStack) { +ol.format.OWS.readAddress_ = function(node, objectStack) { goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); goog.asserts.assert(node.localName == 'Address'); return ol.xml.pushParseAndPop({}, - ol.format.OWSCapabilities.ADDRESS_PARSERS_, node, objectStack); + ol.format.OWS.ADDRESS_PARSERS_, node, objectStack); }; @@ -67,11 +67,11 @@ ol.format.OWSCapabilities.readAddress_ = function(node, objectStack) { * @private * @return {Object|undefined} */ -ol.format.OWSCapabilities.readAllowedValues_ = function(node, objectStack) { +ol.format.OWS.readAllowedValues_ = function(node, objectStack) { goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); goog.asserts.assert(node.localName == 'AllowedValues'); return ol.xml.pushParseAndPop({}, - ol.format.OWSCapabilities.ALLOWED_VALUES_PARSERS_, node, objectStack); + ol.format.OWS.ALLOWED_VALUES_PARSERS_, node, objectStack); }; @@ -81,14 +81,14 @@ ol.format.OWSCapabilities.readAllowedValues_ = function(node, objectStack) { * @private * @return {Object|undefined} */ -ol.format.OWSCapabilities.readConstraint_ = function(node, objectStack) { +ol.format.OWS.readConstraint_ = function(node, objectStack) { goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); goog.asserts.assert(node.localName == 'Constraint'); var object = objectStack[objectStack.length - 1]; goog.asserts.assert(goog.isObject(object)); var name = node.getAttribute('name'); var value = ol.xml.pushParseAndPop({}, - ol.format.OWSCapabilities.CONSTRAINT_PARSERS_, node, + ol.format.OWS.CONSTRAINT_PARSERS_, node, objectStack); if (!goog.isDef(value)) { return undefined; @@ -107,11 +107,11 @@ ol.format.OWSCapabilities.readConstraint_ = function(node, objectStack) { * @private * @return {Object|undefined} */ -ol.format.OWSCapabilities.readContactInfo_ = function(node, objectStack) { +ol.format.OWS.readContactInfo_ = function(node, objectStack) { goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); goog.asserts.assert(node.localName == 'ContactInfo'); return ol.xml.pushParseAndPop({}, - ol.format.OWSCapabilities.CONTACT_INFO_PARSERS_, node, objectStack); + ol.format.OWS.CONTACT_INFO_PARSERS_, node, objectStack); }; @@ -121,11 +121,11 @@ ol.format.OWSCapabilities.readContactInfo_ = function(node, objectStack) { * @private * @return {Object|undefined} */ -ol.format.OWSCapabilities.readDcp_ = function(node, objectStack) { +ol.format.OWS.readDcp_ = function(node, objectStack) { goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); goog.asserts.assert(node.localName == 'DCP'); return ol.xml.pushParseAndPop({}, - ol.format.OWSCapabilities.DCP_PARSERS_, node, objectStack); + ol.format.OWS.DCP_PARSERS_, node, objectStack); }; @@ -135,14 +135,14 @@ ol.format.OWSCapabilities.readDcp_ = function(node, objectStack) { * @private * @return {Object|undefined} */ -ol.format.OWSCapabilities.readGet_ = function(node, objectStack) { +ol.format.OWS.readGet_ = function(node, objectStack) { goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); goog.asserts.assert(node.localName == 'Get'); var object = objectStack[objectStack.length - 1]; var url = ol.format.XLink.readHref(node); goog.asserts.assert(goog.isObject(object)); var value = ol.xml.pushParseAndPop({'url': url}, - ol.format.OWSCapabilities.REQUEST_METHOD_PARSERS_, node, objectStack); + ol.format.OWS.REQUEST_METHOD_PARSERS_, node, objectStack); if (!goog.isDef(value)) { return undefined; } @@ -163,10 +163,10 @@ ol.format.OWSCapabilities.readGet_ = function(node, objectStack) { * @private * @return {Object|undefined} */ -ol.format.OWSCapabilities.readHttp_ = function(node, objectStack) { +ol.format.OWS.readHttp_ = function(node, objectStack) { goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); goog.asserts.assert(node.localName == 'HTTP'); - return ol.xml.pushParseAndPop({}, ol.format.OWSCapabilities.HTTP_PARSERS_, + return ol.xml.pushParseAndPop({}, ol.format.OWS.HTTP_PARSERS_, node, objectStack); }; @@ -177,12 +177,12 @@ ol.format.OWSCapabilities.readHttp_ = function(node, objectStack) { * @private * @return {Object|undefined} */ -ol.format.OWSCapabilities.readOperation_ = function(node, objectStack) { +ol.format.OWS.readOperation_ = function(node, objectStack) { goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); goog.asserts.assert(node.localName == 'Operation'); var name = node.getAttribute('name'); var value = ol.xml.pushParseAndPop({}, - ol.format.OWSCapabilities.OPERATION_PARSERS_, node, objectStack); + ol.format.OWS.OPERATION_PARSERS_, node, objectStack); if (!goog.isDef(value)) { return undefined; } @@ -200,12 +200,12 @@ ol.format.OWSCapabilities.readOperation_ = function(node, objectStack) { * @private * @return {Object|undefined} */ -ol.format.OWSCapabilities.readOperationsMetadata_ = function(node, +ol.format.OWS.readOperationsMetadata_ = function(node, objectStack) { goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); goog.asserts.assert(node.localName == 'OperationsMetadata'); return ol.xml.pushParseAndPop({}, - ol.format.OWSCapabilities.OPERATIONS_METADATA_PARSERS_, node, + ol.format.OWS.OPERATIONS_METADATA_PARSERS_, node, objectStack); }; @@ -216,11 +216,11 @@ ol.format.OWSCapabilities.readOperationsMetadata_ = function(node, * @private * @return {Object|undefined} */ -ol.format.OWSCapabilities.readPhone_ = function(node, objectStack) { +ol.format.OWS.readPhone_ = function(node, objectStack) { goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); goog.asserts.assert(node.localName == 'Phone'); return ol.xml.pushParseAndPop({}, - ol.format.OWSCapabilities.PHONE_PARSERS_, node, objectStack); + ol.format.OWS.PHONE_PARSERS_, node, objectStack); }; @@ -230,12 +230,12 @@ ol.format.OWSCapabilities.readPhone_ = function(node, objectStack) { * @private * @return {Object|undefined} */ -ol.format.OWSCapabilities.readServiceIdentification_ = function(node, +ol.format.OWS.readServiceIdentification_ = function(node, objectStack) { goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); goog.asserts.assert(node.localName == 'ServiceIdentification'); return ol.xml.pushParseAndPop( - {}, ol.format.OWSCapabilities.SERVICE_IDENTIFICATION_PARSERS_, node, + {}, ol.format.OWS.SERVICE_IDENTIFICATION_PARSERS_, node, objectStack); }; @@ -246,11 +246,11 @@ ol.format.OWSCapabilities.readServiceIdentification_ = function(node, * @private * @return {Object|undefined} */ -ol.format.OWSCapabilities.readServiceContact_ = function(node, objectStack) { +ol.format.OWS.readServiceContact_ = function(node, objectStack) { goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); goog.asserts.assert(node.localName == 'ServiceContact'); return ol.xml.pushParseAndPop( - {}, ol.format.OWSCapabilities.SERVICE_CONTACT_PARSERS_, node, + {}, ol.format.OWS.SERVICE_CONTACT_PARSERS_, node, objectStack); }; @@ -261,11 +261,11 @@ ol.format.OWSCapabilities.readServiceContact_ = function(node, objectStack) { * @private * @return {Object|undefined} */ -ol.format.OWSCapabilities.readServiceProvider_ = function(node, objectStack) { +ol.format.OWS.readServiceProvider_ = function(node, objectStack) { goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); goog.asserts.assert(node.localName == 'ServiceProvider'); return ol.xml.pushParseAndPop( - {}, ol.format.OWSCapabilities.SERVICE_PROVIDER_PARSERS_, node, + {}, ol.format.OWS.SERVICE_PROVIDER_PARSERS_, node, objectStack); }; @@ -276,7 +276,7 @@ ol.format.OWSCapabilities.readServiceProvider_ = function(node, objectStack) { * @private * @return {Object|undefined} */ -ol.format.OWSCapabilities.readValue_ = function(node, objectStack) { +ol.format.OWS.readValue_ = function(node, objectStack) { goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT); goog.asserts.assert(node.localName == 'Value'); var object = objectStack[objectStack.length - 1]; @@ -294,7 +294,7 @@ ol.format.OWSCapabilities.readValue_ = function(node, objectStack) { * @type {Array.} * @private */ -ol.format.OWSCapabilities.NAMESPACE_URIS_ = [ +ol.format.OWS.NAMESPACE_URIS_ = [ null, 'http://www.opengis.net/ows/1.1' ]; @@ -305,16 +305,16 @@ ol.format.OWSCapabilities.NAMESPACE_URIS_ = [ * @type {Object.>} * @private */ -ol.format.OWSCapabilities.PARSERS_ = ol.xml.makeParsersNS( - ol.format.OWSCapabilities.NAMESPACE_URIS_, { +ol.format.OWS.PARSERS_ = ol.xml.makeParsersNS( + ol.format.OWS.NAMESPACE_URIS_, { 'ServiceIdentification': ol.xml.makeObjectPropertySetter( - ol.format.OWSCapabilities.readServiceIdentification_, + ol.format.OWS.readServiceIdentification_, 'serviceIdentification'), 'ServiceProvider': ol.xml.makeObjectPropertySetter( - ol.format.OWSCapabilities.readServiceProvider_, + ol.format.OWS.readServiceProvider_, 'serviceProvider'), 'OperationsMetadata': ol.xml.makeObjectPropertySetter( - ol.format.OWSCapabilities.readOperationsMetadata_, + ol.format.OWS.readOperationsMetadata_, 'operationsMetadata') }); @@ -324,8 +324,8 @@ ol.format.OWSCapabilities.PARSERS_ = ol.xml.makeParsersNS( * @type {Object.>} * @private */ -ol.format.OWSCapabilities.ADDRESS_PARSERS_ = ol.xml.makeParsersNS( - ol.format.OWSCapabilities.NAMESPACE_URIS_, { +ol.format.OWS.ADDRESS_PARSERS_ = ol.xml.makeParsersNS( + ol.format.OWS.NAMESPACE_URIS_, { 'DeliveryPoint': ol.xml.makeObjectPropertySetter( ol.format.XSD.readString, 'deliveryPoint'), 'City': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString, @@ -347,9 +347,9 @@ ol.format.OWSCapabilities.ADDRESS_PARSERS_ = ol.xml.makeParsersNS( * @type {Object.>} * @private */ -ol.format.OWSCapabilities.ALLOWED_VALUES_PARSERS_ = ol.xml.makeParsersNS( - ol.format.OWSCapabilities.NAMESPACE_URIS_, { - 'Value': ol.format.OWSCapabilities.readValue_ +ol.format.OWS.ALLOWED_VALUES_PARSERS_ = ol.xml.makeParsersNS( + ol.format.OWS.NAMESPACE_URIS_, { + 'Value': ol.format.OWS.readValue_ } ); @@ -359,10 +359,10 @@ ol.format.OWSCapabilities.ALLOWED_VALUES_PARSERS_ = ol.xml.makeParsersNS( * @type {Object.>} * @private */ -ol.format.OWSCapabilities.CONSTRAINT_PARSERS_ = ol.xml.makeParsersNS( - ol.format.OWSCapabilities.NAMESPACE_URIS_, { +ol.format.OWS.CONSTRAINT_PARSERS_ = ol.xml.makeParsersNS( + ol.format.OWS.NAMESPACE_URIS_, { 'AllowedValues': ol.xml.makeObjectPropertySetter( - ol.format.OWSCapabilities.readAllowedValues_, 'allowedValues' + ol.format.OWS.readAllowedValues_, 'allowedValues' ) } ); @@ -373,12 +373,12 @@ ol.format.OWSCapabilities.CONSTRAINT_PARSERS_ = ol.xml.makeParsersNS( * @type {Object.>} * @private */ -ol.format.OWSCapabilities.CONTACT_INFO_PARSERS_ = ol.xml.makeParsersNS( - ol.format.OWSCapabilities.NAMESPACE_URIS_, { +ol.format.OWS.CONTACT_INFO_PARSERS_ = ol.xml.makeParsersNS( + ol.format.OWS.NAMESPACE_URIS_, { 'Phone': ol.xml.makeObjectPropertySetter( - ol.format.OWSCapabilities.readPhone_, 'phone'), + ol.format.OWS.readPhone_, 'phone'), 'Address': ol.xml.makeObjectPropertySetter( - ol.format.OWSCapabilities.readAddress_, 'address') + ol.format.OWS.readAddress_, 'address') } ); @@ -388,10 +388,10 @@ ol.format.OWSCapabilities.CONTACT_INFO_PARSERS_ = ol.xml.makeParsersNS( * @type {Object.>} * @private */ -ol.format.OWSCapabilities.DCP_PARSERS_ = ol.xml.makeParsersNS( - ol.format.OWSCapabilities.NAMESPACE_URIS_, { +ol.format.OWS.DCP_PARSERS_ = ol.xml.makeParsersNS( + ol.format.OWS.NAMESPACE_URIS_, { 'HTTP': ol.xml.makeObjectPropertySetter( - ol.format.OWSCapabilities.readHttp_, 'http') + ol.format.OWS.readHttp_, 'http') } ); @@ -401,9 +401,9 @@ ol.format.OWSCapabilities.DCP_PARSERS_ = ol.xml.makeParsersNS( * @type {Object.>} * @private */ -ol.format.OWSCapabilities.HTTP_PARSERS_ = ol.xml.makeParsersNS( - ol.format.OWSCapabilities.NAMESPACE_URIS_, { - 'Get': ol.format.OWSCapabilities.readGet_, +ol.format.OWS.HTTP_PARSERS_ = ol.xml.makeParsersNS( + ol.format.OWS.NAMESPACE_URIS_, { + 'Get': ol.format.OWS.readGet_, 'Post': undefined // TODO } ); @@ -414,10 +414,10 @@ ol.format.OWSCapabilities.HTTP_PARSERS_ = ol.xml.makeParsersNS( * @type {Object.>} * @private */ -ol.format.OWSCapabilities.OPERATION_PARSERS_ = ol.xml.makeParsersNS( - ol.format.OWSCapabilities.NAMESPACE_URIS_, { +ol.format.OWS.OPERATION_PARSERS_ = ol.xml.makeParsersNS( + ol.format.OWS.NAMESPACE_URIS_, { 'DCP': ol.xml.makeObjectPropertySetter( - ol.format.OWSCapabilities.readDcp_, 'dcp') + ol.format.OWS.readDcp_, 'dcp') } ); @@ -427,9 +427,9 @@ ol.format.OWSCapabilities.OPERATION_PARSERS_ = ol.xml.makeParsersNS( * @type {Object.>} * @private */ -ol.format.OWSCapabilities.OPERATIONS_METADATA_PARSERS_ = ol.xml.makeParsersNS( - ol.format.OWSCapabilities.NAMESPACE_URIS_, { - 'Operation': ol.format.OWSCapabilities.readOperation_ +ol.format.OWS.OPERATIONS_METADATA_PARSERS_ = ol.xml.makeParsersNS( + ol.format.OWS.NAMESPACE_URIS_, { + 'Operation': ol.format.OWS.readOperation_ } ); @@ -439,8 +439,8 @@ ol.format.OWSCapabilities.OPERATIONS_METADATA_PARSERS_ = ol.xml.makeParsersNS( * @type {Object.>} * @private */ -ol.format.OWSCapabilities.PHONE_PARSERS_ = ol.xml.makeParsersNS( - ol.format.OWSCapabilities.NAMESPACE_URIS_, { +ol.format.OWS.PHONE_PARSERS_ = ol.xml.makeParsersNS( + ol.format.OWS.NAMESPACE_URIS_, { 'Voice': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString, 'voice'), 'Facsimile': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString, @@ -454,9 +454,9 @@ ol.format.OWSCapabilities.PHONE_PARSERS_ = ol.xml.makeParsersNS( * @type {Object.>} * @private */ -ol.format.OWSCapabilities.REQUEST_METHOD_PARSERS_ = ol.xml.makeParsersNS( - ol.format.OWSCapabilities.NAMESPACE_URIS_, { - 'Constraint': ol.format.OWSCapabilities.readConstraint_ +ol.format.OWS.REQUEST_METHOD_PARSERS_ = ol.xml.makeParsersNS( + ol.format.OWS.NAMESPACE_URIS_, { + 'Constraint': ol.format.OWS.readConstraint_ }); @@ -465,15 +465,15 @@ ol.format.OWSCapabilities.REQUEST_METHOD_PARSERS_ = ol.xml.makeParsersNS( * @type {Object.>} * @private */ -ol.format.OWSCapabilities.SERVICE_CONTACT_PARSERS_ = +ol.format.OWS.SERVICE_CONTACT_PARSERS_ = ol.xml.makeParsersNS( - ol.format.OWSCapabilities.NAMESPACE_URIS_, { + ol.format.OWS.NAMESPACE_URIS_, { 'IndividualName': ol.xml.makeObjectPropertySetter( ol.format.XSD.readString, 'individualName'), 'PositionName': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString, 'positionName'), 'ContactInfo': ol.xml.makeObjectPropertySetter( - ol.format.OWSCapabilities.readContactInfo_, 'contactInfo') + ol.format.OWS.readContactInfo_, 'contactInfo') } ); @@ -483,9 +483,9 @@ ol.format.OWSCapabilities.SERVICE_CONTACT_PARSERS_ = * @type {Object.>} * @private */ -ol.format.OWSCapabilities.SERVICE_IDENTIFICATION_PARSERS_ = +ol.format.OWS.SERVICE_IDENTIFICATION_PARSERS_ = ol.xml.makeParsersNS( - ol.format.OWSCapabilities.NAMESPACE_URIS_, { + ol.format.OWS.NAMESPACE_URIS_, { 'Title': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString, 'title'), 'ServiceTypeVersion': ol.xml.makeObjectPropertySetter( @@ -500,14 +500,14 @@ ol.format.OWSCapabilities.SERVICE_IDENTIFICATION_PARSERS_ = * @type {Object.>} * @private */ -ol.format.OWSCapabilities.SERVICE_PROVIDER_PARSERS_ = +ol.format.OWS.SERVICE_PROVIDER_PARSERS_ = ol.xml.makeParsersNS( - ol.format.OWSCapabilities.NAMESPACE_URIS_, { + ol.format.OWS.NAMESPACE_URIS_, { 'ProviderName': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString, 'providerName'), 'ProviderSite': ol.xml.makeObjectPropertySetter(ol.format.XLink.readHref, 'providerSite'), 'ServiceContact': ol.xml.makeObjectPropertySetter( - ol.format.OWSCapabilities.readServiceContact_, 'serviceContact') + ol.format.OWS.readServiceContact_, 'serviceContact') } ); diff --git a/test/spec/ol/format/owscapabilitiesformat.test.js b/test/spec/ol/format/owsformat.test.js similarity index 97% rename from test/spec/ol/format/owscapabilitiesformat.test.js rename to test/spec/ol/format/owsformat.test.js index d0db568d13..d79c7439fb 100644 --- a/test/spec/ol/format/owscapabilitiesformat.test.js +++ b/test/spec/ol/format/owsformat.test.js @@ -1,10 +1,10 @@ -goog.provide('ol.test.format.OWSCapabilities'); +goog.provide('ol.test.format.OWS'); goog.require('ol.xml'); -describe('ol.format.OWSCapabilities 1.1', function() { +describe('ol.format.OWS 1.1', function() { - var parser = new ol.format.OWSCapabilities(); + var parser = new ol.format.OWS(); it('should read ServiceProvider tag properly', function() { var doc = ol.xml.load( @@ -151,4 +151,4 @@ describe('ol.format.OWSCapabilities 1.1', function() { }); -goog.require('ol.format.OWSCapabilities'); +goog.require('ol.format.OWS'); From f325cc3d7ad35a711e2eb2d20a06eb66254346cc Mon Sep 17 00:00:00 2001 From: Hadrien Tulipe Date: Mon, 17 Mar 2014 21:15:03 +0100 Subject: [PATCH 5/5] More syntax fix for OWS format --- src/ol/format/owsformat.js | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/src/ol/format/owsformat.js b/src/ol/format/owsformat.js index 0c120e5bd7..5a4e5d48a6 100644 --- a/src/ol/format/owsformat.js +++ b/src/ol/format/owsformat.js @@ -338,8 +338,7 @@ ol.format.OWS.ADDRESS_PARSERS_ = ol.xml.makeParsersNS( ol.format.XSD.readString, 'country'), 'ElectronicMailAddress': ol.xml.makeObjectPropertySetter( ol.format.XSD.readString, 'electronicMailAddress') - } - ); + }); /** @@ -350,8 +349,7 @@ ol.format.OWS.ADDRESS_PARSERS_ = ol.xml.makeParsersNS( ol.format.OWS.ALLOWED_VALUES_PARSERS_ = ol.xml.makeParsersNS( ol.format.OWS.NAMESPACE_URIS_, { 'Value': ol.format.OWS.readValue_ - } - ); + }); /** @@ -364,8 +362,7 @@ ol.format.OWS.CONSTRAINT_PARSERS_ = ol.xml.makeParsersNS( 'AllowedValues': ol.xml.makeObjectPropertySetter( ol.format.OWS.readAllowedValues_, 'allowedValues' ) - } - ); + }); /** @@ -379,8 +376,7 @@ ol.format.OWS.CONTACT_INFO_PARSERS_ = ol.xml.makeParsersNS( ol.format.OWS.readPhone_, 'phone'), 'Address': ol.xml.makeObjectPropertySetter( ol.format.OWS.readAddress_, 'address') - } - ); + }); /** @@ -392,8 +388,7 @@ ol.format.OWS.DCP_PARSERS_ = ol.xml.makeParsersNS( ol.format.OWS.NAMESPACE_URIS_, { 'HTTP': ol.xml.makeObjectPropertySetter( ol.format.OWS.readHttp_, 'http') - } - ); + }); /** @@ -405,8 +400,7 @@ ol.format.OWS.HTTP_PARSERS_ = ol.xml.makeParsersNS( ol.format.OWS.NAMESPACE_URIS_, { 'Get': ol.format.OWS.readGet_, 'Post': undefined // TODO - } - ); + }); /** @@ -418,8 +412,7 @@ ol.format.OWS.OPERATION_PARSERS_ = ol.xml.makeParsersNS( ol.format.OWS.NAMESPACE_URIS_, { 'DCP': ol.xml.makeObjectPropertySetter( ol.format.OWS.readDcp_, 'dcp') - } - ); + }); /** @@ -430,8 +423,7 @@ ol.format.OWS.OPERATION_PARSERS_ = ol.xml.makeParsersNS( ol.format.OWS.OPERATIONS_METADATA_PARSERS_ = ol.xml.makeParsersNS( ol.format.OWS.NAMESPACE_URIS_, { 'Operation': ol.format.OWS.readOperation_ - } - ); + }); /** @@ -445,8 +437,7 @@ ol.format.OWS.PHONE_PARSERS_ = ol.xml.makeParsersNS( 'voice'), 'Facsimile': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString, 'facsimile') - } - ); + }); /** @@ -474,8 +465,7 @@ ol.format.OWS.SERVICE_CONTACT_PARSERS_ = 'positionName'), 'ContactInfo': ol.xml.makeObjectPropertySetter( ol.format.OWS.readContactInfo_, 'contactInfo') - } - ); + }); /** @@ -509,5 +499,4 @@ ol.format.OWS.SERVICE_PROVIDER_PARSERS_ = 'providerSite'), 'ServiceContact': ol.xml.makeObjectPropertySetter( ol.format.OWS.readServiceContact_, 'serviceContact') - } - ); + });