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() |
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. |
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), |
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 |
|
|