/[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 439 by jonathan, Thu Feb 27 15:54:05 2003 UTC revision 465 by jonathan, Wed Mar 5 18:18:06 2003 UTC
# Line 151  class ProcessSession(xml.sax.handler.Con Line 151  class ProcessSession(xml.sax.handler.Con
151          stroke = parse_color(attrs.get((None, 'stroke'), "#000000"))          stroke = parse_color(attrs.get((None, 'stroke'), "#000000"))
152          stroke_width = int(attrs.get((None, 'stroke_width'), "1"))          stroke_width = int(attrs.get((None, 'stroke_width'), "1"))
153          self.aLayer = layer_class(title, filename, fill = fill,          self.aLayer = layer_class(title, filename, fill = fill,
154                                    stroke = stroke, stroke_width = stroke_width)                                    stroke = stroke, lineWidth = stroke_width)
155      start_dispatcher['layer'] = "start_layer"      start_dispatcher['layer'] = "start_layer"
156    
157      def end_layer(self, name, qname):      def end_layer(self, name, qname):
# Line 159  class ProcessSession(xml.sax.handler.Con Line 159  class ProcessSession(xml.sax.handler.Con
159      end_dispatcher['layer'] = "end_layer"      end_dispatcher['layer'] = "end_layer"
160    
161      def start_classification(self, name, qname, attrs):      def start_classification(self, name, qname, attrs):
162          self.aLayer.GetClassification().SetField(          field = attrs.get((None, 'field'), None)
163              attrs.get((None, 'field'), None))  
164            fieldType = attrs.get((None, 'field_type'), None)
165            dbFieldType = self.aLayer.GetFieldType(field)
166    
167            if fieldType != dbFieldType:
168                raise ValueError(_("xml field type differs from database!"))
169    
170            # setup conversion routines depending on the kind of data
171            # we will be seeing later on
172            if fieldType == FIELDTYPE_STRING:
173                self.conv = str
174            elif fieldType == FIELDTYPE_INT:
175                self.conv = lambda p: int(float(p))
176            elif fieldType == FIELDTYPE_DOUBLE:
177                self.conv = float
178    
179            self.aLayer.GetClassification().SetField(field)
180    
181      start_dispatcher['classification'] = "start_classification"      start_dispatcher['classification'] = "start_classification"
182    
183      def end_classification(self, name, qname):      def end_classification(self, name, qname):
# Line 182  class ProcessSession(xml.sax.handler.Con Line 199  class ProcessSession(xml.sax.handler.Con
199      def start_clpoint(self, name, qname, attrs):      def start_clpoint(self, name, qname, attrs):
200          attrib_value = attrs.get((None, 'value'), "0")          attrib_value = attrs.get((None, 'value'), "0")
201    
202          try:          #try:
203              value  = Str2Num(attrib_value)              #value  = Str2Num(attrib_value)
204          except:          #except:
205              value  = attrib_value              #value  = attrib_value
206    
207            value = self.conv(attrib_value)
208    
209          self.cl_group = ClassGroupSingleton(value)          self.cl_group = ClassGroupSingleton(value)
210          self.cl_group.SetLabel(attrs.get((None, 'label'), ""))          self.cl_group.SetLabel(attrs.get((None, 'label'), ""))
# Line 202  class ProcessSession(xml.sax.handler.Con Line 221  class ProcessSession(xml.sax.handler.Con
221      def start_clrange(self, name, qname, attrs):      def start_clrange(self, name, qname, attrs):
222    
223          try:          try:
224              min = Str2Num(attrs.get((None, 'min'), "0"))              min = self.conv(attrs.get((None, 'min'), "0"))
225              max = Str2Num(attrs.get((None, 'max'), "0"))              max = self.conv(attrs.get((None, 'max'), "0"))
226                #min = Str2Num(attrs.get((None, 'min'), "0"))
227                #max = Str2Num(attrs.get((None, 'max'), "0"))
228          except ValueError:          except ValueError:
229              raise ValueError(_("Classification range is not a number!"))              raise ValueError(_("Classification range is not a number!"))
230    
# Line 220  class ProcessSession(xml.sax.handler.Con Line 241  class ProcessSession(xml.sax.handler.Con
241      end_dispatcher['clrange'] = "end_clrange"      end_dispatcher['clrange'] = "end_clrange"
242    
243      def start_cldata(self, name, qname, attrs):      def start_cldata(self, name, qname, attrs):
244          self.cl_prop.SetStroke(parse_color(attrs.get((None, 'stroke'), "None")))          self.cl_prop.SetLineColor(
245          self.cl_prop.SetStrokeWidth(              parse_color(attrs.get((None, 'stroke'), "None")))
246            self.cl_prop.SetLineWidth(
247              int(attrs.get((None, 'stroke_width'), "0")))              int(attrs.get((None, 'stroke_width'), "0")))
248          self.cl_prop.SetFill(parse_color(attrs.get((None, 'fill'), "None")))          self.cl_prop.SetFill(parse_color(attrs.get((None, 'fill'), "None")))
249      start_dispatcher['cldata'] = "start_cldata"      start_dispatcher['cldata'] = "start_cldata"

Legend:
Removed from v.439  
changed lines
  Added in v.465

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26