在QGIS中使用TimeManager时遇到一个问题,即满足时空要素要求后,时空数据展示不出来。点击数据的layer查看发现其对应的sql语句大概是:
dbname='citybigdata' host=localhost port=5432 sslmode=disable key='id' srid=4326 type=Point table="qqheat"."milocal" (geom) sql=cast("ts" as character) < '2016-11-09 21:05:00' AND cast("ts" as character) >= '2016-11-09 21:00:00'
将类似的语句直接在psql中发现执行的时候有问题,无法返回结果。但将语句修改一下即可解决:
dbname='citybigdata' host=localhost port=5432 sslmode=disable key='id' srid=4326 type=Point table="qqheat"."milocal" (geom) sql=cast("ts" as text) < '2016-11-09 21:05:00' AND cast("ts" as text) >= '2016-11-09 21:00:00'
即将其中的character改成text即可。
为了使插件工作正常,就需要修改timemanager的代码,使用grep工具找到该代码的位置:
cd .qgis2/python/plugins/timemanger
grep -rnw ‘.’ -e ‘character’
发现是如下代码的问题:
./.git/hooks/pre-commit.sample:26:# printable range starts at the space character and ends with tilde.
./CONTRIBUTING.md:13:* Go to http://www.loc.gov/standards/iso639-2/php/code_list.php and find the 2-character ISO 639-1
./docs/Doxyfile:586:# This tag can be used to specify the character encoding of the source files
./query_builder.py:9:STRINGCAST_FORMAT = ‘cast(“{}” as character) {} \'{}\’ AND cast(“{}” as character) >= \'{}\’ ‘
./query_builder.py:56: return ‘ cast(“{}” as character) LIKE \’%BC\”.format(attr)
./query_builder.py:63: return ‘ cast(“{}” as character) LIKE \’%AD\”.format(attr)
./query_builder.py:79: return ” ‘{}’ {} cast(\”{}\” as character) “.format(val, comparison, col)
./query_builder.py:87: return ” ‘{}’ {} cast(\”{}\” as character) “.format(val, comparison, col)
将具体的代码修改,然后重启qgis,即可工作正常。
发表回复