Created
August 24, 2012 17:53
-
-
Save slarosa/3453470 to your computer and use it in GitHub Desktop.
buffer and intersection test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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