Code

Opened 6 years ago

Last modified 5 years ago

#9295 new New feature

Better error handling and/or error reporting when Proj.4 datum shifting files are not found

Reported by: springmeyer Owned by: jbronn
Component: GIS Version: 1.0
Severity: Normal Keywords: proj4, datum shifing, geodjango-basic-apps, postgis, 900913, projections
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

A very common install problem for new users to GeoDjango is to use a package management system for installing proj which does not include the Proj.4 datum shifting files (A key question is do any packager of proj include these files?). Or a user does a source install of proj and misses the instructions here: http://geodjango.org/docs/install.html#proj-4 and fails to manually install the additional files.

The impact of the lacking files is often first seen for new users who download one of the apps that uses the OSMGeoAdmin from http://code.google.com/p/geodjango-basic-apps/. Without a use of GeoDjango like this that does transformations between Google Spherical Mercator projection (http://spatialreference.org/ref/user/google-projection/) and another projection in a different datum, this installation problem might not surface for many users.

OSMGeoAdmin uses GDAL to do reprojection of data into SRID 900913 for the Admin OpenLayers map and then uses the spatial database backend to reproject the data back to the native SRID after the save() method is called.

With a PostGIS backend the spatial data is sent to in the database without proper reprojection due to the missing files with no error warning of the missing files needed. The geometry therefore misses the validation check at the form level, such that and error is throw by a GEOS error check only after finding corrupt coordinates which is not super intuitive as to the original problem:

Error encountered checking Geometry returned from GEOS C function "GEOSGeomFromHEX_buf"

Attachments (1)

geoadminsite.diff (1.9 KB) - added by jbronn 6 years ago.

Download all attachments as: .zip

Change History (11)

comment:1 Changed 6 years ago by springmeyer

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

For the sake of google indexing, here's the whole error which I could prompt by moving the folder '/usr/local/share/proj' to a new spot on the filesystem such that postgis can no longer find it.

This error happens on page reload of a previously saved record in the admin. Again, this is not a GeoDjango problem but I do think GeoDjango could provide better error handling and reporting.

Environment:

Request Method: GET
Request URL: http://localhost:8000/admin/world/worldborders/2/
Django Version: 1.1 pre-alpha SVN-9109
Python Version: 2.5.1
Installed Applications:
['django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.databrowse',
 'django.contrib.gis',
 'world']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.middleware.doc.XViewMiddleware')


Traceback:
File "/Users/spring/src/django-svn-trunk/django/core/handlers/base.py" in get_response
  86.                 response = callback(request, *callback_args, **callback_kwargs)
File "/Users/spring/src/django-svn-trunk/django/contrib/admin/sites.py" in root
  157.                 return self.model_page(request, *url.split('/', 2))
File "/Users/spring/src/django-svn-trunk/django/views/decorators/cache.py" in _wrapped_view_func
  44.         response = view_func(request, *args, **kwargs)
File "/Users/spring/src/django-svn-trunk/django/contrib/admin/sites.py" in model_page
  176.         return admin_obj(request, rest_of_url)
File "/Users/spring/src/django-svn-trunk/django/contrib/admin/options.py" in __call__
  197.             return self.change_view(request, unquote(url))
File "/Users/spring/src/django-svn-trunk/django/db/transaction.py" in _commit_on_success
  238.                 res = func(*args, **kw)
File "/Users/spring/src/django-svn-trunk/django/contrib/admin/options.py" in change_view
  589.             form = ModelForm(instance=obj)
File "/Users/spring/src/django-svn-trunk/django/forms/models.py" in __init__
  201.             object_data = model_to_dict(instance, opts.fields, opts.exclude)
File "/Users/spring/src/django-svn-trunk/django/forms/models.py" in model_to_dict
  123.             data[f.name] = f.value_from_object(instance)
File "/Users/spring/src/django-svn-trunk/django/db/models/fields/__init__.py" in value_from_object
  332.         return getattr(obj, self.attname)
File "/Users/spring/src/django-svn-trunk/django/contrib/gis/db/models/proxy.py" in __get__
  36.             geom = self._klass(geom_value)
File "/Users/spring/src/django-svn-trunk/django/contrib/gis/geos/base.py" in __init__
  66.                 g = from_hex(geo_input, len(geo_input))
File "/Users/spring/src/django-svn-trunk/django/contrib/gis/geos/prototypes/errcheck.py" in check_geom
  32.         raise GEOSException('Error encountered checking Geometry returned from GEOS C function "%s".' % func.__name__)

Exception Type: GEOSException at /admin/world/worldborders/2/
Exception Value: Error encountered checking Geometry returned from GEOS C function "GEOSGeomFromHEX_buf".

comment:2 Changed 6 years ago by jbronn

  • Owner changed from nobody to jbronn

comment:3 Changed 6 years ago by jbronn

Attached is a patch which will bring back GeoAdminSite and override check_dependencies so that GeoDjango may raise an informative exception -- this still needs to be implemented. Moreover, I think I've figured out a way around the registration problem by also overriding autodiscover so that GeoDjango's site instance may also have 'normal' Django site registrations.

Changed 6 years ago by jbronn

comment:4 Changed 6 years ago by springmeyer

Cool jbronn.

As background, here's some context on the lack of inclusion of the files in the debian packages: http://postgis.refractions.net/pipermail/postgis-users/2008-December/022220.html

comment:5 Changed 5 years ago by anonymous

  • milestone post-1.0 deleted

Milestone post-1.0 deleted

comment:6 Changed 5 years ago by Alex

  • Triage Stage changed from Unreviewed to Accepted

comment:7 Changed 5 years ago by springmeyer

A reference for folks working around this error, here is a workaround for the lack of packaging of the datum files that maintains to use of debian packages:

Thanks rcoup!

# note the lack of a complete set of proj files...
$ ls /usr/share/proj/
epsg  esri.extra  nad27  nad.lst      proj_def.dat
esri  GL27	  nad83  other.extra  world

# re build the proj pkg after manually download the data files..
apt-get install fakeroot build-essential debhelper
cd ~/src
apt-get source proj
wget http://download.osgeo.org/proj/proj-datumgrid-1.4.tar.gz
cd proj-4.6.0/nad/
tar xzf ../../proj-datumgrid-1.4.tar.gz
cd ../
dpkg-buildpackage -rfakeroot -b
cd ../
dpkg -i proj_4.6.0-2_i386.deb

$ ls /usr/share/proj/
alaska	epsg  esri.extra  GL27	  MD	 nad83	  ntf_r93.gsb	null		    other.extra   prvi	    stlrnc  TN	WO
conus	esri  FL	  hawaii  nad27  nad.lst  ntv1_can.dat	nzgd2kgrid0005.gsb  proj_def.dat  stgeorge  stpaul  WI	world

comment:8 Changed 3 years ago by lukeplant

  • Severity set to Normal
  • Type set to New feature

comment:9 Changed 2 years ago by aaugustin

  • UI/UX unset

Change UI/UX from NULL to False.

comment:10 Changed 2 years ago by aaugustin

  • Easy pickings unset

Change Easy pickings from NULL to False.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as new
The owner will be changed from jbronn to anonymous. Next status will be 'assigned'
as The resolution will be set. Next status will be 'closed'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.