Ticket #5630: gis_geos_empty.diff

File gis_geos_empty.diff, 1.5 KB (added by Robert Coup, 17 years ago)
  • django/contrib/gis/geos/pointer.py

     
    186186        n_child = len(ptr_list)
    187187
    188188        # Determining whether coordinate sequences pointers were passed in.
    189         if isinstance(ptr_list[0], (tuple, list)):
     189        if n_child and isinstance(ptr_list[0], (tuple, list)):
    190190            self._child_cs = True
    191191        else:
    192192            self._child_cs = False
  • django/contrib/gis/tests/test_geos.py

     
    722722        mpoly = MultiPolygon(poly.clone(), poly)
    723723        self.assertEqual(8.0, mpoly.length)
    724724
     725    def test20_emptyCollections(self):
     726        "Testing empty geometry collections"
     727        g = GeometryCollection([])
     728        self.assert_(g.empty)
     729        self.assertEqual(0, g.num_geom)
     730       
     731        g = GEOSGeometry("GEOMETRYCOLLECTION EMPTY")
     732        self.assert_(g.empty)
     733        self.assert_(isinstance(g, GeometryCollection))
     734        self.assertEqual(0, g.num_geom)
     735       
    725736def suite():
    726737    s = unittest.TestSuite()
    727738    s.addTest(unittest.makeSuite(GEOSTest))
     
    729740
    730741def run(verbosity=2):
    731742    unittest.TextTestRunner(verbosity=verbosity).run(suite())
     743
     744if __name__=="__main__":
     745    unittest.main()
Back to Top