Esempio n. 1
0
 def test03_multipoints(self):
     "Testing MultiPoint objects."
     for mp in self.geometries.multipoints:
         mgeom1 = OGRGeometry(mp.wkt)  # First one from WKT
         self.assertEqual(4, mgeom1.geom_type)
         self.assertEqual("MULTIPOINT", mgeom1.geom_name)
         mgeom2 = OGRGeometry("MULTIPOINT")  # Creating empty multipoint
         mgeom3 = OGRGeometry("MULTIPOINT")
         for g in mgeom1:
             mgeom2.add(g)  # adding each point from the multipoints
             mgeom3.add(g.wkt)  # should take WKT as well
         self.assertEqual(mgeom1, mgeom2)  # they should equal
         self.assertEqual(mgeom1, mgeom3)
         self.assertEqual(mp.coords, mgeom2.coords)
         self.assertEqual(mp.n_p, mgeom2.point_count)
Esempio n. 2
0
    def test14_add(self):
        "Testing GeometryCollection.add()."
        # Can't insert a Point into a MultiPolygon.
        mp = OGRGeometry('MultiPolygon')
        pnt = OGRGeometry('POINT(5 23)')
        self.assertRaises(OGRException, mp.add, pnt)

        # GeometryCollection.add may take an OGRGeometry (if another collection
        # of the same type all child geoms will be added individually) or WKT.
        for mp in self.geometries.multipolygons:
            mpoly = OGRGeometry(mp.wkt)
            mp1 = OGRGeometry('MultiPolygon')
            mp2 = OGRGeometry('MultiPolygon')
            mp3 = OGRGeometry('MultiPolygon')

            for poly in mpoly:
                mp1.add(poly) # Adding a geometry at a time
                mp2.add(poly.wkt) # Adding WKT
            mp3.add(mpoly) # Adding a MultiPolygon's entire contents at once.
            for tmp in (mp1, mp2, mp3): self.assertEqual(mpoly, tmp)