Merge pull request #1610 from fredj/wms-capabilities
Add ol.format.WMSCapabilities format
This commit is contained in:
2
src/ol/format/wmscapabilitiesformat.exports
Normal file
2
src/ol/format/wmscapabilitiesformat.exports
Normal file
@@ -0,0 +1,2 @@
|
||||
@exportSymbol ol.format.WMSCapabilities
|
||||
@exportProperty ol.format.WMSCapabilities.prototype.read
|
||||
818
src/ol/format/wmscapabilitiesformat.js
Normal file
818
src/ol/format/wmscapabilitiesformat.js
Normal file
@@ -0,0 +1,818 @@
|
||||
goog.provide('ol.format.WMSCapabilities');
|
||||
|
||||
goog.require('goog.array');
|
||||
goog.require('goog.asserts');
|
||||
goog.require('goog.dom.NodeType');
|
||||
goog.require('goog.object');
|
||||
goog.require('goog.string');
|
||||
goog.require('ol.format.XLink');
|
||||
goog.require('ol.format.XML');
|
||||
goog.require('ol.format.XSD');
|
||||
goog.require('ol.xml');
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {{westBoundLongitude: number,
|
||||
* southBoundLatitude: number,
|
||||
* eastBoundLongitude: number,
|
||||
* northBoundLatitude: number}}
|
||||
*/
|
||||
ol.format.EXGeographicBoundingBoxType;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.format.XML}
|
||||
*/
|
||||
ol.format.WMSCapabilities = function() {
|
||||
|
||||
goog.base(this);
|
||||
|
||||
/**
|
||||
* @type {string|undefined}
|
||||
*/
|
||||
this.version = undefined;
|
||||
};
|
||||
goog.inherits(ol.format.WMSCapabilities, ol.format.XML);
|
||||
|
||||
|
||||
/**
|
||||
* @param {Document} doc Document.
|
||||
* @return {Object} WMS Capability object.
|
||||
*/
|
||||
ol.format.WMSCapabilities.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} WMS Capability object.
|
||||
*/
|
||||
ol.format.WMSCapabilities.prototype.readFromNode = function(node) {
|
||||
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
|
||||
goog.asserts.assert(node.localName == 'WMS_Capabilities' ||
|
||||
node.localName == 'WMT_MS_Capabilities');
|
||||
this.version = goog.string.trim(node.getAttribute('version'));
|
||||
goog.asserts.assertString(this.version);
|
||||
var wmsCapabilityObject = ol.xml.pushParseAndPop({
|
||||
'version': this.version
|
||||
}, ol.format.WMSCapabilities.PARSERS_, node, []);
|
||||
return goog.isDef(wmsCapabilityObject) ? wmsCapabilityObject : null;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @param {Node} node Node.
|
||||
* @param {Array.<*>} objectStack Object stack.
|
||||
* @return {Object|undefined} Attribution object.
|
||||
*/
|
||||
ol.format.WMSCapabilities.readAttribution_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
|
||||
goog.asserts.assert(node.localName == 'Attribution');
|
||||
return ol.xml.pushParseAndPop(
|
||||
{}, ol.format.WMSCapabilities.ATTRIBUTION_PARSERS_, node, objectStack);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @param {Node} node Node.
|
||||
* @param {Array.<*>} objectStack Object stack.
|
||||
* @return {Object} Bounding box object.
|
||||
*/
|
||||
ol.format.WMSCapabilities.readBoundingBox_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
|
||||
goog.asserts.assert(node.localName == 'BoundingBox');
|
||||
|
||||
var extent = [
|
||||
ol.format.XSD.readDecimalString(node.getAttribute('minx')),
|
||||
ol.format.XSD.readDecimalString(node.getAttribute('miny')),
|
||||
ol.format.XSD.readDecimalString(node.getAttribute('maxx')),
|
||||
ol.format.XSD.readDecimalString(node.getAttribute('maxy'))
|
||||
];
|
||||
|
||||
var resolutions = [
|
||||
ol.format.XSD.readDecimalString(node.getAttribute('resx')),
|
||||
ol.format.XSD.readDecimalString(node.getAttribute('resy'))
|
||||
];
|
||||
|
||||
return {
|
||||
'crs': node.getAttribute('CRS'),
|
||||
'extent': extent,
|
||||
'res': resolutions
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @param {Node} node Node.
|
||||
* @param {Array.<*>} objectStack Object stack.
|
||||
* @return {ol.Extent|undefined} Bounding box object.
|
||||
*/
|
||||
ol.format.WMSCapabilities.readEXGeographicBoundingBox_ =
|
||||
function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
|
||||
goog.asserts.assert(node.localName == 'EX_GeographicBoundingBox');
|
||||
var geographicBoundingBox = ol.xml.pushParseAndPop(
|
||||
/** @type {ol.format.EXGeographicBoundingBoxType} */ ({}),
|
||||
ol.format.WMSCapabilities.EX_GEOGRAPHIC_BOUNDING_BOX_PARSERS_,
|
||||
node, objectStack);
|
||||
if (goog.isDef(geographicBoundingBox)) {
|
||||
return [
|
||||
geographicBoundingBox.westBoundLongitude,
|
||||
geographicBoundingBox.southBoundLatitude,
|
||||
geographicBoundingBox.eastBoundLongitude,
|
||||
geographicBoundingBox.northBoundLatitude
|
||||
];
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {Node} node Node.
|
||||
* @param {Array.<*>} objectStack Object stack.
|
||||
* @private
|
||||
* @return {Object|undefined} Capability object.
|
||||
*/
|
||||
ol.format.WMSCapabilities.readCapability_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
|
||||
goog.asserts.assert(node.localName == 'Capability');
|
||||
return ol.xml.pushParseAndPop(
|
||||
{}, ol.format.WMSCapabilities.CAPABILITY_PARSERS_, node, objectStack);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {Node} node Node.
|
||||
* @param {Array.<*>} objectStack Object stack.
|
||||
* @private
|
||||
* @return {Object|undefined} Service object.
|
||||
*/
|
||||
ol.format.WMSCapabilities.readService_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
|
||||
goog.asserts.assert(node.localName == 'Service');
|
||||
return ol.xml.pushParseAndPop(
|
||||
{}, ol.format.WMSCapabilities.SERVICE_PARSERS_, node, objectStack);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {Node} node Node.
|
||||
* @param {Array.<*>} objectStack Object stack.
|
||||
* @private
|
||||
* @return {Object|undefined} Contact information object.
|
||||
*/
|
||||
ol.format.WMSCapabilities.readContactInformation_ =
|
||||
function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
|
||||
goog.asserts.assert(node.localName == 'ContactInformation');
|
||||
return ol.xml.pushParseAndPop(
|
||||
{}, ol.format.WMSCapabilities.CONTACT_INFORMATION_PARSERS_,
|
||||
node, objectStack);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {Node} node Node.
|
||||
* @param {Array.<*>} objectStack Object stack.
|
||||
* @private
|
||||
* @return {Object|undefined} Contact person object.
|
||||
*/
|
||||
ol.format.WMSCapabilities.readContactPersonPrimary_ =
|
||||
function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
|
||||
goog.asserts.assert(node.localName == 'ContactPersonPrimary');
|
||||
return ol.xml.pushParseAndPop(
|
||||
{}, ol.format.WMSCapabilities.CONTACT_PERSON_PARSERS_,
|
||||
node, objectStack);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {Node} node Node.
|
||||
* @param {Array.<*>} objectStack Object stack.
|
||||
* @private
|
||||
* @return {Object|undefined} Contact address object.
|
||||
*/
|
||||
ol.format.WMSCapabilities.readContactAddress_ =
|
||||
function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
|
||||
goog.asserts.assert(node.localName == 'ContactAddress');
|
||||
return ol.xml.pushParseAndPop(
|
||||
{}, ol.format.WMSCapabilities.CONTACT_ADDRESS_PARSERS_,
|
||||
node, objectStack);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {Node} node Node.
|
||||
* @param {Array.<*>} objectStack Object stack.
|
||||
* @private
|
||||
* @return {Array.<string>|undefined} Format array.
|
||||
*/
|
||||
ol.format.WMSCapabilities.readException_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
|
||||
goog.asserts.assert(node.localName == 'Exception');
|
||||
return ol.xml.pushParseAndPop(
|
||||
[], ol.format.WMSCapabilities.EXCEPTION_PARSERS_, node, objectStack);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {Node} node Node.
|
||||
* @param {Array.<*>} objectStack Object stack.
|
||||
* @private
|
||||
* @return {Object|undefined} Layer object.
|
||||
*/
|
||||
ol.format.WMSCapabilities.readCapabilityLayer_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
|
||||
goog.asserts.assert(node.localName == 'Layer');
|
||||
return ol.xml.pushParseAndPop(
|
||||
{}, ol.format.WMSCapabilities.LAYER_PARSERS_, node, objectStack);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @param {Node} node Node.
|
||||
* @param {Array.<*>} objectStack Object stack.
|
||||
* @return {Object|undefined} Layer object.
|
||||
*/
|
||||
ol.format.WMSCapabilities.readLayer_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
|
||||
goog.asserts.assert(node.localName == 'Layer');
|
||||
var parentLayerObject = /** @type {Object.<string,*>} */
|
||||
(objectStack[objectStack.length - 1]);
|
||||
|
||||
var layerObject = /** @type {Object.<string,*>} */ (ol.xml.pushParseAndPop(
|
||||
{}, ol.format.WMSCapabilities.LAYER_PARSERS_, node, objectStack));
|
||||
|
||||
if (!goog.isDef(layerObject)) {
|
||||
return undefined;
|
||||
}
|
||||
var queryable =
|
||||
ol.format.XSD.readBooleanString(node.getAttribute('queryable'));
|
||||
if (!goog.isDef(queryable)) {
|
||||
queryable = goog.object.get(parentLayerObject, 'queryable');
|
||||
}
|
||||
goog.object.set(
|
||||
layerObject, 'queryable', goog.isDef(queryable) ? queryable : false);
|
||||
|
||||
var cascaded = ol.format.XSD.readNonNegativeIntegerString(
|
||||
node.getAttribute('cascaded'));
|
||||
if (!goog.isDef(cascaded)) {
|
||||
cascaded = goog.object.get(parentLayerObject, 'cascaded');
|
||||
}
|
||||
goog.object.set(layerObject, 'cascaded', cascaded);
|
||||
|
||||
var opaque = ol.format.XSD.readBooleanString(node.getAttribute('opaque'));
|
||||
if (!goog.isDef(opaque)) {
|
||||
opaque = goog.object.get(parentLayerObject, 'opaque');
|
||||
}
|
||||
goog.object.set(layerObject, 'opaque', goog.isDef(opaque) ? opaque : false);
|
||||
|
||||
var noSubsets =
|
||||
ol.format.XSD.readBooleanString(node.getAttribute('noSubsets'));
|
||||
if (!goog.isDef(noSubsets)) {
|
||||
noSubsets = goog.object.get(parentLayerObject, 'noSubsets');
|
||||
}
|
||||
goog.object.set(
|
||||
layerObject, 'noSubsets', goog.isDef(noSubsets) ? noSubsets : false);
|
||||
|
||||
var fixedWidth =
|
||||
ol.format.XSD.readDecimalString(node.getAttribute('fixedWidth'));
|
||||
if (!goog.isDef(fixedWidth)) {
|
||||
fixedWidth = goog.object.get(parentLayerObject, 'fixedWidth');
|
||||
}
|
||||
goog.object.set(layerObject, 'fixedWidth', fixedWidth);
|
||||
|
||||
var fixedHeight =
|
||||
ol.format.XSD.readDecimalString(node.getAttribute('fixedHeight'));
|
||||
if (!goog.isDef(fixedHeight)) {
|
||||
fixedHeight = goog.object.get(parentLayerObject, 'fixedHeight');
|
||||
}
|
||||
goog.object.set(layerObject, 'fixedHeight', fixedHeight);
|
||||
|
||||
// See 7.2.4.8
|
||||
var addKeys = ['Style', 'CRS', 'AuthorityURL'];
|
||||
goog.array.forEach(addKeys, function(key) {
|
||||
var parentValue = goog.object.get(parentLayerObject, key);
|
||||
if (goog.isDef(parentValue)) {
|
||||
var childValue = goog.object.setIfUndefined(layerObject, key, []);
|
||||
childValue = childValue.concat(parentValue);
|
||||
}
|
||||
});
|
||||
|
||||
var replaceKeys = ['EX_GeographicBoundingBox', 'BoundingBox', 'Dimension',
|
||||
'Attribution', 'MinScaleDenominator', 'MaxScaleDenominator'];
|
||||
goog.array.forEach(replaceKeys, function(key) {
|
||||
var childValue = goog.object.get(layerObject, key);
|
||||
if (!goog.isDef(childValue)) {
|
||||
var parentValue = goog.object.get(parentLayerObject, key);
|
||||
goog.object.set(layerObject, key, parentValue);
|
||||
}
|
||||
});
|
||||
|
||||
return layerObject;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @param {Node} node Node.
|
||||
* @param {Array.<*>} objectStack Object stack.
|
||||
* @return {Object} Dimension object.
|
||||
*/
|
||||
ol.format.WMSCapabilities.readDimension_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
|
||||
goog.asserts.assert(node.localName == 'Dimension');
|
||||
var dimensionObject = {
|
||||
'name': node.getAttribute('name'),
|
||||
'units': node.getAttribute('units'),
|
||||
'unitSymbol': node.getAttribute('unitSymbol'),
|
||||
'default': node.getAttribute('default'),
|
||||
'multipleValues': ol.format.XSD.readBooleanString(
|
||||
node.getAttribute('multipleValues')),
|
||||
'nearestValue': ol.format.XSD.readBooleanString(
|
||||
node.getAttribute('nearestValue')),
|
||||
'current': ol.format.XSD.readBooleanString(node.getAttribute('current')),
|
||||
'values': ol.format.XSD.readString(node)
|
||||
};
|
||||
return dimensionObject;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @param {Node} node Node.
|
||||
* @param {Array.<*>} objectStack Object stack.
|
||||
* @return {Object|undefined} Online resource object.
|
||||
*/
|
||||
ol.format.WMSCapabilities.readFormatOnlineresource_ =
|
||||
function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
|
||||
return ol.xml.pushParseAndPop(
|
||||
{}, ol.format.WMSCapabilities.FORMAT_ONLINERESOURCE_PARSERS_,
|
||||
node, objectStack);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @param {Node} node Node.
|
||||
* @param {Array.<*>} objectStack Object stack.
|
||||
* @return {Object|undefined} Request object.
|
||||
*/
|
||||
ol.format.WMSCapabilities.readRequest_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
|
||||
goog.asserts.assert(node.localName == 'Request');
|
||||
return ol.xml.pushParseAndPop(
|
||||
{}, ol.format.WMSCapabilities.REQUEST_PARSERS_, node, objectStack);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @param {Node} node Node.
|
||||
* @param {Array.<*>} objectStack Object stack.
|
||||
* @return {Object|undefined} DCP type object.
|
||||
*/
|
||||
ol.format.WMSCapabilities.readDCPType_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
|
||||
goog.asserts.assert(node.localName == 'DCPType');
|
||||
return ol.xml.pushParseAndPop(
|
||||
{}, ol.format.WMSCapabilities.DCPTYPE_PARSERS_, node, objectStack);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @param {Node} node Node.
|
||||
* @param {Array.<*>} objectStack Object stack.
|
||||
* @return {Object|undefined} HTTP object.
|
||||
*/
|
||||
ol.format.WMSCapabilities.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.WMSCapabilities.HTTP_PARSERS_, node, objectStack);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @param {Node} node Node.
|
||||
* @param {Array.<*>} objectStack Object stack.
|
||||
* @return {Object|undefined} Operation type object.
|
||||
*/
|
||||
ol.format.WMSCapabilities.readOperationType_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
|
||||
return ol.xml.pushParseAndPop(
|
||||
{}, ol.format.WMSCapabilities.OPERATIONTYPE_PARSERS_, node, objectStack);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @param {Node} node Node.
|
||||
* @param {Array.<*>} objectStack Object stack.
|
||||
* @return {Object|undefined} Online resource object.
|
||||
*/
|
||||
ol.format.WMSCapabilities.readSizedFormatOnlineresource_ =
|
||||
function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
|
||||
var formatOnlineresource =
|
||||
ol.format.WMSCapabilities.readFormatOnlineresource_(node, objectStack);
|
||||
if (goog.isDef(formatOnlineresource)) {
|
||||
var size = [
|
||||
ol.format.XSD.readNonNegativeIntegerString(node.getAttribute('width')),
|
||||
ol.format.XSD.readNonNegativeIntegerString(node.getAttribute('height'))
|
||||
];
|
||||
goog.object.set(formatOnlineresource, 'size', size);
|
||||
return formatOnlineresource;
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @param {Node} node Node.
|
||||
* @param {Array.<*>} objectStack Object stack.
|
||||
* @return {Object|undefined} Authority URL object.
|
||||
*/
|
||||
ol.format.WMSCapabilities.readAuthorityURL_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
|
||||
goog.asserts.assert(node.localName == 'AuthorityURL');
|
||||
var authorityObject =
|
||||
ol.format.WMSCapabilities.readFormatOnlineresource_(node, objectStack);
|
||||
if (goog.isDef(authorityObject)) {
|
||||
goog.object.set(authorityObject, 'name', node.getAttribute('name'));
|
||||
return authorityObject;
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @param {Node} node Node.
|
||||
* @param {Array.<*>} objectStack Object stack.
|
||||
* @return {Object|undefined} Metadata URL object.
|
||||
*/
|
||||
ol.format.WMSCapabilities.readMetadataURL_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
|
||||
goog.asserts.assert(node.localName == 'MetadataURL');
|
||||
var metadataObject =
|
||||
ol.format.WMSCapabilities.readFormatOnlineresource_(node, objectStack);
|
||||
if (goog.isDef(metadataObject)) {
|
||||
goog.object.set(metadataObject, 'type', node.getAttribute('type'));
|
||||
return metadataObject;
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @param {Node} node Node.
|
||||
* @param {Array.<*>} objectStack Object stack.
|
||||
* @return {Object|undefined} Style object.
|
||||
*/
|
||||
ol.format.WMSCapabilities.readStyle_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
|
||||
goog.asserts.assert(node.localName == 'Style');
|
||||
return ol.xml.pushParseAndPop(
|
||||
{}, ol.format.WMSCapabilities.STYLE_PARSERS_, node, objectStack);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @param {Node} node Node.
|
||||
* @param {Array.<*>} objectStack Object stack.
|
||||
* @return {Array.<string>|undefined} Keyword list.
|
||||
*/
|
||||
ol.format.WMSCapabilities.readKeywordList_ = function(node, objectStack) {
|
||||
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT);
|
||||
goog.asserts.assert(node.localName == 'KeywordList');
|
||||
return ol.xml.pushParseAndPop(
|
||||
[], ol.format.WMSCapabilities.KEYWORDLIST_PARSERS_, node, objectStack);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @private
|
||||
* @type {Array.<string>}
|
||||
*/
|
||||
ol.format.WMSCapabilities.NAMESPACE_URIS_ = [
|
||||
null,
|
||||
'http://www.opengis.net/wms'
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, Object.<string, ol.xml.Parser>>}
|
||||
* @private
|
||||
*/
|
||||
ol.format.WMSCapabilities.PARSERS_ = ol.xml.makeParsersNS(
|
||||
ol.format.WMSCapabilities.NAMESPACE_URIS_, {
|
||||
'Service': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.WMSCapabilities.readService_),
|
||||
'Capability': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.WMSCapabilities.readCapability_)
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, Object.<string, ol.xml.Parser>>}
|
||||
* @private
|
||||
*/
|
||||
ol.format.WMSCapabilities.CAPABILITY_PARSERS_ = ol.xml.makeParsersNS(
|
||||
ol.format.WMSCapabilities.NAMESPACE_URIS_, {
|
||||
'Request': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.WMSCapabilities.readRequest_),
|
||||
'Exception': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.WMSCapabilities.readException_),
|
||||
'Layer': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.WMSCapabilities.readCapabilityLayer_)
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, Object.<string, ol.xml.Parser>>}
|
||||
* @private
|
||||
*/
|
||||
ol.format.WMSCapabilities.SERVICE_PARSERS_ = ol.xml.makeParsersNS(
|
||||
ol.format.WMSCapabilities.NAMESPACE_URIS_, {
|
||||
'Name': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString),
|
||||
'Title': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString),
|
||||
'Abstract': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString),
|
||||
'KeywordList': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.WMSCapabilities.readKeywordList_),
|
||||
'OnlineResource': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.XLink.readHref),
|
||||
'ContactInformation': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.WMSCapabilities.readContactInformation_),
|
||||
'Fees': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString),
|
||||
'AccessConstraints': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.XSD.readString),
|
||||
'LayerLimit': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.XSD.readNonNegativeInteger),
|
||||
'MaxWidth': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.XSD.readNonNegativeInteger),
|
||||
'MaxHeight': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.XSD.readNonNegativeInteger)
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, Object.<string, ol.xml.Parser>>}
|
||||
* @private
|
||||
*/
|
||||
ol.format.WMSCapabilities.CONTACT_INFORMATION_PARSERS_ = ol.xml.makeParsersNS(
|
||||
ol.format.WMSCapabilities.NAMESPACE_URIS_, {
|
||||
'ContactPersonPrimary': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.WMSCapabilities.readContactPersonPrimary_),
|
||||
'ContactPosition': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.XSD.readString),
|
||||
'ContactAddress': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.WMSCapabilities.readContactAddress_),
|
||||
'ContactVoiceTelephone': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.XSD.readString),
|
||||
'ContactFacsimileTelephone': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.XSD.readString),
|
||||
'ContactElectronicMailAddress': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.XSD.readString)
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, Object.<string, ol.xml.Parser>>}
|
||||
* @private
|
||||
*/
|
||||
ol.format.WMSCapabilities.CONTACT_PERSON_PARSERS_ = ol.xml.makeParsersNS(
|
||||
ol.format.WMSCapabilities.NAMESPACE_URIS_, {
|
||||
'ContactPerson': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.XSD.readString),
|
||||
'ContactOrganization': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.XSD.readString)
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, Object.<string, ol.xml.Parser>>}
|
||||
* @private
|
||||
*/
|
||||
ol.format.WMSCapabilities.CONTACT_ADDRESS_PARSERS_ = ol.xml.makeParsersNS(
|
||||
ol.format.WMSCapabilities.NAMESPACE_URIS_, {
|
||||
'AddressType': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString),
|
||||
'Address': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString),
|
||||
'City': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString),
|
||||
'StateOrProvince': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.XSD.readString),
|
||||
'PostCode': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString),
|
||||
'Country': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString)
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, Object.<string, ol.xml.Parser>>}
|
||||
* @private
|
||||
*/
|
||||
ol.format.WMSCapabilities.EXCEPTION_PARSERS_ = ol.xml.makeParsersNS(
|
||||
ol.format.WMSCapabilities.NAMESPACE_URIS_, {
|
||||
'Format': ol.xml.makeArrayPusher(ol.format.XSD.readString)
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, Object.<string, ol.xml.Parser>>}
|
||||
* @private
|
||||
*/
|
||||
ol.format.WMSCapabilities.LAYER_PARSERS_ = ol.xml.makeParsersNS(
|
||||
ol.format.WMSCapabilities.NAMESPACE_URIS_, {
|
||||
'Name': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString),
|
||||
'Title': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString),
|
||||
'Abstract': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString),
|
||||
'KeywordList': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.WMSCapabilities.readKeywordList_),
|
||||
'CRS': ol.xml.makeObjectPropertyPusher(ol.format.XSD.readString),
|
||||
'EX_GeographicBoundingBox': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.WMSCapabilities.readEXGeographicBoundingBox_),
|
||||
'BoundingBox': ol.xml.makeObjectPropertyPusher(
|
||||
ol.format.WMSCapabilities.readBoundingBox_),
|
||||
'Dimension': ol.xml.makeObjectPropertyPusher(
|
||||
ol.format.WMSCapabilities.readDimension_),
|
||||
'Attribution': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.WMSCapabilities.readAttribution_),
|
||||
'AuthorityURL': ol.xml.makeObjectPropertyPusher(
|
||||
ol.format.WMSCapabilities.readAuthorityURL_),
|
||||
'Identifier': ol.xml.makeObjectPropertyPusher(ol.format.XSD.readString),
|
||||
'MetadataURL': ol.xml.makeObjectPropertyPusher(
|
||||
ol.format.WMSCapabilities.readMetadataURL_),
|
||||
'DataURL': ol.xml.makeObjectPropertyPusher(
|
||||
ol.format.WMSCapabilities.readFormatOnlineresource_),
|
||||
'FeatureListURL': ol.xml.makeObjectPropertyPusher(
|
||||
ol.format.WMSCapabilities.readFormatOnlineresource_),
|
||||
'Style': ol.xml.makeObjectPropertyPusher(
|
||||
ol.format.WMSCapabilities.readStyle_),
|
||||
'MinScaleDenominator': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.XSD.readDecimal),
|
||||
'MaxScaleDenominator': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.XSD.readDecimal),
|
||||
'Layer': ol.xml.makeObjectPropertyPusher(
|
||||
ol.format.WMSCapabilities.readLayer_)
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, Object.<string, ol.xml.Parser>>}
|
||||
* @private
|
||||
*/
|
||||
ol.format.WMSCapabilities.ATTRIBUTION_PARSERS_ = ol.xml.makeParsersNS(
|
||||
ol.format.WMSCapabilities.NAMESPACE_URIS_, {
|
||||
'Title': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString),
|
||||
'OnlineResource': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.XLink.readHref),
|
||||
'LogoURL': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.WMSCapabilities.readSizedFormatOnlineresource_)
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, Object.<string, ol.xml.Parser>>}
|
||||
* @private
|
||||
*/
|
||||
ol.format.WMSCapabilities.EX_GEOGRAPHIC_BOUNDING_BOX_PARSERS_ =
|
||||
ol.xml.makeParsersNS(ol.format.WMSCapabilities.NAMESPACE_URIS_, {
|
||||
'westBoundLongitude': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.XSD.readDecimal),
|
||||
'eastBoundLongitude': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.XSD.readDecimal),
|
||||
'southBoundLatitude': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.XSD.readDecimal),
|
||||
'northBoundLatitude': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.XSD.readDecimal)
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, Object.<string, ol.xml.Parser>>}
|
||||
* @private
|
||||
*/
|
||||
ol.format.WMSCapabilities.REQUEST_PARSERS_ = ol.xml.makeParsersNS(
|
||||
ol.format.WMSCapabilities.NAMESPACE_URIS_, {
|
||||
'GetCapabilities': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.WMSCapabilities.readOperationType_),
|
||||
'GetMap': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.WMSCapabilities.readOperationType_),
|
||||
'GetFeatureInfo': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.WMSCapabilities.readOperationType_)
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, Object.<string, ol.xml.Parser>>}
|
||||
* @private
|
||||
*/
|
||||
ol.format.WMSCapabilities.OPERATIONTYPE_PARSERS_ = ol.xml.makeParsersNS(
|
||||
ol.format.WMSCapabilities.NAMESPACE_URIS_, {
|
||||
'Format': ol.xml.makeObjectPropertyPusher(ol.format.XSD.readString),
|
||||
'DCPType': ol.xml.makeObjectPropertyPusher(
|
||||
ol.format.WMSCapabilities.readDCPType_)
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, Object.<string, ol.xml.Parser>>}
|
||||
* @private
|
||||
*/
|
||||
ol.format.WMSCapabilities.DCPTYPE_PARSERS_ = ol.xml.makeParsersNS(
|
||||
ol.format.WMSCapabilities.NAMESPACE_URIS_, {
|
||||
'HTTP': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.WMSCapabilities.readHTTP_)
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, Object.<string, ol.xml.Parser>>}
|
||||
* @private
|
||||
*/
|
||||
ol.format.WMSCapabilities.HTTP_PARSERS_ = ol.xml.makeParsersNS(
|
||||
ol.format.WMSCapabilities.NAMESPACE_URIS_, {
|
||||
'Get': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.WMSCapabilities.readFormatOnlineresource_),
|
||||
'Post': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.WMSCapabilities.readFormatOnlineresource_)
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, Object.<string, ol.xml.Parser>>}
|
||||
* @private
|
||||
*/
|
||||
ol.format.WMSCapabilities.STYLE_PARSERS_ = ol.xml.makeParsersNS(
|
||||
ol.format.WMSCapabilities.NAMESPACE_URIS_, {
|
||||
'Name': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString),
|
||||
'Title': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString),
|
||||
'Abstract': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString),
|
||||
'LegendURL': ol.xml.makeObjectPropertyPusher(
|
||||
ol.format.WMSCapabilities.readSizedFormatOnlineresource_),
|
||||
'StyleSheetURL': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.WMSCapabilities.readFormatOnlineresource_),
|
||||
'StyleURL': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.WMSCapabilities.readFormatOnlineresource_)
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, Object.<string, ol.xml.Parser>>}
|
||||
* @private
|
||||
*/
|
||||
ol.format.WMSCapabilities.FORMAT_ONLINERESOURCE_PARSERS_ = ol.xml.makeParsersNS(
|
||||
ol.format.WMSCapabilities.NAMESPACE_URIS_, {
|
||||
'Format': ol.xml.makeObjectPropertySetter(ol.format.XSD.readString),
|
||||
'OnlineResource': ol.xml.makeObjectPropertySetter(
|
||||
ol.format.XLink.readHref)
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Object.<string, Object.<string, ol.xml.Parser>>}
|
||||
* @private
|
||||
*/
|
||||
ol.format.WMSCapabilities.KEYWORDLIST_PARSERS_ = ol.xml.makeParsersNS(
|
||||
ol.format.WMSCapabilities.NAMESPACE_URIS_, {
|
||||
'Keyword': ol.xml.makeArrayPusher(ol.format.XSD.readString)
|
||||
});
|
||||
17
src/ol/format/xlinkformat.js
Normal file
17
src/ol/format/xlinkformat.js
Normal file
@@ -0,0 +1,17 @@
|
||||
goog.provide('ol.format.XLink');
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {string}
|
||||
*/
|
||||
ol.format.XLink.NAMESPACE_URI = 'http://www.w3.org/1999/xlink';
|
||||
|
||||
|
||||
/**
|
||||
* @param {Node} node Node.
|
||||
* @return {boolean|undefined} Boolean.
|
||||
*/
|
||||
ol.format.XLink.readHref = function(node) {
|
||||
return node.getAttributeNS(ol.format.XLink.NAMESPACE_URI, 'href');
|
||||
};
|
||||
45
src/ol/format/xmlformat.js
Normal file
45
src/ol/format/xmlformat.js
Normal file
@@ -0,0 +1,45 @@
|
||||
goog.provide('ol.format.XML');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.xml');
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
ol.format.XML = function() {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {Document|Node|string} source Source.
|
||||
* @return {Object}
|
||||
*/
|
||||
ol.format.XML.prototype.read = function(source) {
|
||||
if (ol.xml.isDocument(source)) {
|
||||
return this.readFromDocument(/** @type {Document} */ (source));
|
||||
} else if (ol.xml.isNode(source)) {
|
||||
return this.readFromNode(/** @type {Node} */ (source));
|
||||
} else if (goog.isString(source)) {
|
||||
var doc = ol.xml.load(source);
|
||||
return this.readFromDocument(doc);
|
||||
} else {
|
||||
goog.asserts.fail();
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {Document} doc Document.
|
||||
* @return {Object}
|
||||
*/
|
||||
ol.format.XML.prototype.readFromDocument = goog.abstractMethod;
|
||||
|
||||
|
||||
/**
|
||||
* @param {Node} node Node.
|
||||
* @return {Object}
|
||||
*/
|
||||
ol.format.XML.prototype.readFromNode = goog.abstractMethod;
|
||||
@@ -1,96 +0,0 @@
|
||||
goog.provide('ol.parser.ogc.ExceptionReport');
|
||||
goog.require('goog.dom.xml');
|
||||
goog.require('ol.parser.XML');
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.parser.XML}
|
||||
*/
|
||||
ol.parser.ogc.ExceptionReport = function() {
|
||||
var exceptionReader = function(node, exceptionReport) {
|
||||
var exception = {
|
||||
code: node.getAttribute('exceptionCode'),
|
||||
locator: node.getAttribute('locator'),
|
||||
texts: []
|
||||
};
|
||||
exceptionReport.exceptions.push(exception);
|
||||
this.readChildNodes(node, exception);
|
||||
};
|
||||
var exceptionTextReader = function(node, exception) {
|
||||
var text = this.getChildValue(node);
|
||||
exception.texts.push(text);
|
||||
};
|
||||
this.readers = {
|
||||
'http://www.opengis.net/ogc': {
|
||||
'ServiceExceptionReport': function(node, obj) {
|
||||
obj['exceptionReport'] = {};
|
||||
obj['exceptionReport']['exceptions'] = [];
|
||||
this.readChildNodes(node, obj['exceptionReport']);
|
||||
},
|
||||
'ServiceException': function(node, exceptionReport) {
|
||||
var exception = {};
|
||||
exception['code'] = node.getAttribute('code');
|
||||
exception['locator'] = node.getAttribute('locator');
|
||||
exception['text'] = this.getChildValue(node);
|
||||
exceptionReport['exceptions'].push(exception);
|
||||
}
|
||||
},
|
||||
'http://www.opengis.net/ows': {
|
||||
'ExceptionReport': function(node, obj) {
|
||||
obj.success = false;
|
||||
obj.exceptionReport = {
|
||||
version: node.getAttribute('version'),
|
||||
language: node.getAttribute('language'),
|
||||
exceptions: []
|
||||
};
|
||||
this.readChildNodes(node, obj.exceptionReport);
|
||||
},
|
||||
'Exception': function(node, exceptionReport) {
|
||||
exceptionReader.apply(this, arguments);
|
||||
},
|
||||
'ExceptionText': function(node, exception) {
|
||||
exceptionTextReader.apply(this, arguments);
|
||||
}
|
||||
},
|
||||
'http://www.opengis.net/ows/1.1': {
|
||||
'ExceptionReport': function(node, obj) {
|
||||
obj.exceptionReport = {
|
||||
version: node.getAttribute('version'),
|
||||
language: node.getAttribute('xml:lang'),
|
||||
exceptions: []
|
||||
};
|
||||
this.readChildNodes(node, obj.exceptionReport);
|
||||
},
|
||||
'Exception': function(node, exceptionReport) {
|
||||
exceptionReader.apply(this, arguments);
|
||||
},
|
||||
'ExceptionText': function(node, exception) {
|
||||
exceptionTextReader.apply(this, arguments);
|
||||
}
|
||||
}
|
||||
};
|
||||
goog.base(this);
|
||||
};
|
||||
goog.inherits(ol.parser.ogc.ExceptionReport, ol.parser.XML);
|
||||
|
||||
|
||||
/**
|
||||
* Read OGC exception report data from a string, and return an object with
|
||||
* information about the exceptions.
|
||||
*
|
||||
* @param {string|Document} data to read/parse.
|
||||
* @return {Object} Information about the exceptions that occurred.
|
||||
*/
|
||||
ol.parser.ogc.ExceptionReport.prototype.read = function(data) {
|
||||
if (goog.isString(data)) {
|
||||
data = goog.dom.xml.loadXml(data);
|
||||
}
|
||||
var exceptionInfo = {};
|
||||
exceptionInfo['exceptionReport'] = null;
|
||||
if (data) {
|
||||
this.readChildNodes(data, exceptionInfo);
|
||||
}
|
||||
return exceptionInfo;
|
||||
};
|
||||
@@ -1,121 +0,0 @@
|
||||
goog.provide('ol.parser.ogc.Versioned');
|
||||
goog.require('goog.dom.xml');
|
||||
goog.require('ol.parser.ogc.ExceptionReport');
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @param {Object=} opt_options Options which will be set on this object.
|
||||
*/
|
||||
ol.parser.ogc.Versioned = function(opt_options) {
|
||||
var options = goog.isDef(opt_options) ? opt_options : {};
|
||||
this.options = options;
|
||||
this.defaultVersion = options.defaultVersion || null;
|
||||
this.version = options.version;
|
||||
this.profile = options.profile;
|
||||
if (goog.isDef(options.allowFallback)) {
|
||||
this.allowFallback = options.allowFallback;
|
||||
} else {
|
||||
this.allowFallback = false;
|
||||
}
|
||||
if (goog.isDef(options.stringifyOutput)) {
|
||||
this.stringifyOutput = options.stringifyOutput;
|
||||
} else {
|
||||
this.stringifyOutput = false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {Element} root root element.
|
||||
* @param {Object=} opt_options optional configuration object.
|
||||
* @return {string} the version to use.
|
||||
*/
|
||||
ol.parser.ogc.Versioned.prototype.getVersion = function(root, opt_options) {
|
||||
var version;
|
||||
// read
|
||||
if (root) {
|
||||
version = this.version;
|
||||
if (!version) {
|
||||
version = root.getAttribute('version');
|
||||
if (!version) {
|
||||
version = this.defaultVersion;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// write
|
||||
version = (opt_options && opt_options.version) ||
|
||||
this.version || this.defaultVersion;
|
||||
}
|
||||
return version;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {string} version the version to use.
|
||||
* @return {Object} the parser to use.
|
||||
*/
|
||||
ol.parser.ogc.Versioned.prototype.getParser = function(version) {
|
||||
version = version || this.defaultVersion;
|
||||
var profile = this.profile ? '_' + this.profile : '';
|
||||
if (!this.parser || this.parser.VERSION != version) {
|
||||
var format = this.parsers['v' + version.replace(/\./g, '_') + profile];
|
||||
if (!format) {
|
||||
if (profile !== '' && this.allowFallback) {
|
||||
// fallback to the non-profiled version of the parser
|
||||
profile = '';
|
||||
format = this.parsers['v' + version.replace(/\./g, '_') + profile];
|
||||
}
|
||||
if (!format) {
|
||||
throw 'Can\'t find a parser for version ' +
|
||||
version + profile;
|
||||
}
|
||||
}
|
||||
this.parser = new format(this.options);
|
||||
}
|
||||
return this.parser;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Write a document.
|
||||
*
|
||||
* @param {Object} obj An object representing the document.
|
||||
* @param {Object=} opt_options Optional configuration object.
|
||||
* @return {Element|string} the XML created.
|
||||
*/
|
||||
ol.parser.ogc.Versioned.prototype.write = function(obj, opt_options) {
|
||||
var version = this.getVersion(null, opt_options);
|
||||
this.parser = this.getParser(version);
|
||||
var root = this.parser.write(obj, opt_options);
|
||||
if (this.stringifyOutput === false) {
|
||||
return root;
|
||||
} else {
|
||||
return goog.dom.xml.serialize(root);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {string|Document} data Data to read.
|
||||
* @param {Object=} opt_options Options for the reader.
|
||||
* @return {Object} An object representing the document.
|
||||
*/
|
||||
ol.parser.ogc.Versioned.prototype.read = function(data, opt_options) {
|
||||
if (goog.isString(data)) {
|
||||
data = goog.dom.xml.loadXml(data);
|
||||
}
|
||||
var root = data.documentElement;
|
||||
var version = this.getVersion(root);
|
||||
this.parser = this.getParser(version);
|
||||
var obj = this.parser.read(data, opt_options);
|
||||
var errorProperty = this.parser.errorProperty || null;
|
||||
if (errorProperty !== null && obj[errorProperty] === undefined) {
|
||||
// an error must have happened, so parse it and report back
|
||||
var format = new ol.parser.ogc.ExceptionReport();
|
||||
obj.error = format.read(data);
|
||||
}
|
||||
obj.version = version;
|
||||
return obj;
|
||||
};
|
||||
@@ -1,2 +0,0 @@
|
||||
@exportSymbol ol.parser.ogc.WMSCapabilities
|
||||
@exportProperty ol.parser.ogc.WMSCapabilities.prototype.read
|
||||
@@ -1,69 +0,0 @@
|
||||
goog.provide('ol.parser.ogc.WMSCapabilities');
|
||||
goog.require('ol.parser.ogc.Versioned');
|
||||
goog.require('ol.parser.ogc.WMSCapabilities_v1_0_0');
|
||||
goog.require('ol.parser.ogc.WMSCapabilities_v1_1_0');
|
||||
goog.require('ol.parser.ogc.WMSCapabilities_v1_1_1');
|
||||
goog.require('ol.parser.ogc.WMSCapabilities_v1_1_1_WMSC');
|
||||
goog.require('ol.parser.ogc.WMSCapabilities_v1_3_0');
|
||||
|
||||
|
||||
/**
|
||||
* @define {boolean} Whether to enable WMS Capabilities version 1.0.0.
|
||||
*/
|
||||
ol.ENABLE_WMSCAPS_1_0_0 = false;
|
||||
|
||||
|
||||
/**
|
||||
* @define {boolean} Whether to enable WMS Capabilities version 1.1.0.
|
||||
*/
|
||||
ol.ENABLE_WMSCAPS_1_1_0 = true;
|
||||
|
||||
|
||||
/**
|
||||
* @define {boolean} Whether to enable WMS Capabilities version 1.1.1.
|
||||
*/
|
||||
ol.ENABLE_WMSCAPS_1_1_1 = true;
|
||||
|
||||
|
||||
/**
|
||||
* @define {boolean} Whether to enable WMS Capabilities version 1.3.0.
|
||||
*/
|
||||
ol.ENABLE_WMSCAPS_1_3_0 = true;
|
||||
|
||||
|
||||
/**
|
||||
* @define {boolean} Whether to enable WMS Capabilities version 1.1.1.
|
||||
* WMSC profile.
|
||||
*/
|
||||
ol.ENABLE_WMSCAPS_1_1_1_WMSC = true;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @param {Object=} opt_options Options which will be set on this object.
|
||||
* @extends {ol.parser.ogc.Versioned}
|
||||
* @todo stability experimental
|
||||
*/
|
||||
ol.parser.ogc.WMSCapabilities = function(opt_options) {
|
||||
opt_options = opt_options || {};
|
||||
opt_options['defaultVersion'] = '1.1.1';
|
||||
this.parsers = {};
|
||||
if (ol.ENABLE_WMSCAPS_1_0_0) {
|
||||
this.parsers['v1_0_0'] = ol.parser.ogc.WMSCapabilities_v1_0_0;
|
||||
}
|
||||
if (ol.ENABLE_WMSCAPS_1_1_0) {
|
||||
this.parsers['v1_1_0'] = ol.parser.ogc.WMSCapabilities_v1_1_0;
|
||||
}
|
||||
if (ol.ENABLE_WMSCAPS_1_1_1) {
|
||||
this.parsers['v1_1_1'] = ol.parser.ogc.WMSCapabilities_v1_1_1;
|
||||
}
|
||||
if (ol.ENABLE_WMSCAPS_1_1_1_WMSC) {
|
||||
this.parsers['v1_1_1_WMSC'] = ol.parser.ogc.WMSCapabilities_v1_1_1_WMSC;
|
||||
}
|
||||
if (ol.ENABLE_WMSCAPS_1_3_0) {
|
||||
this.parsers['v1_3_0'] = ol.parser.ogc.WMSCapabilities_v1_3_0;
|
||||
}
|
||||
goog.base(this, opt_options);
|
||||
};
|
||||
goog.inherits(ol.parser.ogc.WMSCapabilities, ol.parser.ogc.Versioned);
|
||||
@@ -1,317 +0,0 @@
|
||||
goog.provide('ol.parser.ogc.WMSCapabilities_v1');
|
||||
goog.require('goog.dom.xml');
|
||||
goog.require('goog.object');
|
||||
goog.require('ol.parser.XML');
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Read [WMS](http://www.opengeospatial.org/standards/wms) capabilities
|
||||
*
|
||||
* @constructor
|
||||
* @extends {ol.parser.XML}
|
||||
*/
|
||||
ol.parser.ogc.WMSCapabilities_v1 = function() {
|
||||
this.defaultNamespaceURI = 'http://www.opengis.net/wms';
|
||||
this.errorProperty = 'service';
|
||||
this.readers = {
|
||||
'http://www.opengis.net/wms': {
|
||||
'Service': function(node, obj) {
|
||||
obj['service'] = {};
|
||||
this.readChildNodes(node, obj['service']);
|
||||
},
|
||||
'Name': function(node, obj) {
|
||||
obj['name'] = this.getChildValue(node);
|
||||
},
|
||||
'Title': function(node, obj) {
|
||||
obj['title'] = this.getChildValue(node);
|
||||
},
|
||||
'Abstract': function(node, obj) {
|
||||
obj['abstract'] = this.getChildValue(node);
|
||||
},
|
||||
'BoundingBox': function(node, obj) {
|
||||
var bbox = {};
|
||||
bbox['bbox'] = [
|
||||
parseFloat(node.getAttribute('minx')),
|
||||
parseFloat(node.getAttribute('miny')),
|
||||
parseFloat(node.getAttribute('maxx')),
|
||||
parseFloat(node.getAttribute('maxy'))
|
||||
];
|
||||
var res = {
|
||||
x: parseFloat(node.getAttribute('resx')),
|
||||
y: parseFloat(node.getAttribute('resy'))
|
||||
};
|
||||
if (! (isNaN(res.x) && isNaN(res.y))) {
|
||||
bbox['res'] = res;
|
||||
}
|
||||
// return the bbox so that descendant classes can set the
|
||||
// CRS and SRS and add it to the obj
|
||||
return bbox;
|
||||
},
|
||||
'OnlineResource': function(node, obj) {
|
||||
obj['href'] = this.getAttributeNS(node, 'http://www.w3.org/1999/xlink',
|
||||
'href');
|
||||
},
|
||||
'ContactInformation': function(node, obj) {
|
||||
obj['contactInformation'] = {};
|
||||
this.readChildNodes(node, obj['contactInformation']);
|
||||
},
|
||||
'ContactPersonPrimary': function(node, obj) {
|
||||
obj['personPrimary'] = {};
|
||||
this.readChildNodes(node, obj['personPrimary']);
|
||||
},
|
||||
'ContactPerson': function(node, obj) {
|
||||
obj['person'] = this.getChildValue(node);
|
||||
},
|
||||
'ContactOrganization': function(node, obj) {
|
||||
obj['organization'] = this.getChildValue(node);
|
||||
},
|
||||
'ContactPosition': function(node, obj) {
|
||||
obj['position'] = this.getChildValue(node);
|
||||
},
|
||||
'ContactAddress': function(node, obj) {
|
||||
obj['contactAddress'] = {};
|
||||
this.readChildNodes(node, obj['contactAddress']);
|
||||
},
|
||||
'AddressType': function(node, obj) {
|
||||
obj['type'] = this.getChildValue(node);
|
||||
},
|
||||
'Address': function(node, obj) {
|
||||
obj['address'] = this.getChildValue(node);
|
||||
},
|
||||
'City': function(node, obj) {
|
||||
obj['city'] = this.getChildValue(node);
|
||||
},
|
||||
'StateOrProvince': function(node, obj) {
|
||||
obj['stateOrProvince'] = this.getChildValue(node);
|
||||
},
|
||||
'PostCode': function(node, obj) {
|
||||
obj['postcode'] = this.getChildValue(node);
|
||||
},
|
||||
'Country': function(node, obj) {
|
||||
obj['country'] = this.getChildValue(node);
|
||||
},
|
||||
'ContactVoiceTelephone': function(node, obj) {
|
||||
obj['phone'] = this.getChildValue(node);
|
||||
},
|
||||
'ContactFacsimileTelephone': function(node, obj) {
|
||||
obj['fax'] = this.getChildValue(node);
|
||||
},
|
||||
'ContactElectronicMailAddress': function(node, obj) {
|
||||
obj['email'] = this.getChildValue(node);
|
||||
},
|
||||
'Fees': function(node, obj) {
|
||||
var fees = this.getChildValue(node);
|
||||
if (fees && fees.toLowerCase() != 'none') {
|
||||
obj['fees'] = fees;
|
||||
}
|
||||
},
|
||||
'AccessConstraints': function(node, obj) {
|
||||
var constraints = this.getChildValue(node);
|
||||
if (constraints && constraints.toLowerCase() != 'none') {
|
||||
obj['accessConstraints'] = constraints;
|
||||
}
|
||||
},
|
||||
'Capability': function(node, obj) {
|
||||
obj['capability'] = {};
|
||||
obj['capability']['nestedLayers'] = [];
|
||||
obj['capability']['layers'] = [];
|
||||
this.readChildNodes(node, obj['capability']);
|
||||
},
|
||||
'Request': function(node, obj) {
|
||||
obj['request'] = {};
|
||||
this.readChildNodes(node, obj['request']);
|
||||
},
|
||||
'GetCapabilities': function(node, obj) {
|
||||
obj['getcapabilities'] = {};
|
||||
obj['getcapabilities']['formats'] = [];
|
||||
this.readChildNodes(node, obj['getcapabilities']);
|
||||
},
|
||||
'Format': function(node, obj) {
|
||||
if (goog.isArray(obj['formats'])) {
|
||||
obj['formats'].push(this.getChildValue(node));
|
||||
} else {
|
||||
obj['format'] = this.getChildValue(node);
|
||||
}
|
||||
},
|
||||
'DCPType': function(node, obj) {
|
||||
this.readChildNodes(node, obj);
|
||||
},
|
||||
'HTTP': function(node, obj) {
|
||||
this.readChildNodes(node, obj);
|
||||
},
|
||||
'Get': function(node, obj) {
|
||||
obj['get'] = {};
|
||||
this.readChildNodes(node, obj['get']);
|
||||
},
|
||||
'Post': function(node, obj) {
|
||||
obj['post'] = {};
|
||||
this.readChildNodes(node, obj['post']);
|
||||
},
|
||||
'GetMap': function(node, obj) {
|
||||
obj['getmap'] = {};
|
||||
obj['getmap']['formats'] = [];
|
||||
this.readChildNodes(node, obj['getmap']);
|
||||
},
|
||||
'GetFeatureInfo': function(node, obj) {
|
||||
obj['getfeatureinfo'] = {};
|
||||
obj['getfeatureinfo']['formats'] = [];
|
||||
this.readChildNodes(node, obj['getfeatureinfo']);
|
||||
},
|
||||
'Exception': function(node, obj) {
|
||||
obj['exception'] = {};
|
||||
obj['exception']['formats'] = [];
|
||||
this.readChildNodes(node, obj['exception']);
|
||||
},
|
||||
'Layer': function(node, obj) {
|
||||
var parentLayer, capability;
|
||||
if (obj['capability']) {
|
||||
capability = obj['capability'];
|
||||
parentLayer = obj;
|
||||
} else {
|
||||
capability = obj;
|
||||
}
|
||||
var attrNode = node.getAttributeNode('queryable');
|
||||
var queryable = (attrNode && attrNode.specified) ?
|
||||
node.getAttribute('queryable') : null;
|
||||
attrNode = node.getAttributeNode('cascaded');
|
||||
var cascaded = (attrNode && attrNode.specified) ?
|
||||
node.getAttribute('cascaded') : null;
|
||||
attrNode = node.getAttributeNode('opaque');
|
||||
var opaque = (attrNode && attrNode.specified) ?
|
||||
node.getAttribute('opaque') : null;
|
||||
var noSubsets = node.getAttribute('noSubsets');
|
||||
var fixedWidth = node.getAttribute('fixedWidth');
|
||||
var fixedHeight = node.getAttribute('fixedHeight');
|
||||
var parent = parentLayer || {};
|
||||
var layer = {
|
||||
'nestedLayers': [],
|
||||
'styles': parentLayer ? [].concat(parentLayer['styles']) : [],
|
||||
'srs': {},
|
||||
'metadataURLs': [],
|
||||
'bbox': {},
|
||||
'llbbox': parent['llbbox'],
|
||||
'dimensions': {},
|
||||
'authorityURLs': {},
|
||||
'identifiers': {},
|
||||
'keywords': [],
|
||||
'queryable': (queryable && queryable !== '') ?
|
||||
(queryable === '1' || queryable === 'true') :
|
||||
(parent['queryable'] || false),
|
||||
'cascaded': (cascaded !== null) ? parseInt(cascaded, 10) :
|
||||
(parent['cascaded'] || 0),
|
||||
'opaque': opaque ?
|
||||
(opaque === '1' || opaque === 'true') :
|
||||
(parent['opaque'] || false),
|
||||
'noSubsets': (noSubsets !== null) ?
|
||||
(noSubsets === '1' || noSubsets === 'true') :
|
||||
(parent['noSubsets'] || false),
|
||||
'fixedWidth': (fixedWidth !== null) ?
|
||||
parseInt(fixedWidth, 10) : (parent['fixedWidth'] || 0),
|
||||
'fixedHeight': (fixedHeight !== null) ?
|
||||
parseInt(fixedHeight, 10) : (parent['fixedHeight'] || 0),
|
||||
'minScale': parent['minScale'],
|
||||
'maxScale': parent['maxScale'],
|
||||
'attribution': parent['attribution']
|
||||
};
|
||||
if (parentLayer) {
|
||||
goog.object.extend(layer['srs'], parent['srs']);
|
||||
goog.object.extend(layer['bbox'], parent['bbox']);
|
||||
goog.object.extend(layer['dimensions'], parent['dimensions']);
|
||||
goog.object.extend(layer['authorityURLs'], parent['authorityURLs']);
|
||||
}
|
||||
obj['nestedLayers'].push(layer);
|
||||
layer['capability'] = capability;
|
||||
this.readChildNodes(node, layer);
|
||||
delete layer['capability'];
|
||||
if (layer['name']) {
|
||||
var parts = layer['name'].split(':'),
|
||||
request = capability['request'],
|
||||
gfi = request['getfeatureinfo'];
|
||||
if (parts.length > 0) {
|
||||
layer['prefix'] = parts[0];
|
||||
}
|
||||
capability['layers'].push(layer);
|
||||
if (!goog.isDef(layer['formats'])) {
|
||||
layer['formats'] = request['getmap']['formats'];
|
||||
}
|
||||
if (!goog.isDef(layer['infoFormats']) && gfi) {
|
||||
layer['infoFormats'] = gfi['formats'];
|
||||
}
|
||||
}
|
||||
},
|
||||
'Attribution': function(node, obj) {
|
||||
obj['attribution'] = {};
|
||||
this.readChildNodes(node, obj['attribution']);
|
||||
},
|
||||
'LogoURL': function(node, obj) {
|
||||
obj['logo'] = {
|
||||
'width': node.getAttribute('width'),
|
||||
'height': node.getAttribute('height')
|
||||
};
|
||||
this.readChildNodes(node, obj['logo']);
|
||||
},
|
||||
'Style': function(node, obj) {
|
||||
var style = {};
|
||||
obj['styles'].push(style);
|
||||
this.readChildNodes(node, style);
|
||||
},
|
||||
'LegendURL': function(node, obj) {
|
||||
var legend = {
|
||||
'width': node.getAttribute('width'),
|
||||
'height': node.getAttribute('height')
|
||||
};
|
||||
obj['legend'] = legend;
|
||||
this.readChildNodes(node, legend);
|
||||
},
|
||||
'MetadataURL': function(node, obj) {
|
||||
var metadataURL = {'type': node.getAttribute('type')};
|
||||
obj['metadataURLs'].push(metadataURL);
|
||||
this.readChildNodes(node, metadataURL);
|
||||
},
|
||||
'DataURL': function(node, obj) {
|
||||
obj['dataURL'] = {};
|
||||
this.readChildNodes(node, obj['dataURL']);
|
||||
},
|
||||
'FeatureListURL': function(node, obj) {
|
||||
obj['featureListURL'] = {};
|
||||
this.readChildNodes(node, obj['featureListURL']);
|
||||
},
|
||||
'AuthorityURL': function(node, obj) {
|
||||
var name = node.getAttribute('name');
|
||||
var authority = {};
|
||||
this.readChildNodes(node, authority);
|
||||
obj['authorityURLs'][name] = authority['href'];
|
||||
},
|
||||
'Identifier': function(node, obj) {
|
||||
var authority = node.getAttribute('authority');
|
||||
obj['identifiers'][authority] = this.getChildValue(node);
|
||||
},
|
||||
'KeywordList': function(node, obj) {
|
||||
this.readChildNodes(node, obj);
|
||||
},
|
||||
'SRS': function(node, obj) {
|
||||
obj['srs'][this.getChildValue(node)] = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
goog.base(this);
|
||||
};
|
||||
goog.inherits(ol.parser.ogc.WMSCapabilities_v1, ol.parser.XML);
|
||||
|
||||
|
||||
/**
|
||||
* @param {string|Document|Element} data Data to read.
|
||||
* @return {Object} An object representing the document.
|
||||
*/
|
||||
ol.parser.ogc.WMSCapabilities_v1.prototype.read = function(data) {
|
||||
if (goog.isString(data)) {
|
||||
data = goog.dom.xml.loadXml(data);
|
||||
}
|
||||
if (data && data.nodeType == 9) {
|
||||
data = data.documentElement;
|
||||
}
|
||||
var obj = {};
|
||||
this.readNode(data, obj);
|
||||
return obj;
|
||||
};
|
||||
@@ -1,66 +0,0 @@
|
||||
goog.provide('ol.parser.ogc.WMSCapabilities_v1_0_0');
|
||||
|
||||
goog.require('goog.object');
|
||||
goog.require('goog.string');
|
||||
goog.require('ol.parser.ogc.WMSCapabilities_v1_1_0');
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Read [WMS](http://www.opengeospatial.org/standards/wms) capabilities
|
||||
* version 1.0.0
|
||||
*
|
||||
* @constructor
|
||||
* @extends {ol.parser.ogc.WMSCapabilities_v1_1_0}
|
||||
*/
|
||||
ol.parser.ogc.WMSCapabilities_v1_0_0 = function() {
|
||||
goog.base(this);
|
||||
this.version = '1.0.0';
|
||||
goog.object.extend(this.readers['http://www.opengis.net/wms'], {
|
||||
'Format': function(node, obj) {
|
||||
for (var i = 0, ii = node.childNodes.length; i < ii; i++) {
|
||||
var child = node.childNodes[i];
|
||||
var local = child.localName || child.nodeName.split(':').pop();
|
||||
if (goog.isArray(obj['formats'])) {
|
||||
obj['formats'].push(local);
|
||||
} else {
|
||||
obj['format'] = local;
|
||||
}
|
||||
}
|
||||
},
|
||||
'Keywords': function(node, obj) {
|
||||
if (!goog.isDef(obj['keywords'])) {
|
||||
obj['keywords'] = [];
|
||||
}
|
||||
var keywords = this.getChildValue(node).split(/ +/);
|
||||
for (var i = 0, ii = keywords.length; i < ii; ++i) {
|
||||
if (!goog.string.isEmpty(keywords[i])) {
|
||||
obj['keywords'].push({'value': keywords[i]});
|
||||
}
|
||||
}
|
||||
},
|
||||
'OnlineResource': function(node, obj) {
|
||||
obj['href'] = this.getChildValue(node);
|
||||
},
|
||||
'Get': function(node, obj) {
|
||||
obj['get'] = {'href': node.getAttribute('onlineResource')};
|
||||
},
|
||||
'Post': function(node, obj) {
|
||||
obj['post'] = {'href': node.getAttribute('onlineResource')};
|
||||
},
|
||||
'Map': function(node, obj) {
|
||||
var reader = this.readers[this.defaultNamespaceURI]['GetMap'];
|
||||
reader.apply(this, arguments);
|
||||
},
|
||||
'Capabilities': function(node, obj) {
|
||||
var reader = this.readers[this.defaultNamespaceURI]['GetCapabilities'];
|
||||
reader.apply(this, arguments);
|
||||
},
|
||||
'FeatureInfo': function(node, obj) {
|
||||
var reader = this.readers[this.defaultNamespaceURI]['GetFeatureInfo'];
|
||||
reader.apply(this, arguments);
|
||||
}
|
||||
});
|
||||
};
|
||||
goog.inherits(ol.parser.ogc.WMSCapabilities_v1_0_0,
|
||||
ol.parser.ogc.WMSCapabilities_v1_1_0);
|
||||
@@ -1,101 +0,0 @@
|
||||
goog.provide('ol.parser.ogc.WMSCapabilities_v1_1');
|
||||
|
||||
goog.require('goog.object');
|
||||
goog.require('ol.parser.ogc.WMSCapabilities_v1');
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.parser.ogc.WMSCapabilities_v1}
|
||||
*/
|
||||
ol.parser.ogc.WMSCapabilities_v1_1 = function() {
|
||||
goog.base(this);
|
||||
var bboxreader = this.readers['http://www.opengis.net/wms']['BoundingBox'];
|
||||
goog.object.extend(this.readers['http://www.opengis.net/wms'], {
|
||||
'WMT_MS_Capabilities': function(node, obj) {
|
||||
this.readChildNodes(node, obj);
|
||||
},
|
||||
'Keyword': function(node, obj) {
|
||||
if (obj['keywords']) {
|
||||
obj['keywords'].push({'value': this.getChildValue(node)});
|
||||
}
|
||||
},
|
||||
'DescribeLayer': function(node, obj) {
|
||||
obj['describelayer'] = {'formats': []};
|
||||
this.readChildNodes(node, obj['describelayer']);
|
||||
},
|
||||
'GetLegendGraphic': function(node, obj) {
|
||||
obj['getlegendgraphic'] = {'formats': []};
|
||||
this.readChildNodes(node, obj['getlegendgraphic']);
|
||||
},
|
||||
'GetStyles': function(node, obj) {
|
||||
obj['getstyles'] = {'formats': []};
|
||||
this.readChildNodes(node, obj['getstyles']);
|
||||
},
|
||||
'PutStyles': function(node, obj) {
|
||||
obj['putstyles'] = {'formats': []};
|
||||
this.readChildNodes(node, obj['putstyles']);
|
||||
},
|
||||
'UserDefinedSymbolization': function(node, obj) {
|
||||
var userSymbols = {
|
||||
'supportSLD': parseInt(node.getAttribute('SupportSLD'), 10) == 1,
|
||||
'userLayer': parseInt(node.getAttribute('UserLayer'), 10) == 1,
|
||||
'userStyle': parseInt(node.getAttribute('UserStyle'), 10) == 1,
|
||||
'remoteWFS': parseInt(node.getAttribute('RemoteWFS'), 10) == 1
|
||||
};
|
||||
obj['userSymbols'] = userSymbols;
|
||||
},
|
||||
'LatLonBoundingBox': function(node, obj) {
|
||||
obj['llbbox'] = [
|
||||
parseFloat(node.getAttribute('minx')),
|
||||
parseFloat(node.getAttribute('miny')),
|
||||
parseFloat(node.getAttribute('maxx')),
|
||||
parseFloat(node.getAttribute('maxy'))
|
||||
];
|
||||
},
|
||||
'BoundingBox': function(node, obj) {
|
||||
var bbox = bboxreader.apply(this, arguments);
|
||||
bbox['srs'] = node.getAttribute('SRS');
|
||||
obj['bbox'][bbox['srs']] = bbox;
|
||||
},
|
||||
'ScaleHint': function(node, obj) {
|
||||
var min = parseFloat(node.getAttribute('min'));
|
||||
var max = parseFloat(node.getAttribute('max'));
|
||||
var rad2 = Math.pow(2, 0.5);
|
||||
var dpi = (25.4 / 0.28);
|
||||
var ipm = 39.37;
|
||||
if (min !== 0) {
|
||||
obj['maxScale'] = parseFloat((min / rad2) * ipm * dpi);
|
||||
}
|
||||
if (max != Infinity) {
|
||||
obj['minScale'] = parseFloat((max / rad2) * ipm * dpi);
|
||||
}
|
||||
},
|
||||
'Dimension': function(node, obj) {
|
||||
var name = node.getAttribute('name').toLowerCase();
|
||||
var dim = {
|
||||
'name': name,
|
||||
'units': node.getAttribute('units'),
|
||||
'unitsymbol': node.getAttribute('unitSymbol')
|
||||
};
|
||||
obj['dimensions'][dim.name] = dim;
|
||||
},
|
||||
'Extent': function(node, obj) {
|
||||
var name = node.getAttribute('name').toLowerCase();
|
||||
if (name in obj['dimensions']) {
|
||||
var extent = obj['dimensions'][name];
|
||||
extent['nearestVal'] =
|
||||
node.getAttribute('nearestValue') === '1';
|
||||
extent['multipleVal'] =
|
||||
node.getAttribute('multipleValues') === '1';
|
||||
extent['current'] = node.getAttribute('current') === '1';
|
||||
extent['default'] = node.getAttribute('default') || '';
|
||||
var values = this.getChildValue(node);
|
||||
extent['values'] = values.split(',');
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
goog.inherits(ol.parser.ogc.WMSCapabilities_v1_1,
|
||||
ol.parser.ogc.WMSCapabilities_v1);
|
||||
@@ -1,29 +0,0 @@
|
||||
goog.provide('ol.parser.ogc.WMSCapabilities_v1_1_0');
|
||||
|
||||
goog.require('goog.object');
|
||||
goog.require('ol.parser.ogc.WMSCapabilities_v1_1');
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Read [WMS](http://www.opengeospatial.org/standards/wms) capabilities
|
||||
* version 1.1.0
|
||||
*
|
||||
* @constructor
|
||||
* @extends {ol.parser.ogc.WMSCapabilities_v1_1}
|
||||
*/
|
||||
ol.parser.ogc.WMSCapabilities_v1_1_0 = function() {
|
||||
goog.base(this);
|
||||
this.version = '1.1.0';
|
||||
goog.object.extend(this.readers['http://www.opengis.net/wms'], {
|
||||
'SRS': function(node, obj) {
|
||||
var srs = this.getChildValue(node);
|
||||
var values = srs.split(/ +/);
|
||||
for (var i = 0, ii = values.length; i < ii; i++) {
|
||||
obj['srs'][values[i]] = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
goog.inherits(ol.parser.ogc.WMSCapabilities_v1_1_0,
|
||||
ol.parser.ogc.WMSCapabilities_v1_1);
|
||||
@@ -1,25 +0,0 @@
|
||||
goog.provide('ol.parser.ogc.WMSCapabilities_v1_1_1');
|
||||
|
||||
goog.require('goog.object');
|
||||
goog.require('ol.parser.ogc.WMSCapabilities_v1_1');
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Read [WMS](http://www.opengeospatial.org/standards/wms) capabilities
|
||||
* version 1.1.1
|
||||
*
|
||||
* @constructor
|
||||
* @extends {ol.parser.ogc.WMSCapabilities_v1_1}
|
||||
*/
|
||||
ol.parser.ogc.WMSCapabilities_v1_1_1 = function() {
|
||||
goog.base(this);
|
||||
this.version = '1.1.1';
|
||||
goog.object.extend(this.readers['http://www.opengis.net/wms'], {
|
||||
'SRS': function(node, obj) {
|
||||
obj['srs'][this.getChildValue(node)] = true;
|
||||
}
|
||||
});
|
||||
};
|
||||
goog.inherits(ol.parser.ogc.WMSCapabilities_v1_1_1,
|
||||
ol.parser.ogc.WMSCapabilities_v1_1);
|
||||
@@ -1,48 +0,0 @@
|
||||
goog.provide('ol.parser.ogc.WMSCapabilities_v1_1_1_WMSC');
|
||||
|
||||
goog.require('goog.object');
|
||||
goog.require('ol.parser.ogc.WMSCapabilities_v1_1_1');
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.parser.ogc.WMSCapabilities_v1_1_1}
|
||||
*/
|
||||
ol.parser.ogc.WMSCapabilities_v1_1_1_WMSC = function() {
|
||||
goog.base(this);
|
||||
this.profile = 'WMSC';
|
||||
goog.object.extend(this.readers['http://www.opengis.net/wms'], {
|
||||
'VendorSpecificCapabilities': function(node, obj) {
|
||||
obj['vendorSpecific'] = {'tileSets': []};
|
||||
this.readChildNodes(node, obj['vendorSpecific']);
|
||||
},
|
||||
'TileSet': function(node, vendorSpecific) {
|
||||
var tileset = {'srs': {}, 'bbox': {}, 'resolutions': []};
|
||||
this.readChildNodes(node, tileset);
|
||||
vendorSpecific.tileSets.push(tileset);
|
||||
},
|
||||
'Resolutions': function(node, tileset) {
|
||||
var res = this.getChildValue(node).split(' ');
|
||||
for (var i = 0, ii = res.length; i < ii; i++) {
|
||||
if (res[i] !== '') {
|
||||
tileset['resolutions'].push(parseFloat(res[i]));
|
||||
}
|
||||
}
|
||||
},
|
||||
'Width': function(node, tileset) {
|
||||
tileset['width'] = parseInt(this.getChildValue(node), 10);
|
||||
},
|
||||
'Height': function(node, tileset) {
|
||||
tileset['height'] = parseInt(this.getChildValue(node), 10);
|
||||
},
|
||||
'Layers': function(node, tileset) {
|
||||
tileset['layers'] = this.getChildValue(node);
|
||||
},
|
||||
'Styles': function(node, tileset) {
|
||||
tileset['styles'] = this.getChildValue(node);
|
||||
}
|
||||
});
|
||||
};
|
||||
goog.inherits(ol.parser.ogc.WMSCapabilities_v1_1_1_WMSC,
|
||||
ol.parser.ogc.WMSCapabilities_v1_1_1);
|
||||
@@ -1,114 +0,0 @@
|
||||
goog.provide('ol.parser.ogc.WMSCapabilities_v1_3_0');
|
||||
|
||||
goog.require('goog.object');
|
||||
goog.require('ol.parser.ogc.WMSCapabilities_v1');
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Read [WMS](http://www.opengeospatial.org/standards/wms) capabilities
|
||||
* version 1.3.0
|
||||
*
|
||||
* @constructor
|
||||
* @extends {ol.parser.ogc.WMSCapabilities_v1}
|
||||
*/
|
||||
ol.parser.ogc.WMSCapabilities_v1_3_0 = function() {
|
||||
goog.base(this);
|
||||
var bboxreader = this.readers['http://www.opengis.net/wms']['BoundingBox'];
|
||||
goog.object.extend(this.readers['http://www.opengis.net/wms'], {
|
||||
'WMS_Capabilities': function(node, obj) {
|
||||
this.readChildNodes(node, obj);
|
||||
},
|
||||
'LayerLimit': function(node, obj) {
|
||||
obj['layerLimit'] = parseInt(this.getChildValue(node), 10);
|
||||
},
|
||||
'MaxWidth': function(node, obj) {
|
||||
obj['maxWidth'] = parseInt(this.getChildValue(node), 10);
|
||||
},
|
||||
'MaxHeight': function(node, obj) {
|
||||
obj['maxHeight'] = parseInt(this.getChildValue(node), 10);
|
||||
},
|
||||
'BoundingBox': function(node, obj) {
|
||||
var bbox = bboxreader.apply(this, arguments);
|
||||
bbox['srs'] = node.getAttribute('CRS');
|
||||
obj['bbox'][bbox['srs']] = bbox;
|
||||
},
|
||||
'CRS': function(node, obj) {
|
||||
// CRS is the synonym of SRS
|
||||
this.readers['http://www.opengis.net/wms']['SRS'].apply(this, arguments);
|
||||
},
|
||||
'EX_GeographicBoundingBox': function(node, obj) {
|
||||
// replacement of LatLonBoundingBox
|
||||
obj['llbbox'] = [];
|
||||
this.readChildNodes(node, obj['llbbox']);
|
||||
},
|
||||
'westBoundLongitude': function(node, obj) {
|
||||
obj[0] = this.getChildValue(node);
|
||||
},
|
||||
'eastBoundLongitude': function(node, obj) {
|
||||
obj[2] = this.getChildValue(node);
|
||||
},
|
||||
'southBoundLatitude': function(node, obj) {
|
||||
obj[1] = this.getChildValue(node);
|
||||
},
|
||||
'northBoundLatitude': function(node, obj) {
|
||||
obj[3] = this.getChildValue(node);
|
||||
},
|
||||
'MinScaleDenominator': function(node, obj) {
|
||||
obj['maxScale'] = parseFloat(this.getChildValue(node)).toPrecision(16);
|
||||
},
|
||||
'MaxScaleDenominator': function(node, obj) {
|
||||
obj['minScale'] = parseFloat(this.getChildValue(node)).toPrecision(16);
|
||||
},
|
||||
'Dimension': function(node, obj) {
|
||||
// dimension has extra attributes: default, multipleValues,
|
||||
// nearestValue, current which used to be part of Extent. It now
|
||||
// also contains the values.
|
||||
var name = node.getAttribute('name').toLowerCase();
|
||||
var dim = {
|
||||
'name': name,
|
||||
'units': node.getAttribute('units'),
|
||||
'unitsymbol': node.getAttribute('unitSymbol'),
|
||||
'nearestVal': node.getAttribute('nearestValue') === '1',
|
||||
'multipleVal': node.getAttribute('multipleValues') === '1',
|
||||
'default': node.getAttribute('default') || '',
|
||||
'current': node.getAttribute('current') === '1',
|
||||
'values': this.getChildValue(node).split(',')
|
||||
};
|
||||
// Theoretically there can be more dimensions with the same
|
||||
// name, but with a different unit. Until we meet such a case,
|
||||
// let's just keep the same structure as the WMS 1.1
|
||||
// GetCapabilities parser uses. We will store the last
|
||||
// one encountered.
|
||||
obj['dimensions'][dim['name']] = dim;
|
||||
},
|
||||
'Keyword': function(node, obj) {
|
||||
var keyword = {'value': this.getChildValue(node),
|
||||
'vocabulary': node.getAttribute('vocabulary')};
|
||||
if (obj['keywords']) {
|
||||
obj['keywords'].push(keyword);
|
||||
}
|
||||
}
|
||||
});
|
||||
this.readers['sld'] = {
|
||||
'UserDefinedSymbolization': function(node, obj) {
|
||||
var readers = this.readers['http://www.opengis.net/wms'];
|
||||
readers.UserDefinedSymbolization.apply(this, arguments);
|
||||
// add the two extra attributes
|
||||
var value = node.getAttribute('InlineFeature');
|
||||
obj['userSymbols']['inlineFeature'] = parseInt(value, 10) == 1;
|
||||
value = node.getAttribute('RemoteWCS');
|
||||
obj['userSymbols']['remoteWCS'] = parseInt(value, 10) == 1;
|
||||
},
|
||||
'DescribeLayer': function(node, obj) {
|
||||
var readers = this.readers['http://www.opengis.net/wms'];
|
||||
readers.DescribeLayer.apply(this, arguments);
|
||||
},
|
||||
'GetLegendGraphic': function(node, obj) {
|
||||
var readers = this.readers['http://www.opengis.net/wms'];
|
||||
readers.GetLegendGraphic.apply(this, arguments);
|
||||
}
|
||||
};
|
||||
};
|
||||
goog.inherits(ol.parser.ogc.WMSCapabilities_v1_3_0,
|
||||
ol.parser.ogc.WMSCapabilities_v1);
|
||||
@@ -1,9 +0,0 @@
|
||||
goog.provide('ol.parser.Parser');
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @todo stability experimental
|
||||
*/
|
||||
ol.parser.Parser = function() {};
|
||||
@@ -1,296 +0,0 @@
|
||||
goog.provide('ol.parser.XML');
|
||||
|
||||
goog.require('goog.dom.xml');
|
||||
goog.require('ol.parser.Parser');
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.parser.Parser}
|
||||
* @todo stability experimental
|
||||
*/
|
||||
ol.parser.XML = function() {
|
||||
if (goog.global.ActiveXObject) {
|
||||
this.xmldom = new ActiveXObject('Microsoft.XMLDOM');
|
||||
}
|
||||
this.regExes = {
|
||||
trimSpace: (/^\s*|\s*$/g),
|
||||
removeSpace: (/\s*/g),
|
||||
splitSpace: (/\s+/),
|
||||
trimComma: (/\s*,\s*/g)
|
||||
};
|
||||
};
|
||||
goog.inherits(ol.parser.XML, ol.parser.Parser);
|
||||
|
||||
|
||||
/**
|
||||
* Shorthand for applying one of the named readers given the node
|
||||
* namespace and local name. Readers take two args (node, obj) and
|
||||
* generally extend or modify the second.
|
||||
*
|
||||
* @param {Element|Document} node The node to be read (required).
|
||||
* @param {Object} obj The object to be modified (optional).
|
||||
* @return {Object} The input object, modified (or a new one if none was
|
||||
* provided).
|
||||
*/
|
||||
ol.parser.XML.prototype.readNode = function(node, obj) {
|
||||
if (!obj) {
|
||||
obj = {};
|
||||
}
|
||||
var group = this.readers[node.namespaceURI] ||
|
||||
this.readers[this.defaultNamespaceURI];
|
||||
if (group) {
|
||||
var local = node.localName || node.nodeName.split(':').pop();
|
||||
var reader = group[local] || group['*'];
|
||||
if (reader) {
|
||||
reader.apply(this, [node, obj]);
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Shorthand for applying the named readers to all children of a node.
|
||||
* For each child of type 1 (element), <readSelf> is called.
|
||||
*
|
||||
* @param {Element|Document} node The node to be read (required).
|
||||
* @param {Object} obj The object to be modified (optional).
|
||||
* @return {Object} The input object, modified.
|
||||
*/
|
||||
ol.parser.XML.prototype.readChildNodes = function(node, obj) {
|
||||
if (!obj) {
|
||||
obj = {};
|
||||
}
|
||||
var children = node.childNodes;
|
||||
var child;
|
||||
for (var i = 0, len = children.length; i < len; ++i) {
|
||||
child = children[i];
|
||||
if (child.nodeType == 1) {
|
||||
this.readNode(child, obj);
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the textual value of the node if it exists, or return an
|
||||
* optional default string. Returns an empty string if no first child
|
||||
* exists and no default value is supplied.
|
||||
*
|
||||
* @param {Element} node The element used to look for a first child value.
|
||||
* @param {string} def Optional string to return in the event that no
|
||||
* first child value exists.
|
||||
* @return {string} The value of the first child of the given node.
|
||||
*/
|
||||
ol.parser.XML.prototype.getChildValue = function(node, def) {
|
||||
var value = def || '';
|
||||
if (node) {
|
||||
for (var child = node.firstChild; child; child = child.nextSibling) {
|
||||
switch (child.nodeType) {
|
||||
case 3: // text node
|
||||
case 4: // cdata section
|
||||
value += child.nodeValue;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return value;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get an attribute node given the namespace URI and local name.
|
||||
*
|
||||
* @param {Element} node Node on which to search for attribute nodes.
|
||||
* @param {string} uri Namespace URI.
|
||||
* @param {string} name Local name of the attribute (without the prefix).
|
||||
* @return {?Element} An attribute node or null if none found.
|
||||
*/
|
||||
ol.parser.XML.prototype.getAttributeNodeNS = function(node, uri, name) {
|
||||
var attributeNode = null;
|
||||
if (node.getAttributeNodeNS) {
|
||||
attributeNode = node.getAttributeNodeNS(uri, name);
|
||||
} else {
|
||||
var attributes = node.attributes;
|
||||
var potentialNode, fullName;
|
||||
for (var i = 0, len = attributes.length; i < len; ++i) {
|
||||
potentialNode = attributes[i];
|
||||
if (potentialNode.namespaceURI == uri) {
|
||||
fullName = (potentialNode.prefix) ?
|
||||
(potentialNode.prefix + ':' + name) : name;
|
||||
if (fullName == potentialNode.nodeName) {
|
||||
attributeNode = potentialNode;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return attributeNode;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get an attribute value given the namespace URI and local name.
|
||||
*
|
||||
* @param {Element} node Node on which to search for an attribute.
|
||||
* @param {string} uri Namespace URI.
|
||||
* @param {string} name Local name of the attribute (without the prefix).
|
||||
* @return {string} An attribute value or and empty string if none found.
|
||||
*/
|
||||
ol.parser.XML.prototype.getAttributeNS = function(node, uri, name) {
|
||||
var attributeValue = '';
|
||||
if (node.getAttributeNS) {
|
||||
attributeValue = node.getAttributeNS(uri, name) || '';
|
||||
} else {
|
||||
var attributeNode = this.getAttributeNodeNS(node, uri, name);
|
||||
if (attributeNode) {
|
||||
attributeValue = attributeNode.nodeValue;
|
||||
}
|
||||
}
|
||||
return attributeValue;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Create a new element with namespace. This node can be appended to
|
||||
* another node with the standard node.appendChild method. For
|
||||
* cross-browser support, this method must be used instead of
|
||||
* document.createElementNS.
|
||||
*
|
||||
* @param {string} name The qualified name of the element (prefix:localname).
|
||||
* @param {string=} opt_uri Namespace URI for the element.
|
||||
* @return {Element} A DOM element with namespace.
|
||||
*/
|
||||
ol.parser.XML.prototype.createElementNS = function(name, opt_uri) {
|
||||
var uri = opt_uri ? opt_uri : this.defaultNamespaceURI;
|
||||
var element;
|
||||
if (this.xmldom) {
|
||||
element = this.xmldom.createNode(1, name, uri);
|
||||
} else {
|
||||
element = document.createElementNS(uri, name);
|
||||
}
|
||||
return element;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Shorthand for applying one of the named writers and appending the
|
||||
* results to a node.
|
||||
*
|
||||
* @param {string} name The name of a node to generate. Only use a local name.
|
||||
* @param {Object|string|number} obj Structure containing data for the writer.
|
||||
* @param {?string=} opt_uri The name space uri to which the node
|
||||
* belongs.
|
||||
* @param {Element=} opt_parent Result will be appended to this node. If no
|
||||
* parent is supplied, the node will not be appended to anything.
|
||||
* @return {?Element} The child node.
|
||||
*/
|
||||
ol.parser.XML.prototype.writeNode = function(name, obj, opt_uri, opt_parent) {
|
||||
var child = null;
|
||||
if (goog.isDef(this.writers)) {
|
||||
var uri = opt_uri ? opt_uri : this.defaultNamespaceURI;
|
||||
child = this.writers[uri][name].apply(this, [obj]);
|
||||
if (opt_parent && child) {
|
||||
opt_parent.appendChild(child);
|
||||
}
|
||||
}
|
||||
return child;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Create a text node. This node can be appended to another node with
|
||||
* the standard node.appendChild method. For cross-browser support,
|
||||
* this method must be used instead of document.createTextNode.
|
||||
*
|
||||
* @param {string} text The text of the node.
|
||||
* @return {Element} A DOM text node.
|
||||
*/
|
||||
ol.parser.XML.prototype.createTextNode = function(text) {
|
||||
var node;
|
||||
if (this.xmldom) {
|
||||
node = this.xmldom.createTextNode(text);
|
||||
} else {
|
||||
node = document.createTextNode(text);
|
||||
}
|
||||
return node;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Adds a new attribute or changes the value of an attribute with the given
|
||||
* namespace and name.
|
||||
*
|
||||
* @param {Element} node Element node on which to set the attribute.
|
||||
* @param {string} uri Namespace URI for the attribute.
|
||||
* @param {string} name Qualified name (prefix:localname) for the attribute.
|
||||
* @param {string} value Attribute value.
|
||||
*/
|
||||
ol.parser.XML.prototype.setAttributeNS = function(node, uri, name, value) {
|
||||
if (node.setAttributeNS) {
|
||||
node.setAttributeNS(uri, name, value);
|
||||
} else {
|
||||
if (this.xmldom) {
|
||||
if (uri) {
|
||||
var attribute = node.ownerDocument.createNode(
|
||||
2, name, uri);
|
||||
attribute.nodeValue = value;
|
||||
node.setAttributeNode(attribute);
|
||||
} else {
|
||||
node.setAttribute(name, value);
|
||||
}
|
||||
} else {
|
||||
throw new Error('setAttributeNS not implemented');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Serializes a node.
|
||||
*
|
||||
* @param {Element} node Element node to serialize.
|
||||
* @return {string} The serialized XML string.
|
||||
*/
|
||||
ol.parser.XML.prototype.serialize = function(node) {
|
||||
if (this.xmldom) {
|
||||
return node.xml;
|
||||
} else if (node.nodeType == 1) {
|
||||
// Add nodes to a document before serializing. Everything else
|
||||
// is serialized as is. This is also needed to get all namespaces
|
||||
// defined in some browsers such as Chrome (xmlns attributes).
|
||||
var doc = document.implementation.createDocument('', '', null);
|
||||
if (doc.importNode) {
|
||||
doc.appendChild(doc.importNode(node, true));
|
||||
} else {
|
||||
doc.appendChild(node);
|
||||
}
|
||||
return goog.dom.xml.serialize(doc);
|
||||
} else {
|
||||
return goog.dom.xml.serialize(node);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Create a document fragment node that can be appended to another node
|
||||
* created by createElementNS. This will call
|
||||
* document.createDocumentFragment outside of IE. In IE, the ActiveX
|
||||
* object's createDocumentFragment method is used.
|
||||
*
|
||||
* @return {Element} A document fragment.
|
||||
*/
|
||||
ol.parser.XML.prototype.createDocumentFragment = function() {
|
||||
var element;
|
||||
if (this.xmldom) {
|
||||
element = this.xmldom.createDocumentFragment();
|
||||
} else {
|
||||
element = document.createDocumentFragment();
|
||||
}
|
||||
return element;
|
||||
};
|
||||
@@ -410,6 +410,36 @@ ol.xml.makeReplacer = function(valueReader, opt_this) {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {function(this: T, Node, Array.<*>): *} valueReader Value reader.
|
||||
* @param {string=} opt_property Property.
|
||||
* @param {T=} opt_this The object to use as `this` in `valueReader`.
|
||||
* @return {ol.xml.Parser} Parser.
|
||||
* @template T
|
||||
*/
|
||||
ol.xml.makeObjectPropertyPusher =
|
||||
function(valueReader, opt_property, opt_this) {
|
||||
goog.asserts.assert(goog.isDef(valueReader));
|
||||
return (
|
||||
/**
|
||||
* @param {Node} node Node.
|
||||
* @param {Array.<*>} objectStack Object stack.
|
||||
*/
|
||||
function(node, objectStack) {
|
||||
var value = valueReader.call(opt_this, node, objectStack);
|
||||
if (goog.isDef(value)) {
|
||||
var object = /** @type {Object} */
|
||||
(objectStack[objectStack.length - 1]);
|
||||
var property = goog.isDef(opt_property) ?
|
||||
opt_property : node.localName;
|
||||
goog.asserts.assert(goog.isObject(object));
|
||||
var array = goog.object.setIfUndefined(object, property, []);
|
||||
array.push(value);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {function(this: T, Node, Array.<*>): *} valueReader Value reader.
|
||||
* @param {string=} opt_property Property.
|
||||
|
||||
Reference in New Issue
Block a user