Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when running manage.py mapit_UK_find_parents: GEOS_ERROR: TopologyException #159

Closed
ollydcuk opened this issue Jan 20, 2015 · 4 comments

Comments

@ollydcuk
Copy link

I'm attempting to setup my own mapit instance.

I've got the ami up and running and I'm trying to get the UK OS data imported, following the instructions here: http://mapit.poplus.org/docs/self-hosted/import/uk/

I'm running: ./manage.py mapit_UK_find_parents.

It works away for a bit and then outputs this error:

<snip>
Parent for Colston Bassett [15335] (CPC) was None, is now Rushcliffe Borough Council [1890] (DIS)
Parent for Coltishall [14239] (CPC) was None, is now Broadland District Council [2102] (DIS)
Parent for Coltishall [4988] (DIW) was None, is now Broadland District Council [2102] (DIS)
Parent for Colton [14639] (CPC) was None, is now Selby District Council [1883] (DIS)
Parent for Colton [16211] (CPC) was None, is now Lichfield District Council [1908] (DIS)
Parent for Colton [10193] (CPC) was None, is now South Lakeland District Council [1763] (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".

Am I doing something obviously wrong here?

@ollydcuk ollydcuk changed the title Error when running manage.py mapit_UK_find_parents: GEOS_ERROR: TopologyException: found non-noded intersection between LINESTRING... Error when running manage.py mapit_UK_find_parents: GEOS_ERROR: TopologyException Jan 20, 2015
@dracos
Copy link
Member

dracos commented Jan 21, 2015

The latest couple of Boundary-Lines have had invalid geometries for six polygons – the first of which alphabetically is Colville, hence why it dies where you quote. The latest version of mapit_UK_import_boundary_line should automatically try and fix these on import, or there is a special management command called mapit_UK_fix_2014-05 which fixes them. Hope that's helpful, let us know if you have any problems.

@dracos dracos closed this as completed Jan 21, 2015
@ollydcuk
Copy link
Author

I've updated my ami, as per your other replies.

When running /manage.py migrate mapit zero I'm now getting:

Operations to perform:
  Unapply all migrations: mapit
Running migrations:
  Unapplying mapit.0001_initial...Traceback (most recent call last):
  File "./manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python2.7/dist-packages/Django-1.7.3-py2.7.egg/django/core/management/__init__.py", line 385, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python2.7/dist-packages/Django-1.7.3-py2.7.egg/django/core/management/__init__.py", line 377, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python2.7/dist-packages/Django-1.7.3-py2.7.egg/django/core/management/base.py", line 288, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/usr/local/lib/python2.7/dist-packages/Django-1.7.3-py2.7.egg/django/core/management/base.py", line 338, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python2.7/dist-packages/Django-1.7.3-py2.7.egg/django/core/management/commands/migrate.py", line 161, in handle
    executor.migrate(targets, plan, fake=options.get("fake", False))
  File "/usr/local/lib/python2.7/dist-packages/Django-1.7.3-py2.7.egg/django/db/migrations/executor.py", line 70, in migrate
    self.unapply_migration(migration, fake=fake)
  File "/usr/local/lib/python2.7/dist-packages/Django-1.7.3-py2.7.egg/django/db/migrations/executor.py", line 122, in unapply_migration
    migration.unapply(project_state, schema_editor)
  File "/usr/local/lib/python2.7/dist-packages/Django-1.7.3-py2.7.egg/django/db/migrations/migration.py", line 157, in unapply
    operation.database_backwards(self.app_label, schema_editor, from_state, to_state)
  File "/usr/local/lib/python2.7/dist-packages/Django-1.7.3-py2.7.egg/django/db/migrations/operations/models.py", line 261, in database_backwards
    return self.database_forwards(app_label, schema_editor, from_state, to_state)
  File "/usr/local/lib/python2.7/dist-packages/Django-1.7.3-py2.7.egg/django/db/migrations/operations/models.py", line 257, in database_forwards
    getattr(new_model._meta, self.option_name, set()),
  File "/usr/local/lib/python2.7/dist-packages/Django-1.7.3-py2.7.egg/django/db/backends/schema.py", line 302, in alter_unique_together
    ", ".join(columns),
ValueError: Found wrong number (0) of constraints for mapit_code(area_id, type_id)

@dracos
Copy link
Member

dracos commented Jan 22, 2015

This comment post-dates your other one, so I assume this is still an issue? Did you follow the steps I gave in #162 (comment) – start AMI, set the configuration for the UK, do the migration back/forward, then run install-site.sh to update the code? If so, you shouldn't need to migrate back/forwards again.

I guess updating the code first off, then trying to migrate backwards won't work because the migrations in Django changed a lot between versions 1.6 and 1.7 of Django, and I assume the update will have pulled in a later version of Django. So it's trying to migrate backwards from the new migrations and that causes an issue (not sure precisely what it means, but that's all I can assume).

If you have updated the code but not updated the configuration, probably easiest to just drop the database (I assume it's empty if you're wanting to migrate back/forwards!) and recreate it from scratch with a manage.py migrate.

@ollydcuk
Copy link
Author

Gotcha. Just did a dropdb and then re-created everything. Up and running now. Thanks for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants