tudelft3d / 3DCityDB-Tools-for-QGIS

This repository contains code of a QGIS plugin that facilitates data handling of the CityGML 3D City Database.
Apache License 2.0
55 stars 2 forks source link

Issues when appending data to database #4

Closed SanttuVP closed 1 year ago

SanttuVP commented 2 years ago

What is the bug or the crash?

First of all, thank you for your efforts and initial contributions + leadership in prodiving this plugin for handling data from 3DCityDB-databases.

As I I've been trying the plugin recently, it seems to be that, there might be an issue when you append more data to your database and you want to import all the new data to QGIS with 3DCityDB-QGIS-loader. This could potentially be a conceptual issue, where I haven't fully grasped the underlying database features, resulting in my inability to use the plugin appropriately.

Issue description

Let me describe the use case and my flow of thought: my use case is related to appending data to the same database and importing the data to QGIS. In other words, I need to update the materialized views when I append data with Importer/Exporter(3dcitydb/impexp). It seems to me that spatial extent of the data within the citydb-schema is not updated as wanted and maybe that's why the materialized views are not updated accordingly.

Workflow: 1) First I loaded some initial .gml data with the Importer/Exporter from the southern Finland. 2) Then I appended the data with another dataset from the South of Finland (see below in blue) and 3) finally, I appended the data with a third .gml file corresponding to the West of Finland.

To clarify, let me share some screenshots.

With blue we can see all the data in the citydb.surface_geometry-table and with red the data that was imported in first instance with 3DCityDB-QGIS-loader Pasted image 20221021153021

So the problem is that I can't refresh the red-coloured LOD2-layer to the full extent of the data. After the first import somehow the 3DCityDB-QGIS-loader does not update the map extent to the full spatial extent of the data: Pasted image 20221021152958

The Set to schema does not result to extend the area to cover the whole spatial extent of citydb.surface_geometry.

Versions

I'm using QGIS version 3.26.3 in Linux (Pop!_OS 22.04). I'm using 3DCityDB with Docker (3dcitydb/3dcitydb-pg:latest (CITYDBVERSION=v4.3.0) and 3dcitydb/impexp:latest (v5.2.1)) and v0.5 of the plugin).

Thank you for any help, hope this is useful, and please, carry on the great work.

gioagu commented 2 years ago

Hi! Thanks for your feedback and sorry for the late reply. Indeed, at the moment it is not possible to update the extents of the city model after new data is imported into the 3DCityDB.

A solution would be to add a refresh button (easy), or to come up with an automatic solution (to be seen at which cost in terms of operation to carry out).

At the moment, a workaround is to delete the record containing the bbox of the city model in the qgis_{usrname}.extents table (the blue one in the GUI). Better if you delete also the associated bbox of the materialized views (the red one in the GUI). When you load the plugin again, it will recompute the bbox. A simple SQL statement could be

DELETE FROM qgis_{usr}.extents WHERE cdb_schema = '_x_cdb_name_x';

where qgis_{usr} stands for your qgis schema on the database (e.g. qgis_giorgio) and '_x_cdb_name_x' is the name of the citydb you are working with. Most likely 'citydb'

gioagu commented 1 year ago

Solved in v. 0.6.0.

Please test and get back to us if you find strange behaviours... :-)

Enjoy!