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

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

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

revision 374 by jan, Mon Jan 27 14:20:02 2003 UTC revision 378 by jonathan, Tue Jan 28 12:13:28 2003 UTC
# Line 37  class Classification: Line 37  class Classification:
37                      is to be used to classify layer properties                      is to be used to classify layer properties
38          """          """
39    
40          self.__points = {}          self.points = {}
41          self.__ranges = []          self.ranges = []
42          self.setField(field)          self.setField(field)
43          self.setNull(None)          self.setNull(None)
44                    
# Line 73  class Classification: Line 73  class Classification:
73    
74          if min >= max:          if min >= max:
75              raise ValueError(_("Range minimum >= maximum!"))              raise ValueError(_("Range minimum >= maximum!"))
76          self.__ranges.append([min, max, data])          self.ranges.append([min, max, data])
77    
78      def addPoint(self, value, data):      def addPoint(self, value, data):
79          """Associate a single value with data.          """Associate a single value with data.
# Line 85  class Classification: Line 85  class Classification:
85             data  -- data that the value maps to. See class description.             data  -- data that the value maps to. See class description.
86          """          """
87    
88          self.__points[value] = data          self.points[value] = data
89    
90      def getProperties(self, value):      def getProperties(self, value):
91          """Return the associated data, or the NullData.          """Return the associated data, or the NullData.
# Line 105  class Classification: Line 105  class Classification:
105              #              #
106              # first check the discrete values              # first check the discrete values
107              #              #
108              if self.__points.has_key(value):              if self.points.has_key(value):
109                  return self.__points[value]                  return self.points[value]
110    
111              #              #
112              # now check the ranges              # now check the ranges
113              #              #
114              for p in self.__ranges:              for p in self.ranges:
115                  if (p[RANGE_MIN] <= value) and (value < p[RANGE_MAX]):                  if (p[RANGE_MIN] <= value) and (value < p[RANGE_MAX]):
116                      return p[RANGE_DATA]                      return p[RANGE_DATA]
117    
118    
119          return self.NullData          return self.NullData
120    
121    

Legend:
Removed from v.374  
changed lines
  Added in v.378

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26