diff --git a/python/plugins/processing/algs/gdal/GdalAlgorithmProvider.py b/python/plugins/processing/algs/gdal/GdalAlgorithmProvider.py index b372fcb13ab5..7b1baea846e2 100644 --- a/python/plugins/processing/algs/gdal/GdalAlgorithmProvider.py +++ b/python/plugins/processing/algs/gdal/GdalAlgorithmProvider.py @@ -82,7 +82,7 @@ from .ExecuteSql import ExecuteSql from .OffsetCurve import OffsetCurve from .ogr2ogr import ogr2ogr -from .ogrinfo import ogrinfo +from .ogrinfo import ogrinfo, ogrinfojson from .OgrToPostGis import OgrToPostGis from .ogr2ogrtopostgislist import Ogr2OgrToPostGisList from .OneSideBuffer import OneSideBuffer @@ -205,6 +205,9 @@ def loadAlgorithms(self): if int(gdal.VersionInfo()) > 3010000: self.algs.append(viewshed()) + if int(gdal.VersionInfo()) >= 3070000: + self.algs.append(ogrinfojson()) + for a in self.algs: self.addAlgorithm(a) diff --git a/python/plugins/processing/algs/gdal/ogrinfo.py b/python/plugins/processing/algs/gdal/ogrinfo.py index e0ea1568f5be..9fcb4e650c91 100644 --- a/python/plugins/processing/algs/gdal/ogrinfo.py +++ b/python/plugins/processing/algs/gdal/ogrinfo.py @@ -22,6 +22,8 @@ from qgis.core import (QgsProcessingException, QgsProcessingParameterVectorLayer, QgsProcessingParameterBoolean, + QgsProcessingParameterDefinition, + QgsProcessingParameterString, QgsProcessingParameterFileDestination) from processing.algs.gdal.GdalAlgorithm import GdalAlgorithm from processing.algs.gdal.GdalUtils import GdalUtils @@ -29,8 +31,10 @@ class ogrinfo(GdalAlgorithm): INPUT = 'INPUT' + ALL_LAYERS = 'ALL_LAYERS' SUMMARY_ONLY = 'SUMMARY_ONLY' NO_METADATA = 'NO_METADATA' + EXTRA = 'EXTRA' OUTPUT = 'OUTPUT' def __init__(self): @@ -39,16 +43,37 @@ def __init__(self): def initAlgorithm(self, config=None): self.addParameter(QgsProcessingParameterVectorLayer(self.INPUT, self.tr('Input layer'))) - self.addParameter(QgsProcessingParameterBoolean(self.SUMMARY_ONLY, - self.tr('Summary output only'), - defaultValue=True)) + self.addParameter(QgsProcessingParameterBoolean(self.ALL_LAYERS, + self.tr('Enable listing of all layers in the dataset'), + defaultValue=False)) + if self.name() == 'ogrinfo': + self.addParameter(QgsProcessingParameterBoolean(self.SUMMARY_ONLY, + self.tr('Summary output only'), + defaultValue=True)) + else: + self.addParameter(QgsProcessingParameterBoolean(self.FEATURES, + self.tr('Enable listing of features'), + defaultValue=False)) + self.addParameter(QgsProcessingParameterBoolean(self.NO_METADATA, self.tr('Suppress metadata info'), defaultValue=False)) - self.addParameter(QgsProcessingParameterFileDestination(self.OUTPUT, - self.tr('Layer information'), - self.tr('HTML files (*.html)'))) + extra_param = QgsProcessingParameterString(self.EXTRA, + self.tr('Additional command-line parameters'), + defaultValue=None, + optional=True) + extra_param.setFlags(extra_param.flags() | QgsProcessingParameterDefinition.Flag.FlagAdvanced) + self.addParameter(extra_param) + + if self.name() == 'ogrinfo': + self.addParameter(QgsProcessingParameterFileDestination(self.OUTPUT, + self.tr('Layer information'), + self.tr('HTML files (*.html)'))) + else: + self.addParameter(QgsProcessingParameterFileDestination(self.OUTPUT, + self.tr('Layer information'), + self.tr('JSON files (*.json)'))) def name(self): return 'ogrinfo' @@ -66,20 +91,33 @@ def commandName(self): return 'ogrinfo' def getConsoleCommands(self, parameters, context, feedback, executing=True): - arguments = ['-al'] + if self.name() == 'ogrinfo': + arguments = ['-al'] + else: + arguments = ['-json'] + + if self.name() == 'ogrinfo': + if self.parameterAsBoolean(parameters, self.SUMMARY_ONLY, context): + arguments.append('-so') + else: + if self.parameterAsBoolean(parameters, self.FEATURES, context): + arguments.append('-features') - if self.parameterAsBoolean(parameters, self.SUMMARY_ONLY, context): - arguments.append('-so') if self.parameterAsBoolean(parameters, self.NO_METADATA, context): arguments.append('-nomd') + if self.EXTRA in parameters and parameters[self.EXTRA] not in (None, ''): + extra = self.parameterAsString(parameters, self.EXTRA, context) + arguments.append(extra) + inLayer = self.parameterAsVectorLayer(parameters, self.INPUT, context) if inLayer is None: raise QgsProcessingException(self.invalidSourceError(parameters, self.INPUT)) input_details = self.getOgrCompatibleSource(self.INPUT, parameters, context, feedback, executing) arguments.append(input_details.connection_string) - arguments.append(input_details.layer_name) + if not self.parameterAsBoolean(parameters, self.ALL_LAYERS, context): + arguments.append(input_details.layer_name) if input_details.open_options: arguments.extend(input_details.open_options_as_arguments()) @@ -99,3 +137,22 @@ def processAlgorithm(self, parameters, context, feedback): f.write('') return {self.OUTPUT: output} + + +class ogrinfojson(ogrinfo): + FEATURES = 'FEATURES' + + def name(self): + return 'ogrinfojson' + + def displayName(self): + return self.tr('Vector information (JSON)') + + def processAlgorithm(self, parameters, context, feedback): + console_output = GdalUtils.runGdal(self.getConsoleCommands(parameters, context, feedback)) + output = self.parameterAsFileOutput(parameters, self.OUTPUT, context) + with open(output, 'w', newline='') as f: + for s in console_output[1:]: + f.write(str(s)) + + return {self.OUTPUT: output} diff --git a/python/plugins/processing/tests/GdalAlgorithmsVectorTest.py b/python/plugins/processing/tests/GdalAlgorithmsVectorTest.py index fd4e1536c5d5..abebefb4c3f9 100644 --- a/python/plugins/processing/tests/GdalAlgorithmsVectorTest.py +++ b/python/plugins/processing/tests/GdalAlgorithmsVectorTest.py @@ -34,7 +34,7 @@ import AlgorithmsTestBase from processing.algs.gdal.ogr2ogr import ogr2ogr -from processing.algs.gdal.ogrinfo import ogrinfo +from processing.algs.gdal.ogrinfo import ogrinfo, ogrinfojson from processing.algs.gdal.Buffer import Buffer from processing.algs.gdal.Dissolve import Dissolve from processing.algs.gdal.OffsetCurve import OffsetCurve @@ -146,6 +146,27 @@ def testOgrInfo(self): '-al -so ' + source + ' polys2']) + source = os.path.join(testDataPath, 'polys.gml') + self.assertEqual( + alg.getConsoleCommands({'INPUT': source, + 'ALL_LAYERS': True, + 'SUMMARY_ONLY': True, + 'NO_METADATA': False}, context, feedback), + ['ogrinfo', + '-al -so ' + + source]) + + source = os.path.join(testDataPath, 'polys.gml') + self.assertEqual( + alg.getConsoleCommands({'INPUT': source, + 'ALL_LAYERS': True, + 'SUMMARY_ONLY': True, + 'EXTRA': '-nocount', + 'NO_METADATA': False}, context, feedback), + ['ogrinfo', + '-al -so -nocount ' + + source]) + source = os.path.join(testDataPath, 'filename with spaces.gml') self.assertEqual( alg.getConsoleCommands({'INPUT': source, @@ -191,6 +212,87 @@ def testOgrInfo(self): '-al -so -nomd "' + source + '" filename_with_spaces --config X Y --config Z A']) + def testOgrInfoJson(self): + context = QgsProcessingContext() + feedback = QgsProcessingFeedback() + source = os.path.join(testDataPath, 'polys.gml') + alg = ogrinfojson() + alg.initAlgorithm() + + self.assertEqual( + alg.getConsoleCommands({'INPUT': source, + 'FEATURES': True, + 'NO_METADATA': False}, context, feedback), + ['ogrinfo', + '-json -features ' + + source + ' polys2']) + + source = os.path.join(testDataPath, 'polys.gml') + self.assertEqual( + alg.getConsoleCommands({'INPUT': source, + 'ALL_LAYERS': True, + 'FEATURES': True, + 'NO_METADATA': False}, context, feedback), + ['ogrinfo', + '-json -features ' + + source]) + + source = os.path.join(testDataPath, 'polys.gml') + self.assertEqual( + alg.getConsoleCommands({'INPUT': source, + 'ALL_LAYERS': True, + 'FEATURES': True, + 'EXTRA': '-nocount', + 'NO_METADATA': False}, context, feedback), + ['ogrinfo', + '-json -features -nocount ' + + source]) + + source = os.path.join(testDataPath, 'filename with spaces.gml') + self.assertEqual( + alg.getConsoleCommands({'INPUT': source, + 'FEATURES': True, + 'NO_METADATA': False}, context, feedback), + ['ogrinfo', + '-json -features "' + + source + '" filename_with_spaces']) + + source = os.path.join(testDataPath, 'filename with spaces.gml') + self.assertEqual( + alg.getConsoleCommands({'INPUT': source, + 'FEATURES': False, + 'NO_METADATA': False}, context, feedback), + ['ogrinfo', + '-json "' + + source + '" filename_with_spaces']) + + source = os.path.join(testDataPath, 'filename with spaces.gml') + self.assertEqual( + alg.getConsoleCommands({'INPUT': source, + 'FEATURES': True, + 'NO_METADATA': True}, context, feedback), + ['ogrinfo', + '-json -features -nomd "' + + source + '" filename_with_spaces']) + + source = os.path.join(testDataPath, 'filename with spaces.gml') + self.assertEqual( + alg.getConsoleCommands({'INPUT': source + '|option:X_POSSIBLE_NAMES=geom_x|option:Y_POSSIBLE_NAMES=geom_y', + 'FEATURES': True, + 'NO_METADATA': True}, context, feedback), + ['ogrinfo', + '-json -features -nomd "' + + source + '" filename_with_spaces -oo X_POSSIBLE_NAMES=geom_x -oo Y_POSSIBLE_NAMES=geom_y']) + + source = os.path.join(testDataPath, 'filename with spaces.gml') + self.assertEqual( + alg.getConsoleCommands({'INPUT': source + '|credential:X=Y|credential:Z=A', + 'FEATURES': True, + 'NO_METADATA': True}, context, feedback), + ['ogrinfo', + '-json -features -nomd "' + + source + '" filename_with_spaces --config X Y --config Z A']) + def testBuffer(self): context = QgsProcessingContext() feedback = QgsProcessingFeedback() diff --git a/python/plugins/processing/tests/testdata/expected/gdal/vector_info.json b/python/plugins/processing/tests/testdata/expected/gdal/vector_info.json new file mode 100644 index 000000000000..2636247e4470 --- /dev/null +++ b/python/plugins/processing/tests/testdata/expected/gdal/vector_info.json @@ -0,0 +1,143 @@ +{ + "description":"C:/OSGeo4W/apps/qgis-dev/python/plugins/processing/tests/testdata/lines.gml", + "driverShortName":"GML", + "driverLongName":"Geography Markup Language (GML)", + "layers":[ + { + "name":"lines", + "metadata":{ + }, + "geometryFields":[ + { + "name":"", + "type":"LineString", + "nullable":true, + "extent":[ + -1.0, + -3.0, + 11.0, + 5.0 + ], + "coordinateSystem":{ + "wkt":"GEOGCRS[\"WGS 84\",\n ENSEMBLE[\"World Geodetic System 1984 ensemble\",\n MEMBER[\"World Geodetic System 1984 (Transit)\"],\n MEMBER[\"World Geodetic System 1984 (G730)\"],\n MEMBER[\"World Geodetic System 1984 (G873)\"],\n MEMBER[\"World Geodetic System 1984 (G1150)\"],\n MEMBER[\"World Geodetic System 1984 (G1674)\"],\n MEMBER[\"World Geodetic System 1984 (G1762)\"],\n MEMBER[\"World Geodetic System 1984 (G2139)\"],\n ELLIPSOID[\"WGS 84\",6378137,298.257223563,\n LENGTHUNIT[\"metre\",1]],\n ENSEMBLEACCURACY[2.0]],\n PRIMEM[\"Greenwich\",0,\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n CS[ellipsoidal,2],\n AXIS[\"geodetic latitude (Lat)\",north,\n ORDER[1],\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n AXIS[\"geodetic longitude (Lon)\",east,\n ORDER[2],\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n USAGE[\n SCOPE[\"Horizontal component of 3D system.\"],\n AREA[\"World.\"],\n BBOX[-90,-180,90,180]],\n ID[\"EPSG\",4326]]", + "projjson":{ + "$schema":"https://proj.org/schemas/v0.7/projjson.schema.json", + "type":"GeographicCRS", + "name":"WGS 84", + "datum_ensemble":{ + "name":"World Geodetic System 1984 ensemble", + "members":[ + { + "name":"World Geodetic System 1984 (Transit)", + "id":{ + "authority":"EPSG", + "code":1166 + } + }, + { + "name":"World Geodetic System 1984 (G730)", + "id":{ + "authority":"EPSG", + "code":1152 + } + }, + { + "name":"World Geodetic System 1984 (G873)", + "id":{ + "authority":"EPSG", + "code":1153 + } + }, + { + "name":"World Geodetic System 1984 (G1150)", + "id":{ + "authority":"EPSG", + "code":1154 + } + }, + { + "name":"World Geodetic System 1984 (G1674)", + "id":{ + "authority":"EPSG", + "code":1155 + } + }, + { + "name":"World Geodetic System 1984 (G1762)", + "id":{ + "authority":"EPSG", + "code":1156 + } + }, + { + "name":"World Geodetic System 1984 (G2139)", + "id":{ + "authority":"EPSG", + "code":1309 + } + } + ], + "ellipsoid":{ + "name":"WGS 84", + "semi_major_axis":6378137, + "inverse_flattening":298.257223563 + }, + "accuracy":"2.0", + "id":{ + "authority":"EPSG", + "code":6326 + } + }, + "coordinate_system":{ + "subtype":"ellipsoidal", + "axis":[ + { + "name":"Geodetic latitude", + "abbreviation":"Lat", + "direction":"north", + "unit":"degree" + }, + { + "name":"Geodetic longitude", + "abbreviation":"Lon", + "direction":"east", + "unit":"degree" + } + ] + }, + "scope":"Horizontal component of 3D system.", + "area":"World.", + "bbox":{ + "south_latitude":-90, + "west_longitude":-180, + "north_latitude":90, + "east_longitude":180 + }, + "id":{ + "authority":"EPSG", + "code":4326 + } + }, + "dataAxisToSRSAxisMapping":[ + 2, + 1 + ] + } + } + ], + "featureCount":6, + "fields":[ + { + "name":"fid", + "type":"String", + "nullable":false, + "uniqueConstraint":false + } + ] + } + ], + "metadata":{ + }, + "domains":{ + } +} \ No newline at end of file diff --git a/python/plugins/processing/tests/testdata/expected/gdal/vector_info_2.html b/python/plugins/processing/tests/testdata/expected/gdal/vector_info_2.html new file mode 100644 index 000000000000..5823f04ae525 --- /dev/null +++ b/python/plugins/processing/tests/testdata/expected/gdal/vector_info_2.html @@ -0,0 +1,74 @@ +
INFO: Open of `C:/OSGeo4W/apps/qgis-dev/python/plugins/processing/tests/testdata/points_lines.gpkg'

+      using driver `GPKG' successful.

+

+Layer name: points

+Geometry: Point

+Feature Count: 9

+Extent: (0.000000, -5.000000) - (8.000000, 3.000000)

+Layer SRS WKT:

+GEOGCRS["WGS 84",

+    ENSEMBLE["World Geodetic System 1984 ensemble",

+        MEMBER["World Geodetic System 1984 (Transit)"],

+        MEMBER["World Geodetic System 1984 (G730)"],

+        MEMBER["World Geodetic System 1984 (G873)"],

+        MEMBER["World Geodetic System 1984 (G1150)"],

+        MEMBER["World Geodetic System 1984 (G1674)"],

+        MEMBER["World Geodetic System 1984 (G1762)"],

+        MEMBER["World Geodetic System 1984 (G2139)"],

+        ELLIPSOID["WGS 84",6378137,298.257223563,

+            LENGTHUNIT["metre",1]],

+        ENSEMBLEACCURACY[2.0]],

+    PRIMEM["Greenwich",0,

+        ANGLEUNIT["degree",0.0174532925199433]],

+    CS[ellipsoidal,2],

+        AXIS["geodetic latitude (Lat)",north,

+            ORDER[1],

+            ANGLEUNIT["degree",0.0174532925199433]],

+        AXIS["geodetic longitude (Lon)",east,

+            ORDER[2],

+            ANGLEUNIT["degree",0.0174532925199433]],

+    USAGE[

+        SCOPE["Horizontal component of 3D system."],

+        AREA["World."],

+        BBOX[-90,-180,90,180]],

+    ID["EPSG",4326]]

+Data axis to CRS axis mapping: 2,1

+FID Column = fid

+Geometry Column = geom

+id: Integer (0.0)

+id2: Integer (0.0)

+

+Layer name: lines

+Geometry: Line String

+Feature Count: 7

+Extent: (-1.000000, -3.000000) - (11.000000, 5.000000)

+Layer SRS WKT:

+GEOGCRS["WGS 84",

+    ENSEMBLE["World Geodetic System 1984 ensemble",

+        MEMBER["World Geodetic System 1984 (Transit)"],

+        MEMBER["World Geodetic System 1984 (G730)"],

+        MEMBER["World Geodetic System 1984 (G873)"],

+        MEMBER["World Geodetic System 1984 (G1150)"],

+        MEMBER["World Geodetic System 1984 (G1674)"],

+        MEMBER["World Geodetic System 1984 (G1762)"],

+        MEMBER["World Geodetic System 1984 (G2139)"],

+        ELLIPSOID["WGS 84",6378137,298.257223563,

+            LENGTHUNIT["metre",1]],

+        ENSEMBLEACCURACY[2.0]],

+    PRIMEM["Greenwich",0,

+        ANGLEUNIT["degree",0.0174532925199433]],

+    CS[ellipsoidal,2],

+        AXIS["geodetic latitude (Lat)",north,

+            ORDER[1],

+            ANGLEUNIT["degree",0.0174532925199433]],

+        AXIS["geodetic longitude (Lon)",east,

+            ORDER[2],

+            ANGLEUNIT["degree",0.0174532925199433]],

+    USAGE[

+        SCOPE["Horizontal component of 3D system."],

+        AREA["World."],

+        BBOX[-90,-180,90,180]],

+    ID["EPSG",4326]]

+Data axis to CRS axis mapping: 2,1

+FID Column = fid

+Geometry Column = geom
\ No newline at end of file diff --git a/python/plugins/processing/tests/testdata/expected/gdal/vector_info_2.json b/python/plugins/processing/tests/testdata/expected/gdal/vector_info_2.json new file mode 100644 index 000000000000..46fb8c98bc15 --- /dev/null +++ b/python/plugins/processing/tests/testdata/expected/gdal/vector_info_2.json @@ -0,0 +1,279 @@ +{ + "description":"C:/OSGeo4W/apps/qgis-dev/python/plugins/processing/tests/testdata/points_lines.gpkg", + "driverShortName":"GPKG", + "driverLongName":"GeoPackage", + "layers":[ + { + "name":"points", + "metadata":{ + }, + "geometryFields":[ + { + "name":"geom", + "type":"Point", + "nullable":true, + "extent":[ + 0.0, + -5.0, + 8.0, + 3.0 + ], + "coordinateSystem":{ + "wkt":"GEOGCRS[\"WGS 84\",\n ENSEMBLE[\"World Geodetic System 1984 ensemble\",\n MEMBER[\"World Geodetic System 1984 (Transit)\"],\n MEMBER[\"World Geodetic System 1984 (G730)\"],\n MEMBER[\"World Geodetic System 1984 (G873)\"],\n MEMBER[\"World Geodetic System 1984 (G1150)\"],\n MEMBER[\"World Geodetic System 1984 (G1674)\"],\n MEMBER[\"World Geodetic System 1984 (G1762)\"],\n MEMBER[\"World Geodetic System 1984 (G2139)\"],\n ELLIPSOID[\"WGS 84\",6378137,298.257223563,\n LENGTHUNIT[\"metre\",1]],\n ENSEMBLEACCURACY[2.0]],\n PRIMEM[\"Greenwich\",0,\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n CS[ellipsoidal,2],\n AXIS[\"geodetic latitude (Lat)\",north,\n ORDER[1],\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n AXIS[\"geodetic longitude (Lon)\",east,\n ORDER[2],\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n USAGE[\n SCOPE[\"Horizontal component of 3D system.\"],\n AREA[\"World.\"],\n BBOX[-90,-180,90,180]],\n ID[\"EPSG\",4326]]", + "projjson":{ + "$schema":"https://proj.org/schemas/v0.7/projjson.schema.json", + "type":"GeographicCRS", + "name":"WGS 84", + "datum_ensemble":{ + "name":"World Geodetic System 1984 ensemble", + "members":[ + { + "name":"World Geodetic System 1984 (Transit)", + "id":{ + "authority":"EPSG", + "code":1166 + } + }, + { + "name":"World Geodetic System 1984 (G730)", + "id":{ + "authority":"EPSG", + "code":1152 + } + }, + { + "name":"World Geodetic System 1984 (G873)", + "id":{ + "authority":"EPSG", + "code":1153 + } + }, + { + "name":"World Geodetic System 1984 (G1150)", + "id":{ + "authority":"EPSG", + "code":1154 + } + }, + { + "name":"World Geodetic System 1984 (G1674)", + "id":{ + "authority":"EPSG", + "code":1155 + } + }, + { + "name":"World Geodetic System 1984 (G1762)", + "id":{ + "authority":"EPSG", + "code":1156 + } + }, + { + "name":"World Geodetic System 1984 (G2139)", + "id":{ + "authority":"EPSG", + "code":1309 + } + } + ], + "ellipsoid":{ + "name":"WGS 84", + "semi_major_axis":6378137, + "inverse_flattening":298.257223563 + }, + "accuracy":"2.0", + "id":{ + "authority":"EPSG", + "code":6326 + } + }, + "coordinate_system":{ + "subtype":"ellipsoidal", + "axis":[ + { + "name":"Geodetic latitude", + "abbreviation":"Lat", + "direction":"north", + "unit":"degree" + }, + { + "name":"Geodetic longitude", + "abbreviation":"Lon", + "direction":"east", + "unit":"degree" + } + ] + }, + "scope":"Horizontal component of 3D system.", + "area":"World.", + "bbox":{ + "south_latitude":-90, + "west_longitude":-180, + "north_latitude":90, + "east_longitude":180 + }, + "id":{ + "authority":"EPSG", + "code":4326 + } + }, + "dataAxisToSRSAxisMapping":[ + 2, + 1 + ] + } + } + ], + "featureCount":9, + "fidColumnName":"fid", + "fields":[ + { + "name":"id", + "type":"Integer", + "nullable":true, + "uniqueConstraint":false + }, + { + "name":"id2", + "type":"Integer", + "nullable":true, + "uniqueConstraint":false + } + ] + }, + { + "name":"lines", + "metadata":{ + }, + "geometryFields":[ + { + "name":"geom", + "type":"LineString", + "nullable":true, + "extent":[ + -1.0, + -3.0, + 11.0, + 5.0 + ], + "coordinateSystem":{ + "wkt":"GEOGCRS[\"WGS 84\",\n ENSEMBLE[\"World Geodetic System 1984 ensemble\",\n MEMBER[\"World Geodetic System 1984 (Transit)\"],\n MEMBER[\"World Geodetic System 1984 (G730)\"],\n MEMBER[\"World Geodetic System 1984 (G873)\"],\n MEMBER[\"World Geodetic System 1984 (G1150)\"],\n MEMBER[\"World Geodetic System 1984 (G1674)\"],\n MEMBER[\"World Geodetic System 1984 (G1762)\"],\n MEMBER[\"World Geodetic System 1984 (G2139)\"],\n ELLIPSOID[\"WGS 84\",6378137,298.257223563,\n LENGTHUNIT[\"metre\",1]],\n ENSEMBLEACCURACY[2.0]],\n PRIMEM[\"Greenwich\",0,\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n CS[ellipsoidal,2],\n AXIS[\"geodetic latitude (Lat)\",north,\n ORDER[1],\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n AXIS[\"geodetic longitude (Lon)\",east,\n ORDER[2],\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n USAGE[\n SCOPE[\"Horizontal component of 3D system.\"],\n AREA[\"World.\"],\n BBOX[-90,-180,90,180]],\n ID[\"EPSG\",4326]]", + "projjson":{ + "$schema":"https://proj.org/schemas/v0.7/projjson.schema.json", + "type":"GeographicCRS", + "name":"WGS 84", + "datum_ensemble":{ + "name":"World Geodetic System 1984 ensemble", + "members":[ + { + "name":"World Geodetic System 1984 (Transit)", + "id":{ + "authority":"EPSG", + "code":1166 + } + }, + { + "name":"World Geodetic System 1984 (G730)", + "id":{ + "authority":"EPSG", + "code":1152 + } + }, + { + "name":"World Geodetic System 1984 (G873)", + "id":{ + "authority":"EPSG", + "code":1153 + } + }, + { + "name":"World Geodetic System 1984 (G1150)", + "id":{ + "authority":"EPSG", + "code":1154 + } + }, + { + "name":"World Geodetic System 1984 (G1674)", + "id":{ + "authority":"EPSG", + "code":1155 + } + }, + { + "name":"World Geodetic System 1984 (G1762)", + "id":{ + "authority":"EPSG", + "code":1156 + } + }, + { + "name":"World Geodetic System 1984 (G2139)", + "id":{ + "authority":"EPSG", + "code":1309 + } + } + ], + "ellipsoid":{ + "name":"WGS 84", + "semi_major_axis":6378137, + "inverse_flattening":298.257223563 + }, + "accuracy":"2.0", + "id":{ + "authority":"EPSG", + "code":6326 + } + }, + "coordinate_system":{ + "subtype":"ellipsoidal", + "axis":[ + { + "name":"Geodetic latitude", + "abbreviation":"Lat", + "direction":"north", + "unit":"degree" + }, + { + "name":"Geodetic longitude", + "abbreviation":"Lon", + "direction":"east", + "unit":"degree" + } + ] + }, + "scope":"Horizontal component of 3D system.", + "area":"World.", + "bbox":{ + "south_latitude":-90, + "west_longitude":-180, + "north_latitude":90, + "east_longitude":180 + }, + "id":{ + "authority":"EPSG", + "code":4326 + } + }, + "dataAxisToSRSAxisMapping":[ + 2, + 1 + ] + } + } + ], + "featureCount":7, + "fidColumnName":"fid", + "fields":[ + ] + } + ], + "metadata":{ + }, + "domains":{ + }, + "relationships":{ + } +} \ No newline at end of file diff --git a/python/plugins/processing/tests/testdata/gdal_algorithm_vector_tests.yaml b/python/plugins/processing/tests/testdata/gdal_algorithm_vector_tests.yaml index 8c8fa9a7bf08..70bf276de90f 100644 --- a/python/plugins/processing/tests/testdata/gdal_algorithm_vector_tests.yaml +++ b/python/plugins/processing/tests/testdata/gdal_algorithm_vector_tests.yaml @@ -242,6 +242,69 @@ tests: - 'Geometry: Line String' - 'Feature Count: [6|7]' # On some platforms returns 6 instead of 7... + - algorithm: gdal:ogrinfo + name: ogrinfo all layers + params: + INPUT: + name: points_lines.gpkg + type: vector + SUMMARY_ONLY: 'True' + ALL_LAYERS: 'True' + results: + OUTPUT: + name: expected/gdal/vector_info_2.html + type: regex + rules: + - 'Layer name: points' + - 'Geometry: Point' + - 'Feature Count: 9' + - 'Extent: \(0.000000, -5.000000\) - \(8.000000, 3.000000\)' + - 'Layer name: lines' + - 'Geometry: Line String' + - 'Feature Count: 7' + - 'Extent: \(-1.000000, -3.000000\) - \(11.000000, 5.000000\)' + + - algorithm: gdal:ogrinfojson + name: ogrinfo (json) + condition: + gdal: + at_least: 3070000 + params: + INPUT: + name: lines.gml + type: vector + results: + OUTPUT: + name: expected/gdal/vector_info.json + type: regex + rules: + - '"extent":\[\n\s*-1.0,\s*-3.0,\n\s*11.0,\n\s*5.0\n\s*\],' + - '"type":"LineString",' + - '"featureCount":[6|7],' # On some platforms returns 6 instead of 7... + + - algorithm: gdal:ogrinfojson + name: ogrinfo (json) all layers + condition: + gdal: + at_least: 3070000 + params: + INPUT: + name: points_lines.gpkg + type: vector + results: + OUTPUT: + name: expected/gdal/vector_info_2.json + type: regex + rules: + - '"name":"points",' + - '"type":"Point",' + - '"extent":\[\n\s*0.0,\s*-5.0,\n\s*8.0,\n\s*3.0\n\s*\],' + - '"featureCount":9,' + - '"name":"lines",' + - '"type":"LineString",' + - '"extent":\[\n\s*-1.0,\s*-3.0,\n\s*11.0,\n\s*5.0\n\s*\],' + - '"featureCount":7,' + - algorithm: gdal:onesidebuffer name: One-sided buffer (left-handed) params: