/[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 1525 by jonathan, Wed Jul 30 15:42:56 2003 UTC revision 1759 by bh, Fri Sep 26 18:36:01 2003 UTC
# Line 152  def generate_quantiles(_list, percents, Line 152  def generate_quantiles(_list, percents,
152    
153      return (adjusted, clazz)      return (adjusted, clazz)
154    
 def GenQuantiles0(_list, percents, ramp, _range):  
     """Same as GenQuantiles, but the first class won't be added to  
     the classification.  
   
     Returns a tuple (adjusted, Classification, upper_class0) where  
     upper_class0 is the highest value inside the first class.  
   
     _list -- a sort list of values  
   
     percents -- a sorted list of floats in the range 0.0-1.0 which  
                 represent the upper bound of each quantile. the  
                 union of all percentiles should be the entire  
                 range from 0.0-1.0  
   
     ramp -- an object which implements the CustomRamp interface  
   
     _range -- a Range object  
   
     Raises a Value Error if 'percents' has fewer than two items, or  
     does not cover the entire range.  
     """  
   
     clazz = Classification()  
     quantiles = calculate_quantiles(_list, percents, _range)  
     adjusted = True  
   
     if quantiles is not None:  
   
         numGroups = len(quantiles[3]) - 1  
   
         if numGroups > 0:  
             adjusted = quantiles[0]  
   
             start, min, endMax, right = _range.GetRange()  
   
             class0 = quantiles[3][0]  
             min = _list[class0[0]]  
             oldp = class0[1]  
             i = 1  
             end = "]"  
   
             maxValue = float(numGroups - 1)  
             if maxValue < 1: maxValue = 1  
             for (q, p) in quantiles[3][1:]:  
                 prop = ramp.GetProperties(float(i-1) / maxValue)  
   
                 if i == numGroups:  
                     max = endMax  
                     end = right  
                 else:  
                     max = _list[q]  
   
                 group = ClassGroupRange(Range((start, min, max, end)), prop)  
       
                 group.SetLabel("%s%% - %s%%" % (round(oldp*100, 2),  
                                                 round(p*100, 2)))  
                 oldp = p  
                 start = "]"  
                 min = max  
                 clazz.AppendGroup(group)  
                 i += 1  
   
     return (adjusted, clazz, _list[class0[0]])  
   
155    
156  def calculate_quantiles(_list, percents, _range):  def calculate_quantiles(_list, percents, _range):
157      """Calculate quantiles for the given _list of percents from the      """Calculate quantiles for the given _list of percents from the

Legend:
Removed from v.1525  
changed lines
  Added in v.1759

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26