def test_linestring(self): l = geometry.LineString([(0, 0), (1, 1)]) self.assertEqual(l.coords, ((0.0, 0.0), (1.0, 1.0))) self.assertEqual(l.coords[:1], ((0.0, 0.0), )) self.assertEqual(l.bounds, (0.0, 0.0, 1.0, 1.0)) self.assertEqual( l.__geo_interface__, { 'type': 'LineString', 'bbox': (0.0, 0.0, 1.0, 1.0), 'coordinates': ((0.0, 0.0), (1.0, 1.0)) }) self.assertEqual(l.to_wkt(), 'LINESTRING (0.0 0.0, 1.0 1.0)') p = geometry.Point(0, 0) p1 = geometry.Point(1, 1) p2 = geometry.Point(2, 2) l1 = geometry.LineString([p, p1, p2]) self.assertEqual(l1.coords, ((0.0, 0.0), (1.0, 1.0), (2.0, 2.0))) l2 = geometry.LineString(l1) self.assertEqual(l2.coords, ((0.0, 0.0), (1.0, 1.0), (2.0, 2.0))) l.coords = l2.coords self.assertEqual(l.__geo_interface__, l2.__geo_interface__) self.assertRaises(ValueError, geometry.LineString, [(0, 0, 0), (1, 1)]) ext = [(0, 0), (0, 2), (2, 2), (2, 0), (0, 0)] int_1 = [(0.5, 0.25), (1.5, 0.25), (1.5, 1.25), (0.5, 1.25), (0.5, 0.25)] int_2 = [(0.5, 1.25), (1, 1.25), (1, 1.75), (0.5, 1.75), (0.5, 1.25)] po = geometry.Polygon(ext, [int_1, int_2]) self.assertRaises(TypeError, geometry.LineString, po) pt = geometry.Point(0, 1) self.assertRaises(TypeError, geometry.LineString, pt) self.assertRaises(TypeError, geometry.LineString, 0) self.assertRaises(ValueError, setattr, l2, 'coords', ((0, 0), (1, 1, 1))) self.assertRaises(ValueError, setattr, l2, 'coords', 0)
def test_geometrycollection(self): self.assertRaises(TypeError, geometry.GeometryCollection) self.assertRaises(TypeError, geometry.GeometryCollection, None) p = geometry.Polygon([(0, 0), (1, 1), (1, 0), (0, 0)]) e = [(0, 0), (0, 2), (2, 2), (2, 0), (0, 0)] i = [(1, 0), (0.5, 0.5), (1, 1), (1.5, 0.5), (1, 0)] ph = geometry.Polygon(e, [i]) p0 = geometry.Point(0, 0) p1 = geometry.Point(-1, -1) r = geometry.LinearRing([(0, 0), (1, 1), (1, 0), (0, 0)]) l = geometry.LineString([(0, 0), (1, 1)]) gc = geometry.GeometryCollection([p, ph, p0, p1, r, l]) self.assertEqual(len(list(gc.geoms)), 6) self.assertEqual(len(gc), 6) self.assertEqual(gc.bounds, (-1.0, -1.0, 2.0, 2.0)) self.assertEqual(gc.__geo_interface__, geometry.as_shape(gc).__geo_interface__) self.assertEqual( gc.__geo_interface__, geometry.as_shape(gc.__geo_interface__).__geo_interface__) f = geometry._Geometry() gc1 = geometry.GeometryCollection( [p.__geo_interface__, ph, p0, p1, r, l.__geo_interface__]) self.assertEqual(gc.__geo_interface__, gc1.__geo_interface__) self.assertRaises(NotImplementedError, geometry.GeometryCollection, [p, f]) mp1 = geometry.MultiPoint([p0, p1]) self.assertRaises(ValueError, geometry.GeometryCollection, [p, mp1]) self.assertEqual([p, ph, p0, p1, r, l], [geom for geom in gc])
def testCoordinates(self): coord = czml._Coordinates([0, 1]) self.assertEqual(len(coord.coords), 1) self.assertEqual(coord.coords[0].x, 0) self.assertEqual(coord.coords[0].y, 1) self.assertEqual(coord.coords[0].z, 0) self.assertEqual(coord.coords[0].t, None) coord = czml._Coordinates([0, 1, 2]) self.assertEqual(len(coord.coords), 1) self.assertEqual(coord.coords[0].x, 0) self.assertEqual(coord.coords[0].y, 1) self.assertEqual(coord.coords[0].z, 2) self.assertEqual(coord.coords[0].t, None) now = datetime.now() coord = czml._Coordinates([now, 0, 1, 2]) self.assertEqual(len(coord.coords), 1) self.assertEqual(coord.coords[0].x, 0) self.assertEqual(coord.coords[0].y, 1) self.assertEqual(coord.coords[0].z, 2) self.assertEqual(coord.coords[0].t, now) y2k = datetime(2000, 1, 1) coord = czml._Coordinates([now, 0, 1, 2, y2k, 3, 4, 5]) self.assertEqual(len(coord.coords), 2) self.assertEqual(coord.coords[0].x, 0) self.assertEqual(coord.coords[0].y, 1) self.assertEqual(coord.coords[0].z, 2) self.assertEqual(coord.coords[0].t, now) self.assertEqual(coord.coords[1].x, 3) self.assertEqual(coord.coords[1].y, 4) self.assertEqual(coord.coords[1].z, 5) self.assertEqual(coord.coords[1].t, y2k) coord = czml._Coordinates([now, 0, 1, 2, 6, 3, 4, 5]) self.assertEqual(coord.coords[1].t, 6) coord = czml._Coordinates([now.isoformat(), 0, 1, 2, '6', 3, 4, 5]) self.assertEqual(coord.coords[1].t, 6) self.assertEqual(coord.coords[0].t, now) p = geometry.Point(0, 1) coord = czml._Coordinates(p) self.assertEqual(coord.coords[0].x, 0) self.assertEqual(coord.coords[0].y, 1) coord = czml._Coordinates([now, p]) self.assertEqual(coord.coords[0].x, 0) self.assertEqual(coord.coords[0].y, 1) self.assertEqual(coord.coords[0].t, now) p1 = geometry.Point(0, 1, 2) coord = czml._Coordinates([now, p, y2k, p1]) self.assertEqual(coord.coords[0].x, 0) self.assertEqual(coord.coords[0].y, 1) self.assertEqual(coord.coords[0].z, 0) self.assertEqual(coord.coords[0].t, now) self.assertEqual(coord.coords[1].x, 0) self.assertEqual(coord.coords[1].y, 1) self.assertEqual(coord.coords[1].z, 2) self.assertEqual(coord.coords[1].t, y2k) self.assertEqual(coord.data(), [now.isoformat(), 0, 1, 0, y2k.isoformat(), 0, 1, 2])
def test_multipolygon(self): p = geometry.Polygon([(0, 0), (1, 1), (1, 0), (0, 0)]) e = [(0, 0), (0, 2), (2, 2), (2, 0), (0, 0)] i = [(1, 0), (0.5, 0.5), (1, 1), (1.5, 0.5), (1, 0)] ph1 = geometry.Polygon(e, [i]) mp = geometry.MultiPolygon([p, ph1]) self.assertEqual(len(mp), 2) self.assertTrue(isinstance(mp.geoms[0], geometry.Polygon)) self.assertTrue(isinstance(mp.geoms[1], geometry.Polygon)) self.assertEqual(mp.bounds, (0.0, 0.0, 2.0, 2.0)) mp = geometry.MultiPolygon([ (((0.0, 0.0), (0.0, 1.0), (1.0, 1.0), (1.0, 0.0)), [((0.1, 0.1), (0.1, 0.2), (0.2, 0.2), (0.2, 0.1))]) ]) self.assertEqual( mp.__geo_interface__, { 'type': 'MultiPolygon', 'bbox': (0.0, 0.0, 1.0, 1.0), 'coordinates': ((((0.0, 0.0), (0.0, 1.0), (1.0, 1.0), (1.0, 0.0), (0.0, 0.0)), ((0.1, 0.1), (0.1, 0.2), (0.2, 0.2), (0.2, 0.1), (0.1, 0.1))), ) }) self.assertEqual(len(mp.geoms), 1) self.assertTrue(isinstance(mp.geoms[0], geometry.Polygon)) mp1 = geometry.MultiPolygon(mp) self.assertEqual(mp.__geo_interface__, mp1.__geo_interface__) mp2 = geometry.MultiPolygon(ph1) self.assertRaises(ValueError, geometry.MultiPolygon, 0) self.assertRaises(ValueError, geometry.MultiPolygon, [0, 0]) pt = geometry.Point(0, 1) self.assertRaises(TypeError, geometry.MultiPolygon, pt)
def test_intersects_attr_point_ewkt(): result = parse('INTERSECTS(geometry, SRID=4326;POINT(1 1))') assert result.rhs.geometry['crs']['properties']['name'] == \ "urn:ogc:def:crs:EPSG::4326" assert result == ast.GeometryIntersects( ast.Attribute('geometry'), values.Geometry(geometry.Point(1, 1).__geo_interface__), )
def test_multipoint(self): p0 = geometry.Point(0, 0) p1 = geometry.Point(1, 1) p2 = geometry.Point(2, 2) p3 = geometry.Point(3, 3) mp = geometry.MultiPoint(p0) self.assertEqual(len(mp.geoms), 1) self.assertEqual(mp.geoms[0].x, 0) mp1 = geometry.MultiPoint([p0, p1, p2]) self.assertEqual(len(mp1.geoms), 3) self.assertEqual(len(mp1), 3) self.assertEqual(mp1.geoms[0].x, 0) self.assertEqual(mp1.geoms[1].x, 1) self.assertEqual(mp1.geoms[2].x, 2) self.assertEqual(mp1.bounds, (0.0, 0.0, 2.0, 2.0)) l1 = geometry.LineString([p0, p1, p2]) mp2 = geometry.MultiPoint(l1) self.assertEqual(len(mp2.geoms), 3) self.assertEqual(mp2.geoms[2].x, 2) mp3 = geometry.MultiPoint([l1, p3]) self.assertEqual(mp3.geoms[3].x, 3) self.assertRaises(TypeError, geometry.MultiPoint, [mp1, mp3]) mp4 = geometry.MultiPoint([p0, p1, p0, p1, p2]) self.assertEqual(len(mp4.geoms), 5) mp4.unique() self.assertEqual(len(mp4.geoms), 3) mp5 = geometry.MultiPoint([[0.0, 0.0], [1.0, 2.0]]) self.assertEqual(len(mp5.geoms), 2) p = geometry.Polygon( (((0.0, 0.0), (0.0, 1.0), (1.0, 1.0), (1.0, 0.0)), ((0.1, 0.1), (0.1, 0.2), (0.2, 0.2), (0.2, 0.1)))) mp6 = geometry.MultiPoint(p) self.assertEqual(mp6.bounds, (0.0, 0.0, 1.0, 1.0)) self.assertRaises(TypeError, geometry.MultiPoint, [0, 0]) self.assertRaises( TypeError, geometry.MultiPoint, 0, ) self.assertEqual( mp1.__geo_interface__, { 'type': 'MultiPoint', 'bbox': (0.0, 0.0, 2.0, 2.0), 'coordinates': ((0.0, 0.0), (1.0, 1.0), (2.0, 2.0)) })
def test_geometrycollection(self): p = geometry.Point(0, 1) l = geometry.LineString([(0, 0), (1, 1)]) f = geometry.GeometryCollection([p, l]) s = geometry.as_shape(f) self.assertEqual(f.__geo_interface__, s.__geo_interface__) self.assertEqual(f.__geo_interface__['geometries'][0], p.__geo_interface__) self.assertEqual(f.__geo_interface__['geometries'][1], l.__geo_interface__)
def test_intersects_attr_point(): result = parse([ 'intersects', ['geometry'], { 'type': 'Point', 'coordinates': [1, 1], } ]) assert result == ast.GeometryIntersects( ast.Attribute('geometry'), values.Geometry(normalize_geom(geometry.Point(1, 1).__geo_interface__)), )
def test_intersects_attr_geometrycollection(): result = parse('INTERSECTS(geometry, GEOMETRYCOLLECTION(POINT(1 1),' 'LINESTRING(1 1,2 2),' 'POLYGON((1 1,2 2,0 3,1 1))' '))') assert result == ast.GeometryIntersects( ast.Attribute('geometry'), values.Geometry( geometry.GeometryCollection([ geometry.Point(1, 1), geometry.LineString([(1, 1), (2, 2)]), geometry.Polygon([(1, 1), (2, 2), (0, 3), (1, 1)]) ]).__geo_interface__), )
def test_multilinestring(self): ml = geometry.MultiLineString([[[0.0, 0.0], [1.0, 2.0]]]) ml1 = geometry.MultiLineString(ml) self.assertEqual(ml.geoms[0].coords, ((0.0, 0.0), (1.0, 2.0))) self.assertEqual(ml.bounds, (0.0, 0.0, 1.0, 2.0)) l = geometry.LineString([(0, 0), (1, 1)]) l1 = geometry.LineString([(0.0, 0.0), (1.0, 1.0), (2.0, 2.0)]) ml2 = geometry.MultiLineString([l, l1]) self.assertEqual(ml2.geoms[0].coords, ((0.0, 0.0), (1.0, 1.0))) self.assertEqual(ml2.geoms[1].coords, ((0.0, 0.0), (1.0, 1.0), (2.0, 2.0))) self.assertEqual(len(ml2), 2) ml3 = geometry.MultiLineString(l) self.assertEqual(ml3.geoms[0].coords, ((0.0, 0.0), (1.0, 1.0))) pt = geometry.Point(0, 1) self.assertRaises(TypeError, geometry.MultiLineString, pt) self.assertRaises(TypeError, geometry.MultiLineString, 0)
def test_point(self): self.assertRaises(ValueError, geometry.Point) p = geometry.Point(0, 1) self.assertEqual(p.bounds, (0.0, 1.0, 0.0, 1.0)) self.assertEqual(p.x, 0.0) self.assertEqual(p.y, 1.0) self.assertEqual(p.__geo_interface__, { 'type': 'Point', 'coordinates': (0.0, 1.0) }) self.assertRaises(ValueError, lambda: p.z) self.assertEqual(p.coords[0], (0.0, 1.0)) p1 = geometry.Point(0, 1, 2) self.assertEqual(p1.x, 0.0) self.assertEqual(p1.y, 1.0) self.assertEqual(p1.z, 2.0) self.assertEqual(p1.coords[0], (0.0, 1.0, 2.0)) self.assertEqual(p1.__geo_interface__, { 'type': 'Point', 'coordinates': (0.0, 1.0, 2.0) }) p2 = geometry.Point([0, 1]) self.assertEqual(p2.x, 0.0) self.assertEqual(p2.y, 1.0) p3 = geometry.Point([0, 1, 2]) self.assertEqual(p3.x, 0.0) self.assertEqual(p3.y, 1.0) self.assertEqual(p3.z, 2.0) p4 = geometry.Point(p) self.assertEqual(p4.x, 0.0) self.assertEqual(p4.y, 1.0) p5 = geometry.Point(p1) self.assertEqual(p5.x, 0.0) self.assertEqual(p5.y, 1.0) self.assertEqual(p5.z, 2.0) self.assertRaises(TypeError, geometry.Point, '1.0, 2.0') self.assertRaises(ValueError, geometry.Point, '1.0', 'a') self.assertRaises(TypeError, geometry.Point, (0, 1, 2, 3, 4)) #you may also pass string values as internally they get converted #into floats, but this is not recommended p6 = geometry.Point('0', '1') self.assertEqual(p.__geo_interface__, p6.__geo_interface__) p6.coords = [0, 1, 2] self.assertEqual(p3.coords, p6.coords) self.assertRaises(TypeError, setattr, p6, 'coords', 0) self.assertRaises(TypeError, setattr, p6, 'coords', [0]) f = geometry._Geometry() self.assertRaises(TypeError, geometry.Point, f)
def setUp(self): self.geometry = geometry._Geometry() self.point = geometry.Point(0, 1) self.linestring = geometry.LineString([[0, 0], [1, 0], [1, 1]]) self.linearring = geometry.LinearRing([[0, 0], [1, 0], [1, 1], [0, 0]]) self.coords_1 = ((0., 0.), (0., 1.), (1., 1.), (1., 0.), (0., 0.)) self.polygon = geometry.Polygon(self.coords_1) self.multipoint = geometry.MultiPoint([[0.0, 0.0], [1.0, 2.0]]) self.multiline = geometry.MultiLineString([[[0.0, 0.0], [1.0, 2.0]]]) self.multipoly = geometry.MultiPolygon([ (((0.0, 0.0), (0.0, 1.0), (1.0, 1.0), (1.0, 0.0)), [((0.1, 0.1), (0.1, 0.2), (0.2, 0.2), (0.2, 0.1))]) ]) self.geo_collect = geometry.GeometryCollection( [self.point, self.linestring, self.linearring]) self.feature = geometry.Feature(self.point, {'a': 1, 'b': 2}) self.feature_list = [self.feature, self.feature] self.fc = geometry.FeatureCollection(self.feature_list)
def test_intersects_attr_point(): result = parse({ "intersects": [ {"property": "geometry"}, { "type": "Point", "coordinates": [1, 1], } ] }) assert result == ast.GeometryIntersects( ast.Attribute('geometry'), values.Geometry( normalize_geom( geometry.Point(1, 1).__geo_interface__ ) ), )
def form_valid(self, form): k = kml.KML() ns = '{http://www.opengis.net/kml/2.2}' d = kml.Document(ns, 'docid', 'MLP Observations', 'KML Document') f = kml.Folder(ns, 'fid', 'MLP Observations Root Folder', 'Contains place marks for specimens and observations.') k.append(d) d.append(f) omo_occurrences = Occurrence.objects.all() for o in omo_occurrences: if o.geom: p = kml.Placemark(ns, 'id', 'name', 'description') # coord = utm.to_latlon(o.geom.coords[0], o.geom.coords[1], 37, 'P') pnt = geometry.Point(o.geom.coords[0], o.geom.coords[1]) p.name = o.__str__() d = "<![CDATA[<table>" open_row = "<tr><td>" middle_row = "</td><td style='font-weight:bold'>" close_row = "</td></tr>" d += open_row d += ''.join(("Basis of Record", middle_row)) d += ''.join([ _f for _f in (o.basis_of_record, close_row, open_row) if _f ]) d += ''.join(("Time", middle_row)) d += ''.join([ _f for _f in (str(o.field_number), close_row, open_row) if _f ]) d += ''.join(("Item Type", middle_row)) d += ''.join( [_f for _f in (o.item_type, close_row, open_row) if _f]) d += ''.join(("Collector", middle_row)) d += ''.join( [_f for _f in (o.collector, close_row, open_row) if _f]) d += ''.join(("Collection Method", middle_row)) d += ''.join([ _f for _f in (o.collecting_method, close_row, open_row) if _f ]) d += ''.join(("Count", middle_row)) d += ''.join([ _f for _f in (str(o.individual_count), close_row, open_row) if _f ]) d += ''.join(("Bar Code", middle_row)) d += ''.join( [_f for _f in (str(o.barcode), close_row, open_row) if _f]) d += ''.join(("Scientific Name", middle_row)) d += ''.join([ _f for _f in (o.item_scientific_name, close_row, open_row) if _f ]) d += ''.join(("Description", middle_row)) d += ''.join([ _f for _f in (o.item_description, close_row, open_row) if _f ]) d += ''.join(("Remarks", middle_row)) d += ''.join( [_f for _f in (o.remarks, close_row, open_row) if _f]) d += ''.join(("In Situ", middle_row)) d += ''.join([_f for _f in (str(o.in_situ), close_row) if _f]) d += "</table>" p.description = d p.geometry = pnt f.append(p) r = k.to_string(prettyprint=True) response = HttpResponse(r, content_type='text/plain') response[ 'Content-Disposition'] = 'attachment; filename="omo_mursi.kml"' return response
def test_intersects_attr_point(): result = parse('INTERSECTS(geometry, POINT(1 1))') assert result == ast.GeometryIntersects( ast.Attribute('geometry'), values.Geometry(geometry.Point(1, 1).__geo_interface__), )
def test_point(self): f = geometry.Point(0, 1) s = geometry.as_shape(f) self.assertEqual(f.__geo_interface__, s.__geo_interface__)
def test_mapping(self): self.assertEqual(geometry.mapping(geometry.Point(1, 1)), { 'type': 'Point', 'coordinates': (1.0, 1.0) })
end = feat.end.timestamp() step = (end - start) / len(feat.geometry.geoms) for point in feat.geometry.geoms: points.append((point, datetime.datetime.utcfromtimestamp(start))) start += step with open(args.gpx) as myfile: doc = myfile.read() gpx = gpxpy.parse(doc) times = [] segment_points = gpx.tracks[0].segments[0].points for track in gpx.tracks: for segment in track.segments: for point in segment.points: p = geometry.Point(point.longitude, point.latitude) times.append((p, point.time)) max_time = times[-1][1] for point in points: if point[1] > max_time: p = point[0] segment_points.append( gpxpy.gpx.GPXTrackPoint(longitude=p.x, latitude=p.y, time=point[1], comment='source is KML')) print(gpx.to_xml())
def test_polygon(self): p = geometry.Polygon([(0, 0), (1, 1), (1, 0), (0, 0)]) self.assertEqual(p.exterior.coords, ((0.0, 0.0), (1.0, 1.0), (1.0, 0.0), (0.0, 0.0))) self.assertEqual(list(p.interiors), []) self.assertEqual( p.__geo_interface__, { 'type': 'Polygon', 'bbox': (0.0, 0.0, 1.0, 1.0), 'coordinates': (((0.0, 0.0), (1.0, 1.0), (1.0, 0.0), (0.0, 0.0)), ) }) self.assertEqual(p.bounds, (0.0, 0.0, 1.0, 1.0)) r = geometry.LinearRing([(0, 0), (1, 1), (1, 0), (0, 0)]) p1 = geometry.Polygon(r) self.assertEqual(p1.exterior.coords, r.coords) e = [(0, 0), (0, 2), (2, 2), (2, 0), (0, 0)] i = [(1, 0), (0.5, 0.5), (1, 1), (1.5, 0.5), (1, 0)] ph1 = geometry.Polygon(e, [i]) self.assertEqual(ph1.__geo_interface__, geometry.as_shape(ph1).__geo_interface__) self.assertEqual(ph1.exterior.coords, tuple(e)) self.assertEqual(list(ph1.interiors)[0].coords, tuple(i)) self.assertEqual( ph1.__geo_interface__, { 'type': 'Polygon', 'bbox': (0.0, 0.0, 2.0, 2.0), 'coordinates': (((0.0, 0.0), (0.0, 2.0), (2.0, 2.0), (2.0, 0.0), (0.0, 0.0)), ((1.0, 0.0), (0.5, 0.5), (1.0, 1.0), (1.5, 0.5), (1.0, 0.0))) }) ext = [(0, 0), (0, 2), (2, 2), (2, 0), (0, 0)] int_1 = [(0.5, 0.25), (1.5, 0.25), (1.5, 1.25), (0.5, 1.25), (0.5, 0.25)] int_2 = [(0.5, 1.25), (1, 1.25), (1, 1.75), (0.5, 1.75), (0.5, 1.25)] ph2 = geometry.Polygon(ext, [int_1, int_2]) self.assertEqual(ph2.exterior.coords, tuple(ext)) self.assertEqual(list(ph2.interiors)[0].coords, tuple(int_1)) self.assertEqual(list(ph2.interiors)[1].coords, tuple(int_2)) self.assertEqual( ph2.__geo_interface__, { 'type': 'Polygon', 'bbox': (0.0, 0.0, 2.0, 2.0), 'coordinates': (((0.0, 0.0), (0.0, 2.0), (2.0, 2.0), (2.0, 0.0), (0.0, 0.0)), ((0.5, 0.25), (1.5, 0.25), (1.5, 1.25), (0.5, 1.25), (0.5, 0.25)), ((0.5, 1.25), (1.0, 1.25), (1.0, 1.75), (0.5, 1.75), (0.5, 1.25))) }) ph3 = geometry.Polygon(ph2) self.assertEqual(ph2.__geo_interface__, ph3.__geo_interface__) # if a polygon is passed as constructor holes will be ignored # XXX or should holes be added to the polygon? ph4 = geometry.Polygon(ph2, [i]) self.assertEqual(ph2.__geo_interface__, ph4.__geo_interface__) coords = ((0., 0.), (0., 1.), (1., 1.), (1., 0.), (0., 0.)) polygon = geometry.Polygon(coords) ph5 = geometry.Polygon( (((0.0, 0.0), (0.0, 1.0), (1.0, 1.0), (1.0, 0.0)), ((0.1, 0.1), (0.1, 0.2), (0.2, 0.2), (0.2, 0.1)))) r1 = geometry.LinearRing([(0, 0), (2, 2), (2, 0), (0, 0)]) r2 = geometry.LinearRing([(0.5, 0.5), (1, 1), (1, 0), (0.5, 0.5)]) p6 = geometry.Polygon(r1, [r2]) pt = geometry.Point(0, 1) self.assertRaises(TypeError, geometry.Polygon, pt) self.assertRaises(TypeError, geometry.Polygon, 0) self.assertRaises(TypeError, geometry.Polygon, pt, [pt])