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