Add ReadOptions and WriteOptions for XML formats
This commit is contained in:
@@ -35,14 +35,15 @@ ol.format.XMLFeature.prototype.getType = function() {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.XMLFeature.prototype.readFeature = function(source) {
|
||||
ol.format.XMLFeature.prototype.readFeature = function(source, opt_options) {
|
||||
if (ol.xml.isDocument(source)) {
|
||||
return this.readFeatureFromDocument(/** @type {Document} */ (source));
|
||||
return this.readFeatureFromDocument(
|
||||
/** @type {Document} */ (source), opt_options);
|
||||
} else if (ol.xml.isNode(source)) {
|
||||
return this.readFeatureFromNode(/** @type {Node} */ (source));
|
||||
return this.readFeatureFromNode(/** @type {Node} */ (source), opt_options);
|
||||
} else if (goog.isString(source)) {
|
||||
var doc = ol.xml.load(source);
|
||||
return this.readFeatureFromDocument(doc);
|
||||
return this.readFeatureFromDocument(doc, opt_options);
|
||||
} else {
|
||||
goog.asserts.fail();
|
||||
return null;
|
||||
@@ -52,10 +53,12 @@ ol.format.XMLFeature.prototype.readFeature = function(source) {
|
||||
|
||||
/**
|
||||
* @param {Document} doc Document.
|
||||
* @param {olx.format.ReadOptions=} opt_options Options.
|
||||
* @return {ol.Feature} Feature.
|
||||
*/
|
||||
ol.format.XMLFeature.prototype.readFeatureFromDocument = function(doc) {
|
||||
var features = this.readFeaturesFromDocument(doc);
|
||||
ol.format.XMLFeature.prototype.readFeatureFromDocument = function(
|
||||
doc, opt_options) {
|
||||
var features = this.readFeaturesFromDocument(doc, opt_options);
|
||||
if (features.length > 0) {
|
||||
return features[0];
|
||||
} else {
|
||||
@@ -66,6 +69,7 @@ ol.format.XMLFeature.prototype.readFeatureFromDocument = function(doc) {
|
||||
|
||||
/**
|
||||
* @param {Node} node Node.
|
||||
* @param {olx.format.ReadOptions=} opt_options Options.
|
||||
* @return {ol.Feature} Feature.
|
||||
*/
|
||||
ol.format.XMLFeature.prototype.readFeatureFromNode = goog.abstractMethod;
|
||||
@@ -74,14 +78,15 @@ ol.format.XMLFeature.prototype.readFeatureFromNode = goog.abstractMethod;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.XMLFeature.prototype.readFeatures = function(source) {
|
||||
ol.format.XMLFeature.prototype.readFeatures = function(source, opt_options) {
|
||||
if (ol.xml.isDocument(source)) {
|
||||
return this.readFeaturesFromDocument(/** @type {Document} */ (source));
|
||||
return this.readFeaturesFromDocument(
|
||||
/** @type {Document} */ (source), opt_options);
|
||||
} else if (ol.xml.isNode(source)) {
|
||||
return this.readFeaturesFromNode(/** @type {Node} */ (source));
|
||||
return this.readFeaturesFromNode(/** @type {Node} */ (source), opt_options);
|
||||
} else if (goog.isString(source)) {
|
||||
var doc = ol.xml.load(source);
|
||||
return this.readFeaturesFromDocument(doc);
|
||||
return this.readFeaturesFromDocument(doc, opt_options);
|
||||
} else {
|
||||
goog.asserts.fail();
|
||||
return [];
|
||||
@@ -91,16 +96,18 @@ ol.format.XMLFeature.prototype.readFeatures = function(source) {
|
||||
|
||||
/**
|
||||
* @param {Document} doc Document.
|
||||
* @param {olx.format.ReadOptions=} opt_options Options.
|
||||
* @protected
|
||||
* @return {Array.<ol.Feature>} Features.
|
||||
*/
|
||||
ol.format.XMLFeature.prototype.readFeaturesFromDocument = function(doc) {
|
||||
ol.format.XMLFeature.prototype.readFeaturesFromDocument = function(
|
||||
doc, opt_options) {
|
||||
/** @type {Array.<ol.Feature>} */
|
||||
var features = [];
|
||||
var n;
|
||||
for (n = doc.firstChild; !goog.isNull(n); n = n.nextSibling) {
|
||||
if (n.nodeType == goog.dom.NodeType.ELEMENT) {
|
||||
goog.array.extend(features, this.readFeaturesFromNode(n));
|
||||
goog.array.extend(features, this.readFeaturesFromNode(n, opt_options));
|
||||
}
|
||||
}
|
||||
return features;
|
||||
@@ -109,6 +116,7 @@ ol.format.XMLFeature.prototype.readFeaturesFromDocument = function(doc) {
|
||||
|
||||
/**
|
||||
* @param {Node} node Node.
|
||||
* @param {olx.format.ReadOptions=} opt_options Options.
|
||||
* @protected
|
||||
* @return {Array.<ol.Feature>} Features.
|
||||
*/
|
||||
@@ -118,14 +126,15 @@ ol.format.XMLFeature.prototype.readFeaturesFromNode = goog.abstractMethod;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.XMLFeature.prototype.readGeometry = function(source) {
|
||||
ol.format.XMLFeature.prototype.readGeometry = function(source, opt_options) {
|
||||
if (ol.xml.isDocument(source)) {
|
||||
return this.readGeometryFromDocument(/** @type {Document} */ (source));
|
||||
return this.readGeometryFromDocument(
|
||||
/** @type {Document} */ (source), opt_options);
|
||||
} else if (ol.xml.isNode(source)) {
|
||||
return this.readGeometryFromNode(/** @type {Node} */ (source));
|
||||
return this.readGeometryFromNode(/** @type {Node} */ (source), opt_options);
|
||||
} else if (goog.isString(source)) {
|
||||
var doc = ol.xml.load(source);
|
||||
return this.readGeometryFromDocument(doc);
|
||||
return this.readGeometryFromDocument(doc, opt_options);
|
||||
} else {
|
||||
goog.asserts.fail();
|
||||
return null;
|
||||
@@ -135,6 +144,7 @@ ol.format.XMLFeature.prototype.readGeometry = function(source) {
|
||||
|
||||
/**
|
||||
* @param {Document} doc Document.
|
||||
* @param {olx.format.ReadOptions=} opt_options Options.
|
||||
* @protected
|
||||
* @return {ol.geom.Geometry} Geometry.
|
||||
*/
|
||||
@@ -143,6 +153,7 @@ ol.format.XMLFeature.prototype.readGeometryFromDocument = goog.abstractMethod;
|
||||
|
||||
/**
|
||||
* @param {Node} node Node.
|
||||
* @param {olx.format.ReadOptions=} opt_options Options.
|
||||
* @protected
|
||||
* @return {ol.geom.Geometry} Geometry.
|
||||
*/
|
||||
@@ -186,13 +197,14 @@ ol.format.XMLFeature.prototype.readProjectionFromNode = goog.abstractMethod;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.XMLFeature.prototype.writeFeature = function(feature) {
|
||||
return this.writeFeatureNode(feature);
|
||||
ol.format.XMLFeature.prototype.writeFeature = function(feature, opt_options) {
|
||||
return this.writeFeatureNode(feature, opt_options);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.Feature} feature Feature.
|
||||
* @param {olx.format.WriteOptions=} opt_options Options.
|
||||
* @protected
|
||||
* @return {Node} Node.
|
||||
*/
|
||||
@@ -202,13 +214,14 @@ ol.format.XMLFeature.prototype.writeFeatureNode = goog.abstractMethod;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.XMLFeature.prototype.writeFeatures = function(features) {
|
||||
return this.writeFeaturesNode(features);
|
||||
ol.format.XMLFeature.prototype.writeFeatures = function(features, opt_options) {
|
||||
return this.writeFeaturesNode(features, opt_options);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {Array.<ol.Feature>} features Features.
|
||||
* @param {olx.format.WriteOptions=} opt_options Options.
|
||||
* @protected
|
||||
* @return {Node} Node.
|
||||
*/
|
||||
@@ -218,13 +231,14 @@ ol.format.XMLFeature.prototype.writeFeaturesNode = goog.abstractMethod;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.format.XMLFeature.prototype.writeGeometry = function(geometry) {
|
||||
return this.writeGeometryNode(geometry);
|
||||
ol.format.XMLFeature.prototype.writeGeometry = function(geometry, opt_options) {
|
||||
return this.writeGeometryNode(geometry, opt_options);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.geom.Geometry} geometry Geometry.
|
||||
* @param {olx.format.WriteOptions=} opt_options Options.
|
||||
* @protected
|
||||
* @return {Node} Node.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user