Skip to content
Browse files

Added test and sample wkt to replicate issue 4189

  • Loading branch information
timlinux committed Oct 10, 2012
1 parent 3d79a0b commit 0617992fb123229c67e78f2fe55da68fb1292d46
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="PyDocumentationSettings">
<option name="myDocStringFormat" value="Plain" />

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="TestRunnerService">
<option name="projectConfiguration" value="Nosetests" />
<option name="PROJECT_TEST_RUNNER" value="Nosetests" />

@@ -12,6 +12,7 @@
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'

import os
from qgis.core import (QgsGeometry,
@@ -20,7 +21,9 @@

from utilities import (getQgisTestApp,
# Convenience instances in case you may need them
# not used in this test

@@ -202,6 +205,41 @@ def testCrosses(self):
("True", crossesGeom))
assert crossesGeom == True, myMessage

def testSimplifyIssue4189(self):
"""Test we can simplify a complex geometry.
Note: there is a ticket related to this issue here:
Backstory: Ole Nielson pointed out an issue to me
(Tim Sutton) where simplify ftools was dropping
features. This test replicates that issues.
Interestingly we could replicate the issue in PostGIS too:
- doing straight simplify returned no feature
- transforming to UTM49, then simplify with e.g. 200 threshold is ok
- as above with 500 threshold drops the feature
pgsql2shp -f /tmp/dissolve500.shp gis 'select *,
transform(simplify(transform(geom,32649),500), 4326) as
simplegeom from dissolve;'
myWKTFile = file(os.path.join(unitTestDataPath('wkt'),
'simplify_error.wkt'), 'rt')
myWKT = myWKTFile.readline()
print myWKT
myGeometry = QgsGeometry().fromWkt(myWKT)
assert myGeometry is not None
myStartLength = len(myWKT)
myTolerance = 0.00001
mySimpleGeometry = myGeometry.simplify(myTolerance)
myEndLength = len(mySimpleGeometry.exportToWkt())
myMessage = 'Before simplify: %i\nAfter simplify: %i\n : Tolerance %e' % (
myStartLength, myEndLength, myTolerance)
myMinimumLength = len('POLYGON(())')
assert myEndLength > myMinimumLength, myMessage

if __name__ == '__main__':

0 comments on commit 0617992

Please sign in to comment.
You can’t perform that action at this time.