/[thuban]/branches/WIP-pyshapelib-bramz/Thuban/Model/load.py
ViewVC logotype

Diff of /branches/WIP-pyshapelib-bramz/Thuban/Model/load.py

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

revision 364 by bh, Thu Aug 22 10:25:30 2002 UTC revision 365 by jonathan, Mon Jan 27 11:47:53 2003 UTC
# Line 23  from Thuban.Model.map import Map Line 23  from Thuban.Model.map import Map
23  from Thuban.Model.layer import Layer  from Thuban.Model.layer import Layer
24  from Thuban.Model.color import Color  from Thuban.Model.color import Color
25  from Thuban.Model.proj import Projection  from Thuban.Model.proj import Projection
26    from Thuban.Model.classification import Classification
27    
28    
29  def parse_color(color):  def parse_color(color):
# Line 51  def parse_color(color): Line 52  def parse_color(color):
52  class ProcessSession(xml.sax.handler.ContentHandler):  class ProcessSession(xml.sax.handler.ContentHandler):
53    
54      # Dictionary mapping element names (or (URI, element name) pairs for      # Dictionary mapping element names (or (URI, element name) pairs for
55      # documents using amespaces) to method names. The methods should      # documents using namespaces) to method names. The methods should
56      # accept the same parameters as the startElement (or startElementNS)      # accept the same parameters as the startElement (or startElementNS)
57      # methods. The start_dispatcher is used by the default startElement      # methods. The start_dispatcher is used by the default startElement
58      # and startElementNS methods to call a method for the open tag of an      # and startElementNS methods to call a method for the open tag of an
# Line 151  class ProcessSession(xml.sax.handler.Con Line 152  class ProcessSession(xml.sax.handler.Con
152          self.aMap.AddLayer(self.aLayer)          self.aMap.AddLayer(self.aLayer)
153      end_dispatcher['layer'] = "end_layer"      end_dispatcher['layer'] = "end_layer"
154    
155        def start_classification(self, name, qname, attrs):
156            self.aLayer.classification.setField(attrs.get((None, 'field'), None))
157        start_dispatcher['classification'] = "start_classification"
158    
159        def end_classification(self, name, qname):
160            pass
161        end_dispatcher['classification'] = "end_classification"
162    
163        def start_clnull(self, name, qname, attrs):
164            self.cl_data = {}
165        start_dispatcher['clnull'] = "start_clnull"
166    
167        def end_clnull(self, name, qname):
168            self.aLayer.classification.setNull(self.cl_data)
169            del self.cl_data
170        end_dispatcher['clnull'] = "end_clnull"
171    
172        def start_clpoint(self, name, qname, attrs):
173            attrib_value = attrs.get((None, 'value'), "0")
174    
175            try:
176                self.cl_value  = int(attrib_value)
177            except:
178                self.cl_value  = attrib_value
179    
180            self.cl_data = {}
181        start_dispatcher['clpoint'] = "start_clpoint"
182    
183        def end_clpoint(self, name, qname):
184            self.aLayer.classification.addPoint(self.cl_value, self.cl_data)
185            del self.cl_value, self.cl_data
186        end_dispatcher['clpoint'] = "end_clpoint"
187    
188        def start_clrange(self, name, qname, attrs):
189    
190            try:
191                self.cl_low = int(attrs.get((None, 'low'), "0"))
192                self.cl_high = int(attrs.get((None, 'high'), "0"))
193            except ValueError:
194                raise ValueError("Classification range is not a number!")
195    
196            self.cl_data = {}
197        start_dispatcher['clrange'] = "start_clrange"
198    
199        def end_clrange(self, name, qname):
200            self.aLayer.classification.addRange(
201                self.cl_low, self.cl_high, self.cl_data)
202            del self.cl_low, self.cl_high, self.cl_data
203        end_dispatcher['clrange'] = "end_clrange"
204    
205        def start_cldata(self, name, qname, attrs):
206            self.cl_data['stroke'] = parse_color(
207                                     attrs.get((None, 'stroke'), "None"))
208            self.cl_data['stroke_width'] = int(
209                                     attrs.get((None, 'stroke_width'), "0"))
210            self.cl_data['fill'] = parse_color(
211                                     attrs.get((None, 'fill'), "None"))
212        start_dispatcher['cldata'] = "start_cldata"
213    
214        def end_cldata(self, name, qname):
215            pass
216        end_dispatcher['cldata'] = "end_cldata"
217    
218      def start_table(self, name, qname, attrs):      def start_table(self, name, qname, attrs):
219          print "table title: %s" % attrs.get('title', None)          print "table title: %s" % attrs.get('title', None)
220      start_dispatcher['table'] = "start_table"      start_dispatcher['table'] = "start_table"

Legend:
Removed from v.364  
changed lines
  Added in v.365

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26