Opened 3 hours ago
Last modified 2 hours ago
#37250 assigned Bug
GeometryCollection should be an allowed type for GeometryCollection — at Version 1
| Reported by: | Jacob Walls | Owned by: | Jacob Walls |
|---|---|---|---|
| Component: | GIS | Version: | 6.0 |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description (last modified by )
The multivalued geometry fields, e.g. MultiPolygon, define which classes they can contain, e.g. Polygon but not Point, via the private attribute _allowed.
GeometryCollection is generic, so it contains all the others:
# Setting the allowed types here since GeometryCollection is defined before # its subclasses. GeometryCollection._allowed = ( Point, LineString, LinearRing, Polygon, MultiPoint, MultiLineString, MultiPolygon, )
However, this list should also contain itself, since GeometryCollections can be nested.
In other words, this should work:
-
django/contrib/gis/geos/collections.py
diff --git a/django/contrib/gis/geos/collections.py b/django/contrib/gis/geos/collections.py index 8659b660b6..16b5c74951 100644
a b GeometryCollection._allowed = ( 123 123 MultiPoint, 124 124 MultiLineString, 125 125 MultiPolygon, 126 GeometryCollection, 126 127 ) -
tests/gis_tests/geos_tests/test_geos.py
diff --git a/tests/gis_tests/geos_tests/test_geos.py b/tests/gis_tests/geos_tests/test_geos.py index 025e4fb4f3..e1a531b979 100644
a b class GEOSTest(SimpleTestCase, TestDataMixin): 1347 1347 # And, they should be equal. 1348 1348 self.assertEqual(gc1, gc2) 1349 1349 1350 # Should also construct ok from GeometryCollection. 1351 gc3 = GeometryCollection(gc2) 1352 self.assertEqual(gc1, gc3[0]) 1353 1350 1354 def test_gdal(self): 1351 1355 "Testing `ogr` and `srs` properties." 1352 1356 g1 = fromstr("POINT(5 23)")
Note:
See TracTickets
for help on using tickets.