|
26 | 26 | City, |
27 | 27 | Country, |
28 | 28 | Feature, |
| 29 | + GeometryCollections, |
| 30 | + Lines, |
29 | 31 | MinusOneSRID, |
30 | 32 | MultiFields, |
31 | 33 | NonConcreteModel, |
32 | 34 | PennsylvaniaCity, |
| 35 | + Points, |
33 | 36 | State, |
34 | 37 | ThreeDimensionalFeature, |
35 | 38 | Track, |
@@ -269,6 +272,47 @@ def test_empty_geometries(self): |
269 | 272 | self.assertEqual(feature.geom.srid, g.srid) |
270 | 273 |
|
271 | 274 |
|
| 275 | +# TODO: contribute these tests added to the MongoDB fork upstream to Django. |
| 276 | +class SaveLoadTests(TestCase): |
| 277 | + def test_multi_line_string_field(self): |
| 278 | + geom = MultiLineString( |
| 279 | + LineString((0, 0), (1, 1), (5, 5)), |
| 280 | + LineString((0, 0), (0, 5), (5, 5), (5, 0), (0, 0)), |
| 281 | + ) |
| 282 | + obj = Lines.objects.create(geom=geom) |
| 283 | + obj.refresh_from_db() |
| 284 | + self.assertEqual(obj.geom.tuple, geom.tuple) |
| 285 | + |
| 286 | + def test_multi_line_string_with_linear_ring(self): |
| 287 | + # LinearRings are transformed to LineString |
| 288 | + geom = MultiLineString( |
| 289 | + LineString((0, 0), (1, 1), (5, 5)), |
| 290 | + LinearRing((0, 0), (0, 5), (5, 5), (5, 0), (0, 0)), |
| 291 | + ) |
| 292 | + obj = Lines.objects.create(geom=geom) |
| 293 | + obj.refresh_from_db() |
| 294 | + self.assertEqual(obj.geom.tuple, geom.tuple) |
| 295 | + self.assertEqual(obj.geom[0].tuple, geom[0].tuple) |
| 296 | + self.assertEqual(obj.geom[1].__class__.__name__, "LineString") |
| 297 | + self.assertEqual(obj.geom[1].tuple, geom[1].tuple) |
| 298 | + |
| 299 | + def test_multi_point_field(self): |
| 300 | + geom = MultiPoint(Point(1, 1), Point(0, 0)) |
| 301 | + obj = Points.objects.create(geom=geom) |
| 302 | + obj.refresh_from_db() |
| 303 | + self.assertEqual(obj.geom, geom) |
| 304 | + |
| 305 | + def test_geometry_collection_field(self): |
| 306 | + geom = GeometryCollection( |
| 307 | + Point(2, 2), |
| 308 | + LineString((0, 0), (2, 2)), |
| 309 | + Polygon(LinearRing((0, 0), (0, 5), (5, 5), (5, 0), (0, 0))), |
| 310 | + ) |
| 311 | + obj = GeometryCollections.objects.create(geom=geom) |
| 312 | + obj.refresh_from_db() |
| 313 | + self.assertEqual(obj.geom, geom) |
| 314 | + |
| 315 | + |
272 | 316 | class GeoLookupTest(TestCase): |
273 | 317 | fixtures = ["initial"] |
274 | 318 |
|
|
0 commit comments