|
29 | 29 | from processing.algs.gdal.OgrToPostGis import OgrToPostGis
|
30 | 30 | from processing.algs.gdal.GdalUtils import GdalUtils
|
31 | 31 | from processing.algs.gdal.AssignProjection import AssignProjection
|
| 32 | +from processing.algs.gdal.Buffer import Buffer |
32 | 33 | from processing.algs.gdal.ClipRasterByExtent import ClipRasterByExtent
|
33 | 34 | from processing.algs.gdal.ClipRasterByMask import ClipRasterByMask
|
34 | 35 | from processing.algs.gdal.Dissolve import Dissolve
|
|
47 | 48 | from processing.algs.gdal.hillshade import hillshade
|
48 | 49 | from processing.algs.gdal.ogr2ogr import ogr2ogr
|
49 | 50 | from processing.algs.gdal.ogrinfo import ogrinfo
|
| 51 | +from processing.algs.gdal.OffsetCurve import OffsetCurve |
50 | 52 | from processing.algs.gdal.OgrToPostGis import OgrToPostGis
|
| 53 | +from processing.algs.gdal.OneSideBuffer import OneSideBuffer |
| 54 | +from processing.algs.gdal.PointsAlongLines import PointsAlongLines |
51 | 55 | from processing.algs.gdal.proximity import proximity
|
52 | 56 | from processing.algs.gdal.rasterize import rasterize
|
53 | 57 | from processing.algs.gdal.retile import retile
|
@@ -358,6 +362,47 @@ def testAssignProjection(self):
|
358 | 362 | '-a_srs EPSG:3111 ' +
|
359 | 363 | source])
|
360 | 364 |
|
| 365 | + def testBuffer(self): |
| 366 | + context = QgsProcessingContext() |
| 367 | + feedback = QgsProcessingFeedback() |
| 368 | + source = os.path.join(testDataPath, 'polys.gml') |
| 369 | + source_with_space = os.path.join(testDataPath, 'filename with spaces.gml') |
| 370 | + alg = Buffer() |
| 371 | + alg.initAlgorithm() |
| 372 | + |
| 373 | + with tempfile.TemporaryDirectory() as outdir: |
| 374 | + self.assertEqual( |
| 375 | + alg.getConsoleCommands({'INPUT': source, |
| 376 | + 'DISTANCE': 5, |
| 377 | + 'OUTPUT': outdir + '/check.shp'}, context, feedback), |
| 378 | + ['ogr2ogr', |
| 379 | + outdir + '/check.shp ' + |
| 380 | + source + ' ' + |
| 381 | + '-dialect sqlite -sql "SELECT ST_Buffer(geometry, 5.0) AS geometry,* FROM \'polys2\'" ' + |
| 382 | + '-f "ESRI Shapefile"']) |
| 383 | + |
| 384 | + self.assertEqual( |
| 385 | + alg.getConsoleCommands({'INPUT': source, |
| 386 | + 'DISTANCE': 5, |
| 387 | + 'DISSOLVE': True, |
| 388 | + 'OUTPUT': outdir + '/check.shp'}, context, feedback), |
| 389 | + ['ogr2ogr', |
| 390 | + outdir + '/check.shp ' + |
| 391 | + source + ' ' + |
| 392 | + '-dialect sqlite -sql "SELECT ST_Union(ST_Buffer(geometry, 5.0)) AS geometry,* FROM \'polys2\'" ' + |
| 393 | + '-f "ESRI Shapefile"']) |
| 394 | + |
| 395 | + self.assertEqual( |
| 396 | + alg.getConsoleCommands({'INPUT': source, |
| 397 | + 'DISTANCE': 5, |
| 398 | + 'EXPLODE_COLLECTIONS': True, |
| 399 | + 'OUTPUT': outdir + '/check.shp'}, context, feedback), |
| 400 | + ['ogr2ogr', |
| 401 | + outdir + '/check.shp ' + |
| 402 | + source + ' ' + |
| 403 | + '-dialect sqlite -sql "SELECT ST_Buffer(geometry, 5.0) AS geometry,* FROM \'polys2\'" ' + |
| 404 | + '-explodecollections -f "ESRI Shapefile"']) |
| 405 | + |
361 | 406 | def testGdalTranslate(self):
|
362 | 407 | context = QgsProcessingContext()
|
363 | 408 | feedback = QgsProcessingFeedback()
|
@@ -2238,6 +2283,85 @@ def testFillnodata(self):
|
2238 | 2283 | source + ' ' +
|
2239 | 2284 | outsource])
|
2240 | 2285 |
|
| 2286 | + def testOffsetCurve(self): |
| 2287 | + context = QgsProcessingContext() |
| 2288 | + feedback = QgsProcessingFeedback() |
| 2289 | + source = os.path.join(testDataPath, 'polys.gml') |
| 2290 | + source_with_space = os.path.join(testDataPath, 'filename with spaces.gml') |
| 2291 | + alg = OffsetCurve() |
| 2292 | + alg.initAlgorithm() |
| 2293 | + |
| 2294 | + with tempfile.TemporaryDirectory() as outdir: |
| 2295 | + self.assertEqual( |
| 2296 | + alg.getConsoleCommands({'INPUT': source, |
| 2297 | + 'DISTANCE': 5, |
| 2298 | + 'OUTPUT': outdir + '/check.shp'}, context, feedback), |
| 2299 | + ['ogr2ogr', |
| 2300 | + outdir + '/check.shp ' + |
| 2301 | + source + ' ' + |
| 2302 | + '-dialect sqlite -sql "SELECT ST_OffsetCurve(geometry, 5.0) AS geometry,* FROM \'polys2\'" ' + |
| 2303 | + '-f "ESRI Shapefile"']) |
| 2304 | + |
| 2305 | + def testOneSidedBuffer(self): |
| 2306 | + context = QgsProcessingContext() |
| 2307 | + feedback = QgsProcessingFeedback() |
| 2308 | + source = os.path.join(testDataPath, 'polys.gml') |
| 2309 | + source_with_space = os.path.join(testDataPath, 'filename with spaces.gml') |
| 2310 | + alg = OneSideBuffer() |
| 2311 | + alg.initAlgorithm() |
| 2312 | + |
| 2313 | + with tempfile.TemporaryDirectory() as outdir: |
| 2314 | + self.assertEqual( |
| 2315 | + alg.getConsoleCommands({'INPUT': source, |
| 2316 | + 'DISTANCE': 5, |
| 2317 | + 'OUTPUT': outdir + '/check.shp'}, context, feedback), |
| 2318 | + ['ogr2ogr', |
| 2319 | + outdir + '/check.shp ' + |
| 2320 | + source + ' ' + |
| 2321 | + '-dialect sqlite -sql "SELECT ST_SingleSidedBuffer(geometry, 5.0, 0) AS geometry,* FROM \'polys2\'" ' + |
| 2322 | + '-f "ESRI Shapefile"']) |
| 2323 | + |
| 2324 | + self.assertEqual( |
| 2325 | + alg.getConsoleCommands({'INPUT': source, |
| 2326 | + 'DISTANCE': 5, |
| 2327 | + 'DISSOLVE': True, |
| 2328 | + 'OUTPUT': outdir + '/check.shp'}, context, feedback), |
| 2329 | + ['ogr2ogr', |
| 2330 | + outdir + '/check.shp ' + |
| 2331 | + source + ' ' + |
| 2332 | + '-dialect sqlite -sql "SELECT ST_Union(ST_SingleSidedBuffer(geometry, 5.0, 0)) AS geometry,* FROM \'polys2\'" ' + |
| 2333 | + '-f "ESRI Shapefile"']) |
| 2334 | + |
| 2335 | + self.assertEqual( |
| 2336 | + alg.getConsoleCommands({'INPUT': source, |
| 2337 | + 'DISTANCE': 5, |
| 2338 | + 'EXPLODE_COLLECTIONS': True, |
| 2339 | + 'OUTPUT': outdir + '/check.shp'}, context, feedback), |
| 2340 | + ['ogr2ogr', |
| 2341 | + outdir + '/check.shp ' + |
| 2342 | + source + ' ' + |
| 2343 | + '-dialect sqlite -sql "SELECT ST_SingleSidedBuffer(geometry, 5.0, 0) AS geometry,* FROM \'polys2\'" ' + |
| 2344 | + '-explodecollections -f "ESRI Shapefile"']) |
| 2345 | + |
| 2346 | + def testPointsAlongLines(self): |
| 2347 | + context = QgsProcessingContext() |
| 2348 | + feedback = QgsProcessingFeedback() |
| 2349 | + source = os.path.join(testDataPath, 'polys.gml') |
| 2350 | + source_with_space = os.path.join(testDataPath, 'filename with spaces.gml') |
| 2351 | + alg = PointsAlongLines() |
| 2352 | + alg.initAlgorithm() |
| 2353 | + |
| 2354 | + with tempfile.TemporaryDirectory() as outdir: |
| 2355 | + self.assertEqual( |
| 2356 | + alg.getConsoleCommands({'INPUT': source, |
| 2357 | + 'DISTANCE': 0.2, |
| 2358 | + 'OUTPUT': outdir + '/check.shp'}, context, feedback), |
| 2359 | + ['ogr2ogr', |
| 2360 | + outdir + '/check.shp ' + |
| 2361 | + source + ' ' + |
| 2362 | + '-dialect sqlite -sql "SELECT ST_Line_Interpolate_Point(geometry, 0.2) AS geometry,* FROM \'polys2\'" ' + |
| 2363 | + '-f "ESRI Shapefile"']) |
| 2364 | + |
2241 | 2365 |
|
2242 | 2366 | class TestGdalOgrToPostGis(unittest.TestCase):
|
2243 | 2367 |
|
|
0 commit comments