Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error while populating layer in layer loader. #71

Open
behjani opened this issue Nov 30, 2024 · 3 comments
Open

Error while populating layer in layer loader. #71

behjani opened this issue Nov 30, 2024 · 3 comments

Comments

@behjani
Copy link

behjani commented Nov 30, 2024

Thank you for your efforts and developing this plugin to process CityGML data.

I have tried applying and the following error message appears several times when updating the layer:

CRITICAL Refreshing layers ERROR at citydb-tools\cdb4\gui_loader\functions\threads.py>refresh_all_gviews_thread
ERROR: FEHLER: Typ »geometry« existiert nicht
LINE 5: snapped_poly geometry(PolygonZ);
^
QUERY:
DECLARE
dec_prec numeric;
srid_id integer;
snapped_poly geometry(PolygonZ);
num_geoms integer;
is_empty_geom boolean;
ring geometry(LinestringZ);
o_ring geometry(LinestringZ);
i_ring geometry(LinestringZ);
i_rings geometry(LinestringZ)[];
n_int_rings integer;
i integer; r RECORD;
area_poly numeric;
new_polygon geometry(PolygonZ);

         BEGIN
         
         CASE 
          WHEN perform_snapping = 0 THEN
          RETURN polygon;
          WHEN perform_snapping = 1 THEN
          dec_prec := 10^(-digits);
          srid_id := ST_SRID(polygon);
          snapped_poly := ST_SnapToGrid(polygon, ST_GeomFromText('Point(0 0 0)'), dec_prec, dec_prec, dec_prec, 0);
          is_empty_geom := ST_IsEmpty(snapped_poly);
         
          IF is_empty_geom IS TRUE THEN
          RETURN NULL;
          ELSE -- there is a geometry from the resulting snap to grid process
          num_geoms := ST_NumGeometries(snapped_poly);
          IF num_geoms > 1 THEN
          RAISE NOTICE 'Number of geometries resulting from the snapped polygon is %', num_geoms;
          END IF;
         
          ring := ST_ExteriorRing(snapped_poly);
          o_ring := ring;
          FOR r IN SELECT
          foo.path[1]-1 AS zero_based_index,
          round(ST_x(foo.geom)::numeric,digits)::double precision AS px,
          round(ST_y(foo.geom)::numeric,digits)::double precision AS py,
          round(ST_z(foo.geom)::numeric,digits)::double precision AS pz
          FROM ST_DumpPoints(ring) AS foo
          LOOP
          o_ring := ST_SetPoint(o_ring, r.zero_based_index, ST_MakePoint(r.px, r.py, r.pz));
          END LOOP;
          o_ring := ST_SetSRID(o_ring, srid_id);
         
          n_int_rings := ST_NumInteriorRings(snapped_poly);
          IF n_int_rings > 0 THEN
          FOR i IN 1..n_int_rings LOOP
          ring := ST_InteriorRingN(snapped_poly, i);
          i_ring := ring;
          FOR r IN SELECT
          foo.path[1]-1 AS zero_based_index,
          round(ST_x(foo.geom)::numeric,digits)::double precision AS px,
          round(ST_y(foo.geom)::numeric,digits)::double precision AS py,
          round(ST_z(foo.geom)::numeric,digits)::double precision AS pz
          FROM ST_DumpPoints(ring) AS foo
          LOOP
          i_ring := ST_SetPoint(i_ring, r.zero_based_index, ST_MakePoint(r.px, r.py, r.pz));
          END LOOP; 
          i_rings := array_append(i_rings, i_ring);
          END LOOP;
          END IF;
          END IF;
         ELSE
          RAISE EXCEPTION 'Value of "perform_snapping" input parameter is invalid. It must be either 0 or 1'; 
         END CASE;
         
         IF n_int_rings = 0 THEN
          new_polygon := ST_MakePolygon(o_ring);
         ELSE
          new_polygon := ST_MakePolygon(o_ring, i_rings);
         END IF;
         
         area_poly := qgis_pkg.ST_3DArea_poly(new_polygon);
         
         IF (area_poly IS NULL) OR (area_poly               RETURN NULL;
         ELSE
          RETURN new_polygon;
         END IF;
         
         EXCEPTION
          WHEN QUERY_CANCELED THEN
          RAISE EXCEPTION 'qgis_pkg.st_snap_poly_to_grid(): Error QUERY_CANCELED';
          WHEN OTHERS THEN
          RAISE EXCEPTION 'qgis_pkg.st_snap_poly_to_grid(): %', SQLERRM;
         END;
         
         CONTEXT: Kompilierung der PL/pgSQL-Funktion »st_snap_poly_to_grid« nahe Zeile 5

As a result, I am unable to complete the task of populating the layer and am stuck at this point.
I am using PostgreSQL 17, PostGIS 3.5.0, QGIS 3.34.13, 3DCityDB Tools 0.8.9 and 3D City Database Importer/Exporter 5.4.0. The data contains the building model of the city of Hamburg in LOD 2 (Link: https://suche.transparenz.hamburg.de/dataset/3d-gebaeudemodell-lod2-de-hamburg2)

Thank you for any help. Keep up the good work.

@pancost
Copy link
Collaborator

pancost commented Dec 1, 2024

Hello @behjani,
"geometry" is a PostGIS construct meaning that something goes wrong there.

Can you triple check that the "postgis" extension is enabled, not only for the default schema but also for the additional schemas that the plugin installs in the db?

Sometimes depending on how PostGIS is installed or loaded, "postgis" may not be accessed in schemas outside of the search path.

In psql you can use to see what versions you have installed and also what schema they are installed.

\connect mygisdb
\x
\dx postgis*

from: https://postgis.net/docs/postgis_installation.html

Let us know :)

@behjani
Copy link
Author

behjani commented Dec 1, 2024

Hello @pancost :)

Thank you very much for the quick response. All schemas are included in search_path and all users have full access rights.
In psql the command \dx postgis* returns the following:

List of installed extensions
-[ RECORD 1 ]+-----------------------------------------------------------
Name | postgis
Version | 3.5.0
Schema | public
Description | PostGIS geometry and geography spatial types and functions
-[ RECORD 2 ]+-----------------------------------------------------------
Name | postgis_raster
Version | 3.5.0
Schema | public
Description | PostGIS raster types and functions
-[ RECORD 3 ]+-----------------------------------------------------------
Name | postgis_sfcgal
Version | 3.5.0
Schema | public
Description | PostGIS SFCGAL functions
-[ RECORD 4 ]+-----------------------------------------------------------
Name | postgis_topology
Version | 3.5.0
Schema | topology
Description | PostGIS topology spatial types and functions

However, the error still exists.
As I understand it, the extension applies to the entire database. Using ALTER EXTENSION postgis SET SCHEMA citydb to move the extension to another schema did not help.
Used SELECT typname FROM pg_type WHERE typname = 'geometry'; to check that geometry is available in the database and SELECT f_table_schema, f_table_name, f_geometry_column, srid, type FROM geometry_columns; shows that the columns with geometry types exist.

@pancost
Copy link
Collaborator

pancost commented Dec 3, 2024

Thanks for checking, you're correct.
still it's weird

Did you already try to reinstall the QGIS Package to your DB?
If not, please do (slides 30-36:install and 106-109:uninstall of the 3DCityDB-Tools_UserGuide.pdf)
Maybe that will set things straight.

Sorry for the "IT101" type of support, I am not able to reproduce the issue.

@gioagu maybe you stumbled upon this issue before?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants