138 Commits

Author SHA1 Message Date
Nyall Dawson
1d62de3f1b Replace use of deprecated methods 2018-08-18 16:53:32 +10:00
Matthias Kuhn
8dd4b3b270
Rename freeConnectionsRequirement to requestMayBeNested 2018-08-03 09:52:42 +02:00
Matthias Kuhn
14643ad98d
Allow specifying the number of required connections
for a request. Most requests should reserve more
than a single connection (default: 3) and only
requests that are executed as nested expressions
should specify 1.
2018-08-02 13:34:45 +02:00
Nyall Dawson
4fb9091e6e QgsRectangle::intersect should use a reference, not a pointer
We never call this method using nullptrs, so there's no need
for this to be a pointer argument in the first place. And
having it a pointer encourages leaky code, such as the
leak this commit fixes in server.
2018-06-18 07:55:17 +10:00
Nyall Dawson
ce74d57b2e [postgres] Really disable dynamic queue size
The original commit speed up some layers, but regressed
performance for others. It was decided to revert the
dynamic queue feature, but it seems this was never actually
done.

Fixes #16239, #19203
2018-06-16 15:36:23 +10:00
Matthias Kuhn
dbe4186a9c
Add tests for compiling string operators 2018-05-31 14:04:23 +02:00
Martin Dobias
6a4b8b4762 Fix retrieval of 4D geometries (XYZM) from postgres (fixes #17814) 2018-01-17 15:38:27 +01:00
Nyall Dawson
6528f1c307 Require a transform context when setting the destination crs for
a feature request

Forces correct datum handling for these requests, and removes
a few more uses of the deprecated/datum unaware transforms.
2017-12-20 12:32:20 +10:00
Nyall Dawson
86d9492372 Remove context-unaware QgsCoordinateTransform constructors from Python bindings
This forces Python code and plugins to become datum transform
aware, and given that upgrading python code is easy (just
add QgsProject.instance() as a new argument to the constructor)
it's relatively painless to force this on PyQGIS users.

Also fix upgrade the easy QgsCoordinateTransform c++ constructors
where the project is available, or where using QgsProject::instance()
is safe to do.

For others, just avoid the deprecated warnings until we can
get access to the correct project instance where the transform
is being constructed.
2017-12-15 14:13:22 +10:00
Matthias Kuhn
62f2091383
[postgres] Early exit iterator if there's nothing to fetch anyway 2017-10-25 17:48:33 +02:00
Matthias Kuhn
a8caf49ae6
Notify feature source when iterator is closed 2017-10-24 23:43:41 +02:00
Matthias Kuhn
f33accab4a
[postgres] respect empty FilterFids list
Considering this statement:

    layer.dataProvider().getFeatures(QgsFeatureRequest().setFilterFids([]))

this resulted in an iteration over the whole postgres source.
Internally, this happened implicitly when iterating over a layer with
an active edit buffer but no edited features. In such a scenario, we are
now much faster.
2017-10-24 16:21:01 +02:00
Harrissou Sant-anna
9e6b8ed59d Use PostGIS and PostgreSQL spelling when appropriate 2017-07-07 01:26:38 +02:00
Nyall Dawson
cbc9e03b9d Consolidate all QgsException subclasses in the same header 2017-06-23 12:08:54 +10:00
Nyall Dawson
e437812a68 Return an invalid iterator if a transform exception occurs
when projecting filter rects from destination crs
2017-06-09 08:57:00 +10:00
Nyall Dawson
7d847bf34a Rename transform methods for clarity 2017-06-09 08:41:46 +10:00
Nyall Dawson
a98923507e Allow specifying a destination CRS in QgsFeatureRequest
If set, all geometries will be reprojected from their original
coordinate reference system to the destination CRS while
iterating over features.

If a CRS has been set as the destination CRS, then the filterRect
parameter should be specified in the same CRS as this destination
CRS.

Additionally, a callback function can be specified on the request
to be called if a transform exception is encountered while
iterating over features.

This is designed to make it easier for scripts and plugins to
correctly reproject layers in an efficient and robust way, instead
of having to implement lots of repeated code themselves and
potentially missing some of the important considerations which
come with reprojecting geometries & bounding boxes.

Now, if a script wants the features from a layer in a specific
CRS, they can call:

    crs = QgsCoordinateReferenceSystem('epsg:4326')
    request = QgsFeatureRequest().setDestinationCrs(crs)
    for f in layer.getFeatures(reqeuest):
        print('geometry in 4326 is {}.format(f.geometry().exportToWkt()))
2017-06-08 19:20:07 +10:00
Nyall Dawson
47ffb588fe Fix some providers not requesting all required attributes needed
for client side order by clauses
2017-05-26 08:06:13 +10:00
Nyall Dawson
3584a5f914 Nicer initialization of members in iterators/sources 2017-04-24 08:59:32 +10:00
Mathieu Pellerin
1ca73f4f29 harmonize all providers to use lowercase qgis as settings key (#4252)
(fixes ArcGisRest browser / connection dialog)
2017-03-13 15:07:16 +07:00
Nyall Dawson
fbe4be884b Dynamically adjust postgres feature queue size
Lower the default queue size, but automatically adjust it
based on how long each fetch takes. This change keeps fetching
responsive even for slow connections or databases. The current
approach with a fixed queue size can result in very slow feature
fetching, which prevents UI updates for multiple seconds.
2017-03-05 08:47:32 +10: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
Denis Rouzaud
2e7de50b42 run astyle on src/* 2017-03-03 09:09:37 +01:00
Nyall Dawson
b5480633e4 Standardise names for static variables
All non-const variables are prefixed with "s", all const
statics are ALL_CAPS
2017-01-14 16:40:24 +10:00
Denis Rouzaud
4467487e1c respect CamelCase for enums and their values 2017-01-11 14:10:11 +01:00
Nyall Dawson
e656c63ab7 Remove duplicate QgsFeature::setFeatureId method
Leave just QgsFeature::setId and document api break
2017-01-11 10:05:31 +01:00
Harrissou Sant-anna
ef85cdcf83 Replace "eg" by "e.g." or "for example" 2016-12-30 00:03:22 +01:00
Nyall Dawson
4166a3ea62 Fix most clazy qstring-unneeded-heap-allocations warnings
By flipping string literals to QStringLiteral/QLatin1String

see

https://woboq.com/blog/qstringliteral.html
2016-10-24 15:26:24 +10:00
Matthias Kuhn
b6779f63ff Rename QgsFields::fieldNameIndex() to lookupField()
To have two clearly different names for tolerant/intolerant index lookup
2016-10-01 15:39:03 +02:00
Patrick Valsecchi
abc55f4c42 Add support for arrays in PostgresQL
Fix parsing of PostgresQL hstore. Had problems when the key or values were
containing comas.
2016-09-12 10:33:00 +02:00
Martin Dobias
46f7c644da Fix postgres pkey map in Qt5 (fixes #15223)
Switching from QVariant to QVariantList solves the underlying Qt issue:
- comparison of QVariantList objects works fine
- comparison of QVariantList objects wrapped in QVariant does not work

The extra wrapping of QVariantList into another QVariant seems unnecessary anyway,
so we may as well save a tiny bit of memory and cpu
2016-08-11 17:10:57 +02:00
Nyall Dawson
ed4d34fdbc QgsFields returns QgsField value instead of const references
(since QgsField is implicitly shared)
2016-08-05 06:08:07 +10:00
Matthias Kuhn
bb79d13e82 Remove deprecated Qgis::WKBType and API cleanup (#3325)
* Remove deprecated Qgis::WKBType and API cleanup

Renames QgsWKBTypes to QgsWkbTypes

Replaces usage of the enums:

* Qgis::WKBType with QgsWkbTypes::Type
* Qgis::GeometryType with QgsWkbTypes::GeometryType

Their values should be forward compatible (a fact that was already
explited up to now by casting between the types)

Renames some SSLxxx to SslXxx and URIxxx to UriXxx

* Fix build warnings and simplify type handling

* Add a fixer to rewrite imports

* The forgotten rebase conflictThe forgotten rebase conflicts

* QgsDataSourcURI > QgsDataSourceUri

* QgsWKBTypes > QgsWkbTypes

* Qgis.WKBGeom > QgsWkbTypes.Geom

* Further python fixes

* Guess what... Qgis::wkbDimensions != QgsWkbTypes::wkbDimensions

* Fix tests

* Python 3 updates

* [travis] pull request caching cannot be disabled

so at least use it in r/w mode

* Fix python3 print in plugins
2016-08-04 09:10:08 +02:00
Nyall Dawson
bd7d913379 Refine QgsFeature geometry getters/setters
All pointer based methods have been removed.

Now we have only:

  void setGeometry( const QgsGeometry& geom )

and

  QgsGeometry geometry() const

Benefits include avoiding a whole lot of tricky pointer lifetime
issues, potential memory leaks, and finally closing #777, which
has survived for over 9 years!...

Impacts on PyQGIS code:
- no more need for the messy
  g = QgsGeometry( feature.geometry() )
  workaround, just use g = feature.geometry() instead
- IMPORTANT: you can no longer test whether a feature has geometry
 using `if f.geometry():`, since QgsFeature::geometry() will
 *always* return an object. Instead, use
 `if not f.geometry().isEmpty():`, or preferably the new method
 `if not f.hasGeometry():`

Fix #777
2016-08-01 16:25:46 +10:00
Nyall Dawson
aceddae65a QgsFeature cleanup, part 1
Deprecate some QgsFeature methods which take or return pointers,
update other classes as required
2016-07-31 21:23:07 +10:00
Nyall Dawson
1a2231f10c Rename QGis class to Qgis, for capitalisation consistency 2016-07-21 22:01:38 +10:00
Nyall Dawson
df0d5969aa Fix virtual fields which depend on other virtual fields may not be
calculated in some circumstances (fix #14939)
2016-06-10 11:18:25 +10:00
Sandro Santilli
9a96414444 Fix storing attribute of feature with negative identifier and test
The test was also bogus in that it expected an inappropriate FID.
2016-06-09 11:48:30 +02:00
Sandro Santilli
92dda429d0 Do not loose signed semantic on converting int32 pk to fid
Fixes again editing of features with negative identifiers.
Now a test fails, but it is the test being broken this time
(testSignedIdentifiers). The test was added as part of
2bd7f446b4dd368968f23b990262c5e8a5a83f80, which fixed a crash
when using signed identifiers.
2016-06-09 11:48:29 +02:00
Sandro Santilli
e763b41c08 Use FidMap for int64 primary keys
Also rename pktInt64 to pktUint64, in case we'll be able to know
in advance the database contains only positive integers (not
implemented in this commit).
2016-06-09 11:48:29 +02:00
Sandro Santilli
a7a0eefe72 Support negative short integer primary keys on PostgreSQL
See http://hub.qgis.org/issues/14262

NOTE: signed int64 keys would still fail
2016-06-09 11:48:28 +02:00
Marco Hugentobler
0aec8e9892 Postgres simplification does not work with curved types 2016-05-27 14:38:42 +02:00
Nyall Dawson
858914eef5 Ensure that providers fetch geometry for a QgsFeatureRequest
with an expression filter which requires geometry
2016-05-16 23:09:18 +10:00
Nyall Dawson
92a18087b3 Add safeguard tests to ensure no regressions in expression compilation
(ie check that expressions are successfully compiled where expected)

Add compilation support for "NOT..." type expressions
2016-04-15 07:52:02 +10:00
Matthias Kuhn
2e515a2ccc [postgres] Avoid deadlocks in transactional editing
Can currently be triggered by using the field calculator to update a selection.
While an iterator is active and the connection is locked, an update statement
waits unsuccessfully for the same (locked) connection.

This commit only locks the connection while an iterator is actually fetching
data and not for its entire lifetime.
2016-04-14 09:39:51 +02:00
Nyall Dawson
402ee9d4cf Fix missing features when combining FilterExpression requests with
subsets of attributes and the filter expression requires fields
which are not included in the attribute subset

Note: I've only fixed the providers which implement the vector
provider conformance unit tests. Other providers (eg GRASS) should
also implement a similar fix.
2016-03-30 16:31:55 +11:00
Nyall Dawson
4825856fd7 Fix provider ordering by test to correctly also test compiled order by
...and as a result, disable compiled order by support for postgres
due to bugs exposed by the test
2016-01-31 20:42:11 +11:00
Larry Shaffer
e7a1e2c2ec Clean up with prepare commit script 2016-01-13 21:29:09 +01:00
Luigi Pirelli
68478a7363 [auth] PKI support to postgres provider 2016-01-13 21:26:52 +01:00
Matthias Kuhn
168c6f70bc Rename OrderBys -> OrderBy and OrderBy -> OrderByClause
And some sip fixes
2015-12-22 09:12:32 +01:00