Ticket #1255 (closed defect: fixed)
ogr.Geometry __init__ method not functionnal with some attributes
| Reported by: | dpinte@… | Owned by: | hobu |
|---|---|---|---|
| Priority: | highest | Milestone: | 1.4.1 |
| Component: | OGR_SF | Version: | unspecified |
| Severity: | blocker | Keywords: | |
| Cc: | dpinte@… |
Description (last modified by hobu) (diff)
__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
Attachments
Change History
Note: See
TracTickets for help on using
tickets.

