我在geodjango应用程序中遇到了一些重复的问题 似乎是源于GEOS。我收到的错误不包括在内 堆栈跟踪信息,所以我不知道如何调试它们。我有 能够将问题与使用GEOS的特定命令隔离开来。
下面的更新:是一个更简单的测试用例,它给我一个错误。我怀疑这会给你一个错误,我强烈怀疑这与我的机器,我的环境或我的GEOS构建有关。任何有关如何解决这个问题的提示都非常感谢。
>>> from django.contrib.gis.geos import Polygon, MultiPolygon
>>> p1 = Polygon( ((0, 0), (0, 1), (1, 1), (0, 0)) )
GEOS_ERROR: Shell is not a LinearRing
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/Users/benjamin/projects/artgeese/lib/python2.7/site-packages/django/contrib/gis/geos/polygon.py", line 42, in __init__
polygon = self._create_polygon(n_holes + 1, (ext_ring,) + init_holes)
File "/Users/benjamin/projects/artgeese/lib/python2.7/site-packages/django/contrib/gis/geos/polygon.py", line 85, in _create_polygon
return capi.create_polygon(shell, holes_param, c_uint(n_holes))
File "/Users/benjamin/projects/artgeese/lib/python2.7/site-packages/django/contrib/gis/geos/prototypes/threadsafe.py", line 49, in __call__
return self.cfunc(self.thread_context.handle.ptr, *args)
File "/Users/benjamin/projects/artgeese/lib/python2.7/site-packages/django/contrib/gis/geos/prototypes/errcheck.py", line 43, in check_geom
raise GEOSException('Error encountered checking Geometry returned from GEOS C function "%s".' % func.__name__)
GEOSException: Error encountered checking Geometry returned from GEOS C function "GEOSGeom_createPolygon_r".
以下是我遇到的各种错误的细分
>>> basins = GroundWater.objects.all()
>>> geoms = [b.geom() for b in basins]
>>> geom = geoms[3]
>>> print type( geom )
<class 'django.contrib.gis.geos.collections.MultiPolygon'>
>>> polygon = geom.cascading_union # this is ok
>>> print type( polygon )
<class 'django.contrib.gis.geos.polygon.Polygon'>
>>> print polygon
# this receives the following error and shuts down the dev server
Assertion failed: (0), function appendGeometryTaggedText, file WKTWriter.cpp,
line 228.
Abort trap
>>> print polygon.num_interior_rings
# causes an error, does not stop the server
GEOS_ERROR: Argument is not a Polygon
and
Error encountered in GEOS C function "GEOSGetNumInteriorRings_r".
>>> print polygon.coords
# causes an error, does not stop the server
GEOS_ERROR: Argument is not a Polygon
and
Error encountered in GEOS C function "GEOSGetNumInteriorRings_r".
>>> print polygon.valid
GEOS_ERROR: UnsupportedOperationException:
Error encountered on GEOS C predicate function "GEOSisValid_r".
关于如何解决或调试这种情况的任何想法?谢谢!
请注意,问题并非特定于该多边形。如果我选择任何其他功能,我会收到相同的错误。
以下是有关环境的统计数据:
Mac OS X==10.6.8
Python==2.7.1
Django==1.4.2
psycopg2==2.4.5
postgis_full_version
---------------------------------------------------------------------------------
POSTGIS="1.5.1" GEOS="3.2.2-CAPI-1.6.2" PROJ="Rel. 4.7.1, 23 September 2009" LIBXML="2.7.3"
我使用KyngChaos二进制文件安装了GEOS和GDAL并将它们放在我的上面 系统路径
export PATH=/Library/Frameworks/GDAL.framework/Versions/1.9/Python/site-packages:$PATH
export PATH=/Library/Frameworks/UnixImageIO.framework/Programs:$PATH
export PATH=/Library/Frameworks/PROJ.framework/Programs:$PATH
export PATH=/Library/Frameworks/GEOS.framework/Programs:$PATH
export PATH=/Library/Frameworks/SQLite3.framework/Programs:$PATH
export PATH=/Library/Frameworks/GDAL.framework/Programs:$PATH
export PATH=/usr/local/pgsql/bin:$PATH