1
|
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
2
|
* full list of contributors). Published under the 2-clause BSD license.
|
3
|
* See license.txt in the OpenLayers distribution or repository for the
|
4
|
* full text of the license. */
|
5
|
|
6
|
/**
|
7
|
* @requires OpenLayers/Format/Context.js
|
8
|
*/
|
9
|
|
10
|
/**
|
11
|
* Class: OpenLayers.Format.OWSContext
|
12
|
* Read and write OWS Context documents. OWS Context documents are a
|
13
|
* preliminary OGC (Open Geospatial Consortium) standard for storing the
|
14
|
* state of a web mapping application. In a way it is the successor to
|
15
|
* Web Map Context (WMC), since it is more generic and more types of layers
|
16
|
* can be stored. Also, nesting of layers is supported since version 0.3.1.
|
17
|
* For more information see: http://www.ogcnetwork.net/context
|
18
|
*
|
19
|
* Inherits from:
|
20
|
* - <OpenLayers.Format.Context>
|
21
|
*/
|
22
|
OpenLayers.Format.OWSContext = OpenLayers.Class(OpenLayers.Format.Context,{
|
23
|
|
24
|
/**
|
25
|
* APIProperty: defaultVersion
|
26
|
* {String} Version number to assume if none found. Default is "0.3.1".
|
27
|
*/
|
28
|
defaultVersion: "0.3.1",
|
29
|
|
30
|
/**
|
31
|
* Constructor: OpenLayers.Format.OWSContext
|
32
|
* Create a new parser for OWS Context documents.
|
33
|
*
|
34
|
* Parameters:
|
35
|
* options - {Object} An optional object whose properties will be set on
|
36
|
* this instance.
|
37
|
*/
|
38
|
|
39
|
/**
|
40
|
* Method: getVersion
|
41
|
* Returns the version to use. Subclasses can override this function
|
42
|
* if a different version detection is needed.
|
43
|
*
|
44
|
* Parameters:
|
45
|
* root - {DOMElement}
|
46
|
* options - {Object} Optional configuration object.
|
47
|
*
|
48
|
* Returns:
|
49
|
* {String} The version to use.
|
50
|
*/
|
51
|
getVersion: function(root, options) {
|
52
|
var version = OpenLayers.Format.XML.VersionedOGC.prototype.getVersion.apply(
|
53
|
this, arguments);
|
54
|
// 0.3.1 is backwards compatible with 0.3.0
|
55
|
if (version === "0.3.0") {
|
56
|
version = this.defaultVersion;
|
57
|
}
|
58
|
return version;
|
59
|
},
|
60
|
|
61
|
/**
|
62
|
* Method: toContext
|
63
|
* Create a context object free from layer given a map or a
|
64
|
* context object.
|
65
|
*
|
66
|
* Parameters:
|
67
|
* obj - {<OpenLayers.Map> | Object} The map or context.
|
68
|
*
|
69
|
* Returns:
|
70
|
* {Object} A context object.
|
71
|
*/
|
72
|
toContext: function(obj) {
|
73
|
var context = {};
|
74
|
if(obj.CLASS_NAME == "OpenLayers.Map") {
|
75
|
context.bounds = obj.getExtent();
|
76
|
context.maxExtent = obj.maxExtent;
|
77
|
context.projection = obj.projection;
|
78
|
context.size = obj.getSize();
|
79
|
context.layers = obj.layers;
|
80
|
}
|
81
|
return context;
|
82
|
},
|
83
|
|
84
|
CLASS_NAME: "OpenLayers.Format.OWSContext"
|
85
|
|
86
|
});
|