Skip to content

Add property on Element model to access polygon more easily

Workers that support cache and want to access an element's polygon need to do the following

if self.use_cache:
   polygon = element.zone.polygon
else:
   polygon = element.polygon

This is rather long and not very useful and makes the code look hard. This happens because the CachedElement class does not have the same field that the Element class (which has the same fields as the Arkindex DB model).

Ideally we would like to always do element.polygon to access the element's polygon. A way to do that without updating the complicated (and unknown) Base-worker cache system would be to store the polygon as a property.