/[thuban]/branches/WIP-pyshapelib-bramz/Extensions/wms/parser.py
ViewVC logotype

Diff of /branches/WIP-pyshapelib-bramz/Extensions/wms/parser.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2165 by joey, Tue Apr 13 16:42:48 2004 UTC revision 2439 by joey, Thu Dec 9 10:37:44 2004 UTC
# Line 40  class WMSCapabilitiesParser: Line 40  class WMSCapabilitiesParser:
40      getLayerBBox(layer, srs)      getLayerBBox(layer, srs)
41    
42      isQueryable(layer)      isQueryable(layer)
   
     get_srs_discrepancies()  
43  """  """
44    
45  __version__ = "$Revision$"  __version__ = "$Revision$"
# Line 49  __version__ = "$Revision$" Line 47  __version__ = "$Revision$"
47  # $Id$  # $Id$
48    
49  import xml.dom.minidom  import xml.dom.minidom
50    from xml.dom import Node
51    
52  from domutils import getElementsByName, getElementByName  from domutils import getElementsByName, getElementByName
53    
# Line 69  class WMSCapabilitiesParser: Line 68  class WMSCapabilitiesParser:
68      fees = None      fees = None
69      access = None      access = None
70      formats = None      formats = None
     srs_discrepancies = None  
71      error = None      error = None
72    
73    
# Line 118  class WMSCapabilitiesParser: Line 116  class WMSCapabilitiesParser:
116                 and foo.childNodes[0].data.lower() != 'none':                 and foo.childNodes[0].data.lower() != 'none':
117              self.access = foo.childNodes[0].data              self.access = foo.childNodes[0].data
118                    
119          # Extract output format information          foo = getElementByName(getElementByName(
120          foo = getElementsByName(              root, 'Capability'), 'Request')
121              getElementByName(getElementByName(getElementByName(  
122              root, 'Capability'), 'Request'), 'GetMap'), 'Format')          # Need to distinguish between Map and GetMap for v1.0 and v1.1
123          self.formats = map((lambda i: i.childNodes[0].data), foo)          bar = getElementByName(foo, 'GetMap')
124            if bar:
125                # WMS 1.1
126                foo = getElementsByName(bar, 'Format')
127                self.formats = map((lambda i: i.childNodes[0].data), foo)
128            else:
129                # WMS 1.0
130                foo = getElementByName(getElementByName(
131                    foo, 'Map'), 'Format')
132                for node in foo.childNodes:
133                    if node.nodeType == Node.ELEMENT_NODE:
134                        try:
135                            self.formats.append(node.nodeName)
136                        except AttributeError:
137                            self.formats = [node.nodeName]
138    
139          # Extract layer names          # Extract layer names
140          self.layers = []          self.layers = []
# Line 170  class WMSCapabilitiesParser: Line 182  class WMSCapabilitiesParser:
182                  if srs[0:5] == 'EPSG:':                  if srs[0:5] == 'EPSG:':
183                      srs = srs[5:]                      srs = srs[5:]
184                  try:                  try:
185                      self.layers[index]['srs'].append(srs)                      int(srs)
186                  except KeyError:                      try:
187                      self.layers[index]['srs'] = [srs]                          self.layers[index]['srs'].append(srs)
188                        except KeyError:
189                            self.layers[index]['srs'] = [srs]
190                    except ValueError:
191                        if srs[0:4].upper() == 'AUTO' \
192                               or srs[0:4].upper() == 'NONE':
193                            try:
194                                self.layers[index]['_srs_'].append(srs)
195                            except KeyError:
196                                self.layers[index]['_srs_'] = [srs]
197                        else:
198                            self.error.append(_("SRS '%s' is not numerical and not"
199                                                " AUTO/NONE in layer '%s'") \
200                                              % (srs, self.layers[index]['title']))
201    
202          foo = getElementByName(top, 'LatLonBoundingBox')          foo = getElementByName(top, 'LatLonBoundingBox')
203          if foo is not None:          if foo is not None:
# Line 445  class WMSCapabilitiesParser: Line 470  class WMSCapabilitiesParser:
470                              if srs in pivot['bbox']:                              if srs in pivot['bbox']:
471                                  return pivot['bbox'][srs]                                  return pivot['bbox'][srs]
472    
473            # No matching BBox found, let's see if it was EPSG:4326
474            if srs == '4326':
475                return self.getLayerLatLonBBox(name)
476    
477          return None          return None
478    
479    
# Line 475  class WMSCapabilitiesParser: Line 504  class WMSCapabilitiesParser:
504          return 0          return 0
505    
506    
     def get_srs_discrepancies(self):  
         """  
         Returns a list of layer identifications where the denoted SRS  
         values differ from the calculated ones through BoundingBox  
         elements.  
         """  
         return self.srs_discrepancies  
   
507    
508  if __name__ == "__main__":  if __name__ == "__main__":
509      print "This module cannot be executed standalone."      print "This module cannot be executed standalone."

Legend:
Removed from v.2165  
changed lines
  Added in v.2439

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26