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

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

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

revision 895 by jonathan, Mon May 12 11:21:02 2003 UTC revision 900 by jonathan, Wed May 14 11:15:41 2003 UTC
# Line 28  class ClassGenerator: Line 28  class ClassGenerator:
28                       generated because the stepping values must                       generated because the stepping values must
29                       be precalculated to ramp between prop1 and prop2.                       be precalculated to ramp between prop1 and prop2.
30    
31          prop1 -- initial group property values          ramp -- an object which implements the CustomRamp interface
   
         prop2 -- final group property values  
32          """          """
33    
34          clazz = Classification()          clazz = Classification()
# Line 62  class ClassGenerator: Line 60  class ClassGenerator:
60    
61          return clazz          return clazz
62    
63      def GenUnifromDistribution(self, min, max, numGroups,      def GenUniformDistribution(self, min, max, numGroups,
64                                 ramp, intStep = False):                                 ramp, intStep = False):
65          """Generate a classification with numGroups range groups          """Generate a classification with numGroups range groups
66          each with the same interval.          each with the same interval.
# Line 141  class ClassGenerator: Line 139  class ClassGenerator:
139    
140                  ramp.SetNumGroups(numGroups)                  ramp.SetNumGroups(numGroups)
141    
142                  min = _list[quantiles[1]]                  start, min, endMax, right = _range.GetRange()
143                  start = "["  
144                    if str(min) == '-inf':
145                        min = "-oo"
146                    elif str(min) == 'inf':
147                        min = "oo"
148    
149                    if str(endMax) == '-inf':
150                        endMax = "-oo"
151                    elif str(endMax) == 'inf':
152                        endMax = "oo"
153    
154                  oldp = 0                  oldp = 0
155                    i = 1
156                    end = "]"
157    
158                  for (q, p), prop in zip(quantiles[3], ramp):                  for (q, p), prop in zip(quantiles[3], ramp):
159                      max = _list[q]                      if i == numGroups:
160                            max = endMax
161                            end = right
162                        else:
163                            max = _list[q]
164    
165                      group = ClassGroupRange(Range(start + str(min) + ";" +                      group = ClassGroupRange(Range(start + str(min) + ";" +
166                                                            str(max) + "]"),                                                            str(max) + end),
167                                              None, prop)                                              None, prop)
168                    
169                      group.SetLabel("%s%% - %s%%" % (round(oldp*100, 2),                      group.SetLabel("%s%% - %s%%" % (round(oldp*100, 2),
# Line 156  class ClassGenerator: Line 172  class ClassGenerator:
172                      start = "]"                      start = "]"
173                      min = max                      min = max
174                      clazz.AppendGroup(group)                      clazz.AppendGroup(group)
175                        i += 1
176    
177          return (adjusted, clazz)          return (adjusted, clazz)
178    

Legend:
Removed from v.895  
changed lines
  Added in v.900

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26