Django

Code

Ticket #9686 (closed: fixed)

Opened 1 year ago

Last modified 1 year ago

GeoDjango should support the sqlite3 back end via SpatiaLite

Reported by: mdh Assigned to: jbronn
Milestone: 1.1 Component: GIS
Version: 1.0 Keywords:
Cc: Triage Stage: Accepted
Has patch: 1 Needs documentation: 1
Needs tests: 0 Patch needs improvement: 1

Description

GeoDjango should support the sqlite3 back end via SpatiaLite?. I've been working on this for a bit, and it mostly works, so I'm uploading my latest code so that other folks can take a look, comment, and help out.

In addition to this patch you will need these things:

  • A reasonably modern version of SQLite3. Definitely at least version 3.3.7. I'm using version 3.6.4. Run “sqlite3 --version” to check yours.
  • At least version 2.5.0 of pysqlite2. Run “python -c "from pysqlite2 import dbapi2 ; print dbapi2.version"” to check yours.
  • Some version of SpatiaLite?. I use 3.6.2. Run “spatialite --version” to check yours.
  • The latest patch from ticket #6064, to let GeoDjango initialize SpatiaLite? when the connection is opened.
  • The latest patch from ticket #9628, to let Django use your pysqlite2 module instead of the built-in sqlite3 module.
  • The latest patch from ticket #9633, to let the SpatiaLiteAdaptor class work. (We may be able to do away with this somehow.)

Right now, unless you're using a test database within the Django testing framework, you will need to initialize your geospatial database yourself. All the code to do it is there for the testing framework, though. This could be done entirely automagically, or it could be done with a special management command. I'm usually not a fan of magic, but in this case the whole point is to make it as trivial to get started with GeoDjango as it is to get started with the rest of Django, so I'm more open to a little bit of it.

Anyway! Let me know if you play with this!

Attachments

9686-spatialite-back-end-for-geodjango.diff (36.7 kB) - added by mdh on 11/24/08 22:01:11.
A first attempt at supporting a SpatiaLite? back end for GeoDjango

Change History

11/24/08 22:01:11 changed by mdh

  • attachment 9686-spatialite-back-end-for-geodjango.diff added.

A first attempt at supporting a SpatiaLite? back end for GeoDjango

11/24/08 22:05:33 changed by mdh

  • needs_better_patch changed.
  • component changed from Uncategorized to GIS.
  • needs_tests changed.
  • needs_docs changed.

Okay, in order to overcome djangoproject.com’s upload file size limitation and create a more readable patch, I ended up removing four data files from the patch. So, in addition to the patch itself, you will need to unpack this tarball into your Django repository in order for the geospatial database initialization and tests to work properly:

http://www.maximumentropy.org/9686-spatialite-data.tar.gz

11/24/08 22:06:35 changed by mdh

  • needs_better_patch set to 1.
  • needs_docs set to 1.

I'm just going ahead and marking this preemptively, because lord knows this patch needs improvement.

11/25/08 09:23:40 changed by jbronn

  • owner changed from nobody to jbronn.
  • status changed from new to assigned.

02/26/09 17:38:38 changed by jacob

  • stage changed from Unreviewed to Accepted.

03/09/09 18:37:42 changed by jbronn

  • milestone set to 1.1.

03/30/09 12:15:50 changed by jbronn

(In [10197]) Refactored and cleaned up parts of the spatial database backend. Changes include:

* Laid foundations for SpatiaLite? support in GeoQuerySet, GeoWhereNode and the tests. * Added the Collect aggregate for PostGIS (still needs tests). * Oracle now goes to 11. * The backend-specific SpatialRefSys and GeometryColumns models are now attributes of SpatialBackend. * Renamed GeometryField attributes to be public that were private (e.g., _srid -> srid and _geom -> geom_type). * Renamed create_test_db to create_test_spatial_db. * Removed the legacy classes GeoMixin and GeoQ. * Removed evil \ from spatial backend fields. * Moved shapefile data from tests/layermap to tests/data.

Fixed #9794. Refs #9686.

03/30/09 17:17:43 changed by Alex

  • status changed from assigned to closed.
  • resolution set to fixed.

Fixed in r10222


Add/Change #9686 (GeoDjango should support the sqlite3 back end via SpatiaLite)




Change Properties
Action