/[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 1642 by bh, Mon Aug 25 10:54:31 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 177  class SessionLoader(XMLReader): Line 178  class SessionLoader(XMLReader):
178    
179          for d in descr:          for d in descr:
180              if d.required and not attrs.has_key(d.fullname):              if d.required and not attrs.has_key(d.fullname):
181                  pass                  raise LoadError("Element %s requires an attribute %r"
182              #raise LoadError("Element %s requires an attribute %r"                                  % (element, d.name))
             #                    % (element, d.name))  
183              value = attrs.get(d.fullname, d.default)              value = attrs.get(d.fullname, d.default)
184    
185              if d.conversion == "shapesource":              if d.conversion == "shapesource":
# Line 249  class SessionLoader(XMLReader): Line 249  class SessionLoader(XMLReader):
249                                    AttrDesc("left", True, conversion="table"),                                    AttrDesc("left", True, conversion="table"),
250                                    AttrDesc("leftcolumn", True),                                    AttrDesc("leftcolumn", True),
251                                    AttrDesc("right", True, conversion="table"),                                    AttrDesc("right", True, conversion="table"),
252                                    AttrDesc("rightcolumn")])                                    AttrDesc("rightcolumn", True),
253    
254                                      # jointype is required for file
255                                      # version 0.9 but this attribute
256                                      # wasn't in the 0.8 version because of
257                                      # an oversight so we assume it's
258                                      # optional since we want to handle
259                                      # both file format versions here.
260                                      AttrDesc("jointype", False,
261                                               default="INNER")])
262    
263            jointype = attrs["jointype"]
264            if jointype == "LEFT OUTER":
265                outer_join = True
266            elif jointype == "INNER":
267                outer_join = False
268            else:
269                raise LoadError("jointype %r not supported" % jointype )
270          table = TransientJoinedTable(self.theSession.TransientDB(),          table = TransientJoinedTable(self.theSession.TransientDB(),
271                                       attrs["left"], attrs["leftcolumn"],                                       attrs["left"], attrs["leftcolumn"],
272                                       attrs["right"], attrs["rightcolumn"])                                       attrs["right"], attrs["rightcolumn"],
273                                         outer_join = outer_join)
274          table.SetTitle(attrs["title"])          table.SetTitle(attrs["title"])
275          self.idmap[attrs["id"]] = self.theSession.AddTable(table)          self.idmap[attrs["id"]] = self.theSession.AddTable(table)
276    
277      def start_map(self, name, qname, attrs):      def start_map(self, name, qname, attrs):
278          """Start a map."""          """Start a map."""
279          self.aMap = Map(attrs.get((None, 'title'), None))          self.aMap = Map(self.encode(attrs.get((None, 'title'), None)))
280    
281      def end_map(self, name, qname):      def end_map(self, name, qname):
282          self.theSession.AddMap(self.aMap)          self.theSession.AddMap(self.aMap)
# Line 344  class SessionLoader(XMLReader): Line 362  class SessionLoader(XMLReader):
362          elif fieldType == FIELDTYPE_DOUBLE:          elif fieldType == FIELDTYPE_DOUBLE:
363              self.conv = float              self.conv = float
364    
365          self.aLayer.GetClassification().SetFieldInfo(field, fieldType)          self.aLayer.SetClassificationColumn(field)
366    
367      def end_classification(self, name, qname):      def end_classification(self, name, qname):
368          pass          pass
# Line 362  class SessionLoader(XMLReader): Line 380  class SessionLoader(XMLReader):
380      def start_clpoint(self, name, qname, attrs):      def start_clpoint(self, name, qname, attrs):
381          attrib_value = attrs.get((None, 'value'), "0")          attrib_value = attrs.get((None, 'value'), "0")
382    
383          value = self.conv(attrib_value)          field = self.aLayer.GetClassificationColumn()
384            if self.aLayer.GetFieldType(field) == FIELDTYPE_STRING:
385                value = self.encode(attrib_value)
386            else:
387                value = self.conv(attrib_value)
388          self.cl_group = ClassGroupSingleton(value)          self.cl_group = ClassGroupSingleton(value)
389          self.cl_group.SetLabel(self.encode(attrs.get((None, 'label'), "")))          self.cl_group.SetLabel(self.encode(attrs.get((None, 'label'), "")))
390          self.cl_prop = ClassGroupProperties()          self.cl_prop = ClassGroupProperties()
# Line 385  class SessionLoader(XMLReader): Line 406  class SessionLoader(XMLReader):
406              if range is not None:              if range is not None:
407                  self.cl_group = ClassGroupRange(Range(range))                  self.cl_group = ClassGroupRange(Range(range))
408              elif min is not None and max is not None:              elif min is not None and max is not None:
409                  self.cl_group = ClassGroupRange(self.conv(min), self.conv(max))                  self.cl_group = ClassGroupRange((self.conv(min),
410                                                     self.conv(max)))
411              else:              else:
412                  self.cl_group = ClassGroupRange(Range(None))                  self.cl_group = ClassGroupRange(Range(None))
413    

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26