invalid Topology issue , face has wrong mbr
The case here is an extreme input polygon
SELECT ST_NPoints(geo), ST_Area(geo), ST_Area(ST_Envelope(geo)) mdr_area, ST_NumInteriorRings(geo) from org_gronnstruktur_fkb.gsk_2023_segmenter_renska where gid = 24789666;
st_npoints | st_area | mdr_area | st_numinteriorrings
------------+----------+-----------+---------------------
3627257 | 20311057 | 742819770 | 10586
(1 row)
which seems to be much off the road network Oslo.
And around more 3 million other polygons in the same area.
We have some problems with missing data here, but that may be related how I handle merging off big road network, I will check that later. I am now also running a tests where I split big polygons like this to check how that affects the results. I also split this to be able work with this data in QGIS in an OK way. For splitting test now use content grids to split selected polygons.
We have multiple cells with invalid data so I started to check them and the first I found was this wrong mbr
SELECT * from "gronn_test_06_data_mangler_topo_01"."multi_input_1_tables_grid_validate_topology" where id = 708;
id | cell_bbox | validate_result
-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------
708 | 0103000020A21000000100000005000000CC6F23CB75CF25404E08271D4BFC4D40CC6F23CB75CF2540D0D1052E1CFD4D40AD025E3E97D72540D0D1052E1CFD4D40AD025E3E97D725404E08271D4BFC4D40CC6F23CB75CF25404E08271D4BFC4D40 | {"(\"face has wrong mbr\",3220177,)"}
(1 row)
There is no problem with using this face and other faces in the same area are OK.
If I check the area of mbr and yes there is slight difference
SELECT
face_id, ST_Area(mbr,true), mbr
from
"gronn_test_06_data_mangler_topo_01".face
where
face_id = 3220177;
face_id | st_area | mbr
---------+-------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
3220177 | 24.99513015151024 | 0103000020A210000001000000050000001CC85FAA8FD72540B25C352E7AFC4D401CC85FAA8FD72540F5B768A77BFC4D40F6C722609BD72540F5B768A77BFC4D40F6C722609BD72540B25C352E7AFC4D401CC85FAA8FD72540B25C352E7AFC4D40
(1 row)
SELECT
ST_Area(mbr,true), mbr
FROM
(
select
ST_Envelope(ST_GetFaceGeometry('gronn_test_06_data_mangler_topo_01', 3220177))
AS
mbr
) e
st_area | mbr
-------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
24.83643464744091 | 0103000020A210000001000000050000001CC85FAA8FD725403FF24F2E7AFC4D401CC85FAA8FD7254057371EA57BFC4D40F6C722609BD7254057371EA57BFC4D40F6C722609BD725403FF24F2E7AFC4D401CC85FAA8FD725403FF24F2E7AFC4D40
(1 row)
This face is on border between two content based cells.