| 260 | | |
|---|
| | 260 | |
|---|
| | 261 | #grid is either a gml:Grid or a gml:RectifiedGrid if supplied as part of the DescribeCoverage response. |
|---|
| | 262 | def _getGrid(self): |
|---|
| | 263 | if not hasattr(self, 'descCov'): |
|---|
| | 264 | self.descCov=self._service.getDescribeCoverage(self.id) |
|---|
| | 265 | gridelem= self.descCov.find(ns('CoverageOffering/')+ns('domainSet/')+ns('spatialDomain/')+'{http://www.opengis.net/gml}RectifiedGrid') |
|---|
| | 266 | if gridelem is not None: |
|---|
| | 267 | grid=RectifiedGrid(gridelem) |
|---|
| | 268 | else: |
|---|
| | 269 | gridelem=self.descCov.find(ns('CoverageOffering/')+ns('domainSet/')+ns('spatialDomain/')+'{http://www.opengis.net/gml}Grid') |
|---|
| | 270 | grid=Grid(gridelem) |
|---|
| | 271 | return grid |
|---|
| | 272 | grid=property(_getGrid, None) |
|---|
| | 273 | |
|---|
| 322 | | |
|---|
| | 335 | |
|---|
| | 336 | #Adding classes to represent gml:grid and gml:rectifiedgrid. One of these is used for the cvg.grid property |
|---|
| | 337 | #(where cvg is a member of the contents dictionary) |
|---|
| | 338 | #There is no simple way to convert the offset values in a rectifiedgrid grid to real values without CRS understanding, therefore this is beyond the current scope of owslib, so the representation here is purely to provide access to the information in the GML. |
|---|
| | 339 | |
|---|
| | 340 | class Grid(object): |
|---|
| | 341 | ''' Simple grid class to provide axis and value information for a gml grid ''' |
|---|
| | 342 | def __init__(self, grid): |
|---|
| | 343 | self.axislabels = [] |
|---|
| | 344 | self.dimension=None |
|---|
| | 345 | self.axes={} |
|---|
| | 346 | if grid is not None: |
|---|
| | 347 | self.dimension=int(grid.get('dimension')) |
|---|
| | 348 | self.lowlimits= grid.find('{http://www.opengis.net/gml}limits/{http://www.opengis.net/gml}GridEnvelope/{http://www.opengis.net/gml}low').text.split(' ') |
|---|
| | 349 | self.highlimits = grid.find('{http://www.opengis.net/gml}limits/{http://www.opengis.net/gml}GridEnvelope/{http://www.opengis.net/gml}high').text.split(' ') |
|---|
| | 350 | for axis in grid.findall('{http://www.opengis.net/gml}axisName'): |
|---|
| | 351 | self.axislabels.append(axis.text) |
|---|
| | 352 | |
|---|
| | 353 | |
|---|
| | 354 | class RectifiedGrid(Grid): |
|---|
| | 355 | ''' RectifiedGrid class, extends Grid with additional offset vector information ''' |
|---|
| | 356 | def __init__(self, rectifiedgrid): |
|---|
| | 357 | super(RectifiedGrid,self).__init__(rectifiedgrid) |
|---|
| | 358 | self.origin=rectifiedgrid.find('{http://www.opengis.net/gml}origin/{http://www.opengis.net/gml}pos').text.split() |
|---|
| | 359 | self.offsetvectors=[] |
|---|
| | 360 | for offset in rectifiedgrid.findall('{http://www.opengis.net/gml}offsetVector'): |
|---|
| | 361 | self.offsetvectors.append(offset.text.split()) |
|---|
| | 362 | |
|---|