57 Commits

Author SHA1 Message Date
signedav
40c6896fb9 check for GDAL Version and exclude by ifdef 2018-12-18 18:32:30 +01:00
signedav
de12239b7e adding and removing json attributes 2018-12-18 09:33:07 +01:00
signedav
7dbd7a1100 basic tests for json writing 2018-12-17 16:26:06 +01:00
signedav
607dffd1aa basic tests for json type in gpkg 2018-12-11 13:12:35 +01:00
Matthias Kuhn
432bec17fc
Add test for QgsVectorLayerExporter with RegeneratePrimaryKey 2018-10-31 10:27:55 +01:00
Matthias Kuhn
6745eecd1d
Add tests for editing filtered gpkg layer 2018-10-18 17:01:39 +02:00
Even Rouault
391ec8a5dd
[OGR provider] Revise significantly the way we handle subset filter to avoid issues with FID (fixes #20136)
Some rationale on this change...

Previously when applying a "regular" subset string, ie. one that is only the
content of a where clause, we issued a full "SELECT * FROM layer WHERE subsetstring",
resulting in a OGR SQL layer. The caveat of that is that most OGR drivers
will have issues retaining the original FID. A hack consisting in adding a
{original_fid_name} as orig_ogc_fid to the select columns was introduced in
4ce2cf1744
to try to retain the original FID, but this added a lot of complexity. And
actually, in the case of the OGR GPKG driver, it caused it to still be confused
when analyzing the column definition of the resulting layer, since it sees
2 FID columns despite the renaming (one included in the '*' wildcard, and the
one of orig_ogc_fid), which caused it to use sequential FID numbering (the
driver when seeing more than once a column that is the FID column assumes that
some cross join is done, and thus that FID are unreliable)

A simpler and more robust (crossing fingers!) approach in that case is
just to use OGR_L_SetAttributeFilter() instead of GDALDatasetExecuteSQL().
Some care must be taken to cancel the filter when removing the subset
filter, or in QgsOgrFeatureIterator when combining with the filter
expression coming from the request, but besides that, this is more
straightforward, and actually solves #20136
2018-10-18 12:28:02 +02:00
Even Rouault
bd6c1115bb [OGR provider] Make createEmptyLayer() work properly on GeoPackage when creating/overwrite a new database (fixes #20040) 2018-10-08 07:23:12 +10:00
Blottiere Paul
80e19b6328 Add core unit test 2018-10-08 05:03:49 +10:00
nirvn
f4a0e743fa Implement a QgsProviderRegistry decodeUri function + test 2018-08-16 16:46:01 +07:00
Even Rouault
6a987f913b
[OGR provider] [FEATURE] Add support for transactions on GPKG databases
For complete support, it requires two GDAL fixes:
- One to avoid feature count to be invalid when using ROLLBACK TO SAVEPOINT
  f73ec8cd1d

- Another one to avoid nasty issues, at least on Linux, with the POSIX
  advisory locks used by libsqlite that could be invalidated due to how GDAL
  could open files behind the back of libsqlite. The consequence of this
  could be the deletion of -wal and -shm files, which caused issues in QGIS
  (non working iterators when the edit is finished, and later edits in the
  same session not working). Those issues could appear for example if doing
  ogrinfo on the .gpkg opened by QGIS, or if opening two QGIS session on the
  .gpkg

Both fixes are queued for GDAL 2.3.1
2018-06-15 12:56:59 +02:00
Even Rouault
4f531359ae
[OGR provider] Performance improvements on huge GeoPackage database (fixes #18402)
- Introduce an approximate feature count for GeoPackage in case there are
  at least 100,000 rows in a table.
- Add a super fast implementation of GetExtent() for GeoPackage when there
  is an RTree
- Do not require feature count when enumerating layers from the browser
2018-06-04 14:23:55 +02:00
Even Rouault
f4bf1ec907
[OGR provider] GPKG: allow repeated creation of int fields with len != 0 (fixes #19009) 2018-06-01 13:15:41 +02:00
Even Rouault
2969ba1e99
test_provider_ogr_gpkg.py: avoid bug_17795.gpkg test sample to be modified by tests 2018-05-31 23:05:37 +02:00
Even Rouault
ee06d52421
[OGR provider] Avoid attribute table to be empty on OGR layer with mixed geom types (fixes #19077) 2018-05-31 23:05:37 +02:00
Alessandro Pasotti
698befa9dd [gpkg] Add test for gpkg subsetstring don't unlock mutex twice
I wanted to add the test for gpkg subsetstring even if
it was not bugged, while testing that, I hit an assert
in Qt core that pointed me to double unlocked locks.
2018-01-25 15:16:53 +01:00
Alessandro Pasotti
9c8533455f [bugfix][ogr] Tests for capabilities update on filter changes
Fixes #17795
2018-01-05 15:43:28 +01:00
Nyall Dawson
aaa18e0b89 Address review comments 2017-12-02 09:01:25 +10:00
Nyall Dawson
791eb91b9b Fix OGR provider cannot create attribute or spatial indexes for
GeoPackage/SQLite layers

Previously this capability was only exposed for shapefiles,
but was available in the spatialite provider. We don't use that
for GeoPackages, so I've ported the functionality across to
the OGR provider for these data sources.

Includes unit tests
2017-12-02 08:27:49 +10:00
Nyall Dawson
f04587eb67 Update tests, add new test for complex layer name 2017-11-26 14:00:35 +10:00
Nyall Dawson
96857ebdd4 Fix crash when a geopackage layer is open in QGIS, and then is overwritten
with another layer with different field definitions
2017-11-26 07:34:51 +11:00
Nyall Dawson
abcdd48580 [ogr] Fix cannot create layers for geopackage datasets when
the database does not yet exist
2017-11-24 09:31:50 +10:00
Alessandro Pasotti
a12939d380 [ogr] Implement skipConstraintsCheck for fid
With test.
2017-11-21 09:03:24 +01:00
Alessandro Pasotti
f97b5a54d0 Fix test for primary key constraints 2017-11-20 18:30:49 +01:00
Alessandro Pasotti
73d6765e89 [bugfix] Editing a GPKG layer added by d&d leads
... to error and data corruption

Fixes #16935 for GPKG (OGR), still  needs to check spatialite

Thanks to Matthias Kuhn for pointing me into the right direction
2017-11-20 17:04:17 +01:00
Nyall Dawson
75885d70d5 Rename various WKT/WKB/GeoJSON/GML methods for consistency
and consistent capitalisation
2017-11-15 20:51:05 +10:00
Even Rouault
2c49631bc9 [OGR provider] Support 64bit FID (partially implemented per 8f3d44d4e9321efc035a6080b161f5dd48d4f230 in master) (fixes #16404) 2017-11-13 15:49:14 +01:00
Even Rouault
3ff0f69794 [OGR provider] Make extent() return a isNull() rectangle on empty layer (fixes #16721) 2017-11-12 14:56:05 +01:00
Even Rouault
8f3d44d4e9 [OGR provider] Allow opening (GeoPackage) datasets with many layers
Currently each time you instanciate a QgsOgrProvider layer, a GDAL dataset is
created. In the case of GeoPackage, this means a SQLite connection and a file
handle. As GDAL enables Spatialite function on GeoPackage connections, we are
bound to Spatialite limits, and Spatialite has a hard limit on a maximum of
64 simultaneous connections. Thus we cannot open more than 64 layers of the
same GeoPackage.
This commits enables sharing of the same GDALDataset object among several
QgsOgrProvider object. Care is made to reuse a GDALDataset object only if the
QgsOgrProvider do not point to the same layer. Mutexes are also taken to
allow safe instanciation and use of QgsOgrProvider objects from multiple
threads (but a same QgsOgrProvider should not be used by more than one thread
at a time)
2017-10-20 17:37:42 +02:00
Alessandro Pasotti
8abf6dc43e Update tests for OGR getLayers now returning also the geometry column name 2017-09-08 12:36:42 +02:00
Even Rouault
5481177699 [OGR provider] Avoid 'database locked' issues when editing several layers of the same GeoPackage (fixes #17034) 2017-08-18 17:58:00 +02:00
Nyall Dawson
75a5d5dda1 Remove unused skipAttributeCreation option in QgsVectorLayerExporter::exportLayer 2017-05-12 08:03:23 +10:00
Nyall Dawson
384369c3c4 Rename QgsVectorLayerImport to QgsVectorLayerExporter
Since the majority of users of this class will be exporting
an existing map layer to a data provider, the QgsVectorLayerImport
name is misleading and suggests that this class is designed
just to bring layers "into" QGIS.

Explicitly naming the class "Exporter" should help API users
discover this class.

Also cleanup API and improve docs
2017-05-12 08:02:51 +10:00
Denis Rouzaud
a86f5ea52d remove PyNames for QgsGeometry::compare methods
single python method with some MethodCode to dispatch to proper cpp methods.
2017-04-30 11:29:45 +02:00
Denis Rouzaud
b0d4a4c201 sipify geometry classes 2017-04-30 11:29:45 +02:00
Juergen E. Fischer
b29a10eeb7 hub.qgis.org moved to issues.qgis.org 2017-04-29 23:34:27 +02:00
Even Rouault
965350b3ae DBManager: fix importing a new layer in a GeoPackage (#16295) 2017-04-24 21:41:25 +02:00
Juergen E. Fischer
a10c890383 More QgsSettings updates:
* revives WMS
* QgsSettings::clear() added
* section added to QgsSettings::contains()
* type parameter added to sip binding of QgsSettings.value()
* TODO: customization & evis
2017-03-04 02:37:59 +01:00
Nyall Dawson
d47d31d13c Rename "Db"/"DB" in API to "Database"
Motivations:
- consistency - we generally use expanded names, and this also
matches Qt API which uses Database instead of Db
- avoids unpredictable capitalization throughout API (mix of "Db"
and "DB")
2017-02-07 09:32:05 +10:00
Nyall Dawson
b0bc763475 Bump minimum GDAL version to 2.0, remove old version #ifdefs 2017-01-03 15:10:28 +10:00
Martin Dobias
d729951dcd Remove caching of WKB from QgsGeometry (was kept just for compatibility)
Also improves the API to export/import WKB as QByteArray
2016-11-14 13:36:12 +08:00
Even Rouault
06dc501139 test_provider_ogr_gpkg.py: Test disabling walForSqlite3 setting 2016-11-02 12:40:20 +01:00
Nyall Dawson
fb849620e7 Avoid unexpected gpkg test success with older GDAL versions 2016-11-02 09:39:59 +10:00
Even Rouault
3b77e4b395 [FEATURE] [OGR provider] Load/save style in database for GPKG and Spatialite 2016-10-25 10:28:54 +02:00
Even Rouault
68cb04a549 [OGR provider] Support full SELECT subset string
This will be useful for DBManager SQL request layer.
2016-10-18 20:08:27 +02:00
Even Rouault
8c37370310 Fix 70ae301310c7a58134ac699fae70af7fd1176684
70ae301310c7a58134ac699fae70af7fd1176684 requires a recent enough GDAL trunk
or GDAL 2.1.2
2016-10-18 15:59:40 +02:00
Even Rouault
70ae301310 [OGR provider] Update layer extent for GPKG layers
When moving or deleting a geometry that previously touched the layer extent,
the layer extent was never shrinked.

This fix requires GDAL 2.1.2 or above as well.

Fixes #15273
2016-10-18 15:03:21 +02:00
Even Rouault
1b48a7432a test_provider_ogr_gpkg.py: remove stuff that shouldn't have gone in 348af7ed5267f66f5ac2426be303a4ea69edd96f 2016-10-18 14:17:38 +02:00
Even Rouault
348af7ed52 test_provider_ogr_gpkg.py: pyflakes fixes 2016-10-18 14:16:20 +02:00
Even Rouault
b6b8759efb Fix database locking when editing GeoPackage
Concurrent read and write can lock a GeoPackage database given
the default journaling mode of SQLite (delete). Use WAL when
possible to avoid that.

Fixes #15351
2016-09-23 17:23:07 +02:00