Opened 8 years ago

Last modified 7 years ago

#1115 assigned defect

Numerical problem in ST_Polygonize

Reported by: gabrimonfa Owned by: strk
Priority: medium Milestone: PostGIS GEOS
Component: postgis Version: 1.5.X
Keywords: Cc:

Description

I'm having what seems a numerical problem cutting a polygon with a linestring using ST_Polygonize. I use ST_union on the boundary of the polygon and the linestring and then use ST_Polygonize to find all possible polygons.

At the end of the ticket there is the query

The expected result of the query is a collection with two polygons, instead I get only one. I've found that if I reduce the precision of the input to ST_Polygonize using ST_SnapToGrid under 10-12 the problem disappear.

I've reproduced the problem on Postgis 1.3.3 and on Postgis 1.5.2 w GEOS=3.3.0-CAPI-1.7.0


Original query:


SELECT AsText?(ST_Polygonize(ST_Union(ST_Boundary(poly), line))) AS mpoly FROM

(SELECT '0103000000010000002D0100003C0AD7E32D4E3A4152B81E250A44524190C2F5282D4E3A41D8A3702D0A44524114AE47E1244E3A41E27A14AE0A4452410CD7A3B0214E3A4186EB51D80A4452410CD7A3701D4E3A4114AE47210B4452410CD7A3B0194E3A4152B81E550B445241703D0A57154E3A4152B81E950B44524190C2F528114E3A41E27A14EE0B445241989999990E4E3A4148E17A040C44524148E17AD4094E3A41AE47E14A0C445241A4703D8A054E3A41666666960C44524184EB5178FD4D3A41B81E852B0D445241B81E85ABFC4D3A41B81E850B0D4452415C8FC2B5F44D3A41343333930D4452412085EB51EE4D3A41CCCCCCFC0D445241989999D9EA4D3A41D8A3702D0E445241000000C0E04D3A41EC51B8BE0E445241EC51B8DEDE4D3A4186EB51D80E445241EC51B8DEDB4D3A410AD7A3000F445241B047E17AC64D3A410000002010445241F4285C0FC34D3A4114AE47811144524150B81E45BE4D3A41A4703D8A104452413C0AD7A3B74D3A41A4703DEA104452412085EBD1B54D3A41AE47E1FA10445241D8A3703DA84D3A41CCCCCCBC11445241686666A6A14D3A41B81E850B124452417C14AE07A14D3A415C8FC21512445241EC51B81E9B4D3A4152B81E75124452415C8FC2358A4D3A417A14AE8713445241285C8F02894D3A4190C2F528124452417C14AE07674D3A41EC51B8DE1344524150B81E45624D3A41CCCCCCFC134452412085EB115C4D3A41CCCCCC3C14445241EC51B8DE5B4D3A4190C2F50814445241285C8F42544D3A41D8A3704D14445241285C8F824F4D3A4114AE47C11444524198999959504D3A41EC51B86E164452412085EB51484D3A4190C2F5C8164452415C8FC235414D3A41D8A3701D1744524114AE47612E4D3A4186EB51D81744524134333333274D3A415C8FC22518445241E07A142E114D3A4114AE471119445241E07A146EEF4C3A41285C8F521A445241703D0A57E74C3A41B81E858B1A4452410CD7A370D54C3A41285C8F121B44524168666626CE4C3A417A14AE571B4452412085EBD1B74C3A417A14AE371C4452417C14AE07B64C3A41EC51B83E1C445241703D0AD7A14C3A417A14AE171D445241B047E13A9C4C3A41E27A144E1D4452415C8FC235984C3A41A4703D6A1D445241B047E1BA8B4C3A41A4703DEA1D4452412085EB91884C3A417A14AE071E4452413C0AD7A3864C3A4186EB51181E445241343333B3834C3A41343333331E445241000000407F4C3A41343333631E44524148E17A547D4C3A41000000801F4452410CD7A330794C3A410AD7A3901E445241F4285C4F754C3A41343333B31E4452417C14AE47734C3A4152B81EC51E4452413C0AD7A3704C3A41CCCCCCDC1E44524150B81E856D4C3A4186EB51F81E445241B047E17A664C3A4148E17A241F4452412085EBD1614C3A4114AE47311F44524114AE47E1554C3A410AD7A3601F445241989999D9534C3A41CCCCCC6C1F44524150B81E85464C3A415C8FC2651F445241B047E17A434C3A41A4703D5A1F445241CCCCCC4C374C3A41AE47E14A1F445241B81E852B324C3A419A9999491F445241343333332A4C3A41343333331F445241285C8F82214C3A4148E17A341F445241703D0AD70D4C3A41343333331F44524168666666054C3A41A4703D3A1F445241285C8F82FE4B3A41EC51B83E1F445241D8A370BDF94B3A415C8FC24520445241B047E17AF54B3A41285C8F221F44524198999999F44B3A41AE47E12A1F4452410CD7A370F04B3A41AE47E12A1F445241EC51B85EEE4B3A41C2F5282C1F44524184EB51B8E94B3A4190C2F5281F44524150B81E05E74B3A419A9999291F44524134333373DC4B3A4152B81E351F44524114AE4761DA4B3A413E0AD7331F445241E07A142ED64B3A41EC51B82E1F4452412085EB11D34B3A41F6285C2F1F445241B81E852BCA4B3A41EC51B82E1F44524198999999C64B3A41C2F5283C1F4452412085EB91A64B3A41CCCCCC4C1F4452412085EB91964B3A41C2F5284C1F44524114AE4721904B3A41C2F5285C1F445241343333F3894B3A41AE47E13A204452415C8FC2F5874B3A415C8FC2D51E445241D8A3703D6F4B3A415C8FC2F51E445241EC51B8DE544B3A4186EB51281F445241D8A3703D524B3A41666666361F445241E07A142E384B3A41666666A61F44524184EB51B8324B3A410AD7A3C01F44524184EB5138264B3A41000000B01F44524198999919234B3A419A9999B91F445241F4285C8F0C4B3A41F6285CCF1F44524150B81E85074B3A41B81E858B214452413C0AD7E3024B3A41E27A14CE1F445241D8A3707DF74A3A41F6285C8F1F445241EC51B8DEF44A3A41E27A147E1F445241B047E1BAE84A3A41C2F5284C1F445241D8A370FDE44A3A4114AE47311F445241B81E85EBD64A3A417A14AEF71E44524190C2F568CB4A3A415C8FC2C51E44524190C2F5A8C44A3A41D8A370AD1E44524168666626C04A3A41E27A148E1E4452417C14AE47AF4A3A41CCCCCC8C1F4452413C0AD7639E4A3A41E27A14FE1D445241B047E1FA944A3A4186EB51E81D44524198999999904A3A4152B81EC51D4452410CD7A3B0834A3A415C8FC2651D4452412085EB91744A3A41CCCCCCEC1C445241343333B3734A3A41666666B61B445241989999D96F4A3A41D8A3709D1B44524134333333664A3A4190C2F5581B445241703D0A57614A3A41D8A3701D1B445241343333335C4A3A4148E17A141B445241B81E852B4B4A3A41EC51B88E1A44524148E17A94484A3A41703D0A771A445241285C8F02324A3A41CCCCCC5C194452412085EB91284A3A417A14AE271944524184EB5138294A3A4152B81E851C445241285C8F42354A3A41A4703D6A1E4452412085EBD1424A3A410AD7A3801E445241CCCCCC0C474A3A415C8FC2851E445241285C8F02474A3A419A9999F91F44524190C2F5E8464A3A41D8A370CD2144524114AE47214A4A3A41C2F528CC2144524150B81E854A4A3A41EC51B83E21445241989999D9494A3A41703D0A3721445241D8A3707D4A4A3A41CCCCCC4C20445241285C8F024A4A3A41703D0A4720445241343333B34A4A3A41AE47E14A1F44524114AE47214A4A3A4148E17A441F44524114AE47E14A4A3A41343333331E445241C4F5285C4F4A3A415C8FC2651E445241000000404F4A3A41CCCCCC8C1E445241CCCCCC4C554A3A4114AE47D11E445241703D0A97524A3A41000000B0224452415C8FC275514A3A41CCCCCC0C24445241B047E17A4F4A3A41CCCCCC6C26445241703D0A574D4A3A415C8FC26529445241C4F5289C4B4A3A415C8FC2C52B44524150B81E45514A3A4148E17AE42B44524150B81E45534A3A410AD7A3F02844524150B81EC5574A3A41000000F022445241000000805A4A3A410AD7A3501E44524190C2F5285D4A3A41EC51B86E1E445241F4285CCF5F4A3A4152B81E851E44524184EB5138644A3A411E85EBB11E44524190C2F5E8664A3A41EC51B8CE1E4452415C8FC2F56F4A3A4148E17A341F445241D8A370BD714A3A419A9999491F4452417C14AE87734A3A41343333531F445241B81E856B754A3A41703D0A271F445241A4703D8A834A3A413E0AD7D31F44524168666666854A3A4190C2F5E81F44524184EB5138874A3A41E27A14FE1F44524150B81E45874A3A41EC51B8FE1F4452417C14AEC7884A3A4100000010204452410CD7A3B0904A3A41A4703D6A204452413C0AD7E39C4A3A41F6285CAF20445241C4F5289CB14A3A417A14AE1721445241A4703D8ABE4A3A41CCCCCC8C21445241EC51B89EC94A3A410AD7A3402244524148E17A54CE4A3A415C8FC2B522445241D8A3703DD54A3A41B81E856B20445241D8A370BDF24A3A41EC51B81E234452412085EBD1FF4A3A41EC51B83E234452415C8FC2750A4B3A417A14AE5723445241686666A60D4B3A41285C8F5223445241EC51B85E0F4B3A41EC51B84E23445241F4285C0F124B3A4186EB5148234452410CD7A3F01B4B3A410AD7A3302344524198999919284B3A41CCCCCCCC22445241CCCCCC0C2A4B3A41A4703D0A22445241E07A146E354B3A41AE47E10A22445241C4F5289C4A4B3A4186EB51F821445241686666A65A4B3A4186EB51B82144524184EB51F8614B3A415C8FC2A52144524198999999644B3A417A14AEA7214452415C8FC2B5664B3A41A4703DAA2144524184EB51B8734B3A41AE47E18A214452413C0AD7A3774B3A4186EB519821445241343333738F4B3A410AD7A38021445241B81E85EB994B3A41EC51B86E2144524190C2F5E8AB4B3A41B81E857B21445241A4703D0AAF4B3A416666666620445241A4703D0AB24B3A41CCCCCC8C2144524148E17AD4B64B3A41D8A3707D2144524114AE47E1BB4B3A410AD7A380214452410CD7A3B0BF4B3A415C8FC275214452415C8FC2F5FF4B3A41666666662144524198999999074C3A4148E17A642144524114AE4761194C3A4186EB51782144524114AE47E11C4C3A4186EB517821445241989999592E4C3A410AD7A3702144524198999919324C3A41B81E854B2044524190C2F5A8354C3A4152B81E7521445241285C8FC2394C3A41A4703D6A21445241CCCCCC8C4A4C3A41343333B32144524184EB51F84D4C3A41A4703DBA21445241C4F5289C514C3A41CCCCCCBC21445241C4F5281C5C4C3A41D8A370AD21445241A4703D4A5E4C3A41EC51B89E214452410CD7A3F0614C3A41E27A145E20445241CCCCCCCC664C3A413E0AD763214452417C14AE87694C3A411E85EB5121445241B047E1BA6F4C3A41C2F5281C214452410CD7A3B0754C3A415C8FC2E520445241D8A3707D814C3A41A4703D6A2044524134333373834C3A415C8FC2552044524114AE47E1874C3A41703D0A2720445241F4285C4F884C3A41AE47E1CA2044524148E17AD4884C3A41F6285C3F21445241EC51B89E8A4C3A41EC51B8DE23445241B047E1BA8B4C3A413E0AD7132544524190C2F5E88F4C3A41D8A3708D2A44524168666666954C3A413E0AD7532A445241989999D9994C3A41EC51B81E2A44524184EB5138984C3A410AD7A3D0274452410CD7A3B0954C3A41F6285C6F2444524114AE47A1944C3A41F6285C3F2444524150B81E05924C3A41CCCCCC7C204452413C0AD723964C3A41EC51B8CE1F445241000000C09B4C3A41343333A31F445241C4F5285CA14C3A41D8A3705D1F445241D8A370BDA34C3A413E0AD7531F44524134333333AF4C3A41EC51B8CE1E44524114AE47E1B44C3A4186EB51A81E445241D8A370FDD04C3A41EC51B86E1D44524114AE47A1DA4C3A4152B81E151D445241285C8F02DC4C3A41343333931D44524184EB51F8DD4C3A410AD7A3801D445241E07A146EE04C3A4152B81E651D445241A4703D8AE24C3A411E85EBD11D4452417C14AE07E44C3A41A4703DAA1B445241A4703D8AEA4C3A41703D0AA71C445241B81E856B124D3A411E85EB311B44524134333373214D3A41666666B61A4452410CD7A330224D3A410AD7A3A01A445241C4F5281C3D4D3A41B81E858B194452410CD7A3703E4D3A41EC51B87E194452417C14AE074D4D3A4114AE47E118445241B81E852B5C4D3A41D8A3702D184452415C8FC275634D3A41B81E85DB17445241703D0A17704D3A4114AE473117445241C4F5289C784D3A410AD7A3C016445241A4703D4A7E4D3A4186EB517816445241CCCCCC4C804D3A41E27A148E1444524100000080864D3A41343333F315445241B047E1BA8B4D3A41343333B31544524184EB5178AD4D3A41CCCCCCDC134452410CD7A330C84D3A41AE47E16A12445241C4F5289CD44D3A41EC51B8BE11445241285C8F02E44D3A41A4703DEA104452415C8FC275E84D3A41C2F528AC104452413C0AD763EC4D3A4190C2F58810445241B81E85EBF04D3A41000000401044524198999999F44D3A4134333303104452412085EB51FE4D3A41D8A3707D0F4452412085EBD1014E3A410AD7A3600F445241B047E1FA064E3A4114AE47110F445241E07A146E0B4E3A415C8FC2C50E44524150B81EC5164E3A41F6285C0F0E445241EC51B8DE1E4E3A4186EB51980D445241F4285C4F244E3A41AE47E14A0D4452417C14AE87274E3A41000000100D445241A4703DCA2B4E3A4186EB51C80C445241CCCCCC8C2E4E3A41666666A60C44524190C2F528334E3A41703D0A670C445241EC51B81E354E3A415C8FC2650C4452415C8FC235364E3A4190C2F5280C445241D8A370BD3A4E3A419A9999E90B445241CCCCCC8C3C4E3A41EC51B8BE0B4452412085EB51414E3A41A4703D7A0B4452417C14AE87434E3A415C8FC2550B44524190C2F568444E3A41703D0A470B445241A4703D4A464E3A41EC51B82E0B44524114AE47E14E4E3A41A4703DAA0A4452412085EB91514E3A41EC51B86E0A445241B81E852B534E3A41AE47E15A0A44524148E17A54554E3A4186EB51480A44524100000000604E3A413E0AD7A30944524100000000604E3A419A9999C9064452412085EB515F4E3A41B81E85DB064452410CD7A3F05B4E3A4114AE4761074452410CD7A3B0594E3A4186EB518807445241CCCCCCCC574E3A4186EB51A807445241000000804E4E3A41EC51B83E08445241343333734A4E3A4114AE47710844524148E17A94404E3A41C2F5280C0944524150B81E053F4E3A41F6285C1F094452413C0AD7A3384E3A41EC51B87E09445241F4285C8F354E3A4186EB51A8094452413C0AD7E32D4E3A4152B81E250A445241'::geometry AS poly) AS a,

(SELECT 'LINESTRING (1722934.9928987455 4788348.64891073,1722933.26000001 4788345.6600000001,1722933.4352710573 4788343.3010556679,1722937.6408658153 4788340.2896421375,1722941.0157258064 4788339.1993027553,1722944.2867439515 4788339.1473818328,1722951.2960685482 4788340.4973258292,1722951.05 4788346.0899999999,1722947.4539202508 4788349.1161990371)'::geometry AS line) as b


Query with ST_SnapToGrid that solves the problem:


SELECT AsText?(ST_Polygonize(ST_SnapToGrid(ST_Union(ST_Boundary(poly), line),0.00000000001))) AS mpoly FROM

(SELECT '0103000000010000002D0100003C0AD7E32D4E3A4152B81E250A44524190C2F5282D4E3A41D8A3702D0A44524114AE47E1244E3A41E27A14AE0A4452410CD7A3B0214E3A4186EB51D80A4452410CD7A3701D4E3A4114AE47210B4452410CD7A3B0194E3A4152B81E550B445241703D0A57154E3A4152B81E950B44524190C2F528114E3A41E27A14EE0B445241989999990E4E3A4148E17A040C44524148E17AD4094E3A41AE47E14A0C445241A4703D8A054E3A41666666960C44524184EB5178FD4D3A41B81E852B0D445241B81E85ABFC4D3A41B81E850B0D4452415C8FC2B5F44D3A41343333930D4452412085EB51EE4D3A41CCCCCCFC0D445241989999D9EA4D3A41D8A3702D0E445241000000C0E04D3A41EC51B8BE0E445241EC51B8DEDE4D3A4186EB51D80E445241EC51B8DEDB4D3A410AD7A3000F445241B047E17AC64D3A410000002010445241F4285C0FC34D3A4114AE47811144524150B81E45BE4D3A41A4703D8A104452413C0AD7A3B74D3A41A4703DEA104452412085EBD1B54D3A41AE47E1FA10445241D8A3703DA84D3A41CCCCCCBC11445241686666A6A14D3A41B81E850B124452417C14AE07A14D3A415C8FC21512445241EC51B81E9B4D3A4152B81E75124452415C8FC2358A4D3A417A14AE8713445241285C8F02894D3A4190C2F528124452417C14AE07674D3A41EC51B8DE1344524150B81E45624D3A41CCCCCCFC134452412085EB115C4D3A41CCCCCC3C14445241EC51B8DE5B4D3A4190C2F50814445241285C8F42544D3A41D8A3704D14445241285C8F824F4D3A4114AE47C11444524198999959504D3A41EC51B86E164452412085EB51484D3A4190C2F5C8164452415C8FC235414D3A41D8A3701D1744524114AE47612E4D3A4186EB51D81744524134333333274D3A415C8FC22518445241E07A142E114D3A4114AE471119445241E07A146EEF4C3A41285C8F521A445241703D0A57E74C3A41B81E858B1A4452410CD7A370D54C3A41285C8F121B44524168666626CE4C3A417A14AE571B4452412085EBD1B74C3A417A14AE371C4452417C14AE07B64C3A41EC51B83E1C445241703D0AD7A14C3A417A14AE171D445241B047E13A9C4C3A41E27A144E1D4452415C8FC235984C3A41A4703D6A1D445241B047E1BA8B4C3A41A4703DEA1D4452412085EB91884C3A417A14AE071E4452413C0AD7A3864C3A4186EB51181E445241343333B3834C3A41343333331E445241000000407F4C3A41343333631E44524148E17A547D4C3A41000000801F4452410CD7A330794C3A410AD7A3901E445241F4285C4F754C3A41343333B31E4452417C14AE47734C3A4152B81EC51E4452413C0AD7A3704C3A41CCCCCCDC1E44524150B81E856D4C3A4186EB51F81E445241B047E17A664C3A4148E17A241F4452412085EBD1614C3A4114AE47311F44524114AE47E1554C3A410AD7A3601F445241989999D9534C3A41CCCCCC6C1F44524150B81E85464C3A415C8FC2651F445241B047E17A434C3A41A4703D5A1F445241CCCCCC4C374C3A41AE47E14A1F445241B81E852B324C3A419A9999491F445241343333332A4C3A41343333331F445241285C8F82214C3A4148E17A341F445241703D0AD70D4C3A41343333331F44524168666666054C3A41A4703D3A1F445241285C8F82FE4B3A41EC51B83E1F445241D8A370BDF94B3A415C8FC24520445241B047E17AF54B3A41285C8F221F44524198999999F44B3A41AE47E12A1F4452410CD7A370F04B3A41AE47E12A1F445241EC51B85EEE4B3A41C2F5282C1F44524184EB51B8E94B3A4190C2F5281F44524150B81E05E74B3A419A9999291F44524134333373DC4B3A4152B81E351F44524114AE4761DA4B3A413E0AD7331F445241E07A142ED64B3A41EC51B82E1F4452412085EB11D34B3A41F6285C2F1F445241B81E852BCA4B3A41EC51B82E1F44524198999999C64B3A41C2F5283C1F4452412085EB91A64B3A41CCCCCC4C1F4452412085EB91964B3A41C2F5284C1F44524114AE4721904B3A41C2F5285C1F445241343333F3894B3A41AE47E13A204452415C8FC2F5874B3A415C8FC2D51E445241D8A3703D6F4B3A415C8FC2F51E445241EC51B8DE544B3A4186EB51281F445241D8A3703D524B3A41666666361F445241E07A142E384B3A41666666A61F44524184EB51B8324B3A410AD7A3C01F44524184EB5138264B3A41000000B01F44524198999919234B3A419A9999B91F445241F4285C8F0C4B3A41F6285CCF1F44524150B81E85074B3A41B81E858B214452413C0AD7E3024B3A41E27A14CE1F445241D8A3707DF74A3A41F6285C8F1F445241EC51B8DEF44A3A41E27A147E1F445241B047E1BAE84A3A41C2F5284C1F445241D8A370FDE44A3A4114AE47311F445241B81E85EBD64A3A417A14AEF71E44524190C2F568CB4A3A415C8FC2C51E44524190C2F5A8C44A3A41D8A370AD1E44524168666626C04A3A41E27A148E1E4452417C14AE47AF4A3A41CCCCCC8C1F4452413C0AD7639E4A3A41E27A14FE1D445241B047E1FA944A3A4186EB51E81D44524198999999904A3A4152B81EC51D4452410CD7A3B0834A3A415C8FC2651D4452412085EB91744A3A41CCCCCCEC1C445241343333B3734A3A41666666B61B445241989999D96F4A3A41D8A3709D1B44524134333333664A3A4190C2F5581B445241703D0A57614A3A41D8A3701D1B445241343333335C4A3A4148E17A141B445241B81E852B4B4A3A41EC51B88E1A44524148E17A94484A3A41703D0A771A445241285C8F02324A3A41CCCCCC5C194452412085EB91284A3A417A14AE271944524184EB5138294A3A4152B81E851C445241285C8F42354A3A41A4703D6A1E4452412085EBD1424A3A410AD7A3801E445241CCCCCC0C474A3A415C8FC2851E445241285C8F02474A3A419A9999F91F44524190C2F5E8464A3A41D8A370CD2144524114AE47214A4A3A41C2F528CC2144524150B81E854A4A3A41EC51B83E21445241989999D9494A3A41703D0A3721445241D8A3707D4A4A3A41CCCCCC4C20445241285C8F024A4A3A41703D0A4720445241343333B34A4A3A41AE47E14A1F44524114AE47214A4A3A4148E17A441F44524114AE47E14A4A3A41343333331E445241C4F5285C4F4A3A415C8FC2651E445241000000404F4A3A41CCCCCC8C1E445241CCCCCC4C554A3A4114AE47D11E445241703D0A97524A3A41000000B0224452415C8FC275514A3A41CCCCCC0C24445241B047E17A4F4A3A41CCCCCC6C26445241703D0A574D4A3A415C8FC26529445241C4F5289C4B4A3A415C8FC2C52B44524150B81E45514A3A4148E17AE42B44524150B81E45534A3A410AD7A3F02844524150B81EC5574A3A41000000F022445241000000805A4A3A410AD7A3501E44524190C2F5285D4A3A41EC51B86E1E445241F4285CCF5F4A3A4152B81E851E44524184EB5138644A3A411E85EBB11E44524190C2F5E8664A3A41EC51B8CE1E4452415C8FC2F56F4A3A4148E17A341F445241D8A370BD714A3A419A9999491F4452417C14AE87734A3A41343333531F445241B81E856B754A3A41703D0A271F445241A4703D8A834A3A413E0AD7D31F44524168666666854A3A4190C2F5E81F44524184EB5138874A3A41E27A14FE1F44524150B81E45874A3A41EC51B8FE1F4452417C14AEC7884A3A4100000010204452410CD7A3B0904A3A41A4703D6A204452413C0AD7E39C4A3A41F6285CAF20445241C4F5289CB14A3A417A14AE1721445241A4703D8ABE4A3A41CCCCCC8C21445241EC51B89EC94A3A410AD7A3402244524148E17A54CE4A3A415C8FC2B522445241D8A3703DD54A3A41B81E856B20445241D8A370BDF24A3A41EC51B81E234452412085EBD1FF4A3A41EC51B83E234452415C8FC2750A4B3A417A14AE5723445241686666A60D4B3A41285C8F5223445241EC51B85E0F4B3A41EC51B84E23445241F4285C0F124B3A4186EB5148234452410CD7A3F01B4B3A410AD7A3302344524198999919284B3A41CCCCCCCC22445241CCCCCC0C2A4B3A41A4703D0A22445241E07A146E354B3A41AE47E10A22445241C4F5289C4A4B3A4186EB51F821445241686666A65A4B3A4186EB51B82144524184EB51F8614B3A415C8FC2A52144524198999999644B3A417A14AEA7214452415C8FC2B5664B3A41A4703DAA2144524184EB51B8734B3A41AE47E18A214452413C0AD7A3774B3A4186EB519821445241343333738F4B3A410AD7A38021445241B81E85EB994B3A41EC51B86E2144524190C2F5E8AB4B3A41B81E857B21445241A4703D0AAF4B3A416666666620445241A4703D0AB24B3A41CCCCCC8C2144524148E17AD4B64B3A41D8A3707D2144524114AE47E1BB4B3A410AD7A380214452410CD7A3B0BF4B3A415C8FC275214452415C8FC2F5FF4B3A41666666662144524198999999074C3A4148E17A642144524114AE4761194C3A4186EB51782144524114AE47E11C4C3A4186EB517821445241989999592E4C3A410AD7A3702144524198999919324C3A41B81E854B2044524190C2F5A8354C3A4152B81E7521445241285C8FC2394C3A41A4703D6A21445241CCCCCC8C4A4C3A41343333B32144524184EB51F84D4C3A41A4703DBA21445241C4F5289C514C3A41CCCCCCBC21445241C4F5281C5C4C3A41D8A370AD21445241A4703D4A5E4C3A41EC51B89E214452410CD7A3F0614C3A41E27A145E20445241CCCCCCCC664C3A413E0AD763214452417C14AE87694C3A411E85EB5121445241B047E1BA6F4C3A41C2F5281C214452410CD7A3B0754C3A415C8FC2E520445241D8A3707D814C3A41A4703D6A2044524134333373834C3A415C8FC2552044524114AE47E1874C3A41703D0A2720445241F4285C4F884C3A41AE47E1CA2044524148E17AD4884C3A41F6285C3F21445241EC51B89E8A4C3A41EC51B8DE23445241B047E1BA8B4C3A413E0AD7132544524190C2F5E88F4C3A41D8A3708D2A44524168666666954C3A413E0AD7532A445241989999D9994C3A41EC51B81E2A44524184EB5138984C3A410AD7A3D0274452410CD7A3B0954C3A41F6285C6F2444524114AE47A1944C3A41F6285C3F2444524150B81E05924C3A41CCCCCC7C204452413C0AD723964C3A41EC51B8CE1F445241000000C09B4C3A41343333A31F445241C4F5285CA14C3A41D8A3705D1F445241D8A370BDA34C3A413E0AD7531F44524134333333AF4C3A41EC51B8CE1E44524114AE47E1B44C3A4186EB51A81E445241D8A370FDD04C3A41EC51B86E1D44524114AE47A1DA4C3A4152B81E151D445241285C8F02DC4C3A41343333931D44524184EB51F8DD4C3A410AD7A3801D445241E07A146EE04C3A4152B81E651D445241A4703D8AE24C3A411E85EBD11D4452417C14AE07E44C3A41A4703DAA1B445241A4703D8AEA4C3A41703D0AA71C445241B81E856B124D3A411E85EB311B44524134333373214D3A41666666B61A4452410CD7A330224D3A410AD7A3A01A445241C4F5281C3D4D3A41B81E858B194452410CD7A3703E4D3A41EC51B87E194452417C14AE074D4D3A4114AE47E118445241B81E852B5C4D3A41D8A3702D184452415C8FC275634D3A41B81E85DB17445241703D0A17704D3A4114AE473117445241C4F5289C784D3A410AD7A3C016445241A4703D4A7E4D3A4186EB517816445241CCCCCC4C804D3A41E27A148E1444524100000080864D3A41343333F315445241B047E1BA8B4D3A41343333B31544524184EB5178AD4D3A41CCCCCCDC134452410CD7A330C84D3A41AE47E16A12445241C4F5289CD44D3A41EC51B8BE11445241285C8F02E44D3A41A4703DEA104452415C8FC275E84D3A41C2F528AC104452413C0AD763EC4D3A4190C2F58810445241B81E85EBF04D3A41000000401044524198999999F44D3A4134333303104452412085EB51FE4D3A41D8A3707D0F4452412085EBD1014E3A410AD7A3600F445241B047E1FA064E3A4114AE47110F445241E07A146E0B4E3A415C8FC2C50E44524150B81EC5164E3A41F6285C0F0E445241EC51B8DE1E4E3A4186EB51980D445241F4285C4F244E3A41AE47E14A0D4452417C14AE87274E3A41000000100D445241A4703DCA2B4E3A4186EB51C80C445241CCCCCC8C2E4E3A41666666A60C44524190C2F528334E3A41703D0A670C445241EC51B81E354E3A415C8FC2650C4452415C8FC235364E3A4190C2F5280C445241D8A370BD3A4E3A419A9999E90B445241CCCCCC8C3C4E3A41EC51B8BE0B4452412085EB51414E3A41A4703D7A0B4452417C14AE87434E3A415C8FC2550B44524190C2F568444E3A41703D0A470B445241A4703D4A464E3A41EC51B82E0B44524114AE47E14E4E3A41A4703DAA0A4452412085EB91514E3A41EC51B86E0A445241B81E852B534E3A41AE47E15A0A44524148E17A54554E3A4186EB51480A44524100000000604E3A413E0AD7A30944524100000000604E3A419A9999C9064452412085EB515F4E3A41B81E85DB064452410CD7A3F05B4E3A4114AE4761074452410CD7A3B0594E3A4186EB518807445241CCCCCCCC574E3A4186EB51A807445241000000804E4E3A41EC51B83E08445241343333734A4E3A4114AE47710844524148E17A94404E3A41C2F5280C0944524150B81E053F4E3A41F6285C1F094452413C0AD7A3384E3A41EC51B87E09445241F4285C8F354E3A4186EB51A8094452413C0AD7E32D4E3A4152B81E250A445241'::geometry AS poly) AS a,

(SELECT 'LINESTRING (1722934.9928987455 4788348.64891073,1722933.26000001 4788345.6600000001,1722933.4352710573 4788343.3010556679,1722937.6408658153 4788340.2896421375,1722941.0157258064 4788339.1993027553,1722944.2867439515 4788339.1473818328,1722951.2960685482 4788340.4973258292,1722951.05 4788346.0899999999,1722947.4539202508 4788349.1161990371)'::geometry AS line) as b


Note: The geometry of the polygon is not given using wkt since the precision reduction implicit in AsText? would have made the problem disappear

Change History (10)

comment:1 Changed 8 years ago by strk

Owner: changed from pramsey to strk
Status: newassigned

Confirmed, looking at it from the geos side.

comment:2 Changed 8 years ago by strk

Simplified input (already noded):

 010500000003000000010200000003000000555C8F42354A3A41A4703D6A1E445241CCCCCC0C474A3A415C8FC2851E445241CCCCCC0C474A3A415C8FC2851E445241010200000005000000555C8F42354A3A41A4703D6A1E445241545C8F42354A3A41A4703D6A1E445241409B06043D4A3A415860C1CC1C445241CDCCCC0C474A3A415C8FC2851E445241CCCCCC0C474A3A415C8FC2851E445241010200000007000000CCCCCC0C474A3A415C8FC2851E445241C4F5289C4B4A3A415C8FC2C52B44524100000000604E3A413E0AD7A30944524100000000604E3A419A9999C9064452412085EB91284A3A417A14AE2719445241285C8F42354A3A41A4703D6A1E445241555C8F42354A3A41A4703D6A1E445241

comment:3 Changed 8 years ago by strk

Confirmed to be a GEOS bug: http://trac.osgeo.org/geos/ticket/458

comment:4 Changed 8 years ago by strk

Basically one of the components being polygonized has a very small segment near the node. This makes GEOS (and probably also JTS) confused about the order in which edges get out from a node, so which way is clockwise and which counterclockwise...

comment:5 Changed 8 years ago by strk

So, it turns out that the input isn't really properly noded. Evidently ST_Union() isn't good enough to node linestrings, which may be another bug... Passing the input trough ST_UnaryUnion fixes it for me (on the simplified case).

comment:6 Changed 8 years ago by strk

For clarity, that'd be:

SELECT AsText(ST_Polygonize(
  ST_UnaryUnion( -- ST_UnaryUnion does proper noding...
   ST_Union(ST_Boundary(poly), line)
  )
)) AS mpoly FROM ...

comment:7 Changed 8 years ago by strk

Substituting the inner ST_Union with ST_Collect makes the bug come back. So it looks like it takes _2_ calls to ST_Union (or ST_UnaryUnion) to really node !!!

comment:8 Changed 8 years ago by strk

I've filed the Union bug (fails to node) as http://trac.osgeo.org/geos/ticket/459

comment:9 Changed 7 years ago by pramsey

Milestone: PostGIS 1.5.4

comment:10 Changed 7 years ago by pramsey

Milestone: PostGIS 1.5.4PostGIS GEOS
Note: See TracTickets for help on using tickets.