184 |
defaultGroup = lc.GetDefaultGroup() |
defaultGroup = lc.GetDefaultGroup() |
185 |
table = layer.ShapeStore().Table() |
table = layer.ShapeStore().Table() |
186 |
|
|
187 |
|
if lc.GetNumGroups() == 0: |
188 |
|
# There's only the default group, so we can pretend that |
189 |
|
# there is no field to classifiy on which makes things |
190 |
|
# faster since we don't need the attribute information at |
191 |
|
# all. |
192 |
|
field = None |
193 |
|
|
194 |
# Determine which render function to use. |
# Determine which render function to use. |
195 |
useraw, draw_func, draw_func_param = self.low_level_renderer(layer) |
useraw, draw_func, draw_func_param = self.low_level_renderer(layer) |
196 |
|
|
197 |
|
# |
198 |
# Iterate through all shapes that have to be drawn. |
# Iterate through all shapes that have to be drawn. |
199 |
|
# |
200 |
|
|
201 |
|
# Count the shapes drawn so that we can yield every few hundred |
202 |
|
# shapes |
203 |
count = 0 |
count = 0 |
204 |
|
|
205 |
|
# Cache the tools (pens and brushes) for the classification |
206 |
|
# groups. This is a mapping from the group's ids to the a tuple |
207 |
|
# (pen, brush) |
208 |
|
tool_cache = {} |
209 |
|
|
210 |
for shape in self.layer_shapes(layer): |
for shape in self.layer_shapes(layer): |
211 |
count += 1 |
count += 1 |
212 |
if field is None: |
if field is None: |
213 |
group = defaultGroup |
group = defaultGroup |
214 |
else: |
else: |
215 |
record = table.ReadRowAsDict(shape.ShapeID()) |
value = table.ReadRowAsDict(shape.ShapeID())[field] |
216 |
assert record is not None |
group = lc.FindGroup(value) |
|
group = lc.FindGroup(record[field]) |
|
217 |
|
|
218 |
if not group.IsVisible(): |
if not group.IsVisible(): |
219 |
continue |
continue |
220 |
|
|
221 |
# don't recreate new objects if they are the same as before |
try: |
222 |
if group is not old_group: |
pen, brush = tool_cache[id(group)] |
223 |
old_group = group |
except KeyError: |
224 |
|
pen, brush = tool_cache[id(group)] \ |
225 |
prop = group.GetProperties() |
= self.tools_for_property(group.GetProperties()) |
|
|
|
|
if prop != old_prop: |
|
|
pen, brush = self.tools_for_property(prop) |
|
226 |
|
|
227 |
if useraw: |
if useraw: |
228 |
data = shape.RawData() |
data = shape.RawData() |