31 |
loadCapabilities(filename) |
loadCapabilities(filename) |
32 |
printCapabilities() |
printCapabilities() |
33 |
|
|
34 |
|
getVersion() |
35 |
|
|
36 |
Requirements: |
Requirements: |
37 |
- PyOGCLib <http://www.sourceforge.net/projects/pyogclib> |
- PyOGCLib <http://www.sourceforge.net/projects/pyogclib> |
38 |
|
|
117 |
|
|
118 |
|
|
119 |
def fetchCapabilities(self, resource): |
def fetchCapabilities(self, resource): |
120 |
"""Fetches the WMS capabilities from an Internet resource""" |
""" |
121 |
|
Fetches the WMS capabilities from an Internet resource |
122 |
|
|
123 |
|
WMS Protocol version 1.1 is tried first, then 1.0. The |
124 |
|
protocol version used can be queried by the getVersion() |
125 |
|
method for later use. If both tries fail, errorMsg will be |
126 |
|
set accordingly, which can be fetched with getErrorMsg(). |
127 |
|
""" |
128 |
|
|
129 |
self.wmsVersion = "1.1" |
self.wmsVersion = "1.1" |
130 |
self.capabilities = self.getCapabilities(resource, self.wmsVersion) |
self.capabilities = self.getCapabilities(resource, self.wmsVersion) |
131 |
if not self.capabilities: |
if not self.capabilities: |
132 |
self.wmsVersion = "1.0" |
self.wmsVersion = "1.0" |
133 |
self.capabilities = self.getCapabilities(resource, self.wmsVersion) |
self.capabilities = self.getCapabilities(resource, self.wmsVersion) |
134 |
|
if not self.capabilities: |
135 |
|
self.wmsVersion = None |
136 |
|
self.errorMsg \ |
137 |
|
= _("Resource '%s' " |
138 |
|
"does support neither WMS version 1.1 nor 1.0") \ |
139 |
|
% resource |
140 |
|
|
141 |
if self.capabilities: |
if self.capabilities: |
142 |
self.grok(self.capabilities) |
self.grok(self.capabilities) |
174 |
print self.capabilities |
print self.capabilities |
175 |
|
|
176 |
|
|
177 |
|
def getVersion(self): |
178 |
|
""" |
179 |
|
Returns the WMS protocol version |
180 |
|
|
181 |
|
If no capabilities could be fetched, None is returned. |
182 |
|
""" |
183 |
|
return self.wmsVersion |
184 |
|
|
185 |
|
|
186 |
if __name__ == "__main__": |
if __name__ == "__main__": |
187 |
capabilities \ |
capabilities \ |