Support geographic types
Hi,
At PyconFR Cedric told me that GIS patches needed more testing before inclusion
in repositories.
This is a summary of my tests with GIS patches. These patches have been
developed by Nicolas Evrard for B2CK and financed by Bio Eco Forests.
Patches are available in these codereviews:
- Tryton client: review210002 (patch set 14)
- Tryton server: review208001 (patch set 18)
python-dbgis is a dependency of these patches and is available here:
https://projects.bioecoforests.com/projects/python-dbgis
Below, "+patch -dbgis -postgis" means "patch set applied, python module dbgis
not available, postgis extension not installed on current database".
*GIS features enabled on tryton but disabled on trytond*
trytond: -patch -dbgis -postgis
tryton: +patch -dbgis
=> No problem found.
trytond: -patch -dbgis -postgis
tryton: +patch, +dbgis
=>No problem found.
*GIS features disabled on tryton but enabled on trytond*
trytond: +patch -dbgis -postgis
tryton: -patch -dbgis
=>No problem found.
trytond: +patch +dbgis -postgis
tryton: -patch -dbgis
=>No problem found (was NOK with trytond patch set 16).
trytond: +patch +dbgis +postgis, test module 'forest' installed
tryton: -patch -dbgis
=> Views related to the 'forest' module can not be displayed: an exception occurs.
trytond: +patch +dbgis +postgis
tryton: +patch -dbgis
=> Views related to the 'forest' module can not be displayed: an exception occurs.
Regarding the behavior of trytond with pyspatialite, it is the same as with postgis.
When installing a model with GIS fields (trytond -i geo -d db):
Following exceptions are encountered when trying to install a module with a
geometric field and GIS features not available:
*trytond: -patch -dbgis -postgis*
--> call to register fails:
INFO:modules:foret:registering classes
[...]
File "trytond/trytond/modules/foret/foret.py", line 14, in Foret
geom = fields.MultiPolygon(u"Géométrie", srid=2154, required=True,
AttributeError: 'module' object has no attribute 'MultiPolygon'
*trytond +patch -dbgis -postgis*
--> call to register fails:
INFO:modules:foret:register foret.foret
[...]
File "trytond/trytond/model/modelsql.py", line 132, in __register__
FIELDS[field._type].sql_type(field), field.srid,
KeyError: 'multipolygon'
*trytond +patch +dbgis -postgis*
-->
ERROR:sql:Wrong SQL: SELECT AddGeometryColumn('foret_foret', 'geom', 2154,
'MULTIPOLYGON', 2)
[...]
File "trytond/backend/postgresql/database.py", line 323, in execute
res = self.cursor.execute(sql, params)
psycopg2.ProgrammingError: ERREUR: function addgeometrycolumn(unknown, unknown,
integer, unknown, integer) doesn't exist
LINE 1: SELECT AddGeometryColumn('foret_foret', 'geom', 2154, 'MULTI...
Is there a point blocking the inclusion of these patches?
NB: in order to enable PostGIS, execute SQL commands from postgis.sql &
spatial_ref_sys.sql files:
psql -d db_name -f /usr/share/postgresql/9.1/contrib/postgis-1.5/postgis.sql
psql -d db_name -f
/usr/share/postgresql/9.1/contrib/postgis-1.5/spatial_ref_sys.sql
and the following rights need to be granted:
grant select on spatial_ref_sys to db_user;
grant all on geometry_columns to db_user;
grant all on geography_columns to db_user;