MapIt - 加载数据获取GEOSException

时间:2014-10-30 16:14:42

标签: django postgis geodjango geos

在使用英国数据加载mapit时遇到此问题(基于本指南:http://mapit.poplus.org/docs/self-hosted/import/uk/

我正在运行此命令: ./ manage.py mapit_UK_find_parents

Parent for Colton [10193] (CPC) was None, is now South Lakeland District Council [1763] (DIS)
Parent for Colton [16211] (CPC) was None, is now Lichfield District Council [1908] (DIS)
Parent for Colton [14639] (CPC) was None, is now Selby District Council [1883] (DIS)
Parent for Colton and Mavesyn Ridware [5835] (DIW) was None, is now Lichfield District Council [1908] (DIS)
GEOS_ERROR: TopologyException: found non-noded intersection between LINESTRING (524864 545.5, 524859 540.2) and LINESTRING (524859 540.2, 524859 540.2) at 524859 540.2
Traceback (most recent call last):
    File "./manage.py", line 11, in <module>
        execute_manager(settings)
    File "/usr/lib/python2.7/dist-packages/django/core/management/__init__.py", line 438, in execute_manager
        utility.execute()
    File "/usr/lib/python2.7/dist-packages/django/core/management/__init__.py", line 379, in execute
        self.fetch_command(subcommand).run_from_argv(self.argv)
    File "/usr/lib/python2.7/dist-packages/django/core/management/base.py", line 191, in run_from_argv
        self.execute(*args, **options.__dict__)
    File "/usr/lib/python2.7/dist-packages/django/core/management/base.py", line 220, in execute
        output = self.handle(*args, **options)
    File "/usr/lib/python2.7/dist-packages/django/core/management/base.py", line 351, in handle
        return self.handle_noargs(**options)
    File "/var/www/mapit/mapit/mapit/management/commands/mapit_UK_find_parents.py", line 52, in handle_noargs
        'polygons__polygon__contains': polygon.polygon.point_on_surface,
    File "/usr/lib/python2.7/dist-packages/django/contrib/gis/geos/geometry.py", line 593, in point_on_surface
        return self._topology(capi.geos_pointonsurface(self.ptr))
    File "/usr/lib/python2.7/dist-packages/django/contrib/gis/geos/prototypes/threadsafe.py", line 49, in __call__
        return self.cfunc(self.thread_context.handle.ptr, *args)
    File "/usr/lib/python2.7/dist-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__)
django.contrib.gis.geos.error.GEOSException: Error encountered checking Geometry returned from GEOS C function "GEOSPointOnSurface_r".

1 个答案:

答案 0 :(得分:0)

您导入的边界线数据中有几个无效的几何图形,导入正常但在尝试用于地理空间计算时出错。

导入脚本已更新,可在导入阶段尝试修复此类边界:https://github.com/mysociety/mapit/commit/e20425be025cfece2c7172774a4d1202fe068704

您可以使用更新的命令再次导入数据,也可以在运行mapit_UK_find_parents之前手动修复数据库中的数据(您还需要--commit来保存数据)。要手动修复,您需要运行类似于mapit_UK_fix_2014-05https://github.com/mysociety/mapit/blob/master/mapit_gb/management/commands/mapit_UK_fix_2014-05.py)的脚本,但删除了W04 / W05行 - 因为这些边界已从2014年10月版的Boundary-Line。