[GRASS-dev] v.out.ogr patch: support OGR "update"

Dear all,

I have attached a very small patch to v.out.org against the
version in 6.4.SVN. It adds a "-u" flag that allows users
to update data in existing OGR sources. It's the same as
ogr2ogr's "-update" option and _very_ important for being able
to write layers as tables into existing spatial databases.
It should not be able to break any existing functionality.

If a data source does not support updates (like Shapefiles),
then Ogr_Dr_open() behaves the same as Ogr_Dr_CreateDataSource().

Despite the update, I have not been able to successfully
write OGR features to an existing (or new) SQLite DB.

OGR_L_CreateFeature() results in this error from the SQLite driver
after the first feature has been written:

ERROR 1: sqlite3_step() failed:
   SQL logic error or missing database

Strangely, the first feature is written into the table just fine,
but the error appears for all consecutive writes.

I will have to do more tests to see if this is an SQLite
and GRASS specific problem (ogr2ogr works fine).

Cheers,

Ben

--
Benjamin Ducke
Senior Geospatial Consultant

Oxford Archaeology
Janus House
Osney Mead
OX2 0ES
Oxford, U.K.

Tel: +44 (0)1865 263 800 (switchboard)
Tel: +44 (0)1865 980 758 (direct)
Fax :+44 (0)1865 793 496
benjamin.ducke@oxfordarch.co.uk

------
Files attached to this email may be in ISO 26300 format (OASIS Open Document Format). If you have difficulty opening them, please visit http://iso26300.info for more information.

(attachments)

v.out.ogr.patch (2.46 KB)

The patch I just sent was slightly faulty in that it always produced
a warning about ignoring OGR dsco parameters in update mode even when
none were given. Sorry about that. Attached is a fixed version.
I have run some tests with a PostGIS database and that seemed to work
just fine (adding new layers as tables to an existing DB), so this
is an SQLite issue. However, since ogr2ogr manages to stuff features
into an SQLite DB just fine, there must be something wrong with
either the GRASS interface or my own installation.

Maybe someone else could do some quick SQLite testing just to
confirm I am not the only one for who things don't work?
That would make it much easier for me to narrow down the problem.

Thanks,

Ben

Benjamin Ducke wrote:

Dear all,

I have attached a very small patch to v.out.org against the
version in 6.4.SVN. It adds a "-u" flag that allows users
to update data in existing OGR sources. It's the same as
ogr2ogr's "-update" option and _very_ important for being able
to write layers as tables into existing spatial databases.
It should not be able to break any existing functionality.

If a data source does not support updates (like Shapefiles),
then Ogr_Dr_open() behaves the same as Ogr_Dr_CreateDataSource().

Despite the update, I have not been able to successfully
write OGR features to an existing (or new) SQLite DB.

OGR_L_CreateFeature() results in this error from the SQLite driver
after the first feature has been written:

ERROR 1: sqlite3_step() failed:
  SQL logic error or missing database

Strangely, the first feature is written into the table just fine,
but the error appears for all consecutive writes.

I will have to do more tests to see if this is an SQLite
and GRASS specific problem (ogr2ogr works fine).

Cheers,

Ben

------------------------------------------------------------------------

_______________________________________________
grass-dev mailing list
grass-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-dev

--
Benjamin Ducke
Senior Geospatial Consultant

Oxford Archaeology
Janus House
Osney Mead
OX2 0ES
Oxford, U.K.

Tel: +44 (0)1865 263 800 (switchboard)
Tel: +44 (0)1865 980 758 (direct)
Fax :+44 (0)1865 793 496
benjamin.ducke@oxfordarch.co.uk

------
Files attached to this email may be in ISO 26300 format (OASIS Open Document Format). If you have difficulty opening them, please visit http://iso26300.info for more information.

(attachments)

v.out.ogr.patch (2.65 KB)