[geos-commits] r3553 - in trunk: include/geos/geom tests/xmltester
tests/xmltester/tests/ticket
svn_geos at osgeo.org
svn_geos at osgeo.org
Thu Dec 15 09:36:15 EST 2011
Author: strk
Date: 2011-12-15 06:36:15 -0800 (Thu, 15 Dec 2011)
New Revision: 3553
Added:
trunk/tests/xmltester/tests/ticket/bug488.xml
Modified:
trunk/include/geos/geom/BinaryOp.h
trunk/tests/xmltester/Makefile.am
Log:
Check validity after snapping in BinaryOp. Fixes bug #488
Adds regression test. This is a GEOS-only approach.
Modified: trunk/include/geos/geom/BinaryOp.h
===================================================================
--- trunk/include/geos/geom/BinaryOp.h 2011-12-15 14:18:38 UTC (rev 3552)
+++ trunk/include/geos/geom/BinaryOp.h 2011-12-15 14:36:15 UTC (rev 3553)
@@ -68,6 +68,7 @@
#ifdef GEOS_DEBUG_BINARYOP
# include <iostream>
# include <iomanip>
+# include <sstream>
#endif
@@ -150,6 +151,37 @@
return true;
}
+/* A single component may become a multi component */
+inline std::auto_ptr<Geometry>
+fix_snap_collapses(std::auto_ptr<Geometry> g, const std::string& label)
+{
+
+ // Areal geometries may become self-intersecting on snapping
+ if ( g->getGeometryTypeId() == GEOS_POLYGON ||
+ g->getGeometryTypeId() == GEOS_MULTIPOLYGON )
+ {
+
+ // TODO: use only ConsistentAreaTester
+ if ( ! check_valid(*g, label) ) {
+#if GEOS_DEBUG_BINARYOP
+ std::cerr << label << ": self-unioning" << std::endl;
+#endif
+ g = g->Union();
+#if GEOS_DEBUG_BINARYOP
+ std::stringstream ss;
+ ss << label << " self-unioned";
+ check_valid(*g, ss.str());
+#endif
+ }
+
+ }
+
+ // TODO: check linear collapses ? (!isSimple)
+
+ return g;
+}
+
+
/// \brief
/// Apply a binary operation to the given geometries
/// after snapping them to each other after common-bits
@@ -201,15 +233,13 @@
GeometrySnapper snapper0( operand0 );
GeomPtr snapG0( snapper0.snapTo(operand1, snapTolerance) );
+ snapG0 = fix_snap_collapses(snapG0, "SNAP: snapped geom 0");
// NOTE: second geom is snapped on the snapped first one
GeometrySnapper snapper1( operand1 );
GeomPtr snapG1( snapper1.snapTo(*snapG0, snapTolerance) );
+ snapG1 = fix_snap_collapses(snapG1, "SNAP: snapped geom 1");
-#if GEOS_DEBUG_BINARYOP
- check_valid(*snapG0, "SNAP: snapped geom 0");
- check_valid(*snapG1, "SNAP: snapped geom 1");
-#endif
// Run the binary op
GeomPtr result( _Op(snapG0.get(), snapG1.get()) );
Modified: trunk/tests/xmltester/Makefile.am
===================================================================
--- trunk/tests/xmltester/Makefile.am 2011-12-15 14:18:38 UTC (rev 3552)
+++ trunk/tests/xmltester/Makefile.am 2011-12-15 14:36:15 UTC (rev 3553)
@@ -32,6 +32,7 @@
$(srcdir)/tests/ticket/bug392.xml \
$(srcdir)/tests/ticket/bug398.xml \
$(srcdir)/tests/ticket/bug434.xml \
+ $(srcdir)/tests/ticket/bug488.xml \
$(srcdir)/tests/general/TestBoundary.xml \
$(srcdir)/tests/general/TestBuffer.xml \
$(srcdir)/tests/general/TestBufferMitredJoin.xml \
Added: trunk/tests/xmltester/tests/ticket/bug488.xml
===================================================================
--- trunk/tests/xmltester/tests/ticket/bug488.xml (rev 0)
+++ trunk/tests/xmltester/tests/ticket/bug488.xml 2011-12-15 14:36:15 UTC (rev 3553)
@@ -0,0 +1,45 @@
+
+<run>
+ <desc>
+ http://trac.osgeo.org/geos/ticket/488
+ </desc>
+ <precisionModel type="FLOATING" />
+
+ <case>
+ <desc>
+ TopologyException unioning two valid polygons.
+ Cause is very high precision causing almost-coincident line segments.
+ This causes robustness failures in noding in JTS 1.12.
+ Reduced version.
+ </desc>
+ <a>
+01060000000100000001030000000100000005000000DF52A140EC490340251EBD88237048404F7F9BC7814D0340D9C5653E1270484041B01B9F1C4C0340A9FB014212704840002EF0471C4C0340EC39718803704840DF52A140EC490340251EBD8823704840
+ </a>
+ <b>
+01060000000200000001030000000100000004000000EF54EBB0384B03403FC50B78F36F484040B01B9F1C4C0340A9FB0142127048404F7F9BC7814D0340D9C5653E12704840EF54EBB0384B03403FC50B78F36F4840010300000001000000040000008D246CEE344E034016CFC66D597048404F7F9BC7814D0340D9C5653E1270484041B01B9F1C4C0340A9FB0142127048408D246CEE344E034016CFC66D59704840
+ </b>
+ <test>
+ <op name='union' arg1='A' arg2='B' >
+01030000000100000007000000DF52A140EC490340251EBD8823704840E66E8AF0484C034079579A23187048408D246CEE344E034016CFC66D597048404F7F9BC7814D0340D9C5653E12704840EF54EBB0384B03403FC50B78F36F484032DCBFEACF4B034080B385E507704840DF52A140EC490340251EBD8823704840
+ </op>
+ </test>
+ </case>
+
+ <case>
+ <desc>
+ TopologyException unioning two valid polygons.
+ Cause is very high precision causing almost-coincident line segments.
+ This causes robustness failures in noding in JTS 1.12.
+ Full version, using UnaryUnion.
+ </desc>
+ <a>
+ 01070000000800000001030000000100000017000000655E3A27EC4703406906F11FE66F48407285047CEC4703400D8482D9F46F484029EB1855874603407741FDDCF46F4840409518A987460340F4658E9603704840B888AA59BD43034025CD6A9D03704840D8D514ACBD4303404A9AFB5612704840806492835842034008445D5A127048408858D22659420340B8D07DCD2F704840F888EA50BE4303404E231CCA2F704840FCEE55A3BE43034025DFAB833E704840AFA238CE23450340B2D241803E7048401F486F21244503408B31D1394D704840CCCD75A45349034040D7602F4D7048406A9947F952490340C5C941BC2F704840F56B8977824D03401F3486B12F7048404F7F9BC7814D0340D9C5653E1270484041B01B9F1C4C0340A9FB014212704840002EF0471C4C0340EC397188037048401ADA3A20B74A0340A210058C037048402798DAC9B64A0340E1F173D2F46F48406022AF17814D03403BEB43CBF46F4840CB89B9BF804D03405375B211E66F4840655E3A27EC4703406906F11FE66F4840010300000002000000160000005A59B2EB13530340E0CCA41CAB6F48405AC5D14614530340D2A637D6B96F4840E03957FF495003403886AADDB96F48400F5AE1584A50034036093D97C86F48406384CF0F804D034067788E9EC86F48404F7F9BC7814D0340D9C565
3E1270484041B01B9F1C4C0340A9FB0142127048408A9547F61C4C0340516292FB2070484078A940254D5003408D53C4633E7048402D5DCE7E4D500340E8A2531D4D7048400E3B22D617530340FC9AE0154D704840D919463118530340228B6FCF5B70484063CDDE9B775B0340CD31DC716A704840F24C3EADAA580340574EC66603704840169AEFD40F5A034042D4DE620370484086DEF9DC735B03402ED93A32D76F4840F92E99273E5E03405720422AD76F4840F0AB1DAC07610340ED7A03AFB96F484068C81149076103404DB670F5AA6F48405AC22326A25F0340CEF481F9AA6F484025CD6488A25F0340A0BB14B3B96F48405A59B2EB13530340E0CCA41CAB6F484005000000BCF099184C500340C3421437127048403F7326724C50034076A3A4F020704840DF8DDC48E74E0340949551F42070484070EA1AF0E64E0340E032C13A12704840BCF099184C500340C3421437127048400103000000010000000500000016D36D62BC4303405943B670D76F48405807D7B4BC430340A921482AE66F48402E83F8DA214503405620DE26E66F48406F73C48721450340E3434C6DD76F484016D36D62BC4303405943B670D76F4840010300000002000000170000006A9947F952490340C5C941BC2F704840CCCD75A45349034040D7602F4D704840167F1C4D89460340FFC55E3
64D704840C1651EA189460340D4C7EDEF5B704840F71F96CDEE4703402BFD72EC5B704840AB496322EF470340F0A101A66A7048402387A54F5449034021787EA26A704840AAF53DA554490340CABF0C5C7970484060B64AD3B94A0340CD368158797048408A6BAE29BA4A03405C210F1288704840570D33B6E94E0340C9503A078870484009A86E5DE94E03401F6CAC4D797048402CD0AB71485703403F00213779704840E474261448570340A4CC927D6A7048402B536441AD580340F4A0B3796A704840947E14E3AC5803404A1425C05B704840D919463118530340228B6FCF5B7048400E3B22D617530340FC9AE0154D7048402D5DCE7E4D500340E8A2531D4D70484077A940254D5003408D53C4633E7048403E0361FAE74E0340AC4971673E70484023969EA1E74E0340329DE1AD2F7048406A9947F952490340C5C941BC2F704840050000002EF880CF824D034094E2156B3E70484057E87827834D0340EC35A5244D7048409097CDFB1D4C0340957341284D7048403089A0A41D4C0340491EB26E3E7048402EF880CF824D034094E2156B3E70484001030000000100000015000000F2AB10721F3E0340743421EB496E484097F444C11F3E034025AEBCA4586E4840CCF603D2843F0340765174A1586E4840835D0322853F0340C36E0F5B676E484032977910203E034040
CD575E676E4840C193AE5F203E0340B791F217766E4840131F0372853F03406E31AA14766E4840803B03C2853F0340759944CE846E484078CC40E84F42034052BF9AC7846E4840EA326D8B504203401D78CE3AA26E48403A6ED4B41A450340E2230334A26E4840477DA8611A4503408878697A936E4840FEC590757F4603403745F776936E4840B66C9A217F4603400C415DBD846E4840458FB734E4470340F1B2E2B9846E4840E76F368BE34703406B9EAD46676E484031E12668194503406C569A4D676E4840156AFC14194503407040FF93586E4840B1D83E04B4430340A00F6997586E48403A83DFB1B34303402A9DCDDD496E4840F2AB10721F3E0340743421EB496E48400103000000020000000F000000C039DB99564203405A14F300BA6F484021D5163D57420340B6E51774D76F48408DB20FCD273E0340559E0A7ED76F4840676279928D3F0340BA7FE5EDF46F484016998B6B283E03406C0E2EF1F46F4840B5E7080A293E03404612506412704840D8D514ACBD4303404A9AFB5612704840B888AA59BD43034025CD6A9D037048403F9518A987460340F4658E9603704840655E3A27EC4703406906F11FE66F4840CA89B9BF804D03405375B211E66F4840380346EB1A4C034069A42AA2C86F4840C0D831A25049034034E549A9C86F4840F7F89D4C504903406558B
7EFB96F4840C039DB99564203405A14F300BA6F4840050000006E73C48721450340E3434C6DD76F48402E83F8DA214503405620DE26E66F48405807D7B4BC430340A921482AE66F484016D36D62BC4303405943B670D76F48406E73C48721450340E3434C6DD76F4840010300000001000000050000009351D4474949034027C85FB6846E48406F38609D4949034086C8F96F936E48405C6047B1AE4A0340227F6E6C936E4840B7B2F05AAE4A0340B480D4B2846E48409351D4474949034027C85FB6846E4840010300000001000000050000002798DAC9B64A0340E1F173D2F46F484040B01B9F1C4C0340A9FB0142127048404F7F9BC7814D0340D9C5653E127048405F22AF17814D03403BEB43CBF46F48402798DAC9B64A0340E1F173D2F46F4840
+ </a>
+ <test>
+ <op name='union' arg1='A' >
+01060000000300000001030000000100000015000000F2AB10721F3E0340743421EB496E484097F444C11F3E034025AEBCA4586E4840CCF603D2843F0340765174A1586E4840835D0322853F0340C36E0F5B676E484032977910203E034040CD575E676E4840C193AE5F203E0340B791F217766E4840131F0372853F03406E31AA14766E4840803B03C2853F0340759944CE846E484078CC40E84F42034052BF9AC7846E4840EA326D8B504203401D78CE3AA26E48403A6ED4B41A450340E2230334A26E4840477DA8611A4503408878697A936E4840FEC590757F4603403745F776936E4840B66C9A217F4603400C415DBD846E4840458FB734E4470340F1B2E2B9846E4840E76F368BE34703406B9EAD46676E484031E12668194503406C569A4D676E4840156AFC14194503407040FF93586E4840B1D83E04B4430340A00F6997586E48403A83DFB1B34303402A9DCDDD496E4840F2AB10721F3E0340743421EB496E4840010300000001000000050000009351D4474949034027C85FB6846E48406F38609D4949034086C8F96F936E48405C6047B1AE4A0340227F6E6C936E4840B7B2F05AAE4A0340B480D4B2846E48409351D4474949034027C85FB6846E484001030000000800000033000000C039DB99564203405A14F300BA6F484021D5163D57420340B6E51774D76F4
8408DB20FCD273E0340559E0A7ED76F4840676279928D3F0340BA7FE5EDF46F484016998B6B283E03406C0E2EF1F46F4840B5E7080A293E03404612506412704840D8D514ACBD4303404A9AFB5612704840806492835842034008445D5A127048408858D22659420340B8D07DCD2F704840F888EA50BE4303404E231CCA2F704840FCEE55A3BE43034025DFAB833E704840AFA238CE23450340B2D241803E7048401F486F21244503408B31D1394D704840CCCD75A45349034040D7602F4D704840167F1C4D89460340FFC55E364D704840C1651EA189460340D4C7EDEF5B704840F71F96CDEE4703402BFD72EC5B704840AB496322EF470340F0A101A66A7048402387A54F5449034021787EA26A704840AAF53DA554490340CABF0C5C7970484060B64AD3B94A0340CD368158797048408A6BAE29BA4A03405C210F1288704840570D33B6E94E0340C9503A078870484009A86E5DE94E03401F6CAC4D797048402CD0AB71485703403F00213779704840E474261448570340A4CC927D6A7048402B536441AD580340F4A0B3796A7048407B7FF321AD5803401C780B916570484063CDDE9B775B0340CD31DC716A704840F24C3EADAA580340574EC66603704840169AEFD40F5A034042D4DE620370484086DEF9DC735B03402ED93A32D76F4840F92E99273E5E03405720422AD7
6F4840F0AB1DAC07610340ED7A03AFB96F484068C81149076103404DB670F5AA6F48405AC22326A25F0340CEF481F9AA6F484025CD6488A25F0340A0BB14B3B96F48405A59B2EB13530340E0CCA41CAB6F48405AC5D14614530340D2A637D6B96F4840E03957FF495003403886AADDB96F48400F5AE1584A50034036093D97C86F48406384CF0F804D034067788E9EC86F48404F7F9BC7814D0340D9C5653E127048406022AF17814D03403BEB43CBF46F4840CB89B9BF804D03405375B211E66F4840655E3A27EC4703406906F11FE66F4840CA89B9BF804D03405375B211E66F4840380346EB1A4C034069A42AA2C86F4840C0D831A25049034034E549A9C86F4840F7F89D4C504903406558B7EFB96F4840C039DB99564203405A14F300BA6F484004000000655E3A27EC4703406906F11FE66F48407285047CEC4703400D8482D9F46F4840485227E839470340C4E33FDBF46F4840655E3A27EC4703406906F11FE66F484004000000B888AA59BD43034025CD6A9D037048403F9518A987460340F4658E9603704840409518A987460340F4658E9603704840B888AA59BD43034025CD6A9D03704840040000002798DAC9B64A0340E1F173D2F46F4840EF4C7DB4694B03403D243B8A037048401ADA3A20B74A0340A210058C037048402798DAC9B64A0340E1F173D2F46F484
00400000024BB365A824D0340CBF1F0C82A7048402AB8160E354E0340DF9EADAF2F70484002218977824D034056A879B12F70484024BB365A824D0340CBF1F0C82A70484004000000925A34BFE74E034062EC56963470484077A940254D5003408D53C4633E7048403E0361FAE74E0340AC4971673E704840925A34BFE74E034062EC56963470484005000000BCF099184C500340C3421437127048403F7326724C50034076A3A4F020704840DF8DDC48E74E0340949551F42070484070EA1AF0E64E0340E032C13A12704840BCF099184C500340C342143712704840050000002EF880CF824D034094E2156B3E70484057E87827834D0340EC35A5244D7048409097CDFB1D4C0340957341284D7048403089A0A41D4C0340491EB26E3E7048402EF880CF824D034094E2156B3E704840
+ </op>
+ </test>
+ </case>
+
+</run>
More information about the geos-commits
mailing list