implement versioned format base class, r=ahocevar (closes #2954)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@12155 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -4,20 +4,14 @@
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
* @requires OpenLayers/Format/XML.js
|
||||
* @requires OpenLayers/Format/XML/VersionedOGC.js
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class: OpenLayers.Format.Context
|
||||
* Base class for both Format.WMC and Format.OWSContext
|
||||
*/
|
||||
OpenLayers.Format.Context = OpenLayers.Class({
|
||||
|
||||
/**
|
||||
* APIProperty: version
|
||||
* {String} Specify a version string if one is known.
|
||||
*/
|
||||
version: null,
|
||||
OpenLayers.Format.Context = OpenLayers.Class(OpenLayers.Format.XML.VersionedOGC, {
|
||||
|
||||
/**
|
||||
* Property: layerOptions
|
||||
@@ -35,13 +29,6 @@ OpenLayers.Format.Context = OpenLayers.Class({
|
||||
*/
|
||||
layerParams: null,
|
||||
|
||||
/**
|
||||
* Property: parser
|
||||
* {Object} Instance of the versioned parser. Cached for multiple read and
|
||||
* write calls of the same version.
|
||||
*/
|
||||
parser: null,
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Format.Context
|
||||
* Create a new parser for Context documents.
|
||||
@@ -50,10 +37,6 @@ OpenLayers.Format.Context = OpenLayers.Class({
|
||||
* options - {Object} An optional object whose properties will be set on
|
||||
* this instance.
|
||||
*/
|
||||
initialize: function(options) {
|
||||
OpenLayers.Util.extend(this, options);
|
||||
this.options = options;
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: read
|
||||
@@ -72,16 +55,8 @@ OpenLayers.Format.Context = OpenLayers.Class({
|
||||
* {<OpenLayers.Map>} A map based on the context.
|
||||
*/
|
||||
read: function(data, options) {
|
||||
if(typeof data == "string") {
|
||||
data = OpenLayers.Format.XML.prototype.read.apply(this, [data]);
|
||||
}
|
||||
var root = data.documentElement;
|
||||
var version = this.version;
|
||||
if(!version) {
|
||||
version = root.getAttribute("version");
|
||||
}
|
||||
var parser = this.getParser(version);
|
||||
var context = parser.read(data, options);
|
||||
var context = OpenLayers.Format.XML.VersionedOGC.prototype.read.apply(this,
|
||||
arguments);
|
||||
var map;
|
||||
if(options && options.map) {
|
||||
this.context = context;
|
||||
@@ -334,10 +309,8 @@ OpenLayers.Format.Context = OpenLayers.Class({
|
||||
*/
|
||||
write: function(obj, options) {
|
||||
obj = this.toContext(obj);
|
||||
var version = options && options.version;
|
||||
var parser = this.getParser(version);
|
||||
var context = parser.write(obj, options);
|
||||
return context;
|
||||
return OpenLayers.Format.XML.VersionedOGC.prototype.write.apply(this,
|
||||
arguments);
|
||||
},
|
||||
|
||||
CLASS_NAME: "OpenLayers.Format.Context"
|
||||
|
||||
Reference in New Issue
Block a user