Opened 2 years ago

Last modified 6 months ago

#5310 new defect

Robustness issue when adding certain valid geometries to topology

Reported by: Björn Harrtell Owned by: strk
Priority: medium Milestone: PostGIS Fund Me
Component: topology Version: 3.3.x
Keywords: Cc:

Description

select topology.DropTopology('tmp_topo2');
select topology.CreateTopology('tmp_topo2', 25832, 0.05);

select TopoGeo_AddPolygon('tmp_topo2',
  st_geomfromtext(
    'Polygon ((512793.76999999955296516 6331770.53999999910593033, 512535.54200000036507845 6331834.9010000005364418, 512434.58600000012665987 6331855.78800000064074993, 512423.37000000011175871 6331802.21499999985098839, 512648.65699999965727329 6331751.01200000010430813, 512640.12299999967217445 6331694.27199999988079071, 512625.41000000014901161 6331608.75699999928474426, 512628.27199999988079071 6331584.09200000017881393, 512700.48099999967962503 6331662.90300000086426735, 512703.58800000045448542 6331674.73399999924004078, 512750.73799999989569187 6331715.29399999976158142, 512753.55599999986588955 6331720.26799999922513962, 512793.76999999955296516 6331770.53999999910593033))'
  )
, 0.05);

select TopoGeo_AddPolygon('tmp_topo2',
  st_geomfromtext(
    'Polygon ((512423.37000000011175871 6331802.21509999968111515, 512434.58600000012665987 6331855.78790000081062317, 512339.56900000013411045 6331873.47690000012516975, 512188.74500000011175871 6331895.69390000030398369, 512121.39450000040233135 6331904.24159999936819077, 511897.91559999994933605 6331939.16019999980926514, 511798.39759999979287386 6331956.61959999985992908, 511797.11490000039339066 6331934.38370000012218952, 511797.31749999988824129 6331934.33100000023841858, 511797.17509999964386225 6331896.27410000003874302, 511808.14479999989271164 6331894.90300000086426735, 511808.14479999989271164 6331894.86009999923408031, 511846.19350000005215406 6331890.35979999974370003, 511915.47640000004321337 6331880.1375999990850687, 511923.42669999971985817 6331877.86620000004768372, 511923.09599999990314245 6331870.75129999965429306, 511922.29100000020116568 6331853.44690000079572201, 511914.49540000036358833 6331809.27180000022053719, 511906.15259999968111515 6331761.99609999917447567, 511906.6365999998524785 6331761.88279999978840351, 511906.62530000042170286 6331761.83469999954104424, 511904.81610000040382147 6331762.30929999984800816, 511884.24230000004172325 6331658.66009999997913837, 511885.94589999970048666 6331645.59850000031292439, 511889.35329999960958958 6331642.75899999961256981, 511901.84700000006705523 6331639.91960000060498714, 511902.2417000001296401 6331641.00559999980032444, 512073.36039999965578318 6331616.78009999915957451, 512084.70789999980479479 6331686.48680000007152557, 512101.17690000031143427 6331685.35080000013113022, 512130.13929999992251396 6331677.40049999952316284, 512184.08899999968707561 6331657.52410000003874302, 512191.4715999998152256 6331655.25269999913871288, 512190.01499999966472387 6331643.84200000017881393, 512190.57089999970048666 6331643.60600000061094761, 512206.62509999983012676 6331639.63010000064969063, 512239.68090000003576279 6331631.43799999915063381, 512259.11699999962002039 6331619.56090000085532665, 512264.66409999970346689 6331617.16499999910593033, 512289.30109999980777502 6331606.53199999965727329, 512339.54090000037103891 6331575.48210000060498714, 512374.70309999957680702 6331552.88010000064969063, 512423.37000000011175871 6331802.21509999968111515),(511995.61830000020563602 6331645.16359999962151051, 511990.19560000021010637 6331646.8205999992787838, 511985.59179999958723783 6331649.70820000022649765, 511984.69759999960660934 6331651.56550000049173832, 511985.67669999971985817 6331653.8250999990850687, 511986.35429999977350235 6331654.80419999919831753, 511987.40890000015497208 6331656.61170000024139881, 511990.34609999973326921 6331658.87099999934434891, 511991.85259999986737967 6331659.09710000082850456, 511995.76889999955892563 6331658.41919999942183495, 511999.15809999965131283 6331656.46089999936521053, 512002.24600000027567148 6331654.35209999978542328, 512004.80690000019967556 6331652.16809999942779541, 512004.73159999959170818 6331648.47760000079870224, 512004.73159999959170818 6331646.14279999956488609, 512003.14989999961107969 6331644.93759999983012676, 512000.28799999970942736 6331644.71179999969899654, 511995.61830000020563602 6331645.16359999962151051))'
  )
, 0.05);

Results in: SQL Error [XX000]: ERROR: SQL/MM Spatial exception - curve not simple

In this case, reducing (!) tolerance will make it acceptable but since that is dependent on case by case it's difficult to determine before hand on a larger dataset.

Change History (6)

comment:1 by robe, 2 years ago

Component: postgistopology
Owner: changed from pramsey to strk

comment:2 by robe, 21 months ago

As Bjorn mentioned. Seems to be something with the tolerance at play here. So perhaps the application of the tolerance is causing an invalid geometry.

I can load these fine if I specify no tolerance as follows:

select topology.DropTopology('tmp_topo2');
select topology.CreateTopology('tmp_topo2', 25832);

select TopoGeo_AddPolygon('tmp_topo2',
  st_geomfromtext(
    'Polygon ((512793.76999999955296516 6331770.53999999910593033, 512535.54200000036507845 6331834.9010000005364418, 512434.58600000012665987 6331855.78800000064074993, 512423.37000000011175871 6331802.21499999985098839, 512648.65699999965727329 6331751.01200000010430813, 512640.12299999967217445 6331694.27199999988079071, 512625.41000000014901161 6331608.75699999928474426, 512628.27199999988079071 6331584.09200000017881393, 512700.48099999967962503 6331662.90300000086426735, 512703.58800000045448542 6331674.73399999924004078, 512750.73799999989569187 6331715.29399999976158142, 512753.55599999986588955 6331720.26799999922513962, 512793.76999999955296516 6331770.53999999910593033))'
  ));

select TopoGeo_AddPolygon('tmp_topo2',
  st_geomfromtext(
    'Polygon ((512423.37000000011175871 6331802.21509999968111515, 512434.58600000012665987 6331855.78790000081062317, 512339.56900000013411045 6331873.47690000012516975, 512188.74500000011175871 6331895.69390000030398369, 512121.39450000040233135 6331904.24159999936819077, 511897.91559999994933605 6331939.16019999980926514, 511798.39759999979287386 6331956.61959999985992908, 511797.11490000039339066 6331934.38370000012218952, 511797.31749999988824129 6331934.33100000023841858, 511797.17509999964386225 6331896.27410000003874302, 511808.14479999989271164 6331894.90300000086426735, 511808.14479999989271164 6331894.86009999923408031, 511846.19350000005215406 6331890.35979999974370003, 511915.47640000004321337 6331880.1375999990850687, 511923.42669999971985817 6331877.86620000004768372, 511923.09599999990314245 6331870.75129999965429306, 511922.29100000020116568 6331853.44690000079572201, 511914.49540000036358833 6331809.27180000022053719, 511906.15259999968111515 6331761.99609999917447567, 511906.6365999998524785 6331761.88279999978840351, 511906.62530000042170286 6331761.83469999954104424, 511904.81610000040382147 6331762.30929999984800816, 511884.24230000004172325 6331658.66009999997913837, 511885.94589999970048666 6331645.59850000031292439, 511889.35329999960958958 6331642.75899999961256981, 511901.84700000006705523 6331639.91960000060498714, 511902.2417000001296401 6331641.00559999980032444, 512073.36039999965578318 6331616.78009999915957451, 512084.70789999980479479 6331686.48680000007152557, 512101.17690000031143427 6331685.35080000013113022, 512130.13929999992251396 6331677.40049999952316284, 512184.08899999968707561 6331657.52410000003874302, 512191.4715999998152256 6331655.25269999913871288, 512190.01499999966472387 6331643.84200000017881393, 512190.57089999970048666 6331643.60600000061094761, 512206.62509999983012676 6331639.63010000064969063, 512239.68090000003576279 6331631.43799999915063381, 512259.11699999962002039 6331619.56090000085532665, 512264.66409999970346689 6331617.16499999910593033, 512289.30109999980777502 6331606.53199999965727329, 512339.54090000037103891 6331575.48210000060498714, 512374.70309999957680702 6331552.88010000064969063, 512423.37000000011175871 6331802.21509999968111515),(511995.61830000020563602 6331645.16359999962151051, 511990.19560000021010637 6331646.8205999992787838, 511985.59179999958723783 6331649.70820000022649765, 511984.69759999960660934 6331651.56550000049173832, 511985.67669999971985817 6331653.8250999990850687, 511986.35429999977350235 6331654.80419999919831753, 511987.40890000015497208 6331656.61170000024139881, 511990.34609999973326921 6331658.87099999934434891, 511991.85259999986737967 6331659.09710000082850456, 511995.76889999955892563 6331658.41919999942183495, 511999.15809999965131283 6331656.46089999936521053, 512002.24600000027567148 6331654.35209999978542328, 512004.80690000019967556 6331652.16809999942779541, 512004.73159999959170818 6331648.47760000079870224, 512004.73159999959170818 6331646.14279999956488609, 512003.14989999961107969 6331644.93759999983012676, 512000.28799999970942736 6331644.71179999969899654, 511995.61830000020563602 6331645.16359999962151051))'
  ));

comment:3 by strk, 20 months ago

Tolerances are known to possibly introduce these problems, yes. The missing functionality is handling of edge merges (an incoming point on an existing edge "attracting" a near-by edge so that it would share a portion with the other one).

I didn't check to see if this is the problem of this specific case, but it's a general robustness problem with PostGIS Topology.

Last edited 9 months ago by strk (previous) (diff)

comment:4 by robe, 19 months ago

Milestone: PostGIS 3.3.3PostGIS 3.4.0

comment:5 by strk, 17 months ago

Milestone: PostGIS 3.4.0PostGIS Fund Me

comment:6 by strk, 6 months ago

I can still reproduce as of

POSTGIS="3.5.0dev 3.4.0rc1-1172-g37fb070ef" [EXTENSION] PGSQL="160" GEOS="3.13.0dev-CAPI-1.19.0"

Note: See TracTickets for help on using tickets.