1
|
/*
|
2
|
License: LGPL as per: http://www.gnu.org/copyleft/lesser.html
|
3
|
$Id$
|
4
|
*/
|
5
|
|
6
|
/**
|
7
|
* Stores a Web Map Server (WMS) Capabilities document as defined by the
|
8
|
* Open Geospatial Consortium (http://opengis.org and extensions the the WMC.
|
9
|
*
|
10
|
* @constructor
|
11
|
* @author Mike Adair
|
12
|
* @param modelNode The model's XML object node from the configuration document.
|
13
|
* @param parent The model object that this widget belongs to.
|
14
|
*/
|
15
|
function WmsCapabilities(modelNode, parent) {
|
16
|
// Inherit the ModelBase functions and parameters
|
17
|
ModelBase.apply(this, new Array(modelNode, parent));
|
18
|
|
19
|
this.namespace = "xmlns:wms='http://www.opengis.net/wms' xmlns:xlink='http://www.w3.org/1999/xlink'";
|
20
|
|
21
|
/**
|
22
|
* Returns the serverUrl for the WMS request passed in with the specified
|
23
|
* HTTP method from the capabilities doc.
|
24
|
* @param requestName the WMS request to get the URL for
|
25
|
* @param method http method for the request
|
26
|
* @param feature ignored for WMS docs
|
27
|
* @return URL for the specified request with the specified method
|
28
|
*/
|
29
|
this.getServerUrl = function(requestName, method, feature) {
|
30
|
var version = this.getVersion();
|
31
|
if (version == "1.0.0") {
|
32
|
requestName = requestName.substring(3); //strip of "Get" part of request name
|
33
|
var xpath = "/WMT_MS_Capabilities/Capability/Request/"+requestName;
|
34
|
if (method.toLowerCase() == "post") {
|
35
|
xpath += "/DCPType/HTTP/Post";
|
36
|
} else {
|
37
|
xpath += "/DCPType/HTTP/Get";
|
38
|
}
|
39
|
return this.doc.selectSingleNode(xpath).getAttribute("onlineResource");
|
40
|
} else {
|
41
|
var xpath = "/WMT_MS_Capabilities/Capability/Request/"+requestName;
|
42
|
if (method.toLowerCase() == "post") {
|
43
|
xpath += "/DCPType/HTTP/Post/OnlineResource";
|
44
|
} else {
|
45
|
xpath += "/DCPType/HTTP/Get/OnlineResource";
|
46
|
}
|
47
|
return this.doc.selectSingleNode(xpath).getAttribute("xlink:href");
|
48
|
}
|
49
|
}
|
50
|
|
51
|
/**
|
52
|
* Returns the version for the WMS
|
53
|
* @return the WMS version
|
54
|
*/
|
55
|
this.getVersion = function() {
|
56
|
var xpath = "/WMT_MS_Capabilities";
|
57
|
return this.doc.selectSingleNode(xpath).getAttribute("version");
|
58
|
}
|
59
|
|
60
|
/**
|
61
|
* @return the title of the WMS server
|
62
|
*/
|
63
|
this.getServerTitle = function() {
|
64
|
var xpath = "/WMT_MS_Capabilities/Service/Title";
|
65
|
var node = this.doc.selectSingleNode(xpath);
|
66
|
return node.firstChild.nodeValue;
|
67
|
}
|
68
|
|
69
|
/**
|
70
|
* @return the first image format listed
|
71
|
*/
|
72
|
this.getImageFormat = function() {
|
73
|
var version = this.getVersion();
|
74
|
if (version == "1.0.0") {
|
75
|
var xpath = "/WMT_MS_Capabilities/Capability/Request/Map/Format"; //strip of "Get" part of request name
|
76
|
var node = this.doc.selectSingleNode(xpath);
|
77
|
if(_SARISSA_IS_IE) {
|
78
|
return "image/"+node.firstChild.baseName.toLowerCase();
|
79
|
}
|
80
|
else {
|
81
|
return "image/"+node.firstChild.localName.toLowerCase();
|
82
|
}
|
83
|
} else {
|
84
|
var xpath = "/WMT_MS_Capabilities/Capability/Request/GetMap/Format";
|
85
|
var node = this.doc.selectSingleNode(xpath);
|
86
|
return node.firstChild.nodeValue;
|
87
|
}
|
88
|
}
|
89
|
|
90
|
/**
|
91
|
* @return the name of the WMS server
|
92
|
*/
|
93
|
this.getServiceName = function() {
|
94
|
var xpath = "/WMT_MS_Capabilities/Service/Name";
|
95
|
var node = this.doc.selectSingleNode(xpath);
|
96
|
return node.firstChild.nodeValue;
|
97
|
}
|
98
|
|
99
|
/**
|
100
|
* Returns the Layer node with the specified name from the list of nodes
|
101
|
* selected by the nodeSelectXpath from the capabilities doc.
|
102
|
* @param featureName name of the featureType to look up
|
103
|
* @return the Layer node with the specified name.
|
104
|
*/
|
105
|
this.getFeatureNode = function(featureName) {
|
106
|
return this.doc.selectSingleNode(this.nodeSelectXpath+"[Name='"+featureName+"']");
|
107
|
}
|
108
|
|
109
|
}
|
110
|
|