Skip to content

Commit

Permalink
Followup feeeaf0, add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed May 17, 2016
1 parent feeeaf0 commit e92dc26
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/src/python/test_qgsgeometry.py
Expand Up @@ -1648,6 +1648,31 @@ def testReshape(self):
wkt = g.exportToWkt()
assert compareWkt(expWkt, wkt), "testReshape failed: mismatch Expected:\n%s\nGot:\n%s\n" % (expWkt, wkt)

# Test reshape a line from first/last vertex
g = QgsGeometry.fromWkt('LineString (0 0, 5 0, 5 1)')
# extend start
self.assertEqual(g.reshapeGeometry([QgsPoint(0, 0), QgsPoint(-1, 0)]), 0)
expWkt = 'LineString (-1 0, 0 0, 5 0, 5 1)'
wkt = g.exportToWkt()
assert compareWkt(expWkt, wkt), "testReshape failed: mismatch Expected:\n%s\nGot:\n%s\n" % (expWkt, wkt)
# extend end
self.assertEqual(g.reshapeGeometry([QgsPoint(5, 1), QgsPoint(10, 1), QgsPoint(10, 2)]), 0)
expWkt = 'LineString (-1 0, 0 0, 5 0, 5 1, 10 1, 10 2)'
wkt = g.exportToWkt()
assert compareWkt(expWkt, wkt), "testReshape failed: mismatch Expected:\n%s\nGot:\n%s\n" % (expWkt, wkt)
# test with reversed lines
g = QgsGeometry.fromWkt('LineString (0 0, 5 0, 5 1)')
# extend start
self.assertEqual(g.reshapeGeometry([QgsPoint(-1, 0), QgsPoint(0, 0)]), 0)
expWkt = 'LineString (-1 0, 0 0, 5 0, 5 1)'
wkt = g.exportToWkt()
assert compareWkt(expWkt, wkt), "testReshape failed: mismatch Expected:\n%s\nGot:\n%s\n" % (expWkt, wkt)
# extend end
self.assertEqual(g.reshapeGeometry([QgsPoint(10, 2), QgsPoint(10, 1), QgsPoint(5, 1)]), 0)
expWkt = 'LineString (-1 0, 0 0, 5 0, 5 1, 10 1, 10 2)'
wkt = g.exportToWkt()
assert compareWkt(expWkt, wkt), "testReshape failed: mismatch Expected:\n%s\nGot:\n%s\n" % (expWkt, wkt)

def testConvertToMultiType(self):
""" Test converting geometries to multi type """
point = QgsGeometry.fromWkt('Point (1 2)')
Expand Down

1 comment on commit e92dc26

@wonder-sk
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @nyalldawson 👍

Please sign in to comment.