qgis / QGIS

QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)
https://qgis.org
GNU General Public License v2.0
10.68k stars 3.02k forks source link

QgsVectorDataProvider.minimumValue() and maximumValue() don't work for Date fields #17859

Closed qgib closed 5 years ago

qgib commented 10 years ago

Author Name: Anita Graser (@anitagraser) Original Redmine Issue: 9241 Affected QGIS version: 2.0.1 Redmine category:data_provider/ogr Assignee: Matthias Kuhn


minimumValue(idx).toString() and maximumValue(idx).toString() only return empty strings.

The issue popped up because TimeManager currently does not support Date fields: https://github.com/anitagraser/TimeManager/issues/37

If you need a test dataset try: http://ge.tt/6DBclJh/v/0

To reproduce:

l=iface.activeLayer()
p=l.dataProvider()
idx=p.fieldNameIndex("DATE")
p.minimumValue(idx).toString()
p.maximumValue(idx).toString()

Related issue(s): #18619 (relates) Redmine related issue(s): 10165


qgib commented 10 years ago

Author Name: Matthias Kuhn (@m-kuhn)


This seems to be an upstream OGR issue:

$ 
$ ogrinfo /tmp/test/test2.shp -sql "SELECT MAX( 'DATE' ) from test2"
$ 
$ INFO: Open of `/tmp/test/test2.shp'
$   using driver `ESRI Shapefile' successful.
$ 
$ Layer name: test2
$ Geometry: 3D Point
$ Feature Count: 1
$ Layer SRS WKT:
$ (unknown)
$ MAX_DATE: Date (10.0)
$ OGRFeature(test2):0
$   MAX_DATE (Date) = (null)

Please open a bug report there


qgib commented 10 years ago

Author Name: Anita Graser (@anitagraser)


Reported: https://trac.osgeo.org/gdal/ticket/5333

qgib commented 10 years ago

Author Name: Anita Graser (@anitagraser)


Should I close the ticket here or wait until the new OGR version is released and included in QGIS downloads?

qgib commented 10 years ago

Author Name: Matthias Kuhn (@m-kuhn)


I guess we have the same kind of bug in the generic fallback code as well, so let's keep it open until we are sure it is fixed there as well.

qgib commented 10 years ago

Author Name: Anita Graser (@anitagraser)


The fix has been implemented upstream: http://trac.osgeo.org/gdal/ticket/5333#comment:2

qgib commented 10 years ago

Author Name: Jürgen Fischer (@jef-n)


qgib commented 10 years ago

Author Name: Anita Graser (@anitagraser)


@Matthias: The OGR side seems to be fixed. Can you have a look at our own code? Or do you know whom to ask? Will QGIS 2.2 use the fixed OGR version?


qgib commented 10 years ago

Author Name: Matthias Kuhn (@m-kuhn)


As soon as you install the updated OGR on your machine, QGIS will make use of it, even if you still run QGIS 2.0. The only platforms where we can control this are OSGeo4W and Mac OS X. Best to ping the responsible people there.

For our side, I think I have a branch somewhere which implements this. But this would need to be tested with a provider which uses the fallback code (i.e. which is NOT in the list below) and I am very tight on time right now... I will check the code I have and upload if it's useful.

Provider side implementations for maximumValue:

qgib commented 10 years ago

Author Name: Anita Graser (@anitagraser)


Min/max looks fine in master (OSGeo4W) with the new OGR included.

Unfortunately there is still an issue querying date fields: I cannot seem to use < and > operators in queries:

OGR[3] error 1: Type mismatch or improper type of arguments to < operator.

... guess that should be a new ticket?

qgib commented 10 years ago

Author Name: Jürgen Fischer (@jef-n)


qgib commented 10 years ago

Author Name: Anita Graser (@anitagraser)


follow-up issue: #18619