Skip to content

Instantly share code, notes, and snippets.

@slarosa
Created August 24, 2012 17:53
Show Gist options
  • Save slarosa/3453470 to your computer and use it in GitHub Desktop.
Save slarosa/3453470 to your computer and use it in GitHub Desktop.
buffer and intersection test
def testIntersection(self):
myLine = QgsGeometry.fromPolyline([QgsPoint(0, 0),QgsPoint(1, 1),QgsPoint(2, 2)])
myPoint = QgsGeometry.fromPoint(QgsPoint(1, 1))
intersectionGeom = QgsGeometry.intersection(myLine, myPoint)
myMessage = ('Expected:\n%s\nGot:\n%s\n' %
(QGis.Point, intersectionGeom.type()))
assert intersectionGeom.wkbType() == QGis.WKBPoint, myMessage
def testBuffer(self):
myPoint = QgsGeometry.fromPoint(QgsPoint(1, 1))
bufferGeom = myPoint.buffer(10, 5)
myMessage = ('Expected:\n%s\nGot:\n%s\n' %
(QGis.Polygon, bufferGeom.type()))
assert bufferGeom.wkbType() == QGis.WKBPolygon, myMessage
intersectBuffer = QgsGeometry.intersects(myPoint, bufferGeom)
myMessage = ('Expected:\n%s\nGot:\n%s\n' %
("True", intersectBuffer))
assert intersectBuffer == True, myMessage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment