/[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 1098 by jonathan, Fri May 30 06:27:44 2003 UTC revision 1128 by tkoester, Tue Jun 3 17:00:47 2003 UTC
# Line 170  def GenQuantiles(_list, percents, ramp, Line 170  def GenQuantiles(_list, percents, ramp,
170    
171      return (adjusted, clazz)      return (adjusted, clazz)
172    
173    
174    def GenQuantiles0(_list, percents, ramp, _range):
175        """Same as GenQuantiles, but the first class won't be added to
176        the classification.
177    
178        Returns a tuple (adjusted, Classification, upper_class0) where
179        upper_class0 is the highest value inside the first class.
180    
181        _list -- a sort list of values
182    
183        percents -- a sorted list of floats in the range 0.0-1.0 which
184                    represent the upper bound of each quantile
185    
186        ramp -- an object which implements the CustomRamp interface
187    
188        _range -- a Range object
189        """
190    
191        clazz = Classification()
192        quantiles = CalculateQuantiles(_list, percents, _range)
193        adjusted = True
194    
195        if quantiles is not None:
196    
197            numGroups = len(quantiles[3]) - 1
198    
199            if numGroups > 0:
200                adjusted = quantiles[0]
201    
202                ramp.SetNumGroups(numGroups)
203    
204                start, min, endMax, right = _range.GetRange()
205    
206                class0 = quantiles[3][0]
207                min = _list[class0[0]]
208                oldp = class0[1]
209                i = 1
210                end = "]"
211    
212                for (q, p), prop in zip(quantiles[3][1:], ramp):
213                    if i == numGroups:
214                        max = endMax
215                        end = right
216                    else:
217                        max = _list[q]
218    
219                    group = ClassGroupRange(Range((start, min, max, end)),
220                                            None, prop)
221        
222                    group.SetLabel("%s%% - %s%%" % (round(oldp*100, 2),
223                                                    round(p*100, 2)))
224                    oldp = p
225                    start = "]"
226                    min = max
227                    clazz.AppendGroup(group)
228                    i += 1
229    
230        return (adjusted, clazz, _list[class0[0]])
231    
232    
233  def CalculateQuantiles(_list, percents, _range):  def CalculateQuantiles(_list, percents, _range):
234      """Calculate quantiles for the given _list of percents from the      """Calculate quantiles for the given _list of percents from the
235      sorted list of values that are in range.      sorted list of values that are in range.

Legend:
Removed from v.1098  
changed lines
  Added in v.1128

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26