18 |
from gdalconst import GA_ReadOnly |
from gdalconst import GA_ReadOnly |
19 |
|
|
20 |
from messages import LAYER_PROJECTION_CHANGED, LAYER_VISIBILITY_CHANGED, \ |
from messages import LAYER_PROJECTION_CHANGED, LAYER_VISIBILITY_CHANGED, \ |
21 |
LAYER_CHANGED |
LAYER_CHANGED, LAYER_SHAPESTORE_REPLACED |
22 |
|
|
23 |
from color import Color |
from color import Color |
24 |
|
|
199 |
|
|
200 |
self.shapetree = shptree.SHPTree(self.shapefile.cobject(), 2, |
self.shapetree = shptree.SHPTree(self.shapefile.cobject(), 2, |
201 |
maxdepth) |
maxdepth) |
202 |
|
# Set the classification to None if there is a classification |
203 |
|
# and the new shapestore doesn't have a table with a suitable |
204 |
|
# column, i.e one with the same name and type as before |
205 |
|
# FIXME: Maybe we should keep it the same if the type is |
206 |
|
# compatible enough such as FIELDTYPE_DOUBLE and FIELDTYPE_INT |
207 |
if self.__classification is not None: |
if self.__classification is not None: |
208 |
fieldname = self.__classification.GetField() |
fieldname = self.__classification.GetField() |
209 |
if fieldname is not None and \ |
fieldtype = self.__classification.GetFieldType() |
210 |
not self.store.Table().HasColumn(fieldname): |
table = self.store.Table() |
211 |
|
if (fieldname is not None |
212 |
|
and (not table.HasColumn(fieldname) |
213 |
|
or table.Column(fieldname).type != fieldtype)): |
214 |
self.SetClassification(None) |
self.SetClassification(None) |
215 |
self.changed(LAYER_CHANGED, self) |
self.changed(LAYER_SHAPESTORE_REPLACED, self) |
216 |
|
|
217 |
def ShapeStore(self): |
def ShapeStore(self): |
218 |
return self.store |
return self.store |
220 |
def Destroy(self): |
def Destroy(self): |
221 |
BaseLayer.Destroy(self) |
BaseLayer.Destroy(self) |
222 |
self.SetClassification(None) |
self.SetClassification(None) |
223 |
|
self.store = self.shapetree = None |
224 |
|
self.table = self.shapefile = self.shapetable = None |
225 |
|
|
226 |
def BoundingBox(self): |
def BoundingBox(self): |
227 |
"""Return the layer's bounding box in the intrinsic coordinate system. |
"""Return the layer's bounding box in the intrinsic coordinate system. |
360 |
def TreeInfo(self): |
def TreeInfo(self): |
361 |
items = [] |
items = [] |
362 |
|
|
363 |
items.append(_("Filename: %s") % self.filename) |
if hasattr(self, 'filename'): |
364 |
|
items.append(_("Filename: %s") % self.filename) |
365 |
|
|
366 |
if self.Visible(): |
if self.Visible(): |
367 |
items.append(_("Shown")) |
items.append(_("Shown")) |