MCPcopy
hub / github.com/django/django / test_3d_layermapping

Method test_3d_layermapping

tests/gis_tests/geo3d/tests.py:178–207  ·  view source on GitHub ↗

Testing LayerMapping on 3D models.

(self)

Source from the content-addressed store, hash-verified

176 self.assertEqual(p3d.poly.srid, 32140)
177
178 def test_3d_layermapping(self):
179 """
180 Testing LayerMapping on 3D models.
181 """
182 # Import here as GDAL is required for those imports
183 from django.contrib.gis.utils import LayerMapError, LayerMapping
184
185 point_mapping = {"point": "POINT"}
186 mpoint_mapping = {"mpoint": "MULTIPOINT"}
187
188 # The VRT is 3D, but should still be able to map sans the Z.
189 lm = LayerMapping(Point2D, vrt_file, point_mapping, transform=False)
190 lm.save()
191 self.assertEqual(3, Point2D.objects.count())
192
193 # The city shapefile is 2D, and won't be able to fill the coordinates
194 # in the 3D model -- thus, a LayerMapError is raised.
195 with self.assertRaises(LayerMapError):
196 LayerMapping(Point3D, city_file, point_mapping, transform=False)
197
198 # 3D model should take 3D data just fine.
199 lm = LayerMapping(Point3D, vrt_file, point_mapping, transform=False)
200 lm.save()
201 self.assertEqual(3, Point3D.objects.count())
202
203 # Making sure LayerMapping.make_multi works right, by converting
204 # a Point25D into a MultiPoint25D.
205 lm = LayerMapping(MultiPoint3D, vrt_file, mpoint_mapping, transform=False)
206 lm.save()
207 self.assertEqual(3, MultiPoint3D.objects.count())
208
209 def test_bulk_create_point_field(self):
210 objs = Point2D.objects.bulk_create([Point2D(), Point2D()])

Callers

nothing calls this directly

Calls 3

saveMethod · 0.95
LayerMappingClass · 0.90
countMethod · 0.45

Tested by

no test coverage detected