16 |
import os |
import os |
17 |
import unittest |
import unittest |
18 |
|
|
19 |
|
import mockgeo |
20 |
import support |
import support |
21 |
support.initthuban() |
support.initthuban() |
22 |
|
|
161 |
self.assertEquals(layer.ShapesInRegion((-24.0, 64.0, -23.80, 64.1)), |
self.assertEquals(layer.ShapesInRegion((-24.0, 64.0, -23.80, 64.1)), |
162 |
[0, 1, 2, 3, 4, 5, 27, 28, 29, 30, 31]) |
[0, 1, 2, 3, 4, 5, 27, 28, 29, 30, 31]) |
163 |
|
|
164 |
|
def test_point_layer_with_projection(self): |
165 |
|
"""Test Layer with point shapes and a projection""" |
166 |
|
# We use mock data here so that we have precise control over the |
167 |
|
# values |
168 |
|
table = MemoryTable([("FOO", FIELDTYPE_STRING)], [("bla",)]) |
169 |
|
store = mockgeo.SimpleShapeStore(SHAPETYPE_POINT, [[[(10,10)]]], table) |
170 |
|
layer = self.layer = Layer("Test Layer", store) |
171 |
|
|
172 |
|
# Rotation by 45 degrees counter clockwise. This detects a bug |
173 |
|
# in the ShapesInRegion method which transforms the bounding box |
174 |
|
# by only transforming two opposite corners because they have |
175 |
|
# the same x or y coordinates after application of the |
176 |
|
# projection or its inverse. |
177 |
|
proj = mockgeo.AffineProjection((1, 1, -1, 1, 0, 0)) |
178 |
|
layer.SetProjection(proj) |
179 |
|
|
180 |
|
self.assertEquals(layer.BoundingBox(), (10, 10, 10, 10)) |
181 |
|
self.assertEquals(layer.LatLongBoundingBox(), (10.0, 0.0, 10.0, 0.0)) |
182 |
|
self.assertEquals(layer.ShapesInRegion((0, 0, 20, 20)), [0]) |
183 |
|
|
184 |
def test_empty_layer(self): |
def test_empty_layer(self): |
185 |
"""Test Layer with empty shape file""" |
"""Test Layer with empty shape file""" |
186 |
# create an empty shape file |
# create an empty shape file |