/[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 1339 by jonathan, Tue Jul 1 16:10:14 2003 UTC revision 1428 by jonathan, Wed Jul 16 13:23:01 2003 UTC
# Line 120  class SessionLoader(XMLReader): Line 120  class SessionLoader(XMLReader):
120              'labellayer'    : ("start_labellayer",     None),              'labellayer'    : ("start_labellayer",     None),
121              'label'         : ("start_label",          None)}              'label'         : ("start_label",          None)}
122    
123          # all dispatchers should be used for the 0.8 namespace          # all dispatchers should be used for the 0.8 and 0.9 namespaces too
124          xmlns = "http://thuban.intevation.org/dtds/thuban-0.8.dtd"          for xmlns in ("http://thuban.intevation.org/dtds/thuban-0.8.dtd",
125          for key, value in dispatchers.items():                        "http://thuban.intevation.org/dtds/thuban-0.9-dev.dtd"):
126              dispatchers[(xmlns, key)] = value              for key, value in dispatchers.items():
127                    dispatchers[(xmlns, key)] = value
128    
129          XMLReader.AddDispatchers(self, dispatchers)          XMLReader.AddDispatchers(self, dispatchers)
130    
# Line 249  class SessionLoader(XMLReader): Line 250  class SessionLoader(XMLReader):
250                                    AttrDesc("left", True, conversion="table"),                                    AttrDesc("left", True, conversion="table"),
251                                    AttrDesc("leftcolumn", True),                                    AttrDesc("leftcolumn", True),
252                                    AttrDesc("right", True, conversion="table"),                                    AttrDesc("right", True, conversion="table"),
253                                    AttrDesc("rightcolumn")])                                    AttrDesc("rightcolumn", True),
254    
255                                      # jointype is required for file
256                                      # version 0.9 but this attribute
257                                      # wasn't in the 0.8 version because of
258                                      # an oversight so we assume it's
259                                      # optional since we want to handle
260                                      # both file format versions here.
261                                      AttrDesc("jointype", False,
262                                               default="INNER")])
263    
264            jointype = attrs["jointype"]
265            if jointype == "LEFT OUTER":
266                outer_join = True
267            elif jointype == "INNER":
268                outer_join = False
269            else:
270                raise LoadError("jointype %r not supported" % jointype )
271          table = TransientJoinedTable(self.theSession.TransientDB(),          table = TransientJoinedTable(self.theSession.TransientDB(),
272                                       attrs["left"], attrs["leftcolumn"],                                       attrs["left"], attrs["leftcolumn"],
273                                       attrs["right"], attrs["rightcolumn"])                                       attrs["right"], attrs["rightcolumn"],
274                                         outer_join = outer_join)
275          table.SetTitle(attrs["title"])          table.SetTitle(attrs["title"])
276          self.idmap[attrs["id"]] = self.theSession.AddTable(table)          self.idmap[attrs["id"]] = self.theSession.AddTable(table)
277    
278      def start_map(self, name, qname, attrs):      def start_map(self, name, qname, attrs):
279          """Start a map."""          """Start a map."""
280          self.aMap = Map(attrs.get((None, 'title'), None))          self.aMap = Map(self.encode(attrs.get((None, 'title'), None)))
281    
282      def end_map(self, name, qname):      def end_map(self, name, qname):
283          self.theSession.AddMap(self.aMap)          self.theSession.AddMap(self.aMap)
# Line 344  class SessionLoader(XMLReader): Line 363  class SessionLoader(XMLReader):
363          elif fieldType == FIELDTYPE_DOUBLE:          elif fieldType == FIELDTYPE_DOUBLE:
364              self.conv = float              self.conv = float
365    
366          self.aLayer.GetClassification().SetFieldInfo(field, fieldType)          self.aLayer.SetClassificationField(field)
367    
368      def end_classification(self, name, qname):      def end_classification(self, name, qname):
369          pass          pass
# Line 362  class SessionLoader(XMLReader): Line 381  class SessionLoader(XMLReader):
381      def start_clpoint(self, name, qname, attrs):      def start_clpoint(self, name, qname, attrs):
382          attrib_value = attrs.get((None, 'value'), "0")          attrib_value = attrs.get((None, 'value'), "0")
383    
384          value = self.conv(attrib_value)          field = self.aLayer.GetClassificationField()
385            if self.aLayer.GetFieldType(field) == FIELDTYPE_STRING:
386                value = self.encode(attrib_value)
387            else:
388                value = self.conv(attrib_value)
389          self.cl_group = ClassGroupSingleton(value)          self.cl_group = ClassGroupSingleton(value)
390          self.cl_group.SetLabel(self.encode(attrs.get((None, 'label'), "")))          self.cl_group.SetLabel(self.encode(attrs.get((None, 'label'), "")))
391          self.cl_prop = ClassGroupProperties()          self.cl_prop = ClassGroupProperties()
# Line 385  class SessionLoader(XMLReader): Line 407  class SessionLoader(XMLReader):
407              if range is not None:              if range is not None:
408                  self.cl_group = ClassGroupRange(Range(range))                  self.cl_group = ClassGroupRange(Range(range))
409              elif min is not None and max is not None:              elif min is not None and max is not None:
410                  self.cl_group = ClassGroupRange(self.conv(min), self.conv(max))                  self.cl_group = ClassGroupRange((self.conv(min),
411                                                     self.conv(max)))
412              else:              else:
413                  self.cl_group = ClassGroupRange(Range(None))                  self.cl_group = ClassGroupRange(Range(None))
414    

Legend:
Removed from v.1339  
changed lines
  Added in v.1428

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26