20 |
|
|
21 |
import classifier, resource |
import classifier, resource |
22 |
|
|
23 |
from Thuban.Model.classgen import ClassGenerator, \ |
from Thuban.Model.classgen import \ |
24 |
|
generate_uniform_distribution, generate_singletons, generate_quantiles, \ |
25 |
CustomRamp, GreyRamp, RedRamp, GreenRamp, BlueRamp, GreenToRedRamp, \ |
CustomRamp, GreyRamp, RedRamp, GreenRamp, BlueRamp, GreenToRedRamp, \ |
26 |
HotToColdRamp |
HotToColdRamp |
27 |
|
|
60 |
self.layer = layer |
self.layer = layer |
61 |
self.clazz = None |
self.clazz = None |
62 |
|
|
63 |
col = layer.table.Column(fieldName) |
col = layer.ShapeStore().Table().Column(fieldName) |
64 |
self.type = col.type |
self.type = col.type |
65 |
|
|
66 |
self.fieldName = fieldName |
self.fieldName = fieldName |
211 |
and max is not None \ |
and max is not None \ |
212 |
and numGroups is not None: |
and numGroups is not None: |
213 |
|
|
214 |
self.clazz = ClassGenerator().GenUniformDistribution( |
self.clazz = generate_uniform_distribution( |
215 |
min, max, numGroups, ramp, |
min, max, numGroups, ramp, |
216 |
self.type == FIELDTYPE_INT) |
self.type == FIELDTYPE_INT) |
217 |
|
|
224 |
if len(list) > 0 \ |
if len(list) > 0 \ |
225 |
and numGroups is not None: |
and numGroups is not None: |
226 |
|
|
227 |
self.clazz = ClassGenerator().GenSingletonsFromList( |
self.clazz = generate_singletons( |
228 |
list, numGroups, ramp) |
list, numGroups, ramp) |
229 |
|
|
230 |
self.parent._SetClassification(self.clazz) |
self.parent._SetClassification(self.clazz) |
238 |
delta = 1 / float(numGroups) |
delta = 1 / float(numGroups) |
239 |
percents = [delta * i for i in range(1, numGroups + 1)] |
percents = [delta * i for i in range(1, numGroups + 1)] |
240 |
adjusted, self.clazz = \ |
adjusted, self.clazz = \ |
241 |
ClassGenerator().GenQuantiles(_list, percents, ramp, _range) |
generate_quantiles(_list, percents, ramp, _range) |
242 |
|
|
243 |
if adjusted: |
if adjusted: |
244 |
dlg = wxMessageDialog(self, |
dlg = wxMessageDialog(self, |
504 |
self.parent.AllowGenerate(False) |
self.parent.AllowGenerate(False) |
505 |
|
|
506 |
def _OnRetrieve(self, event): |
def _OnRetrieve(self, event): |
507 |
|
table = self.layer.ShapeStore().Table() |
508 |
if self.layer.table is not None: |
if table is not None: |
509 |
wxBeginBusyCursor() |
wxBeginBusyCursor() |
510 |
min, max = self.layer.table.ValueRange(self.fieldName) |
try: |
511 |
self.minCtrl.SetValue(str(min)) |
min, max = table.ValueRange(self.fieldName) |
512 |
self.maxCtrl.SetValue(str(max)) |
self.minCtrl.SetValue(str(min)) |
513 |
wxEndBusyCursor() |
self.maxCtrl.SetValue(str(max)) |
514 |
|
finally: |
515 |
|
wxEndBusyCursor() |
516 |
|
|
517 |
def __GetValidatedTypeEntry(self, win, value, type, badValue = None): |
def __GetValidatedTypeEntry(self, win, value, type, badValue = None): |
518 |
|
|
554 |
return valid |
return valid |
555 |
|
|
556 |
def __CalcStepping(self, min, max, ngroups): |
def __CalcStepping(self, min, max, ngroups): |
|
step = (max - min) / float(ngroups) |
|
557 |
if self.fieldType == FIELDTYPE_INT: |
if self.fieldType == FIELDTYPE_INT: |
558 |
step = int(step) |
step = int((max - min + 1) / float(ngroups)) |
559 |
|
else: |
560 |
|
step = (max - min) / float(ngroups) |
561 |
|
|
562 |
return step |
return step |
563 |
|
|
720 |
self.list_avail.DeleteAllItems() |
self.list_avail.DeleteAllItems() |
721 |
self.list_avail_data = [] |
self.list_avail_data = [] |
722 |
|
|
723 |
list = self.layer.table.UniqueValues(self.fieldName) |
list = self.layer.ShapeStore().Table().UniqueValues(self.fieldName) |
724 |
index = 0 |
index = 0 |
725 |
for v in list: |
for v in list: |
726 |
self.dataList.append(v) |
self.dataList.append(v) |
832 |
return self.__range |
return self.__range |
833 |
|
|
834 |
def GetList(self): |
def GetList(self): |
|
|
|
835 |
_list = [] |
_list = [] |
836 |
|
table = self.layer.ShapeStore().Table() |
837 |
if self.layer.table is not None: |
if table is not None: |
838 |
wxBeginBusyCursor() |
wxBeginBusyCursor() |
839 |
|
try: |
840 |
# |
# |
841 |
# FIXME: Replace with a call to table when the method |
# FIXME: Replace with a call to table when the method |
842 |
# has been written to get all the values |
# has been written to get all the values |
843 |
# |
# |
844 |
table = self.layer.table |
for i in range(table.NumRows()): |
845 |
for i in range(table.NumRows()): |
_list.append(table.ReadValue(i, self.fieldName)) |
846 |
_list.append(table.ReadValue(i, self.fieldName)) |
finally: |
847 |
|
wxEndBusyCursor() |
|
wxEndBusyCursor() |
|
848 |
|
|
849 |
return _list |
return _list |
850 |
|
|
861 |
self.text_range.SetForegroundColour(wxRED) |
self.text_range.SetForegroundColour(wxRED) |
862 |
|
|
863 |
def OnRetrieve(self, event): |
def OnRetrieve(self, event): |
864 |
|
table = self.layer.ShapeStore().Table() |
865 |
if self.layer.table is not None: |
if table is not None: |
866 |
wxBeginBusyCursor() |
wxBeginBusyCursor() |
867 |
min, max = self.layer.table.ValueRange(self.fieldName) |
try: |
868 |
self.text_range.SetValue("[" + str(min) + ";" + str(max) + "]") |
min, max = table.ValueRange(self.fieldName) |
869 |
wxEndBusyCursor() |
self.text_range.SetValue("[" + str(min) + ";" + str(max) + "]") |
870 |
|
finally: |
871 |
|
wxEndBusyCursor() |
872 |
|
|
873 |
ID_CUSTOMRAMP_COPYSTART = 4001 |
ID_CUSTOMRAMP_COPYSTART = 4001 |
874 |
ID_CUSTOMRAMP_COPYEND = 4002 |
ID_CUSTOMRAMP_COPYEND = 4002 |