Skip to content
Permalink
Browse files

Update tests to new API

  • Loading branch information
m-kuhn committed Aug 23, 2018
1 parent 063ccf4 commit 907fb55f82fa37edc897b6b1dab10906705dae9e
Showing with 6 additions and 6 deletions.
  1. +6 −6 tests/src/python/test_qgsvectorlayer.py
@@ -2758,36 +2758,36 @@ def testFeatureRequestWithReprojectionAndVirtualFields(self):

def testPrecision(self):
layer = QgsVectorLayer("Polygon?crs=epsg:2056&field=pk:int", "vl", "memory")
layer.setGeometryPrecision(10)
layer.geometryFixes().setGeometryPrecision(10)
geom = QgsGeometry.fromWkt('Polygon ((2596411 1224654, 2596400 1224652, 2596405 1224640, 2596410 1224641, 2596411 1224654))')
feature = QgsFeature(layer.fields())
feature.setGeometry(geom)
layer.startEditing()
layer.addFeature(feature)
self.assertGeometriesEqual(QgsGeometry.fromWkt('Polygon ((2596410 1224650, 2596400 1224650, 2596410 1224640, 2596410 1224650))'), feature.geometry(), 'geometry with unsnapped nodes', 'fixed geometry')
layer.setGeometryPrecision(0.0)
layer.geometryFixes().setGeometryPrecision(0.0)
feature.setGeometry(QgsGeometry.fromWkt('Polygon ((2596411 1224654, 2596400 1224652, 2596405 1224640, 2596410 1224641, 2596411 1224654))'))
layer.addFeature(feature)
self.assertGeometriesEqual(QgsGeometry.fromWkt('Polygon ((2596411 1224654, 2596400 1224652, 2596405 1224640, 2596410 1224641, 2596411 1224654))'), feature.geometry(), 'geometry with duplicates', 'unchanged geometry')

def testRemoveDuplicateNodes(self):
layer = QgsVectorLayer("Polygon?crs=epsg:2056&field=pk:int", "vl", "memory")
layer.setRemoveDuplicateNodes(True)
layer.geometryFixes().setRemoveDuplicateNodes(True)
geom = QgsGeometry.fromWkt('Polygon ((70 80, 80 90, 80 90, 60 50, 70 80))')
feature = QgsFeature(layer.fields())
feature.setGeometry(geom)
layer.startEditing()
layer.addFeature(feature)
self.assertGeometriesEqual(feature.geometry(), QgsGeometry.fromWkt('Polygon ((70 80, 80 90, 60 50, 70 80))'), 'fixed geometry', 'geometry with duplicates')
layer.setRemoveDuplicateNodes(False)
layer.geometryFixes().setRemoveDuplicateNodes(False)
feature.setGeometry(QgsGeometry.fromWkt('Polygon ((70 80, 80 90, 80 90, 60 50, 70 80))'))
layer.addFeature(feature)
self.assertGeometriesEqual(feature.geometry(), QgsGeometry.fromWkt('Polygon ((70 80, 80 90, 80 90, 60 50, 70 80))'), 'unchanged geometry', 'geometry with duplicates')

def testPrecisionAndDuplicateNodes(self):
layer = QgsVectorLayer("Polygon?crs=epsg:2056&field=pk:int", "vl", "memory")
layer.setGeometryPrecision(10)
layer.setRemoveDuplicateNodes(True)
layer.geometryFixes().setGeometryPrecision(10)
layer.geometryFixes().setRemoveDuplicateNodes(True)
geom = QgsGeometry.fromWkt('Polygon ((2596411 1224654, 2596400 1224652, 2596402 1224653, 2596405 1224640, 2596410 1224641, 2596411 1224654))')
feature = QgsFeature(layer.fields())
feature.setGeometry(geom)

0 comments on commit 907fb55

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