@@ -5001,23 +5001,27 @@ def testIsGeosValid(self):
5001
5001
5002
5002
def testValidateGeometry (self ):
5003
5003
tests = [
5004
- ["" , []],
5005
- ["Point (100 100)" , [], []],
5006
- ["MultiPoint (100 100, 100 200)" , [], []],
5007
- ["LINESTRING (0 0, 0 100, 100 100)" , [], []],
5008
- ["POLYGON((-1 -1, 4 0, 4 2, 0 2, -1 -1))" , [], []],
5009
- ["MULTIPOLYGON(Polygon((-1 -1, 4 0, 4 2, 0 2, -1 -1)),Polygon((100 100, 200 100, 200 200, 100 200, 100 100)))" , [], []],
5010
- ['MultiPolygon (((159865.14786298031685874 6768656.31838363595306873, 159858.97975336571107619 6769211.44824895076453686, 160486.07089751763851382 6769211.44824895076453686, 160481.95882444124436006 6768658.37442017439752817, 160163.27316101978067309 6768658.37442017439752817, 160222.89822062765597366 6769116.87056819349527359, 160132.43261294672265649 6769120.98264127038419247, 160163.27316101978067309 6768658.37442017439752817, 159865.14786298031685874 6768656.31838363595306873)))' , [], []],
5011
- ['Polygon((0 3, 3 0, 3 3, 0 0, 0 3))' , [QgsGeometry .Error ('Self-intersection' , QgsPointXY (1.5 , 1.5 ))], [QgsGeometry .Error ('segments 0 and 2 of line 0 intersect at 1.5, 1.5' , QgsPointXY (1.5 , 1.5 ))]],
5004
+ ["" , [], [], []],
5005
+ ["Point (100 100)" , [], [], []],
5006
+ ["MultiPoint (100 100, 100 200)" , [], [], []],
5007
+ ["LINESTRING (0 0, 0 100, 100 100)" , [], [], []],
5008
+ ["POLYGON((-1 -1, 4 0, 4 2, 0 2, -1 -1))" , [], [], []],
5009
+ ["MULTIPOLYGON(Polygon((-1 -1, 4 0, 4 2, 0 2, -1 -1)),Polygon((100 100, 200 100, 200 200, 100 200, 100 100)))" , [], [], []],
5010
+ ['POLYGON ((200 400, 400 400, 400 200, 300 200, 350 250, 250 250, 300 200, 200 200, 200 400))' , [QgsGeometry .Error ('Ring self-intersection' , QgsPointXY (300 , 200 ))], [], []],
5011
+ ['MultiPolygon (((159865.14786298031685874 6768656.31838363595306873, 159858.97975336571107619 6769211.44824895076453686, 160486.07089751763851382 6769211.44824895076453686, 160481.95882444124436006 6768658.37442017439752817, 160163.27316101978067309 6768658.37442017439752817, 160222.89822062765597366 6769116.87056819349527359, 160132.43261294672265649 6769120.98264127038419247, 160163.27316101978067309 6768658.37442017439752817, 159865.14786298031685874 6768656.31838363595306873)))' , [QgsGeometry .Error ('Ring self-intersection' , QgsPointXY (160163.27316101978067309 , 6768658.37442017439752817 ))], [], []],
5012
+ ['Polygon((0 3, 3 0, 3 3, 0 0, 0 3))' , [QgsGeometry .Error ('Self-intersection' , QgsPointXY (1.5 , 1.5 ))], [QgsGeometry .Error ('Self-intersection' , QgsPointXY (1.5 , 1.5 ))], [QgsGeometry .Error ('segments 0 and 2 of line 0 intersect at 1.5, 1.5' , QgsPointXY (1.5 , 1.5 ))]],
5012
5013
]
5013
5014
for t in tests :
5014
5015
g1 = QgsGeometry .fromWkt (t [0 ])
5015
5016
res = g1 .validateGeometry (QgsGeometry .ValidatorGeos )
5016
5017
self .assertEqual (res , t [1 ],
5017
5018
"mismatch for {}, expected:\n {}\n Got:\n {}\n " .format (t [0 ], t [1 ], res [0 ].where () if res else '' ))
5018
- res = g1 .validateGeometry (QgsGeometry .ValidatorQgisInternal )
5019
+ res = g1 .validateGeometry (QgsGeometry .ValidatorGeos , QgsGeometry . FlagAllowSelfTouchingHoles )
5019
5020
self .assertEqual (res , t [2 ],
5020
5021
"mismatch for {}, expected:\n {}\n Got:\n {}\n " .format (t [0 ], t [2 ], res [0 ].where () if res else '' ))
5022
+ res = g1 .validateGeometry (QgsGeometry .ValidatorQgisInternal )
5023
+ self .assertEqual (res , t [3 ],
5024
+ "mismatch for {}, expected:\n {}\n Got:\n {}\n " .format (t [0 ], t [3 ], res [0 ].where () if res else '' ))
5021
5025
5022
5026
def renderGeometry (self , geom , use_pen , as_polygon = False , as_painter_path = False ):
5023
5027
image = QImage (200 , 200 , QImage .Format_RGB32 )
0 commit comments