__init__ methods cannot return anything else than None in Python. If trying to return something else, it raises a TypeError.
When using ogr.Geometry constructor with wkt, wkb or gml parameters, the class cannot be used.
For example :
org.py - line 1019
elif wkt:
if srs:
return CreateGeometryFromWkt(wkt, srs)
else:
return CreateGeometryFromWkt(wkt)
This causes the following error while trying to use ogr.Geometry(wkt=mywkt):
======================================================================
ERROR: testpoly (__main__.TestIntrusionPoly)
----------------------------------------------------------------------
Traceback (most recent call last):
File "alert/test/testoutflow.py", line 125, in testpoly
polylist = poly.create_polygons()
File "/home/did/Documents/ucl/alert/python/alert/data/intrusion.py", line 460, in create_polygons
coast_poly = geometry.create_ogrgeom(ccorners, srs)
File "/home/did/Documents/ucl/alert/python/alert/gis/geometry.py", line 71, in create_ogrgeom
poly = ogr.Geometry(wkt=wktpoly)
TypeError: __init__() should return None
You should consider to rewrite this part of the code :
ogr.py - line 1019 :
elif wkt:
if srs:
self._o = CreateGeometryFromWkt(wkt, srs)
self.thisown = 1
else:
self._o = CreateGeometryFromWkt(wkt)
self.thisown = 1
I'll make and send a patch in the next minutes.
Cheers,
Didrik