23 |
import dbflib |
import dbflib |
24 |
|
|
25 |
from Thuban.Model.session import Session |
from Thuban.Model.session import Session |
26 |
from Thuban.Model.layer import BaseLayer, Layer, RasterLayer, \ |
from Thuban.Model.layer import BaseLayer, Layer, RasterLayer |
27 |
SHAPETYPE_POLYGON, SHAPETYPE_ARC, SHAPETYPE_POINT |
from Thuban.Model.data import SHAPETYPE_POLYGON, SHAPETYPE_ARC, SHAPETYPE_POINT |
28 |
from Thuban.Model.messages import LAYER_LEGEND_CHANGED, \ |
from Thuban.Model.messages import LAYER_LEGEND_CHANGED, \ |
29 |
LAYER_VISIBILITY_CHANGED, LAYER_SHAPESTORE_REPLACED, LAYER_CHANGED |
LAYER_VISIBILITY_CHANGED, LAYER_SHAPESTORE_REPLACED, LAYER_CHANGED |
30 |
from Thuban.Model.table import FIELDTYPE_DOUBLE, FIELDTYPE_STRING, MemoryTable |
from Thuban.Model.table import FIELDTYPE_DOUBLE, FIELDTYPE_STRING, MemoryTable |
217 |
layer.SetShapeStore(derived) |
layer.SetShapeStore(derived) |
218 |
self.assert_(layer.ShapeStore() is derived) |
self.assert_(layer.ShapeStore() is derived) |
219 |
|
|
220 |
# check that an exception is raised when the number |
self.assertEquals(layer.ShapeType(), SHAPETYPE_ARC) |
221 |
# of shapes differ from the number of rows in a table. |
self.assertEquals(layer.NumShapes(), 839) |
222 |
layer2 = Layer("Test Layer", |
shape = layer.Shape(32) |
223 |
self.open_shapefile("political.shp")) |
self.assertFloatTuplesEqual(shape.Points(), |
224 |
store2 = layer2.ShapeStore() |
[(-15.082174301147461, 66.27738189697265), |
225 |
self.assertRaises(ValueError, |
(-15.026350021362305, 66.27339172363281)]) |
226 |
DerivedShapeStore, store2, store.Table()) |
self.assertFloatSeqEqual(layer.BoundingBox(), |
227 |
|
[-24.450359344482422, 63.426830291748047, |
228 |
|
-13.55668830871582, 66.520111083984375]) |
229 |
|
self.assertEquals(layer.ShapesInRegion((-24.0, 64.0, |
230 |
|
-23.75, 64.25)), |
231 |
|
[613, 726, 838]) |
232 |
|
|
233 |
|
self.assertFloatSeqEqual(layer.ShapesBoundingBox([32]), |
234 |
|
[-15.082174301147461, 66.27339172363281, |
235 |
|
-15.026350021362305, 66.27738189697265]) |
236 |
|
|
237 |
finally: |
finally: |
238 |
store = derived = None |
store = derived = None |
|
layer2.Destroy() |
|
|
store2 = None |
|
239 |
|
|
240 |
|
|
241 |
class SetShapeStoreTests(unittest.TestCase, support.SubscriberMixin): |
class SetShapeStoreTests(unittest.TestCase, support.SubscriberMixin): |