Opened 4 years ago
Closed 3 years ago
#4893 closed defect (fixed)
Topology Exception on st_intersection
Reported by: | mlt35 | Owned by: | pramsey |
---|---|---|---|
Priority: | medium | Milestone: | PostGIS GEOS |
Component: | postgis | Version: | 3.1.x |
Keywords: | Geos Error, Topology Exception, lwgeom_intersection_prec | Cc: |
Description
I was running an st_intersection operation on very complex, albeit valid geometries, and received the following message:
SQL Error [XX000]: ERROR: lwgeom_intersection_prec: GEOS Error: TopologyException: Directed Edge visited twice during ring-building at 1007901.2646933049 165954.35405701387
I realize the multipolygon object is extremely complex and not ideal to work with (I didn't realize quite how bad it was until this problem arose). Ultimately, running st_subdivide on the multipolygon object allowed me to run an equivalent of this intersection with no issue.
Further down is a reproducible example that throws the error, but first, here's my postgis info (Running on Windows 10 x64; Postgres 13.0, installed via StackBuilder):
select postgis_full_version(); --POSTGIS="3.1.1 3.1.1" [EXTENSION] PGSQL="130" GEOS="3.9.0-CAPI-1.14.1" SFCGAL="1.3.8" PROJ="7.1.1" GDAL="GDAL 3.2.1, released 2020/12/29" LIBXML="2.9.9" LIBJSON="0.12" LIBPROTOBUF="1.2.1" WAGYU="0.5.0 (Internal)" TOPOLOGY RASTER
Reproducible Example:
select st_intersection(st_geomfromtext('MULTIPOLYGON (((1007897.6751335859 165975.99421341717, 1007898.4300533384 165975.52472616732, 1007899.1482277513 165975.01029150188, 1007899.8312972635 165974.44992516935, 1007900.475981012 165973.8459237516, 1007900.6751275957 165973.64251208305, 1007900.722699672 165973.59264342487, 1007900.7725683451 165973.54507133365, 1007900.9759800136 165973.34592474997, 1007901.5799814165 165972.7012410015, 1007902.1403477639 165972.01817150414, 1007902.6547824293 165971.30032517016, 1007903.1213169247 165970.5499985963, 1007903.5376546681 165969.77080066502, 1007903.9024833441 165968.96634033322, 1007904.213506341 165968.1395703405, 1007904.4700675011 165967.29409958422, 1007904.67052643 165966.43386508524, 1007904.734830752 165966.08773717284, 1007904.738767758 165966.0647713393, 1007904.7459855974 165966.0424616784, 1007904.9700665027 165965.29410359263, 1007905.1705254167 165964.43386909366, 1007905.2348297536 165964.08774116635, 1007905.2387667596 165964.0647753328, 1007905.2459845841 165964.0424656719, 1007905.4700655043 165963.29410758615, 1007905.6705244184 165962.43387308717, 1007905.8145530075 165961.56215567887, 1007905.9011670053 165960.68289233744, 1007905.9300383329 165959.80002008379, 1007905.9300383329 165959.62482358515, 1007906.1800378412 165959.49129366875, 1007906.9300363362 165959.0247591734, 1007907.6482107639 165958.51032450795, 1007908.3312802613 165957.94995817542, 1007908.9759640098 165957.34595675766, 1007909.1751105934 165957.14254508913, 1007909.2226826698 165957.09267641604, 1007909.2725513428 165957.04510433972, 1007909.4759630114 165956.84595775604, 1007909.6751095951 165956.6425460875, 1007909.7226816714 165956.59267742932, 1007909.7725503445 165956.5451053381, 1007909.975962013 165956.34595875442, 1007910.1751085967 165956.14254708588, 1007910.222680673 165956.0926784277, 1007910.2725493461 165956.04510633647, 1007910.4759609997 165955.8459597528, 1007910.6751075834 165955.64254808426, 1007910.7226796746 165955.59267942607, 1007910.7725483477 165955.54510733485, 1007910.9759600013 165955.34596075118, 1007911.175106585 165955.14254908264, 1007911.2226786762 165955.09268042445, 1007911.2725473344 165955.04510833323, 1007911.475959003 165954.84596174955, 1007912.0799604207 165954.20127800107, 1007912.6403267533 165953.51820850372, 1007913.1547614187 165952.80036216974, 1007913.3772019297 165952.44242325425, 1007913.4759550095 165952.34596675634, 1007913.6751015931 165952.1425550878, 1007913.7226736695 165952.09268642962, 1007913.7725423425 165952.0451143384, 1007913.9759540111 165951.84596775472, 1007914.1751005948 165951.64255608618, 1007914.2226726711 165951.592687428, 1007914.2725413442 165951.54511533678, 1007914.4759530127 165951.3459687531, 1007914.6750995964 165951.14255708456, 1007914.7226716727 165951.09268842638, 1007914.7725403458 165951.04511633515, 1007914.9759520143 165950.84596975148, 1007915.1750985831 165950.64255808294, 1007915.2226706743 165950.59268942475, 1007915.2725393474 165950.54511733353, 1007915.475951001 165950.34597074986, 1007915.6750975847 165950.14255909622, 1007915.722669676 165950.09269042313, 1007915.7725383341 165950.0451183319, 1007915.9759500027 165949.84597174823, 1007916.0743750036 165949.74525016546, 1007916.6921559274 165949.6845547557, 1007917.5638733357 165949.54052616656, 1007918.4241078347 165949.34006725252, 1007919.269578591 165949.08350609243, 1007920.0963485837 165948.77248309553, 1007920.9008089304 165948.40765441954, 1007921.6800068468 165947.99131667614, 1007922.4303334206 165947.52478216588, 1007923.1481797546 165947.01034750044, 1007923.831249252 165946.4499811679, 1007924.4759330004 165945.84597975016, 1007925.0799344182 165945.20129600167, 1007925.6403007507 165944.51822650433, 1007926.1547354311 165943.80005209148, 1007926.6212699264 165943.0500535816, 1007927.0379357636 165942.2708556652, 1007927.4024363458 165941.46606725454, 1007927.7134593427 165940.63929726183, 1007927.7698896676 165940.47263091803, 1007927.9007949233 165940.4076704234, 1007928.6799928397 165939.9913326651, 1007929.4303194284 165939.52479816973, 1007930.1481657624 165939.0103635043, 1007930.8312352598 165938.44999717176, 1007931.4759190083 165937.845995754, 1007932.079920426 165937.20131200552, 1007932.6402867585 165936.51824250817, 1007933.154721424 165935.80006809533, 1007933.3774900138 165935.4424572587, 1007933.4759149998 165935.3460007608, 1007934.0799164176 165934.7013170123, 1007934.6353615075 165934.02448108792, 1007934.6438916773 165934.01365433633, 1007934.6543903351 165934.00545226038, 1007935.3312262595 165933.44967909157, 1007935.975910008 165932.84600575268, 1007936.5799114257 165932.2013220042, 1007937.1402777582 165931.51825250685, 1007937.6547124237 165930.800078094, 1007938.121246919 165930.05007958412, 1007938.5379127562 165929.27088166773, 1007938.9024133384 165928.46609325707, 1007939.2134363353 165927.63932324946, 1007939.4699975103 165926.79418058693, 1007939.6704564244 165925.9336180091, 1007939.8144850135 165925.06222867966, 1007939.9010990113 165924.18296533823, 1007939.9299703389 165923.30009308457, 1007939.9299703389 165922.47266691923, 1007940.0379097611 165922.27089567482, 1007940.4024103433 165921.46610724926, 1007940.7134333402 165920.63933725655, 1007940.9699945003 165919.79419459403, 1007941.1704534292 165918.93363200128, 1007941.3144820035 165918.06224267185, 1007941.4010960013 165917.18297934532, 1007941.4299673438 165916.30010709167, 1007941.4299673438 165913.8463718444, 1007940.5029754043 165913.70642201602, 1007939.5879342258 165913.50246206298, 1007938.6892583369 165913.23547594246, 1007937.8112831711 165912.90675169227, 1007936.9582444428 165912.51787518707, 1007936.1342574953 165912.07072250542, 1007935.343297541 165911.56745087352, 1007934.5891804098 165911.01048823443, 1007933.8755442499 165910.40252158788, 1007933.205831915 165909.74648395923, 1007932.583274275 165909.0455403104, 1007932.0108748077 165908.30307223645, 1007931.4913949369 165907.5226616561, 1007931.0273408293 165906.7080735415, 1007930.6209512352 165905.86323775348, 1007930.2741867303 165904.9922300726, 1007929.9887202083 165904.09925253686, 1007929.7659288942 165903.18861318377, 1007929.6068875492 165902.2647052519, 1007929.5123634934 165901.33198598772, 1007929.4828127623 165900.39495517313, 1007928.8128665835 165900.329010427, 1007927.9299943447 165900.30013908446, 1007927.4299953431 165900.30013908446, 1007926.5471230894 165900.329010427, 1007925.7951560915 165900.40282917023, 1007925.4007999301 165900.19219967723, 1007924.5963395834 165899.827699095, 1007923.7695695907 165899.51634800434, 1007922.9240988344 165899.26011492312, 1007922.0638643354 165899.0593279153, 1007921.1921469271 165898.91562741995, 1007920.3128835857 165898.82901342213, 1007919.4300113469 165898.8001420945, 1007917.9300143421 165898.8001420945, 1007917.0471420884 165898.82901342213, 1007916.1678787619 165898.91562741995, 1007915.2961613387 165899.0593279153, 1007914.4359268397 165899.26011492312, 1007913.5904560834 165899.51634800434, 1007912.7636860907 165899.827699095, 1007911.9592257589 165900.19219967723, 1007911.1800278425 165900.60853742063, 1007910.4297012538 165901.07507191598, 1007909.7118549198 165901.5898346752, 1007909.0287854224 165902.15020100772, 1007908.384101674 165902.75420242548, 1007907.7801002562 165903.39888617396, 1007907.2197339237 165904.08162759244, 1007906.7052992582 165904.7998020053, 1007906.2387647629 165905.55012859404, 1007905.8220989257 165906.32899841666, 1007905.7951960862 165906.38870958984, 1007905.2325331718 165907.04979750514, 1007904.8024159223 165907.5816205889, 1007904.2879812568 165908.29979500175, 1007903.8214467615 165909.0501215905, 1007903.4051090032 165909.82899142802, 1007903.040608421 165910.63377983868, 1007902.7292573452 165911.4605498463, 1007902.4726961702 165912.30602058768, 1007902.4379193336 165912.44020667672, 1007901.881490007 165912.69217467308, 1007901.1022920907 165913.10851241648, 1007900.3522935957 165913.57504692674, 1007899.6341191679 165914.08980967104, 1007898.9510496706 165914.65017600358, 1007898.3063659221 165915.25417742133, 1007897.7023645043 165915.89886116982, 1007897.5393070877 165916.08849333227, 1007897.1511845142 165916.54813808203, 1007896.7935736775 165916.9648039192, 1007896.7574845105 165917.0067985952, 1007896.6495450884 165917.13376684487, 1007896.5311070085 165917.2748426795, 1007896.4743485898 165917.34341208637, 1007896.4156216681 165917.41066917777, 1007896.2952150851 165917.55010458827, 1007895.6495470852 165918.30863325298, 1007895.2197579294 165918.84012825787, 1007894.705323264 165919.55830267072, 1007894.2387887537 165920.30862925947, 1007893.8221229166 165921.08782717586, 1007893.4576223344 165921.89228750765, 1007893.1465993375 165922.71905750036, 1007892.8900381774 165923.56452825665, 1007892.6892511696 165924.42476275563, 1007892.5455506742 165925.29648017883, 1007892.4589366764 165926.17574350536, 1007892.4349865913 165926.70428575575, 1007892.3841336668 165926.75415442884, 1007891.7801322639 165927.39883817732, 1007891.2197659165 165928.0815795958, 1007890.7050031722 165928.79975400865, 1007890.4825626761 165929.15769292414, 1007890.3841376752 165929.25414942205, 1007889.7801362574 165929.89883317053, 1007889.7128791809 165929.9742923379, 1007889.590504095 165930.016286999, 1007888.7637340873 165930.32763808966, 1007887.9589456767 165930.69213867188, 1007887.1800758392 165931.10880450904, 1007886.4297492504 165931.57501092553, 1007885.7115748376 165932.08977366984, 1007885.0288334191 165932.65014000237, 1007884.3841496706 165933.25414142013, 1007883.7801482528 165933.8988251686, 1007883.2197819203 165934.5815665871, 1007882.705019176 165935.29974099994, 1007882.2388127595 165936.0500675887, 1007881.8221469223 165936.82926550508, 1007881.4576463401 165937.63372583687, 1007881.1462952644 165938.46049584448, 1007880.8900621682 165939.30596658587, 1007880.6892751753 165940.16620108485, 1007880.54557468 165941.03791850805, 1007880.4589606673 165941.91718183458, 1007880.4330420941 165942.70622225106, 1007879.6800908446 165943.10878050327, 1007878.9297642559 165943.57531499863, 1007878.211589843 165944.08974967897, 1007877.5288484246 165944.6501160115, 1007876.8841646761 165945.25411742926, 1007876.4202548414 165945.74164925516, 1007876.3972890079 165945.76723974943, 1007876.3716985136 165945.79020558298, 1007875.8841666728 165946.2541154176, 1007875.6850200891 165946.45752708614, 1007875.6371199191 165946.50706766546, 1007875.5875793397 165946.55496783555, 1007875.3841676712 165946.75411441922, 1007875.1850210875 165946.95752608776, 1007875.1371209174 165947.00706666708, 1007875.0875803381 165947.05496683717, 1007874.8841686696 165947.25411342084, 1007874.6850220859 165947.45752508938, 1007874.6371219307 165947.5070656687, 1007874.5875813365 165947.5549658388, 1007874.384169668 165947.75411242247, 1007873.7801682502 165948.39879617095, 1007873.2198019177 165949.0818656683, 1007872.7050391734 165949.79971200228, 1007872.238504678 165950.55003859103, 1007871.8221669197 165951.32923650742, 1007871.6335190088 165951.7281858325, 1007871.6154744178 165951.76788392663, 1007871.5944770873 165951.80594158173, 1007871.3221679181 165952.32923451066, 1007870.9576673359 165953.13369484246, 1007870.6463162601 165953.96046483517, 1007870.3900831789 165954.80593559146, 1007870.1892961711 165955.66617009044, 1007870.0455956757 165956.53788749874, 1007869.9589816779 165957.41715084016, 1007869.9301103354 165958.30002309382, 1007869.9301103354 165960.80001808703, 1007869.9589816779 165961.6828903407, 1007870.0455956757 165962.5621536672, 1007870.1892961711 165963.4338710904, 1007870.3900831789 165964.2941055894, 1007870.6463162601 165965.13957634568, 1007870.9576673359 165965.9663463384, 1007871.3221679181 165966.7708066702, 1007871.7385056764 165967.55000458658, 1007872.2050401717 165968.30033117533, 1007872.6712465882 165968.9519046694, 1007872.822164923 165969.2708016783, 1007873.0944740921 165969.79409459233, 1007873.1154714227 165969.83215226233, 1007873.1335160136 165969.87185034156, 1007873.3221639246 165970.27079966664, 1007873.738501668 165971.04999758303, 1007874.2050361782 165971.80032417178, 1007874.7197989225 165972.51817050576, 1007875.2801652551 165973.2012400031, 1007875.8841666728 165973.8459237516, 1007876.0875783414 165974.04507033527, 1007876.1371189207 165974.0926424265, 1007876.1850190908 165974.14251108468, 1007876.3841656744 165974.34592275321, 1007877.0288494229 165974.94992417097, 1007877.7115908414 165975.5102905035, 1007878.4297652543 165976.02472516894, 1007879.180091843 165976.4912596792, 1007879.9589616805 165976.90792550147, 1007880.7637500912 165977.27242608368, 1007881.5905200839 165977.5834490955, 1007882.4359908402 165977.84001025558, 1007883.2962253392 165978.04046916962, 1007883.6420251727 165978.10477350652, 1007883.6653190851 165978.10871051252, 1007883.6876287609 165978.11625641584, 1007884.4359868467 165978.3400092572, 1007885.2962213457 165978.54046817124, 1007886.167938754 165978.68449676037, 1007887.0472020954 165978.77111075819, 1007887.9300743341 165978.79998208582, 1007889.430071339 165978.79998208582, 1007890.3129435927 165978.77111075819, 1007891.1922069192 165978.68449676037, 1007892.0635962635 165978.54046817124, 1007892.9241588414 165978.3400092572, 1007893.7693015039 165978.0834480822, 1007894.5960715115 165977.7724250853, 1007895.4008599222 165977.4079245031, 1007896.1800578386 165976.99125866592, 1007896.9300563335 165976.52472417057, 1007897.6305142641 165976.0240690112, 1007897.6518396735 165976.0076648444, 1007897.6751335859 165975.99421341717), (1007899.4300513417 165947.80004408956, 1007898.93005234 165947.80004408956, 1007898.93005234 165945.80004808307, 1007898.4300533384 165945.80004808307, 1007898.4300533384 165945.30004909635, 1007897.9300543368 165945.30004909635, 1007897.9300543368 165944.80005009472, 1007897.4300553352 165944.80005009472, 1007897.4300553352 165945.30004909635, 1007896.9300563335 165945.30004909635, 1007896.9300563335 165945.80004808307, 1007896.4300573468 165945.80004808307, 1007896.4300573468 165946.3000470847, 1007895.9300583452 165946.3000470847, 1007895.9300583452 165946.8000460863, 1007895.4300593436 165946.8000460863, 1007895.4300593436 165946.3000470847, 1007893.9300623387 165946.3000470847, 1007893.9300623387 165942.80005408823, 1007896.9300563335 165942.80005408823, 1007896.9300563335 165942.3000550866, 1007897.9300543368 165942.3000550866, 1007897.9300543368 165941.30005708337, 1007898.4300533384 165941.30005708337, 1007898.4300533384 165940.80005808175, 1007898.93005234 165940.80005808175, 1007898.93005234 165940.30005909503, 1007899.4300513417 165940.30005909503, 1007899.4300513417 165939.8000600934, 1007899.9300503433 165939.8000600934, 1007899.9300503433 165938.80006209016, 1007900.4300493449 165938.80006209016, 1007900.4300493449 165938.30006308854, 1007900.9300483465 165938.30006308854, 1007900.9300483465 165937.8000640869, 1007901.4300473332 165937.8000640869, 1007901.4300473332 165937.3000650853, 1007901.9300463349 165937.3000650853, 1007901.9300463349 165936.30006708205, 1007902.4300453365 165936.30006708205, 1007902.4300453365 165935.80006809533, 1007903.4300433397 165935.80006809533, 1007903.4300433397 165935.3000690937, 1007903.9300423414 165935.3000690937, 1007903.9300423414 165934.80007009208, 1007904.430041343 165934.80007009208, 1007904.430041343 165934.30007109046, 1007904.9300403446 165934.30007109046, 1007904.9300403446 165933.80007208884, 1007905.4300393462 165933.80007208884, 1007905.4300393462 165933.30007308722, 1007905.9300383329 165933.30007308722, 1007905.9300383329 165932.8000740856, 1007906.4300373346 165932.8000740856, 1007906.4300373346 165931.80007608235, 1007906.9300363362 165931.80007608235, 1007906.9300363362 165929.30008108914, 1007906.4300373346 165929.30008108914, 1007906.4300373346 165928.3000830859, 1007905.9300383329 165928.3000830859, 1007905.9300383329 165927.05861575902, 1007906.5757063478 165926.3000870943, 1007906.9300363362 165926.3000870943, 1007906.9300363362 165925.883749336, 1007907.0379757583 165925.75678108633, 1007907.4300353378 165925.30008909106, 1007907.8522785902 165924.80009008944, 1007907.9300343394 165924.80009008944, 1007907.9300343394 165925.30008909106, 1007908.9300323427 165925.30008909106, 1007908.9300323427 165925.80008809268, 1007910.9300283343 165925.80008809268, 1007910.9300283343 165925.30008909106, 1007911.9300263375 165925.30008909106, 1007911.9300263375 165924.80009008944, 1007912.4300253391 165924.80009008944, 1007912.4300253391 165924.30009108782, 1007912.9300243407 165924.30009108782, 1007912.9300243407 165923.8000920862, 1007913.4300233424 165923.8000920862, 1007913.4300233424 165923.30009308457, 1007913.930022344 165923.30009308457, 1007913.930022344 165922.80009408295, 1007914.4300213456 165922.80009408295, 1007914.4300213456 165922.30009509623, 1007914.9300203472 165922.30009509623, 1007914.9300203472 165921.300097093, 1007915.430019334 165921.300097093, 1007915.430019334 165920.30009908974, 1007915.9300183356 165920.30009908974, 1007915.9300183356 165918.30010308325, 1007916.4300173372 165918.30010308325, 1007916.4300173372 165916.30010709167, 1007915.9300183356 165916.30010709167, 1007915.9300183356 165915.80010809004, 1007915.5126963407 165915.80010809004, 1007918.156719923 165912.6938150823, 1007917.9300143421 165912.5009020865, 1007917.9300143421 165912.3001150936, 1007919.4300113469 165912.3001150936, 1007919.4300113469 165912.8001140952, 1007919.9300103337 165912.8001140952, 1007919.9300103337 165913.80011208355, 1007920.4300093353 165913.80011208355, 1007920.4300093353 165914.30011108518, 1007920.9300083369 165914.30011108518, 1007920.9300083369 165914.8001100868, 1007921.4300073385 165914.8001100868, 1007921.4300073385 165915.30010908842, 1007921.9300063401 165915.30010908842, 1007921.9300063401 165915.80010809004, 1007922.9300043434 165915.80010809004, 1007922.9300043434 165916.30010709167, 1007924.930000335 165916.30010709167, 1007924.930000335 165915.80010809004, 1007925.4299993366 165915.80010809004, 1007925.4299993366 165915.30010908842, 1007925.9299983382 165915.30010908842, 1007925.9299983382 165914.30011108518, 1007927.4299953431 165914.30011108518, 1007927.4299953431 165913.80011208355, 1007927.9299943447 165913.80011208355, 1007927.9299943447 165916.30010709167, 1007927.4299953431 165916.30010709167, 1007927.4299953431 165916.8001060933, 1007926.9299963415 165916.8001060933, 1007926.9299963415 165917.3001050949, 1007926.4299973398 165917.3001050949, 1007926.4299973398 165923.30009308457, 1007925.4299993366 165923.30009308457, 1007925.4299993366 165923.8000920862, 1007924.930000335 165923.8000920862, 1007924.930000335 165924.30009108782, 1007924.4300013334 165924.30009108782, 1007924.4300013334 165924.80009008944, 1007923.9300023466 165924.80009008944, 1007923.9300023466 165925.80008809268, 1007923.430003345 165925.80008809268, 1007923.430003345 165926.3000870943, 1007922.9300043434 165926.3000870943, 1007922.9300043434 165926.80008609593, 1007922.4300053418 165926.80008609593, 1007922.4300053418 165927.30008508265, 1007921.9300063401 165927.30008508265, 1007921.9300063401 165928.3000830859, 1007918.4300133437 165928.3000830859, 1007918.4300133437 165928.80008208752, 1007917.4300153404 165928.80008208752, 1007917.4300153404 165929.30008108914, 1007916.9300163388 165929.30008108914, 1007916.9300163388 165929.80008009076, 1007916.4300173372 165929.80008009076, 1007916.4300173372 165930.30007909238, 1007915.430019334 165930.30007909238, 1007915.430019334 165929.80008009076, 1007914.4300213456 165929.80008009076, 1007914.4300213456 165930.30007909238, 1007913.4300233424 165930.30007909238, 1007913.4300233424 165931.30007709563, 1007912.9300243407 165931.30007709563, 1007912.9300243407 165932.8000740856, 1007913.4300233424 165932.8000740856, 1007913.4300233424 165933.30007308722, 1007913.930022344 165933.30007308722, 1007913.930022344 165933.80007208884, 1007914.9300203472 165933.80007208884, 1007914.9300203472 165936.30006708205, 1007914.4300213456 165936.30006708205, 1007914.4300213456 165935.80006809533, 1007913.930022344 165935.80006809533, 1007913.930022344 165935.3000690937, 1007910.9300283343 165935.3000690937, 1007910.9300283343 165935.80006809533, 1007910.4300293475 165935.80006809533, 1007910.4300293475 165936.30006708205, 1007909.9300303459 165936.30006708205, 1007909.9300303459 165936.80006608367, 1007908.9300323427 165936.80006608367, 1007908.9300323427 165937.3000650853, 1007908.430033341 165937.3000650853, 1007908.430033341 165937.8000640869, 1007907.9300343394 165937.8000640869, 1007907.9300343394 165938.30006308854, 1007907.4300353378 165938.30006308854, 1007907.4300353378 165939.30006109178, 1007906.9300363362 165939.30006109178, 1007906.9300363362 165939.8000600934, 1007906.4300373346 165939.8000600934, 1007906.4300373346 165940.30005909503, 1007905.9300383329 165940.30005909503, 1007905.9300383329 165940.80005808175, 1007905.4300393462 165940.80005808175, 1007905.4300393462 165941.30005708337, 1007904.9300403446 165941.30005708337, 1007904.9300403446 165941.800056085, 1007904.430041343 165941.800056085, 1007904.430041343 165942.3000550866, 1007903.9300423414 165942.3000550866, 1007903.9300423414 165942.80005408823, 1007903.4300433397 165942.80005408823, 1007903.4300433397 165943.30005308986, 1007902.9300443381 165943.30005308986, 1007902.9300443381 165943.80005209148, 1007902.4300453365 165943.80005209148, 1007902.4300453365 165944.3000510931, 1007901.9300463349 165944.3000510931, 1007901.9300463349 165945.30004909635, 1007901.4300473332 165945.30004909635, 1007901.4300473332 165945.80004808307, 1007900.9300483465 165945.80004808307, 1007900.9300483465 165946.3000470847, 1007900.4300493449 165946.3000470847, 1007900.4300493449 165946.8000460863, 1007899.9300503433 165946.8000460863, 1007899.9300503433 165947.30004508793, 1007899.4300513417 165947.30004508793, 1007899.4300513417 165947.80004408956)), ((1007890.3657650054 165975.80654975772, 1007891.3074774145 165975.7736644372, 1007892.2446018754 165975.6751686893, 1007893.1725728511 165975.51154237238, 1007894.0868693291 165975.28358265755, 1007894.983036965 165974.99240013954, 1007895.8567096888 165974.6394134387, 1007896.7036311327 165974.22634226826, 1007897.5196750759 165973.75519905981, 1007898.3008659183 165973.22827918825, 1007899.0433977543 165972.64814974365, 1007899.7436530291 165972.0176370665, 1007900.3982201515 165971.33981294927, 1007901.0039101838 165970.6179796755, 1007901.5577722489 165969.8556539565, 1007902.0571079849 165969.0565497577, 1007902.4994846581 165968.22456024584, 1007902.882747054 165967.36373877522, 1007903.2050279974 165966.47827918825, 1007903.4647573231 165965.57249534872, 1007903.6606696843 165964.65080016103, 1007903.7918106018 165963.7176840156, 1007903.8575411736 165962.77769296613, 1007903.8575411736 165961.8354065567, 1007903.7918106018 165960.89541550723, 1007903.6606696843 165959.9622993618, 1007903.4647573231 165959.04060416666, 1007903.2050279974 165958.13482033458, 1007902.882747054 165957.2493607476, 1007902.4994846581 165956.388539277, 1007902.0571079849 165955.5565497577, 1007901.5577722489 165954.75744556633, 1007901.0039101838 165953.99511984733, 1007900.3982201515 165953.27328657356, 1007899.7436530291 165952.59546245632, 1007899.0433977543 165951.96494977918, 1007898.3008659183 165951.38482033458, 1007897.5196750759 165950.85790046302, 1007896.7036311327 165950.38675725457, 1007895.8567096888 165949.97368608412, 1007894.983036965 165949.6206993833, 1007894.0868693291 165949.32951686528, 1007893.1725728511 165949.10155715045, 1007892.2446018754 165948.93793082607, 1007891.3074774145 165948.83943508563, 1007890.3657650054 165948.80654975696, 1007889.4240526258 165948.83943508563, 1007888.4869281648 165948.93793082607, 1007887.5589571892 165949.10155715045, 1007886.6446607112 165949.32951686528, 1007885.7484930753 165949.6206993833, 1007884.8748203515 165949.97368608412, 1007884.0278989075 165950.38675725457, 1007883.2118549644 165950.85790046302, 1007882.430664122 165951.38482033458, 1007881.688132286 165951.96494977918, 1007880.9878770112 165952.59546245632, 1007880.3333098887 165953.27328657356, 1007879.7276198565 165953.99511984733, 1007879.1737577914 165954.75744556633, 1007878.6744220554 165955.5565497577, 1007878.2320453821 165956.388539277, 1007877.8487829863 165957.2493607476, 1007877.5265020429 165958.13482033458, 1007877.2667727171 165959.04060416666, 1007877.070860356 165959.9622993618, 1007876.9397194384 165960.89541550723, 1007876.8739888667 165961.8354065567, 1007876.8739888667 165962.77769296613, 1007876.9397194384 165963.7176840156, 1007877.070860356 165964.65080016103, 1007877.2667727171 165965.57249534872, 1007877.5265020429 165966.47827918825, 1007877.8487829863 165967.36373877522, 1007878.2320453821 165968.22456024584, 1007878.6744220554 165969.0565497577, 1007879.1737577914 165969.8556539565, 1007879.7276198565 165970.6179796755, 1007880.3333098887 165971.33981294927, 1007880.9878770112 165972.0176370665, 1007881.688132286 165972.64814974365, 1007882.430664122 165973.22827918825, 1007883.2118549644 165973.75519905981, 1007884.0278989075 165974.22634226826, 1007884.8748203515 165974.6394134387, 1007885.7484930753 165974.99240013954, 1007886.6446607112 165975.28358265755, 1007887.5589571892 165975.51154237238, 1007888.4869281648 165975.6751686893, 1007889.4240526258 165975.7736644372, 1007890.3657650054 165975.80654975772))) '), st_geomfromtext('POLYGON ((1007898.2646993101 165955.73802031577, 1007898.2646993101 165958.7380143106, 1007895.2647053003 165958.7380143106, 1007895.2647053003 165961.1422873552, 1007903.0009145737 165967.71595335007, 1007916.4510178566 165951.53980731964, 1007917.8975553513 165949.8003230095, 1007910.2646753043 165943.3143946815, 1007910.2646753043 165943.73771622777, 1007907.2646813095 165943.73771622777, 1007907.2646813095 165949.7380323112, 1007904.2646872997 165949.7380323112, 1007904.2646872997 165952.73802630603, 1007901.2646933049 165952.73802630603, 1007901.2646933049 165955.73802031577, 1007898.2646993101 165955.73802031577)) ')) --SQL Error [XX000]: ERROR: lwgeom_intersection_prec: GEOS Error: TopologyException: Directed Edge visited twice during ring-building at 1007901.2646933049 165954.35405701387
Again - I checked validity of both of the objects and they come back valid using
select st_isvalid([insert st_geomfromtext]);
Thanks to the devs who work on this and who have made PostGIS such a powerful and robust product!
Best, Mike Treglia
Attachments (1)
Change History (9)
comment:1 by , 4 years ago
comment:2 by , 4 years ago
JTS reports the first geometry as invalid, due to the two element polygons overlapping.
So the next question is why is this polygon being reported as valid by GEOS?
by , 4 years ago
Attachment: | pg-4893-invalid-multipolygon.png added |
---|
comment:4 by , 4 years ago
To clarify, this is not an issue with ST_Intersection
. The issue is that GEOS is incorrectly reporting a MultiPolygon with nested shells and a hole as valid. ST_Intersection
is failing as expected when used on invalid geometry.
The GEOS IsValid issue is due to a bug. This is now fixed.
comment:5 by , 4 years ago
Milestone: | PostGIS 3.1.2 → 3.1.3 |
---|
comment:8 by , 3 years ago
Milestone: | PostGIS 3.1.4 → PostGIS GEOS |
---|---|
Resolution: | → fixed |
Status: | new → closed |
Martin says it's fixed in GEOS. I tested on
POSTGIS="3.1.4dev 3.1.3-25-gef2995b4a" [EXTENSION] PGSQL="140" GEOS="3.10.0dev-CAPI-1.15.0" PROJ="7.1.1" LIBXML="2.9.9" LIBJSON="0.12" LIBPROTOBUF="1.2.1" WAGYU="0.5.0 (Internal)"
my GEOS 3.10 branch and the first polygon indeed now returns false for ST_IsValid.
Only question for this is which version of GEOS was this fixed in. Anyrate it's a geos bug so pushing to PostGIS GEOS and closing.
On my production running:
POSTGIS="3.1.2 3.1.2" [EXTENSION] PGSQL="120" GEOS="3.9.1-CAPI-1.14.1" PROJ="7.1.1" LIBXML="2.9.9" LIBJSON="0.12" LIBPROTOBUF="1.2.1" WAGYU="0.5.0 (Internal)" (core procs from "3.1.1 3.1.1" need upgrade)
The first polygon returns ST_IsValid = true.
So I assume this was fixed either in 3.10 or not yet released GEOS 3.9.2
Confirmed on OSX, latest GEOS main. Both inputs valid, topology exception on intersection.