Opened 8 weeks ago

Last modified 2 weeks ago

#5786 new defect

Side-location conflict: new edge starts in face 42 and ends in face 10

Reported by: Lars Aksel Opsahl Owned by: strk
Priority: medium Milestone: PostGIS 3.5.1
Component: topology Version: master
Keywords: robustness Cc:

Description

When running the sql script below on

POSTGIS="3.6.0dev 3.5.0-13-g290fffd11" [EXTENSION] PGSQL="160" GEOS="3.13.0-CAPI-1.19.0" PROJ="8.2.1 NETWORK_ENABLED=OFF URL_ENDPOINT=https://cdn.proj.org USER_WRITABLE_DIRECTORY=/tmp/proj DATABASE_PATH=/usr/share/proj/proj.db" (compiled against PROJ 8.13.0) LIBXML="2.9.13" LIBJSON="0.13.1" LIBPROTOBUF="1.3.3" WAGYU="0.5.0 (Internal)" TOPOLOGY

I get the error

ERROR:  XX000: Side-location conflict: new edge starts in face 28 and ends in face 10
LOCATION:  pg_error, lwgeom_pg.c:363

The sql code is here

select topology.CreateTopology ('rmp_temp_data_01_3226_114', 4258, 1e-06);

-- to get this to work I have use tolerance 1e-04

SELECT abs(topogeo_addlinestring) FROM topology.TopoGeo_addLinestring('rmp_temp_data_01_3226_114','0102000020A2100000130000002ABE03D06B9F2740265193D3C6E34D40EFDF3F266C9F2740507B01F2C5E34D406EBB112E509F274032848DC6C5E34D40E57F2BD84F9F274097D334A8C6E34D40599CF6D5569F2740971407B3C6E34D40957ABA7F569F2740FC63AE94C7E34D40447DDB7D5D9F2740FCA4809FC7E34D40F37FFC7B649F27408B5F68AAC7E34D402E5EC025649F27406135FA8BC8E34D40DD60E1236B9F2740EFEFE196C8E34D408C630222729F2740EF30B4A1C8E34D40C841C6CB719F274054805B83C9E34D40EB60B2C77F9F2740E37B1599C9E34D40AF82EE1D809F27407E2C6EB7C8E34D4030A71C169C9F27409C23E2E2C8E34D40F4C8586C9C9F274037D43A01C8E34D4045C6376E959F2740379368F6C7E34D4009E873C4959F2740D243C114C7E34D402ABE03D06B9F2740265193D3C6E34D40',0);
SELECT abs(topogeo_addlinestring) FROM topology.TopoGeo_addLinestring('rmp_temp_data_01_3226_114','0102000020A210000017000000BDCB1BB2CC9F2740ADA68910CAE34D406CCE3CB0D39F2740ADE75B1BCAE34D4031F07806D49F2740D711CA39C9E34D4024E8150CBF9F2740BA5B2819C9E34D409BAC2FB6BE9F27401EABCFFAC9E34D401A8801BEA29F274001B45BCFC9E34D402C0760C0A39F2740613F7B2AC7E34D4009E873C4959F2740D243C114C7E34D4045C6376E959F2740379368F6C7E34D40F4C8586C9C9F274037D43A01C8E34D4030A71C169C9F27409C23E2E2C8E34D4081A4FB17959F27409CE20FD8C8E34D40BC82BFC1949F274072B8A1B9C9E34D406B85E0BF9B9F2740017389C4C9E34D40E34168139B9F27403B98C287CBE34D4092448911A29F2740CA52AA92CBE34D405C07FEBEA19F2740E859426BCCE34D40AD0F8F89BE9F2740942DD543CCE34D4080BC6FFFC39F2740650C42F9CBE34D4003571DFEC49F2740E87730E2CBE34D40868D145EC59F2740833B49E7CAE34D40F9A9DF5BCC9F274012F630F2CAE34D40BDCB1BB2CC9F2740ADA68910CAE34D40',0);
SELECT abs(topogeo_addlinestring) FROM topology.TopoGeo_addLinestring('rmp_temp_data_01_3226_114','0102000020A21000001800000088FC6CE35891274063E71364DAE34D40FB1838E15F912740811B116FDAE34D40C02A508A5F91274057F1A250DBE34D406F2D7188669127407525A05BDBE34D40333F893166912740D974473DDCE34D40D5394735589127409E0C4D27DCE34D401775D5F157912740038274D6DCE34D40BC6E9405669127409262DCAEDCE34D401CE845B271912740C73FFA8DDCE34D403F1E967972912740AA317D50DCE34D40F6598569749127402D9190B7DBE34D40FBB6BA1778912740C8BBFB94DAE34D40B937BE1679912740CFCF6146DAE34D4040B334217C912740BE335723D7E34D40F9124AFB7B9127408FC27A12D7E34D40A96CF4DD74912740D24E94EBD3E34D407DDBBF9062912740C662A476D3E34D40857C8D4C5E9127406110615BD3E34D40626EAC9A5B912740EAD81957D3E34D402780C4435B9127404F28C138D4E34D40787DA3455491274031F4C32DD4E34D4014E8333C5291274070DD8477D9E34D40C3EA543A599127408D118282D9E34D4088FC6CE35891274063E71364DAE34D40',0);
SELECT abs(topogeo_addlinestring) FROM topology.TopoGeo_addLinestring('rmp_temp_data_01_3226_114','0102000020A2100000170000006CEAF9C2029E2740E6B744CFF2E34D40F7212C52FF9D2740453B3D6FF3E34D40CE8E1178FE9D2740B65AD596F3E34D4008E85A27F59D274068D496E3F3E34D4007FF298EEB9D27402C209C32F4E34D40A9B217BFE89D2740382EC349F4E34D40DAB6FEE8E69D27402C7CC07AF4E34D400386F5B0E69D2740AF8C370DF5E34D40628B37ADF49D27403E88F122F5E34D4026AD7303F59D274068B25F41F4E34D4033B5D6FD099E2740F7EEEB61F4E34D40F7D612540A9E274021195A80F3E34D4004DF754E1F9E2740B055E6A0F3E34D40C900B2A41F9E2740DA7F54BFF2E34D4063BCDD992B9E27403370DED1F2E34D400F46CABA2D9E2740877DB090F2E34D400D0B40053D9E2740C30D1ABCF0E34D40B43D7978549E27407E7FD7EFEBE34D40983E2969399E2740A06FCA2AEFE34D4087681803159E27402EECE6FFF1E34D403A2AEC78079E2740CEC5BF99F2E34D40CBB20D99039E27404596B4C5F2E34D406CEAF9C2029E2740E6B744CFF2E34D40',0);
SELECT abs(topogeo_addlinestring) FROM topology.TopoGeo_addLinestring('rmp_temp_data_01_3226_114','0102000020A210000025000000856718C9699E27402697F8D00CE44D40D664F7CA629E274097DC10C60CE44D409A863321639E2740328D69E40BE44D40CD7A8B025D9E274020E5EEDA0BE44D407E79F839609E27408B3A32A40DE44D40D6F8AED5619E274007A2DE880EE44D40B2AA13A6639E27404EC1D18A0FE44D409D0B4380689E27404E90232D10E44D40380264C6689E2740C50BD9750FE44D40450AC7C07D9E2740544865960FE44D40092C03177E9E27407E72D3B40EE44D40B01FFE0DA19E27409CAA19EB0EE44D40ECFDC1B7A09E274001FAC0CC0FE44D409B00E3B5A79E27408FB4A8D70FE44D405F221F0CA89E27402B6501F60EE44D40A3FA722BAE9E27403D0D7CFF0EE44D407336B11AAF9E27406688E0D50EE44D4065886212B39E2740491AF6240EE44D4087AAB09CB69E27406DEF2B870DE44D4057DA130AB79E2740BA2521740DE44D4021693E20B89E27400294B04A0DE44D4008BA8A1FC79E274068842C0F0BE44D402A34B4C6CA9E2740E5643EC10AE44D4006ED58B5BE9E2740DF0774AE0AE44D40CA0E950BBF9E27407BB8CCCC09E44D401B0C740DB89E27407B77FAC109E44D4057EA37B7B79E2740E0C6A1A30AE44D40F9E4F5BAA99E2740C251D28D0AE44D4035C3B964A99E274027A1796F0BE44D4086C09866A29E27402760A7640BE44D40C19E5C10A29E2740FC3539460CE44D40B496F9158D9E27406EF9AC250CE44D40F074BDBF8C9E274044CF3E070DE44D40926F7BC37E9E2740B5D384F10CE44D40CE4D3F6D7E9E274019232CD30DE44D40C145DC72699E2740FC6C8AB20DE44D40856718C9699E27402697F8D00CE44D40',0);
SELECT abs(topogeo_addlinestring) FROM topology.TopoGeo_addLinestring('rmp_temp_data_01_3226_114','0102000020A21000002B000000C5044DCE829E27403701035E02E44D40240A8FCA909E2740C6FCBC7302E44D405F4C0913919E274026F5D1B501E44D408F0839CD8F9E2740FC47129001E44D4074BFB65C8A9E27403EA5D7EE00E44D4034404FC0879E2740145F6AA100E44D40C518BAA6839E27405655DD2700E44D40D97765B37F9E27402D76C2B2FFE34D40DA8B67F07C9E27406E05E360FFE34D407EAF7BA6779E2740458D1AC4FEE34D4056CBC5CD689E2740289CDE0BFDE34D40C81EA88C679E2740E741B5E6FCE34D4045BFEFDE5A9E2740BDABFED2FCE34D40819DB3885A9E274022FBA5B4FDE34D40D29A928A539E274022BAD3A9FDE34D4096BCCEE0539E2740BD6A2CC8FCE34D40E7B9ADE24C9E27402EB044BDFCE34D4070FD258F4D9E2740F38A0BFAFAE34D40C1FA0491469E274065D023EFFAE34D40FCD8C83A469E2740C91FCBD0FBE34D404DD6A73C3F9E27403A65E3C5FBE34D4089B46BE63E9E27409FB48AA7FCE34D40DAB14AE8379E27409F73B89CFCE34D4016900E92379E274075494A7EFDE34D40B88ACC95299E2740E64D9068FDE34D40F9C11127299E274009F70D8AFEE34D4045BBE8CF2C9E27409E7DA4D6FEE34D40556AB3D92F9E27405CC8035BFFE34D40F475525E349E2740C1BFCF1F00E44D40FE07786E369E2740854CA77900E44D404AF9BCC0399E2740C1EA450A01E44D40155DAB97439E2740D854EEB602E44D409EEC23DF439E27406D5833FC01E44D404DEF44DD4A9E27406D99050702E44D40121181334B9E274097C3732501E44D40C113A231529E27409704463001E44D400D795634539E2740F88F658BFEE34D401A81B92E689E2740154607ACFEE34D40565F7DD8679E27407A95AE8DFFE34D40B464BFD4759E2740099168A3FFE34D40F042837E759E2740DF66FA8400E44D404E48C57A839E2740FCDBC99A00E44D40C5044DCE829E27403701035E02E44D40',0);
SELECT abs(topogeo_addlinestring) FROM topology.TopoGeo_addLinestring('rmp_temp_data_01_3226_114','0102000020A21000003000000094D3639CC09F2740CEA9028743E24D401D0F4AF2C09F27406A5A5BA542E24D40E888B5F7B29F2740DB5EA18F42E24D40246779A1B29F27403FAE487143E24D40B4FA8EA6A49F2740B1B28E5B43E24D402BBFA850A49F27401502363D44E24D40F38833539D9F274087474E3244E24D402F67F7FC9C9F2740EB96F51345E24D40F73082FF959F2740EB55230945E24D40AAD35F53959F2740267B5CCC46E24D40729DEA558E9F2740263A8AC146E24D40E96104008E9F2740FC0F1CA347E24D40B12B8F02879F2740FCCE499847E24D40ED0953AC869F2740611EF17948E24D40B5D3DDAE7F9F2740D263096F48E24D402C98F7587F9F274037B3B05049E24D40F461825B789F2740A8F8C84549E24D406C1E0AAF779F2740719717094BE24D4034E894B1709F2740E2DC2FFE4AE24D40ABACAE5B709F2740472CD7DF4BE24D407376395E699F274047EB04D54BE24D40AF54FD07699F27401DC196B64CE24D40771E880A629F27401D80C4AB4CE24D402AC1655E619F274058A5FD6E4EE24D4062F7DA5B689F2740E65FE5794EE24D40261917B2689F274082103E984DE24D40236936AF6F9F2740825110A34DE24D40E78A7205709F2740AC7B7EC14CE24D401FC1E702779F2740ACBC50CC4CE24D40E3E22359779F2740476DA9EA4BE24D40E03243567E9F2740D62791F54BE24D40A4547FAC7E9F274071D8E9134BE24D40DC8AF4A9859F27400093D11E4BE24D40A0AC3000869F27409B432A3D4AE24D40D432C5FA939F27402A3FE4524AE24D4099540151949F2740C5EF3C7149E24D40D18A764E9B9F274054AA247C49E24D4095ACB2A49B9F2740EF5A7D9A48E24D4091FCD1A1A29F2740EF9B4FA548E24D40561E0EF8A29F27401AC6BDC347E24D401A404A4EA39F2740B57616E246E24D405276BF4BAA9F2740B5B7E8EC46E24D40DBB1A5A1AA9F2740DFE1560B46E24D4013E81A9FB19F2740DF22291646E24D40D70957F5B19F27407AD3813445E24D400F40CCF2B89F2740098E693F45E24D405C9DEE9EB99F27403FEF1A7C43E24D4094D3639CC09F2740CEA9028743E24D40',0);
SELECT abs(topogeo_addlinestring) FROM topology.TopoGeo_addLinestring('rmp_temp_data_01_3226_114','0102000020A21000001C00000094ABCB0791A32740736EEB1F3BE14D409FC4282059A32740E5EC43C93AE14D40168942CA58A32740493CEBAA3BE14D40E6BB49E220A32740BBBA43543BE14D405D80638C20A327409190D5353CE14D40A0C67A9212A32740910E31203CE14D40178B943C12A32740F55DD8013DE14D401A3B753F0BA3274067A3F0F63CE14D40C78C63020BA3274096CC15983DE14D40233D970B12A3274007D15B823DE14D40AD1ADE2727A3274078D158413DE14D4009CB11312EA32740E9D59E2B3DE14D4059B91EBE34A32740F5DF7C173DE14D40647B453A35A3274078CD0F163DE14D40C5D9DE544AA32740D28B3ED93CE14D40EF72109460A3274067C527993CE14D4078B326B26BA3274031621C793CE14D408F4BE1826DA327401974E06E3CE14D400B7260A37BA32740FC4E5A1F3CE14D40D26063C880A327406D7D69023CE14D4057BC67AF89A327404FF5D9053CE14D4038D858B196A32740CC72E20A3CE14D4085EDC3ED97A3274097D24D0B3CE14D4014362B9098A32740C697BC0D3CE14D408333D6A2B3A32740D802AE373CE14D4094AAA24EB4A327409DDD74743AE14D401DE7B15D91A327400F1F443E3AE14D4094ABCB0791A32740736EEB1F3BE14D40',0);
SELECT abs(topogeo_addlinestring) FROM topology.TopoGeo_addLinestring('rmp_temp_data_01_3226_114','0102000020A210000037000000A2F5E7A930A327403CD8E7A04AE24D406ABF72AC29A327403C9715964AE24D405948A60029A3274076BC4E594CE24D40061ADFF526A32740D02A34564CE24D40D80EE2762FA327404699CCC64DE24D407A93B5D838A327409321655D4FE24D40AEDC86483DA327408DF2AC6E4FE24D40E0590DEB43A32740BC4837424FE24D40C759BEEB44A32740164C813B4FE24D40D9CC416C45A32740B780D12B4FE24D409A1A0C3A4BA32740EC3A0B774EE24D4094D940564CA327406A1F66544EE24D4014F0C59252A32740C3661E924DE24D408ACC954053A327401DBEFA7C4DE24D408DC57FEB59A327409A9231AD4CE24D40B654519A5AA32740CBD7EAE14AE24D40EE8AC69761A32740CB18BDEC4AE24D4077C6ACED61A32740F5422B0B4AE24D40AFFC21EB68A32740F583FD154AE24D403838084169A327409034563449E24D400002934362A3274090F3832949E24D40C423CF9962A327402BA4DC4748E24D40C073EE9669A327402BE5AE5248E24D4049AFD4EC69A32740C695077147E24D40B91BBFE777A327405591C18647E24D404257A53D78A32740F0411AA546E24D407A8D1A3B7FA32740F082ECAF46E24D4003C900917FA327408C3345CE45E24D403BFF758E86A327401BEE2CD945E24D406F64DB9188A327404D8B568F40E24D40A79A508F8FA327404DCC289A40E24D4030D636E58FA3274077F696B83FE24D40F89FC1E788A3274077B5C4AD3FE24D40C4192DED7AA32740E8B90A983FE24D403BDE46977AA327404D09B27940E24D4003A8D19973A327404DC8DF6E40E24D407A6CEB4373A32740B217875041E24D40423676466CA32740235D9F4541E24D40B9FA8FF06BA3274088AC462742E24D4081C41AF364A32740886B741C42E24D40F988349D64A32740ECBA1BFE42E24D40C152BF9F5DA32740EC7949F342E24D403817D9495DA32740C24FDBD443E24D4000E1634C56A32740C20E09CA43E24D4077A57DF655A32740275EB0AB44E24D403F6F08F94EA32740271DDEA044E24D40B63322A34EA32740FDF26F8245E24D407EFDACA547A32740FDB19D7745E24D40F6C1C64F47A327406201455946E24D40BE8B515240A3274062C0724E46E24D4035506BFC3FA32740C60F1A3047E24D40FD19F6FE38A327403855322547E24D40ECA2295338A3274001F480E848E24D40B46CB45531A3274001B3AEDD48E24D40A2F5E7A930A327403CD8E7A04AE24D40',0);
SELECT abs(topogeo_addlinestring) FROM topology.TopoGeo_addLinestring('rmp_temp_data_01_3226_114','0102000020A210000029000000B0AA1B17AC9F2740EC35DBAEC3E34D403C45F4286D9F2740B106214DC3E34D407723B8D26C9F274087DCB22EC4E34D40B3017C7C6C9F2740EB2B5A10C5E34D4056459670969F2740981E8851C5E34D401A67D2C6969F274033CFE06FC4E34D409B8B00BFB29F274051C6549BC4E34D401CB02EB7CE9F27406EBDC8C6C4E34D40578EF260CE9F2740D30C70A8C5E34D4029B0FF5AE39F27406249FCC8C5E34D40658EC304E39F2740C798A3AAC6E34D401491E402EA9F2740C7D975B5C6E34D40C3930501F19F2740C71A48C0C6E34D40FE71C9AAF09F27402B6AEFA1C7E34D402191B5A6FE9F2740BA65A9B7C7E34D40D093D6A405A02740BAA67BC2C7E34D40BF1478A204A02740E9947167CAE34D40E133649E12A02740E916167DCAE34D40282C2AE112A027406CF484CEC9E34D40236FF25A12A027406C25332CC9E34D404EA67D510FA0274025D4E4DAC7E34D406C6B962D0FA0274085B254D1C7E34D40F6125ADD0CA0274091DA2034C7E34D403EEBD7C50BA027409D9FE3E9C6E34D40862B55780BA02740DE4956D5C6E34D40FF9B719507A02740E5E64501C6E34D40A0CBCB6806A027407A202FC1C5E34D404223955103A027400F3B7D18C5E34D40D1A38FB602A02740272570F7C4E34D4052C9E667FB9F2740C2067773C3E34D40CC214D81F69F274040236513C2E34D401AE3BA30F49F27408881D03CC1E34D40935B69A4F09F2740CAC4F04FC1E34D401ACA1D90E89F27402F2AF451C1E34D40B6986425E79F27405241A9B0C1E34D4059D42EDFE29F27404C570CF8C1E34D408A5F0BF5D49F2740F3570B2AC2E34D40C06B43A3C89F274016954056C2E34D40BA0A3065C89F2740A5DDA7F8C2E34D4075CC576DAC9F274087E633CDC2E34D40B0AA1B17AC9F2740EC35DBAEC3E34D40',0);
SELECT abs(topogeo_addlinestring) FROM topology.TopoGeo_addLinestring('rmp_temp_data_01_3226_114','0102000020A2100000320000007723B8D26C9F274087DCB22EC4E34D403C45F4286D9F2740B106214DC3E34D40AF61BF26749F2740B147F357C3E34D403086ED1E909F2740CE3E6783C3E34D40B0AA1B17AC9F2740EC35DBAEC3E34D4075CC576DAC9F274087E633CDC2E34D4097EB4369BA9F274016E2EDE2C2E34D40BA0A3065C89F2740A5DDA7F8C2E34D40C06B43A3C89F274016954056C2E34D408B8DD38BBA9F2740A5E8D588C2E34D40C41D34FCA89F2740CF82D5C7C2E34D405A0239929A9F27402E7C97FBC2E34D40A1A58546909F274081D2CD1BC3E34D4042244243849F27408D8C6241C3E34D40EBF7CB60749F274093C648C0C2E34D40B1212F72719F274010EC75A8C2E34D4071425A626E9F27403A50D16CC2E34D4098B067B5669F2740A02755D7C1E34D40DC2767C4619F274070841D77C1E34D403CB0EAE55F9F27403570B552C1E34D40E1AF6D16599F27403B3F00CEC0E34D40F91B050B599F2740A67F29CDC0E34D40D0A8C7EF559F2740775E9682C0E34D4017FCCADD4B9F2740596ABE90BFE34D40BEF0EE8D4B9F2740AD274789BFE34D405E4FCECB419F2740CBEFFB9EBEE34D40F03E9D7D309F274055127FFFBCE34D40EBF5D4A72D9F27401F8161BBBCE34D4069C1ED9D149F2740252E7594BCE34D40A59FB147149F27408A7D1C76BDE34D40247B834FF89E27406C86A84ABDE34D40605947F9F79E2740D1D54F2CBEE34D408F8096EF1A9F2740EF0D9662BEE34D40039D61ED219F27407EC87D6DBEE34D403F7B2597219F2740E217254FBFE34D40EE7D4695289F2740E258F759BFE34D40295C0A3F289F274047A89E3BC0E34D40FB7D17393D9F2740D6E42A5CC0E34D40BF9F538F3D9F2740000F997ABFE34D406EA2748D449F274000506B85BFE34D40AA803837449F2740659F1267C0E34D40598359354B9F274065E0E471C0E34D4095611DDF4A9F2740C92F8C53C1E34D4044643EDD519F2740C9705E5EC1E34D407F420287519F27402EC00540C2E34D40F35ECD84589F2740BD7AED4AC2E34D406A23E72E589F274093507F2CC3E34D40DE3FB22C5F9F2740220B6737C3E34D40191E76D65E9F2740F8E0F818C4E34D407723B8D26C9F274087DCB22EC4E34D40',0);
SELECT abs(topogeo_addlinestring) FROM topology.TopoGeo_addLinestring('rmp_temp_data_01_3226_114','0102000020A210000002000000E229DB8ECBA32740ACB5083D92E24D406B077D69D9A327407DE57A5292E24D40',0);
SELECT abs(topogeo_addlinestring) FROM topology.TopoGeo_addLinestring('rmp_temp_data_01_3226_114','0102000020A2100000080000006B077D69D9A327400258634755E14D4004F89627CFA327401887EAE256E14D409FDA4A95CEA327407728D1F956E14D407CD84465CCA327406BE1692E57E14D40943801D8CBA32740F96707A258E14D40918820D5D2A32740F9A8D9AC58E14D40084D3A7FD2A327405EF8808E59E14D406B077D69D9A32740D904369959E14D40',0);
SELECT abs(topogeo_addlinestring) FROM topology.TopoGeo_addLinestring('rmp_temp_data_01_3226_114','0102000020A21000002A0000006B077D69D9A3274053A62B8E90E24D4067BD7238D3A32740E2578C8490E24D40F3A0A73ACCA32740E216BA7990E24D407CDC8D90CCA327407EC712988FE24D4029E7ED9CA9A327407E82F7618FE24D40A0AB0747A9A32740E3D19E4390E24D4068759249A2A327405417B73890E24D40DF39ACF3A1A32740B8665E1A91E24D40A70337F69AA32740B9258C0F91E24D401EC850A09AA327401D7533F191E24D40ABAB85A293A327401D3461E691E24D4022709F4C93A32740F309F3C792E24D403C28CC408FA32740A6E6BDC192E24D40DF7703D38BA327401CE6710394E24D40F1D6197B8BA327406F3CA82394E24D408BCD3AC18BA327408DDB403294E24D404245713A90A327402231292195E24D407E04D42699A32740A4997BD095E24D40BA42054499A32740B66BBFD295E24D404B787B0FA0A3274039DF3F1296E24D4054D278F8A6A327408CF8EC5296E24D4028533692AAA32740EBDAA57496E24D40A2DEBD89C7A32740440DAF8397E24D40B97AC185C9A327409DFD389697E24D40C1D4BE6ED0A32740F116E6D697E24D4021E14089D0A32740EBDF9B9197E24D405917B686D7A32740EB206E9C97E24D40E1529CDCD7A3274086D1C6BA96E24D40A91C27DFD0A327408690F4AF96E24D4032580D35D1A32740B0BA62CE95E24D408705CD39C3A3274021BFA8B895E24D40FEC9E6E3C2A32740860E509A96E24D40C69371E6BBA3274086CD7D8F96E24D404FCF573CBCA32740217ED6AD95E24D40A37C1741AEA3274021FC319895E24D402CB8FD96AEA32740BDAC8AB694E24D40F4818899A7A32740BD6BB8AB94E24D408E343B9BA8A327401DF7D70692E24D40C66AB098AFA327401D38AA1192E24D404FA696EEAFA32740B8E8023091E24D406A65C1E4CBA327404766615B91E24D40E229DB8ECBA32740ACB5083D92E24D40',0);
SELECT abs(topogeo_addlinestring) FROM topology.TopoGeo_addLinestring('rmp_temp_data_01_3226_114','0102000020A2100000460000006B077D69D9A32740D4402D663EE24D4035854177D6A327403C5B94613EE24D40240E75CBD5A3274006FAE22440E24D40B4A18AD0C7A3274006783E0F40E24D40A22ABE24C7A32740409D77D241E24D40FB875E2CB2A3274040DA00B241E24D400CFF2AD8B2A32740773BB2EE3FE24D404435A0D5B9A32740777C84F93FE24D40CD70862BBAA32740A1A6F2173FE24D4005A7FB28C1A32740A1E7C4223FE24D408EE2E17EC1A327403C981D413EE24D40FE4ECC79CFA327403C1AC2563EE24D40A9784B27D1A327406280A8EE39E24D40E1AEC024D8A3274062C17AF939E24D406AEAA67AD8A32740FD71D31739E24D40C2474782C3A32740FDAE5CF738E24D4028959480C2A327409D233D9C3BE24D40F05E1F83BBA327409DE26A913BE24D40DEE752D7BAA32740D707A4543DE24D40A6B1DDD9B3A32740D7C6D1493DE24D401E76F783B3A327403C16792B3EE24D40B1B9ED8B9EA327403C53020B3EE24D40C330BA379FA3274073B4B3473CE24D40FB662F35A6A3274073F585523CE24D400CDEFBE0A6A3274038D04C8F3AE24D40441471DEADA3274038111F9A3AE24D40568B3D8AAEA327406F72D0D638E24D40E61E538FA0A327406FF02BC138E24D40D4A786E39FA32740388F7A843AE24D409C7111E698A32740A9D492793AE24D407983788E97A32740AD981A003EE24D40414D039190A32740AD5748F53DE24D40B9111D3B90A3274012A7EFD63EE24D4081DBA73D89A3274012661DCC3EE24D40F89FC1E788A3274077B5C4AD3FE24D4030D636E58FA3274077F696B83FE24D40A79A508F8FA327404DCC289A40E24D406F64DB9188A327404D8B568F40E24D403BFF758E86A327401BEE2CD945E24D4003C900917FA327408C3345CE45E24D407A8D1A3B7FA32740F082ECAF46E24D404257A53D78A32740F0411AA546E24D40B91BBFE777A327405591C18647E24D4049AFD4EC69A32740C695077147E24D40C073EE9669A327402BE5AE5248E24D40C423CF9962A327402BA4DC4748E24D400002934362A3274090F3832949E24D403838084169A327409034563449E24D40AFFC21EB68A32740F583FD154AE24D4077C6ACED61A32740F5422B0B4AE24D40EE8AC69761A32740CB18BDEC4AE24D40B654519A5AA32740CBD7EAE14AE24D40A5DD84EE59A32740947639A54CE24D408DC57FEB59A327409A9231AD4CE24D4045D9942A5AA32740D05C8FA54CE24D40122E46F16DA3274048B06A3D4AE24D40C6690B1877A32740D1C0DAA849E24D4022F264707CA32740254C085249E24D402FD9987385A32740C02EBCBF48E24D40F3661DBF86A327403779C3AA48E24D40C8E3912D8AA327402BBF2E8548E24D4000CFED2C9CA32740374E4DC047E24D4005D2CCCCB4A327400348A83E45E24D4041B17713BFA327406F9AE43244E24D40F0634F4BC6A32740BCB9D00D44E24D407C448D5ACDA327409E9893E943E24D409D16921ED1A327403F6248D643E24D40A8C4B65DD4A32740ECCA3FAB43E24D403C063274D4A327401C2513AA43E24D406B077D69D9A3274089096F6843E24D40',0);
SELECT abs(topogeo_addlinestring) FROM topology.TopoGeo_addLinestring('rmp_temp_data_01_3226_114','0102000020A21000000E0000001F63503AD4A02740652928C5D7E04D40702F1EB492A027406B044EC2D7E04D40DCDF8E4679A02740536AA4A9D7E04D408767AD2D66A027400031AF0ED6E04D4066C3700048A02740F414BE2DD7E04D40EF6A9F4B49A02740BCF39CA5DBE04D40EC9EBF194FA02740AEE5E029DFE04D407CE5ABCA64A02740EE4EECA5E2E04D406B841A317AA027403C12B438E2E04D40441049C196A02740481F2E5EE1E04D405BCE6251AFA027409C551C24E0E04D409E9E8FB5B8A02740BAEB75EADEE04D400B932C70CCA027402E34BF7DDAE04D401F63503AD4A02740652928C5D7E04D40',0);
SELECT abs(topogeo_addlinestring) FROM topology.TopoGeo_addLinestring('rmp_temp_data_01_3226_114','0102000020A21000000F000000865BB90EC59E274019EA0C2D77E34D405483F5C0C89E27406603C19478E34D407FB87061DE9E27405C70283E7FE34D40F8B6EB07F29E2740834DBF0685E34D405193AD88FE9E27409990A58F89E34D408318C681059F274061D529EE8CE34D40AF051F17189F2740631B877A8AE34D404EEACA87259F27405EB0870288E34D408718AE2E2C9F2740B3981B4A85E34D401C9605332B9F2740AE76803383E34D40437C36FD249F27405054375D80E34D4002047A1A189F27401074B55B7CE34D4002CEF6AD009F27406B69CAEF79E34D404F381D95DE9E27409C525FDC77E34D40865BB90EC59E274019EA0C2D77E34D40',0);
SELECT abs(topogeo_addlinestring) FROM topology.TopoGeo_addLinestring('rmp_temp_data_01_3226_114','0102000020A210000011000000200C3BACF5A12740857F4C9046E14D40F1DDFEDF0AA22740EA737C1B48E14D40C775DE282FA227407EA3E43C49E14D402C1ADE8A51A227406C6369FD49E14D40A93EE2B974A2274000845A634BE14D40910485068CA22740ED574CFC4CE14D406539420590A22740F93FF3454DE14D40F7AA94BE95A2274054447F954AE14D40B65307D394A22740AFA3823B47E14D40B76EB4C987A227408DF018E043E14D403BEC106179A227408732346842E14D40C5F8B36854A227404DCB7BA83FE14D40E1E3D8BB40A227408FAAE51C3FE14D403DA1100025A22740D6F63D513FE14D402FAD1ADE10A2274071EE0B8940E14D40B79F622707A2274099CF80E142E14D40200C3BACF5A12740857F4C9046E14D40',0);
SELECT abs(topogeo_addlinestring) FROM topology.TopoGeo_addLinestring('rmp_temp_data_01_3226_114','0102000020A210000014000000F9EC45F5D7A22740E02AF51750E24D40D5AC959DC1A22740A34E8B5152E24D40C9D0EAE3AAA227403CD5851255E24D4003EE57A5A2A227403CB4FB6156E24D407BE35958ABA22740415A2AD656E24D40648DFD75C1A22740B2412F3B58E24D40999B6EF9CDA227403A3DF07759E24D40EF75CDDBC8A227400A0F40555BE24D407C8D4C75C0A22740AE89BCE15EE24D401683861EB6A22740D15E5DDF61E24D40D5690EF6CCA227402F0DCC6963E24D4017DB1F1FE4A227403B7B60F463E24D40CDBF852AF4A22740A8071FF35FE24D4073E945AA00A32740DAD307BF5BE24D400978A8F80AA32740F90F2C8558E24D40D016625710A32740B40884EB54E24D4039673BADFDA22740DE484E2A53E24D40DB018C3DEFA22740C198E47C51E24D409F758C4BDAA227405725B33C50E24D40F9EC45F5D7A22740E02AF51750E24D40',0);
SELECT abs(topogeo_addlinestring) FROM topology.TopoGeo_addLinestring('rmp_temp_data_01_3226_114','0102000020A210000014000000F3C349B27AA227408650AE88AEE14D409917F43870A22740AD516B3BB2E14D40C071FF4E6BA22740834E2ADCB3E14D40001F580185A22740403FBFFBB5E14D4028C086329FA22740FF484C75B6E14D404D3038F6B3A22740C967E56AB6E14D401815C337CAA22740C4096E66B5E14D4053786C77D6A227407E1A7CD0B2E14D404550EAA1F1A227405CB6AE49AEE14D40981E4439F3A227405CC52505AEE14D40A663ACDAE3A227403BFDA1DFA8E14D4098A45288DCA227402B43A945A6E14D4083F8BF43D6A227408B1491C8A4E14D40487D6000C9A227407A1EBC40A3E14D4052052680B5A2274039B02543A2E14D40FE019BB4AAA22740D3BEFC8CA3E14D404A0DA66096A22740C595EED3A6E14D4034A4055F88A22740C3393527AAE14D40E11C7C9A7BA227408097BF2DAEE14D40F3C349B27AA227408650AE88AEE14D40',0);
SELECT abs(topogeo_addlinestring) FROM topology.TopoGeo_addLinestring('rmp_temp_data_01_3226_114','0102000020A2100000170000001498EA75529F2740F653B21C31E24D40E5CA44D6449F27408CD741942EE24D407EF0EA863C9F2740C2DD7B7A2DE24D401BCABA652D9F2740639AA8F32BE24D4072E73554199F27405721E6D82BE24D400C559374109F2740570ADDC62BE24D40DADF9E280A9F2740F111CFAB2DE24D4057BBDBCBF19E27400A4030CF2CE24D40EE872A5EE29E274016DB298C2CE24D400B94130DD79E2740EB08978A2DE24D40FFF57D16D89E2740324C1B1230E24D409985F1CAE59E274023F30BED34E24D40D46F90F6E59E2740B138D75536E24D4065762E0FCB9E2740A4DD6D4D39E24D4023D60217C09E27406D282A1F3BE24D40001EED2BD69E2740AE9A09483CE24D4081C91010E69E27401F79CF643CE24D40E7E82ADCFB9E2740BB94C3863BE24D4093F581A11F9F274015D28F8A38E24D40BA9D5B8C2F9F2740E794FD1037E24D40B942897C3D9F2740D0C69EC534E24D40263FB88D519F2740EA60DD4231E24D401498EA75529F2740F653B21C31E24D40',0);
SELECT abs(topogeo_addlinestring) FROM topology.TopoGeo_addLinestring('rmp_temp_data_01_3226_114','0102000020A210000015000000996B0A63149227407230FFDBD4E34D400895AFD2FF912740E4C74FDFD2E34D40B769DFBAEF91274086BDBC0CD1E34D402DFC29BFDB912740D5C29800CEE34D40601C3AE1D3912740709528C1CCE34D4094D44A39CB912740009EFFAECAE34D4016EEC668C3912740D74BB7DFC9E34D40548316CFB19127407DB8FE06CBE34D40229E9062AA91274029C04612CDE34D406C1EC892A59127400FFDEB8DD1E34D40A2B32E02A6912740B87CC2ABD8E34D409A9E86FAA891274062B1DA84DDE34D4092412783AC91274036683C99E1E34D4093E1B90FAC9127407D32F0B7E1E34D4075DD62B7B7912740EF8AC893E1E34D40289D26D7C2912740C51200F7E0E34D409852AFDEDA912740B4EACF1FDFE34D40382B80CDE79127405C3622FBDDE34D4036783D3CF9912740C263279FDBE34D40ECB47E64099227401D1B0662D8E34D40996B0A63149227407230FFDBD4E34D40',0);
SELECT abs(topogeo_addlinestring) FROM topology.TopoGeo_addLinestring('rmp_temp_data_01_3226_114','0102000020A210000018000000564921B868912740DF9FD70EC5E34D4099C7CB8059912740027BB07FC6E34D40434018F3539127409603A1AFC8E34D401900A96D4891274035EBAEAECBE34D40CCFEAA09489127405E8F9A27CEE34D407468250750912740C2692567D0E34D409EDF40B24F9127407A134C94D1E34D4072FEC29E3D91274019756C52D4E34D40EFDB38173E912740FF36521DD8E34D40238D9EB53F912740CE5A45A4DBE34D40180B9D523E912740448126A5DDE34D404815067D5591274008A362FBDDE34D40ACB3EE796291274014779C6CDDE34D40D0EE6E096E912740BC89AE93DCE34D404F79CE917591274010928A35DBE34D40FF43F1317A912740F99DAB1CD9E34D40B863E1F27A9127407864ADE7D5E34D4028B93EA3649127400E5E06F3D2E34D40F8640EB366912740DF1050CCD0E34D4076FB48BD6E912740E766CADECDE34D4081C20A9D7D912740FBEBF5B8C9E34D40643AB54B87912740D2975306C7E34D4049C42862759127404AECDB8FC5E34D40564921B868912740DF9FD70EC5E34D40',0);
SELECT abs(topogeo_addlinestring) FROM topology.TopoGeo_addLinestring('rmp_temp_data_01_3226_114','0102000020A21000001700000006D670B1279F2740F09761333BE24D404CC60F392B9F27406D06F37C3BE24D40F1BB8521399F2740906E9E933CE24D4024D555253F9F2740EFC431013EE24D4030B310353D9F2740707C8B2041E24D400778D1773C9F274009B7854644E24D4036D0B52E3E9F2740DEDCCB8948E24D4017F351EA409F27409B6372974BE24D402B9FE42E479F27403B928A144DE24D40951A4D0C569F27408753635F4EE24D40C7A8DEF8679F27408F9570994AE24D407337FBE1749F27407486DBCE45E24D401E4A16C4839F27409A396FF341E24D40CD54C9188B9F2740B990E5F63EE24D40BECD6D24869F2740C6BEE9CC3CE24D40FED713D87C9F2740D3E7F78539E24D4013AF77C0769F274022C4B77237E24D40107AB127719F2740A0C10AAA35E24D409EF8DD525B9F274066841BE332E24D4070E01EB5589F274018C4EF8932E24D40490C22EE469F2740471253A235E24D408AA54FE4319F2740BC994E0839E24D4006D670B1279F2740F09761333BE24D40',0);
SELECT abs(topogeo_addlinestring) FROM topology.TopoGeo_addLinestring('rmp_temp_data_01_3226_114','0102000020A21000001A000000A2F883E3AF9F27401F10E9FDB0E34D40553E5652A49F27405A3475CFB1E34D40AF338CF48A9F27409CAD395DB2E34D40F6EA4581819F274048B08B4BB3E34D40DE6511EC759F2740245DFAFEB3E34D40598AC2D26E9F27407C24680AB5E34D40A18136DD609F27401C892402B7E34D40DBA635F5589F27405D50430EB9E34D40838E2CEB499F274031AAD3E8BBE34D40D9BF7F4D3A9F27406C1428E2BDE34D4028D74D284D9F2740EECD7049BFE34D407722D135629F27404C342864C1E34D4090385B47779F274004CC3B9CC3E34D404CDAF8D8879F2740ABC8F1A2C3E34D400E4F0903AF9F2740E0B8CF68C3E34D40EA62A980C69F2740A5AF95D4C2E34D40E9428AA5F69F2740224C3942C3E34D40BE6B6C22FA9F2740A50F0348C3E34D40C29FE082F19F274035B5D088C1E34D400EDC3ED3E99F2740483317FEBDE34D400EE4D029EA9F274074C8B584B9E34D4067E71A23EA9F2740680E215FB9E34D40CD301FF6E89F2740B065A723B9E34D404C214573D89F27400BE0FC06B6E34D40E4712763C79F2740E38AAD62B2E34D40A2F883E3AF9F27401F10E9FDB0E34D40',0);

Attachments (6)

topo.png (8.9 KB ) - added by strk 8 weeks ago.
magnified.png (19.2 KB ) - added by strk 8 weeks ago.
Screenshot 2024-10-02 at 11.16.31.png (386.3 KB ) - added by Lars Aksel Opsahl 7 weeks ago.
What happens when change from tolerance 1e-06 to 1e-04
before_snap.png (19.4 KB ) - added by strk 7 weeks ago.
after_snap.png (17.5 KB ) - added by strk 7 weeks ago.
input_and_overlay_intersection_jts.png (5.5 KB ) - added by strk 6 weeks ago.

Download all attachments as: .zip

Change History (32)

comment:1 by strk, 8 weeks ago

Simplified testcase:

select NULL FROM topology.DropTopology ('t5786');                                                                                                                                              
select NULL FROM topology.CreateTopology ('t5786');                                                                                                                                            
                                                                                                                                                                                               
SELECT NULL FROM topology.TopoGeo_addLinestring('t5786', 'LINESTRING(                                                                                                                          
11.812075769533624 59.77938755222866,                                                                                                                                                          
11.811862389533625 59.77938237222866,                                                                                                                                                          
11.811859819533623 59.77940927222866)                                                                                                                                                          
');                                                                                                                                                                                            
                                                                                                                                                                                               
SELECT NULL FROM topology.TopoGeo_addLinestring('t5786', 'LINESTRING(                                                                                                                          
11.811862389533625 59.77938237222866,                                                                                                                                                          
11.811969079533624 59.77938496222866,                                                                                                                                                          
11.812075769533624 59.77938755222866                                                                                                                                                           
)');                                                                                                                                                                                           
                                                                                                                                                                                               
SELECT * FROM ValidateTopology('t5786');                                                                                                                                                       
                                                                                                                                                                                               
SELECT NULL FROM topology.TopoGeo_addLinestring('t5786', 'LINESTRING(                                                                                                                          
11.811882109533624 59.77940092222866,                                                                                                                                                          
11.812061329533623 59.77938325222866                                                                                                                                                           
)');

I can reproduce with PostGIS in master branch as of commit [290fffd11dac294431056e6d152098ac0afe60de/git] (with the fix for #5782)

I can ALSO reproduce with the GEOS implemented ST_Distance ( https://git.osgeo.org/gitea/postgis/postgis/pulls/218 )

by strk, 8 weeks ago

Attachment: topo.png added

comment:2 by strk, 8 weeks ago

Also in this case we see two almost coincident edges (1 and 3), and the incoming line crosses both:

by strk, 8 weeks ago

Attachment: magnified.png added

comment:3 by strk, 8 weeks ago

Further simplification:

select NULL FROM topology.DropTopology ('t5786');                                                                                                                                              
select NULL FROM topology.CreateTopology ('t5786');                                                                                                                                            
                                                                                                                                                                                               
SELECT NULL FROM topology.TopoGeo_addLinestring('t5786', 'LINESTRING(                                                                                                                          
11.812075769533624 59.77938755222866,                                                                                                                                                          
11.811862389533625 59.77938237222866                                                                                                                                                           
)');                                                                                                                                                                                           
                                                                                                                                                                                               
SELECT NULL FROM topology.TopoGeo_addLinestring('t5786', 'LINESTRING(                                                                                                                          
11.811862389533625 59.77938237222866,                                                                                                                                                          
11.811969079533624 59.77938496222866,                                                                                                                                                          
11.812075769533624 59.77938755222866                                                                                                                                                           
)');                                                                                                                                                                                           
                                                                                                                                                                                               
SELECT * FROM ValidateTopology('t5786');                                                                                                                                                       
                                                                                                                                                                                               
SELECT NULL FROM topology.TopoGeo_addLinestring('t5786', 'LINESTRING(                                                                                                                          
11.811882109533624 59.77940092222866,                                                                                                                                                          
11.812061329533623 59.77938325222866                                                                                                                                                           
)');    

The second line has endpoints in common with the first line and a single 3rd internal vertex that according to PostGIS topology is ABOVE the straight line, thus forming a face which is on the right of both edges (first edge goes right to left, second edge goes left to right).

Here's an magnified topology version according to PostGIS topology:

comment:4 by strk, 8 weeks ago

Milestone: PostGIS 3.6.0PostGIS 3.5.1

Further simplification as the problem is with adding the intersection point with the incoming line, which can be done independentely:

select NULL FROM topology.DropTopology ('t5786');                                                                                                                                              
select NULL FROM topology.CreateTopology ('t5786');                                                                                                                                            
                                                                                                                                                                                               
SELECT NULL FROM topology.TopoGeo_addLinestring('t5786', 'LINESTRING(                                                                                                                          
11.812075769533624 59.77938755222866,                                                                                                                                                          
11.811862389533625 59.77938237222866                                                                                                                                                           
)');                                                                                                                                                                                           
                                                                                                                                                                                               
SELECT NULL FROM topology.TopoGeo_addLinestring('t5786', 'LINESTRING(                                                                                                                          
11.811862389533625 59.77938237222866,                                                                                                                                                          
11.811969079533624 59.77938496222866,                                                                                                                                                          
11.812075769533624 59.77938755222866                                                                                                                                                           
)');                                                                                                                                                                                           
                                                                                                                                                                                               
SELECT * FROM ValidateTopology('t5786');  -- topology is valid here                                                                                                                                                     
                                                                                                                                                                                               
BEGIN;                      

-- This breaks the topology                                                                                                                                                                   
SELECT NULL FROM topology.TopoGeo_addPoint('t5786',                                                                                                                                            
'POINT(11.812029186127067 59.7793864213727)');                                                                                                                                                 
                                                                                                                                                                                               
SELECT * FROM ValidateTopology('t5786');  

This is the new experimental edge-merging code that was introduced in PostGIS-3.5.0 - in previous versions 3.4 no merge is attempted and thus the intersection point always ever splits one of those two edges (edge 2) resulting in subsequent error: SQL/MM Spatial exception - geometry crosses edge 1

This is to justify setting 3.5 as the milestone, nothing earlier, as if a fix is found it should go into the edge-merging code.

comment:5 by strk, 8 weeks ago

Debugging this I found another pretty old bug with ST_ChangeEdgeGeom: #5787

comment:6 by strk, 8 weeks ago

Keywords: robustness added

comment:7 by Lars Aksel Opsahl, 7 weeks ago

So with that new merge line code I assume lines may be merged into a single line ?

Just like what happens when I define the topology.CreateTopology ('t5786',4258,1e-04); the two lines are merge into one and we get no error.

One issue is how handle bleeding polygons.

We could off always add closed polygons , but that's not possible since we polygons that may cover many content based grid cells.

So If endpoints of a line connecting to another cell has been moved we will not be able connect them.

What happens if we disable the new line merge code ?

comment:8 by Lars Aksel Opsahl, 7 weeks ago

One more thing is that we should not silently end with a topology error. It's much better that we get exception than we get a invalid topology structure.

Is it possible to fix this first ?

by Lars Aksel Opsahl, 7 weeks ago

What happens when change from tolerance 1e-06 to 1e-04

comment:9 by Lars Aksel Opsahl, 7 weeks ago

I tested with topology.CreateTopology (topo,4258,1e-04) on a bigger dataset now and that is not usable in real life. The green thick blur lines are with 1e-06. The red lines we get when using 1e-04 in picture below

https://trac.osgeo.org/postgis/attachment/ticket/5786/Screenshot%202024-10-02%20at%2011.16.31.png

Last edited 7 weeks ago by Lars Aksel Opsahl (previous) (diff)

comment:10 by strk, 7 weeks ago

I believe in this specific case we DO get an exception rather than a silently invalid topology, is this not the case ?

Edge merging is required when the floating point grid cannot represent distinct intersection points between a line and two almost collinear lines. This means that we'd not be moving existing vertices and thus should not be breaking existing connections.

comment:11 by strk, 7 weeks ago

Oh you are right, we are able to silently create an invalid topology with the last testcase (the one adding a single point). I believe that's due to #5787 basically

in reply to:  11 comment:12 by Lars Aksel Opsahl, 7 weeks ago

Replying to strk:

Oh you are right, we are able to silently create an invalid topology with the last testcase (the one adding a single point). I believe that's due to #5787 basically

I have been testing on this setup today.

POSTGIS="3.6.0dev 3.5.0-13-g290fffd11" [EXTENSION] PGSQL="160" GEOS="3.13.0beta2-CAPI-1.19.0" PROJ="9.3.0 NETWORK_ENABLED=OFF URL_ENDPOINT=https://cdn.proj.org USER_WRITABLE_DIRECTORY=/tmp/proj DATABASE_PATH=/usr/local/share/proj/proj.db" (compiled against PROJ 9.13.0) LIBXML="2.9.13" LIBJSON="0.15" LIBPROTOBUF="1.3.3" WAGYU="0.5.0 (Internal)" TOPOLOGY

1) When running on the master topology where I do COPY in data from working sub topologies area get lost. I did see that a lot line that could form a face but left_fact right_face was wrong.

2) If I instead used Topology.AddLinstring from the temp toplogies into the master topology the missings faces turn out OK.

(I have to test more on this but now this servers are used for trying fixing prod

data, so I have to test more on this later)

comment:13 by strk, 7 weeks ago

A fix for issue #5787 was pushed to branches from 3.3 to master but unfortunately that fix doesn't help this case at all. I'll continue analyzing the problem.

comment:14 by strk, 7 weeks ago

The problem seems to be in the experimental edge merging code. The code correctly finds that splitting the lower edge (edge 1) on the same new node as the upper edge (edge 2) ends up collapsing to the newly created edge 3 on the last part of original edge 2, but fails to set the side face:

=# select edge_id, left_face, right_face from t5786.edge;
 edge_id | left_face | right_face 
---------+-----------+------------
       2 |         0 |          1
       3 |         1 |          1
       1 |         0 |          1

The correct labeling for edge_id=3 would be that both left and right face are 0.

These are the debug log of the wrong operation:

[.././../liblwgeom/topo/lwgeom_topo.c:_lwt_SnapEdgeToExistingNode:5411] Existing edge 3 (post-modEdgeSplit) next_right:-2, next_left:1, face_right:1, face_left:0                              
[.././../liblwgeom/topo/lwgeom_topo.c:_lwt_SnapEdgeToExistingNode:5446] Setting nextEdge/sideFace of CCW edge -2 to 1/0                                                                        
[.././../liblwgeom/topo/lwgeom_topo.c:_lwt_SnapEdgeToExistingNode:5472] Will update next_left/face_left of incoming CCW edge 2 to 1/0                                                          
[.././../liblwgeom/topo/lwgeom_topo.c:_lwt_SnapEdgeToExistingNode:5505] Setting sideFace of CW edge 3 to 1   

Inn particular, the last line shows the wrong operation

comment:15 by strk, 7 weeks ago

It looks like the code having robustness issues is the one determining order of edges around the new node:

Component 1 of split edge 1 next CW is 3, next CCW is -2

Truth is next CW should be -2 and next CCW should be 3 The code in charge of telling is _lwt_FindAdjacentEdges We have the subject edge found to have an azimuth of 4.68811780780983, edge 3 found to have azimuth of 1.54652515429415 and edge 2 found to have azimuth of 4.68811780778147

This means edge 2 is found to be BELOW the subject edge.

This should never happen when no edge crossing is detected, and that check is performed successfully:

liblwgeom/topo/lwgeom_topo.c:lwt_ChangeEdgeGeom:3384 lwt_ChangeEdgeGeom: edge crossing check passed

I should note that raising by 1e-14 the Y value of the middle point of edge 2 fixes the issue, confirming this is definitely a problem of numerical robustness

comment:16 by strk, 7 weeks ago

Edge 2 is found to be ABOVE edge 1 before the snapping:

=# select edge_id, st_azimuth(st_pointn(geom,1),st_pointn(geom,2)) from t5786.edge where edge_id = 1;
 edge_id |    st_azimuth     
---------+-------------------
       1 | 4.688117807826012

=# select edge_id, st_azimuth(st_pointn(geom,3),st_pointn(geom,2)) from t5786.edge where edge_id = 2;
 edge_id |    st_azimuth     
---------+-------------------
       2 | 4.688117807826215

Once both edges are snapped to the new node, edge 2 is found to be BELOW edge 1:

=# update t5786.edge set geom = ST_Snap(geom, 'POINT(11.812029186127067 59.7793864213727)', 1e-6);
UPDATE 2
=# select edge_id, st_azimuth(st_pointn(geom,2),st_pointn(geom,3)) from t5786.edge where edge_id = 1;
 edge_id |    st_azimuth     
---------+-------------------
       1 | 4.688117807809833
(1 row)

strk@strk=# select edge_id, st_azimuth(st_pointn(geom,3),st_pointn(geom,2)) from t5786.edge where edge_id = 2;
 edge_id |    st_azimuth     
---------+-------------------
       2 | 4.688117807781473
(1 row)

comment:17 by strk, 7 weeks ago

PostGIS, SFCGAL and GEOS all agree about the fact that the ring formed by the snapped edges changes orientation:

#                                                                                                                                                                                              
# Before snap                                                                                                                                                                                  
#                                                                                                                                                                                              
                                                                                                                                                                                               
# A = LINESTRING(11.812075769533624 59.77938755222866,11.811862389533625 59.77938237222866)                                                                                                    
A=010200000002000000BA0A3065C89F2740A5DDA7F8C2E34D4075CC576DAC9F274087E633CDC2E34D40                                                                                                           
# B = LINESTRING(11.811862389533625 59.77938237222866,11.811969079533624 59.77938496222866,11.812075769533624 59.77938755222866)                                                               
B=01020000000300000075CC576DAC9F274087E633CDC2E34D4097EB4369BA9F274016E2EDE2C2E34D40BA0A3065C89F2740A5DDA7F8C2E34D40                                                                           
                                                                                                                                                                                               
#                                                                                                                                                                                              
# PAB = POLYGON((11.812075769533624 59.77938755222866,11.811862389533625 59.77938237222866,11.811969079533624 59.77938496222866,11.812075769533624 59.77938755222866))                         
# CW according to CG_Orientation and ST_IsPolygonCW and GEOS !Orientation::isCCW                                                                                                               
#                                                                                                                                                                                              
PAB=01030000000100000004000000BA0A3065C89F2740A5DDA7F8C2E34D4075CC576DAC9F274087E633CDC2E34D4097EB4369BA9F274016E2EDE2C2E34D40BA0A3065C89F2740A5DDA7F8C2E34D40                                 
                                                                                                                                                                                               
                                                                                                                                                                                               
#                                                                                                                                                                                              
# After snap                                                                                                                                                                                   
#                                                                                                                                                                                                                                                                                                                                                                                             
# A1 = LINESTRING(11.812029186127067 59.7793864213727,11.811862389533625 59.77938237222866)                                                                                                    
A1=01020000000200000062A01B4AC29F2740015F2BEFC2E34D4075CC576DAC9F274087E633CDC2E34D40                                                                                                          
# B1 = LINESTRING(11.811862389533625 59.77938237222866,11.811969079533624 59.77938496222866,11.812029186127067 59.7793864213727)                                                               
B1=01020000000300000075CC576DAC9F274087E633CDC2E34D4097EB4369BA9F274016E2EDE2C2E34D4062A01B4AC29F2740015F2BEFC2E34D40                                                                          
                                                                                                                                                                                               
#                                                                                                                                                                                              
# PA1B1 = POLYGON((11.812029186127067 59.7793864213727,11.811862389533625 59.77938237222866,11.811969079533624 59.77938496222866,11.812029186127067 59.7793864213727))                         
# CCW according to CG_Orientation and ST_IsPolygonCCW and GEOS Orientation::isCCW                                                                                                              
#                                                                                                                                                                                              
PA1B1=0103000000010000000400000062A01B4AC29F2740015F2BEFC2E34D4075CC576DAC9F274087E633CDC2E34D4097EB4369BA9F274016E2EDE2C2E34D4062A01B4AC29F2740015F2BEFC2E34D40                   

I don't understand how this is possible

by strk, 7 weeks ago

Attachment: before_snap.png added

by strk, 7 weeks ago

Attachment: after_snap.png added

comment:18 by strk, 7 weeks ago

JTS also confirms the swapped position of A and B upon snapping. Magnified version of the two situations:

comment:19 by strk, 6 weeks ago

JTS Test builder showing in red the intersection point found between the input lines (in blue) and a line crossing both, in a topology-magnified way.

comment:20 by strk, 6 weeks ago

For the record: PR https://git.osgeo.org/gitea/postgis/postgis/pulls/226 earlier catches the problem erroring out at the time second edge snapping and splitting is attempted, giving an error like:

ERROR: snapping edge 17 to new node moves it past edge 18

comment:21 by Sandro Santilli <strk@…>, 4 weeks ago

In f02b6db/git:

Check motion range upon snap/splitting edge to existing node

References #5792 (fixing it)
References #5786 (not resolving the problem)
Includes regress test

comment:22 by Sandro Santilli <strk@…>, 4 weeks ago

In 158efb88/git:

Check motion range upon snap/splitting edge to existing node

Fixes #5792 in 3.5 branch (3.5.1dev)
References #5786 (not resolving the problem)
Includes regress test

comment:23 by Sandro Santilli <strk@…>, 3 weeks ago

In 26d0eb1/git:

Revert "Check motion range upon snap/splitting edge to existing node"

The check is bogus, we need a different approach

This reverts commit 69abb0721c7f4e551f0061de9293db61b83a0037.
This reverts commit 158efb88c1ecc59c3dc195eed6a68bfe87fd9aaf.

Re-opens #5792 in 3.5 branch (3.5.1dev)
References #5786

comment:24 by Sandro Santilli <strk@…>, 3 weeks ago

In c8c34542/git:

Revert "Check motion range upon snap/splitting edge to existing node"

This reverts commit fc88b11cdbf25999c7f1510cf7e26d40e8a9dfd3.
This reverts commit f02b6db36beb5e9e772c211dc08556377cf1a4d0.

Re-opens #5792 in master branch (3.6.0dev)
References #5786

comment:25 by Sandro Santilli <strk@…>, 2 weeks ago

In 6366bd6/git:

Check motion range upon snap/splitting edge to existing node

This time make the polygon valid before using Covers on it

Closes #5792 in master branch (3.6.0dev)
References #5786

comment:26 by Sandro Santilli <strk@…>, 2 weeks ago

In 58d45d6/git:

Check motion range upon snap/splitting edge to existing node

This time make the polygon valid before using Covers on it

Closes #5792 in 3.5 branch (3.5.1dev)
References #5786

Note: See TracTickets for help on using tickets.