/[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 986 by tkoester, Thu May 22 16:41:10 2003 UTC
# Line 5  Line 5 
5  # This program is free software under the GPL (>=v2)  # This program is free software under the GPL (>=v2)
6  # Read the file COPYING coming with Thuban for details.  # Read the file COPYING coming with Thuban for details.
7    
8    """
9    ClassGenerator
10    """
11    
12    __version__ = "$Revision$"
13    # $Source$
14    # $Id$
15    
16  import operator  import operator
17    
18  from color import Color  from color import Color
# Line 28  class ClassGenerator: Line 36  class ClassGenerator:
36                       generated because the stepping values must                       generated because the stepping values must
37                       be precalculated to ramp between prop1 and prop2.                       be precalculated to ramp between prop1 and prop2.
38    
39          prop1 -- initial group property values          ramp -- an object which implements the CustomRamp interface
   
         prop2 -- final group property values  
40          """          """
41    
42          clazz = Classification()          clazz = Classification()
# Line 62  class ClassGenerator: Line 68  class ClassGenerator:
68    
69          return clazz          return clazz
70    
71      def GenUnifromDistribution(self, min, max, numGroups,      def GenUniformDistribution(self, min, max, numGroups,
72                                 ramp, intStep = False):                                 ramp, intStep = False):
73          """Generate a classification with numGroups range groups          """Generate a classification with numGroups range groups
74          each with the same interval.          each with the same interval.
# Line 97  class ClassGenerator: Line 103  class ClassGenerator:
103    
104              # this check guards against rounding issues              # this check guards against rounding issues
105              if cur_min != cur_max:              if cur_min != cur_max:
106                  range = Range("[" + str(float(cur_min)) + ";" +                  range = Range(("[", cur_min, cur_max, end))
                                     str(float(cur_max)) + end)  
107                  clazz.AppendGroup(ClassGroupRange(range, None, prop))                  clazz.AppendGroup(ClassGroupRange(range, None, prop))
108    
109              cur_min = cur_max              cur_min = cur_max
# Line 141  class ClassGenerator: Line 146  class ClassGenerator:
146    
147                  ramp.SetNumGroups(numGroups)                  ramp.SetNumGroups(numGroups)
148    
149                  min = _list[quantiles[1]]                  start, min, endMax, right = _range.GetRange()
150                  start = "["  
151                  oldp = 0                  oldp = 0
152                    i = 1
153                    end = "]"
154    
155                  for (q, p), prop in zip(quantiles[3], ramp):                  for (q, p), prop in zip(quantiles[3], ramp):
156                      max = _list[q]                      if i == numGroups:
157                      group = ClassGroupRange(Range(start + str(min) + ";" +                          max = endMax
158                                                            str(max) + "]"),                          end = right
159                        else:
160                            max = _list[q]
161    
162                        group = ClassGroupRange(Range((start, min, max, end)),
163                                              None, prop)                                              None, prop)
164                    
165                      group.SetLabel("%s%% - %s%%" % (round(oldp*100, 2),                      group.SetLabel("%s%% - %s%%" % (round(oldp*100, 2),
# Line 156  class ClassGenerator: Line 168  class ClassGenerator:
168                      start = "]"                      start = "]"
169                      min = max                      min = max
170                      clazz.AppendGroup(group)                      clazz.AppendGroup(group)
171                        i += 1
172    
173          return (adjusted, clazz)          return (adjusted, clazz)
174    

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26