Add unit tests & fix some review issues

This commit is contained in:
Withalion 2024-12-18 01:42:46 +01:00 committed by Martin Dobias
parent 057402a895
commit ad1475e735
10 changed files with 974 additions and 37 deletions

View File

@ -11088,21 +11088,6 @@ Qgis.MouseHandlesAction.__doc__ = """Action to be performed by the mouse handles
# --
Qgis.MouseHandlesAction.baseClass = Qgis
# monkey patching scoped based enum
Qgis.PointCloudZoomOutRenderBehavior.RenderExtents.__doc__ = "Render just point cloud extends when zoomed out"
Qgis.PointCloudZoomOutRenderBehavior.RenderOverview.__doc__ = "Render overview point cloud when zoomed out"
Qgis.PointCloudZoomOutRenderBehavior.RenderOverviewAndExtents.__doc__ = "Render extent polygons over overview point cloud"
Qgis.PointCloudZoomOutRenderBehavior.__doc__ = """Point cloud zoom out options
.. versionadded:: 3.42
* ``RenderExtents``: Render just point cloud extends when zoomed out
* ``RenderOverview``: Render overview point cloud when zoomed out
* ``RenderOverviewAndExtents``: Render extent polygons over overview point cloud
"""
# --
Qgis.PointCloudZoomOutRenderBehavior.baseClass = Qgis
# monkey patching scoped based enum
Qgis.MeshRangeLimit.NotSet.__doc__ = "User defined"
Qgis.MeshRangeLimit.MinimumMaximum.__doc__ = "Real min-max values"
Qgis.MeshRangeLimit.__doc__ = """Describes the limits used to compute mesh ranges (min/max values).
@ -11131,6 +11116,21 @@ Qgis.MeshRangeExtent.__doc__ = """Describes the extent used to compute mesh rang
# --
Qgis.MeshRangeExtent.baseClass = Qgis
# monkey patching scoped based enum
Qgis.PointCloudZoomOutRenderBehavior.RenderExtents.__doc__ = "Render only point cloud extents when zoomed out"
Qgis.PointCloudZoomOutRenderBehavior.RenderOverview.__doc__ = "Render overview point cloud when zoomed out"
Qgis.PointCloudZoomOutRenderBehavior.RenderOverviewAndExtents.__doc__ = "Render point cloud extents over overview point cloud"
Qgis.PointCloudZoomOutRenderBehavior.__doc__ = """Point cloud zoom out options
.. versionadded:: 3.42
* ``RenderExtents``: Render only point cloud extents when zoomed out
* ``RenderOverview``: Render overview point cloud when zoomed out
* ``RenderOverviewAndExtents``: Render point cloud extents over overview point cloud
"""
# --
Qgis.PointCloudZoomOutRenderBehavior.baseClass = Qgis
# monkey patching scoped based enum
Qgis.PointCloudAccessType.Local.__doc__ = "Local means the source is a local file on the machine"
Qgis.PointCloudAccessType.Remote.__doc__ = "Remote means it's loaded through a protocol like HTTP"
Qgis.PointCloudAccessType.__doc__ = """The access type of the data, local is for local files and remote for remote files (over HTTP).

View File

@ -10998,23 +10998,6 @@ Qgis.MouseHandlesAction.__doc__ = """Action to be performed by the mouse handles
# --
Qgis.MouseHandlesAction.baseClass = Qgis
# monkey patching scoped based enum
Qgis.PointCloudZoomOutRenderBehavior.RenderExtents.__doc__ = "Render just point cloud extends when zoomed out"
Qgis.PointCloudZoomOutRenderBehavior.RenderOverview.__doc__ = "Render overview point cloud when zoomed out"
Qgis.PointCloudZoomOutRenderBehavior.RenderOverviewAndExtents.__doc__ = "Render extent polygons over overview point cloud"
Qgis.PointCloudZoomOutRenderBehavior.__doc__ = """Point cloud zoom out options
.. versionadded:: 3.42
* ``RenderExtents``: Render just point cloud extends when zoomed out
* ``RenderOverview``: Render overview point cloud when zoomed out
* ``RenderOverviewAndExtents``: Render extent polygons over overview point cloud
"""
# --
Qgis.PointCloudZoomOutRenderBehavior.baseClass = Qgis
# --
Qgis.MouseHandlesAction.baseClass = Qgis
# monkey patching scoped based enum
Qgis.MeshRangeLimit.NotSet.__doc__ = "User defined"
Qgis.MeshRangeLimit.MinimumMaximum.__doc__ = "Real min-max values"
Qgis.MeshRangeLimit.__doc__ = """Describes the limits used to compute mesh ranges (min/max values).
@ -11043,6 +11026,21 @@ Qgis.MeshRangeExtent.__doc__ = """Describes the extent used to compute mesh rang
# --
Qgis.MeshRangeExtent.baseClass = Qgis
# monkey patching scoped based enum
Qgis.PointCloudZoomOutRenderBehavior.RenderExtents.__doc__ = "Render only point cloud extents when zoomed out"
Qgis.PointCloudZoomOutRenderBehavior.RenderOverview.__doc__ = "Render overview point cloud when zoomed out"
Qgis.PointCloudZoomOutRenderBehavior.RenderOverviewAndExtents.__doc__ = "Render point cloud extents over overview point cloud"
Qgis.PointCloudZoomOutRenderBehavior.__doc__ = """Point cloud zoom out options
.. versionadded:: 3.42
* ``RenderExtents``: Render only point cloud extents when zoomed out
* ``RenderOverview``: Render overview point cloud when zoomed out
* ``RenderOverviewAndExtents``: Render point cloud extents over overview point cloud
"""
# --
Qgis.PointCloudZoomOutRenderBehavior.baseClass = Qgis
# monkey patching scoped based enum
Qgis.PointCloudAccessType.Local.__doc__ = "Local means the source is a local file on the machine"
Qgis.PointCloudAccessType.Remote.__doc__ = "Remote means it's loaded through a protocol like HTTP"
Qgis.PointCloudAccessType.__doc__ = """The access type of the data, local is for local files and remote for remote files (over HTTP).

View File

@ -5740,9 +5740,9 @@ class CORE_EXPORT Qgis
*/
enum class PointCloudZoomOutRenderBehavior : int
{
RenderExtents, //!< Render just point cloud extends when zoomed out
RenderExtents, //!< Render only point cloud extents when zoomed out
RenderOverview, //!< Render overview point cloud when zoomed out
RenderOverviewAndExtents //!< Render extent polygons over overview point cloud
RenderOverviewAndExtents //!< Render point cloud extents over overview point cloud
};
Q_ENUM( PointCloudZoomOutRenderBehavior )

View File

@ -129,6 +129,7 @@ QgsPointCloudRendererPropertiesWidget::QgsPointCloudRendererPropertiesWidget( Qg
if ( !mLayer->dataProvider()->subIndexes().isEmpty() )
{
mLabelOptions->setDialogTitle( tr( "Customize label text" ) );
mLabelOptions->setText( tr( "Label format" ) );
connect( mLabels, &QCheckBox::stateChanged, this, &QgsPointCloudRendererPropertiesWidget::emitWidgetChanged );
connect( mLabelOptions, &QgsFontButton::changed, this, &QgsPointCloudRendererPropertiesWidget::emitWidgetChanged );
mZoomOutOptions->addItem( tr( "Show Extents Only" ), QVariant::fromValue( Qgis::PointCloudZoomOutRenderBehavior::RenderExtents ) );
@ -146,8 +147,8 @@ QgsPointCloudRendererPropertiesWidget::QgsPointCloudRendererPropertiesWidget( Qg
mZoomOutOptions->setEnabled( false );
}
connect( mZoomOutOptions, qOverload<int>( &QComboBox::currentIndexChanged ), this, [this]( int currentZoomOutOption ) {
switch ( static_cast<Qgis::PointCloudZoomOutRenderBehavior>( currentZoomOutOption ) )
connect( mZoomOutOptions, qOverload<int>( &QComboBox::currentIndexChanged ), this, [this]( int ) {
switch ( mZoomOutOptions->currentData().value<Qgis::PointCloudZoomOutRenderBehavior>() )
{
case Qgis::PointCloudZoomOutRenderBehavior::RenderOverview:
mLabels->setEnabled( false );

View File

@ -1301,7 +1301,7 @@ void TestQgsIdentify::identifyPointCloud()
void TestQgsIdentify::identifyVirtualPointCloud()
{
#ifdef HAVE_COPC
std::unique_ptr<QgsPointCloudLayer> pointCloud = std::make_unique<QgsPointCloudLayer>( QStringLiteral( TEST_DATA_DIR ) + "/point_clouds/virtual/sunshine-coast/combined.vpc", QStringLiteral( "pointcloud" ), QStringLiteral( "vpc" ) );
std::unique_ptr<QgsPointCloudLayer> pointCloud = std::make_unique<QgsPointCloudLayer>( QStringLiteral( TEST_DATA_DIR ) + "/point_clouds/virtual/sunshine-coast/new-combined.vpc", QStringLiteral( "pointcloud" ), QStringLiteral( "vpc" ) );
QVERIFY( pointCloud->isValid() );
pointCloud->setCrs( QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:28356" ) ) );
QCOMPARE( pointCloud->crs3D().horizontalCrs().authid(), QStringLiteral( "EPSG:28356" ) );

View File

@ -468,6 +468,67 @@ class TestQgsPointCloudClassifiedRenderer(QgisTestCase):
)
)
@unittest.skipIf(
"vpc" not in QgsProviderRegistry.instance().providerList(),
"VPC provider not available",
)
def testOverviewRender(self):
layer = QgsPointCloudLayer(
unitTestDataPath()
+ "/point_clouds/virtual/sunshine-coast/new-combined.vpc",
"test",
"vpc",
)
self.assertTrue(layer.isValid())
layer.setRenderer(layer.dataProvider().createRenderer())
layer.renderer().setPointSize(2)
layer.renderer().setPointSizeUnit(QgsUnitTypes.RenderUnit.RenderMillimeters)
mapsettings = QgsMapSettings()
mapsettings.setOutputSize(QSize(400, 400))
mapsettings.setOutputDpi(96)
mapsettings.setDestinationCrs(layer.crs())
mapsettings.setExtent(QgsRectangle(498061, 7050991, 498069, 7050999))
mapsettings.setLayers([layer])
self.assertTrue(
self.render_map_settings_check(
"classified_render_overview", "classified_render_overview", mapsettings
)
)
@unittest.skipIf(
"vpc" not in QgsProviderRegistry.instance().providerList(),
"VPC provider not available",
)
def testExtentsRender(self):
layer = QgsPointCloudLayer(
unitTestDataPath() + "/point_clouds/virtual/sunshine-coast/combined.vpc",
"test",
"vpc",
)
self.assertTrue(layer.isValid())
layer.setRenderer(layer.dataProvider().createRenderer())
layer.renderer().setPointSize(2)
layer.renderer().setPointSizeUnit(QgsUnitTypes.RenderUnit.RenderMillimeters)
mapsettings = QgsMapSettings()
mapsettings.setOutputSize(QSize(400, 400))
mapsettings.setOutputDpi(96)
mapsettings.setDestinationCrs(layer.crs())
mapsettings.setExtent(QgsRectangle(498061, 7050991, 498069, 7050999))
mapsettings.setLayers([layer])
self.assertTrue(
self.render_map_settings_check(
"classified_render_extents", "classified_render_extents", mapsettings
)
)
if __name__ == "__main__":
unittest.main()

Binary file not shown.

After

Width:  |  Height:  |  Size: 460 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 460 KiB

View File

@ -0,0 +1,877 @@
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"stac_version": "1.0.0",
"stac_extensions": [
"https://stac-extensions.github.io/pointcloud/v1.0.0/schema.json",
"https://stac-extensions.github.io/projection/v1.1.0/schema.json"
],
"id": "0-0.copc",
"geometry": {
"coordinates": [
[
[
498062.0,
7050992.85,
74.68
],
[
498062.0,
7050995.82,
74.68
],
[
498064.98,
7050995.82,
75.16
],
[
498064.98,
7050992.85,
75.16
],
[
498062.0,
7050992.85,
74.68
]
]
],
"type": "Polygon"
},
"bbox": [
498062.0,
7050992.85,
74.68,
498064.98,
7050995.82,
75.16
],
"properties": {
"datetime": "2024-10-18T00:00:00Z",
"pc:count": 91,
"pc:encoding": "?",
"pc:schemas": [
{
"name": "X",
"size": 8,
"type": "floating"
},
{
"name": "Y",
"size": 8,
"type": "floating"
},
{
"name": "Z",
"size": 8,
"type": "floating"
},
{
"name": "Intensity",
"size": 2,
"type": "unsigned"
},
{
"name": "ReturnNumber",
"size": 1,
"type": "unsigned"
},
{
"name": "NumberOfReturns",
"size": 1,
"type": "unsigned"
},
{
"name": "ScanDirectionFlag",
"size": 1,
"type": "unsigned"
},
{
"name": "EdgeOfFlightLine",
"size": 1,
"type": "unsigned"
},
{
"name": "Classification",
"size": 1,
"type": "unsigned"
},
{
"name": "Synthetic",
"size": 1,
"type": "unsigned"
},
{
"name": "KeyPoint",
"size": 1,
"type": "unsigned"
},
{
"name": "Withheld",
"size": 1,
"type": "unsigned"
},
{
"name": "Overlap",
"size": 1,
"type": "unsigned"
},
{
"name": "ScanAngleRank",
"size": 4,
"type": "floating"
},
{
"name": "UserData",
"size": 1,
"type": "unsigned"
},
{
"name": "PointSourceId",
"size": 2,
"type": "unsigned"
},
{
"name": "GpsTime",
"size": 8,
"type": "floating"
},
{
"name": "ScanChannel",
"size": 1,
"type": "unsigned"
},
{
"name": "Red",
"size": 2,
"type": "unsigned"
},
{
"name": "Green",
"size": 2,
"type": "unsigned"
},
{
"name": "Blue",
"size": 2,
"type": "unsigned"
}
],
"pc:type": "lidar",
"proj:bbox": [
498062.0,
7050992.85,
74.68,
498064.98,
7050995.82,
75.16
],
"proj:geometry": {
"coordinates": [
[
[
498062.0,
7050992.85,
74.68
],
[
498062.0,
7050995.82,
74.68
],
[
498064.98,
7050995.82,
75.16
],
[
498064.98,
7050992.85,
75.16
],
[
498062.0,
7050992.85,
74.68
]
]
],
"type": "Polygon"
},
"proj:wkt2": ""
},
"links": [],
"assets": {
"data": {
"href": "./0-0.copc.laz",
"roles": [
"data"
]
},
"overview": {
"href": "./new-combined-overview.copc.laz",
"roles": [
"overview"
]
}
}
},
{
"type": "Feature",
"stac_version": "1.0.0",
"stac_extensions": [
"https://stac-extensions.github.io/pointcloud/v1.0.0/schema.json",
"https://stac-extensions.github.io/projection/v1.1.0/schema.json"
],
"id": "0-1.copc",
"geometry": {
"coordinates": [
[
[
498062.04,
7050995.84,
74.64
],
[
498062.04,
7050997.03,
74.64
],
[
498064.91,
7050997.03,
79.0
],
[
498064.91,
7050995.84,
79.0
],
[
498062.04,
7050995.84,
74.64
]
]
],
"type": "Polygon"
},
"bbox": [
498062.04,
7050995.84,
74.64,
498064.91,
7050997.03,
79.0
],
"properties": {
"datetime": "2024-10-18T00:00:00Z",
"pc:count": 47,
"pc:encoding": "?",
"pc:schemas": [
{
"name": "X",
"size": 8,
"type": "floating"
},
{
"name": "Y",
"size": 8,
"type": "floating"
},
{
"name": "Z",
"size": 8,
"type": "floating"
},
{
"name": "Intensity",
"size": 2,
"type": "unsigned"
},
{
"name": "ReturnNumber",
"size": 1,
"type": "unsigned"
},
{
"name": "NumberOfReturns",
"size": 1,
"type": "unsigned"
},
{
"name": "ScanDirectionFlag",
"size": 1,
"type": "unsigned"
},
{
"name": "EdgeOfFlightLine",
"size": 1,
"type": "unsigned"
},
{
"name": "Classification",
"size": 1,
"type": "unsigned"
},
{
"name": "Synthetic",
"size": 1,
"type": "unsigned"
},
{
"name": "KeyPoint",
"size": 1,
"type": "unsigned"
},
{
"name": "Withheld",
"size": 1,
"type": "unsigned"
},
{
"name": "Overlap",
"size": 1,
"type": "unsigned"
},
{
"name": "ScanAngleRank",
"size": 4,
"type": "floating"
},
{
"name": "UserData",
"size": 1,
"type": "unsigned"
},
{
"name": "PointSourceId",
"size": 2,
"type": "unsigned"
},
{
"name": "GpsTime",
"size": 8,
"type": "floating"
},
{
"name": "ScanChannel",
"size": 1,
"type": "unsigned"
},
{
"name": "Red",
"size": 2,
"type": "unsigned"
},
{
"name": "Green",
"size": 2,
"type": "unsigned"
},
{
"name": "Blue",
"size": 2,
"type": "unsigned"
}
],
"pc:type": "lidar",
"proj:bbox": [
498062.04,
7050995.84,
74.64,
498064.91,
7050997.03,
79.0
],
"proj:geometry": {
"coordinates": [
[
[
498062.04,
7050995.84,
74.64
],
[
498062.04,
7050997.03,
74.64
],
[
498064.91,
7050997.03,
79.0
],
[
498064.91,
7050995.84,
79.0
],
[
498062.04,
7050995.84,
74.64
]
]
],
"type": "Polygon"
},
"proj:wkt2": ""
},
"links": [],
"assets": {
"data": {
"href": "./0-1.copc.laz",
"roles": [
"data"
]
},
"overview": {
"href": "./new-combined-overview.copc.laz",
"roles": [
"overview"
]
}
}
},
{
"type": "Feature",
"stac_version": "1.0.0",
"stac_extensions": [
"https://stac-extensions.github.io/pointcloud/v1.0.0/schema.json",
"https://stac-extensions.github.io/projection/v1.1.0/schema.json"
],
"id": "1-0.copc",
"geometry": {
"coordinates": [
[
[
498065.0,
7050992.84,
74.46
],
[
498065.0,
7050995.83,
74.46
],
[
498067.39,
7050995.83,
74.91
],
[
498067.39,
7050992.84,
74.91
],
[
498065.0,
7050992.84,
74.46
]
]
],
"type": "Polygon"
},
"bbox": [
498065.0,
7050992.84,
74.46,
498067.39,
7050995.83,
74.91
],
"properties": {
"datetime": "2024-10-18T00:00:00Z",
"pc:count": 77,
"pc:encoding": "?",
"pc:schemas": [
{
"name": "X",
"size": 8,
"type": "floating"
},
{
"name": "Y",
"size": 8,
"type": "floating"
},
{
"name": "Z",
"size": 8,
"type": "floating"
},
{
"name": "Intensity",
"size": 2,
"type": "unsigned"
},
{
"name": "ReturnNumber",
"size": 1,
"type": "unsigned"
},
{
"name": "NumberOfReturns",
"size": 1,
"type": "unsigned"
},
{
"name": "ScanDirectionFlag",
"size": 1,
"type": "unsigned"
},
{
"name": "EdgeOfFlightLine",
"size": 1,
"type": "unsigned"
},
{
"name": "Classification",
"size": 1,
"type": "unsigned"
},
{
"name": "Synthetic",
"size": 1,
"type": "unsigned"
},
{
"name": "KeyPoint",
"size": 1,
"type": "unsigned"
},
{
"name": "Withheld",
"size": 1,
"type": "unsigned"
},
{
"name": "Overlap",
"size": 1,
"type": "unsigned"
},
{
"name": "ScanAngleRank",
"size": 4,
"type": "floating"
},
{
"name": "UserData",
"size": 1,
"type": "unsigned"
},
{
"name": "PointSourceId",
"size": 2,
"type": "unsigned"
},
{
"name": "GpsTime",
"size": 8,
"type": "floating"
},
{
"name": "ScanChannel",
"size": 1,
"type": "unsigned"
},
{
"name": "Red",
"size": 2,
"type": "unsigned"
},
{
"name": "Green",
"size": 2,
"type": "unsigned"
},
{
"name": "Blue",
"size": 2,
"type": "unsigned"
}
],
"pc:type": "lidar",
"proj:bbox": [
498065.0,
7050992.84,
74.46,
498067.39,
7050995.83,
74.91
],
"proj:geometry": {
"coordinates": [
[
[
498065.0,
7050992.84,
74.46
],
[
498065.0,
7050995.83,
74.46
],
[
498067.39,
7050995.83,
74.91
],
[
498067.39,
7050992.84,
74.91
],
[
498065.0,
7050992.84,
74.46
]
]
],
"type": "Polygon"
},
"proj:wkt2": ""
},
"links": [],
"assets": {
"data": {
"href": "./1-0.copc.laz",
"roles": [
"data"
]
},
"overview": {
"href": "./new-combined-overview.copc.laz",
"roles": [
"overview"
]
}
}
},
{
"type": "Feature",
"stac_version": "1.0.0",
"stac_extensions": [
"https://stac-extensions.github.io/pointcloud/v1.0.0/schema.json",
"https://stac-extensions.github.io/projection/v1.1.0/schema.json"
],
"id": "1-1.copc",
"geometry": {
"coordinates": [
[
[
498065.01,
7050995.9,
74.34
],
[
498065.01,
7050997.04,
74.34
],
[
498067.32,
7050997.04,
80.02
],
[
498067.32,
7050995.9,
80.02
],
[
498065.01,
7050995.9,
74.34
]
]
],
"type": "Polygon"
},
"bbox": [
498065.01,
7050995.9,
74.34,
498067.32,
7050997.04,
80.02
],
"properties": {
"datetime": "2024-10-18T00:00:00Z",
"pc:count": 38,
"pc:encoding": "?",
"pc:schemas": [
{
"name": "X",
"size": 8,
"type": "floating"
},
{
"name": "Y",
"size": 8,
"type": "floating"
},
{
"name": "Z",
"size": 8,
"type": "floating"
},
{
"name": "Intensity",
"size": 2,
"type": "unsigned"
},
{
"name": "ReturnNumber",
"size": 1,
"type": "unsigned"
},
{
"name": "NumberOfReturns",
"size": 1,
"type": "unsigned"
},
{
"name": "ScanDirectionFlag",
"size": 1,
"type": "unsigned"
},
{
"name": "EdgeOfFlightLine",
"size": 1,
"type": "unsigned"
},
{
"name": "Classification",
"size": 1,
"type": "unsigned"
},
{
"name": "Synthetic",
"size": 1,
"type": "unsigned"
},
{
"name": "KeyPoint",
"size": 1,
"type": "unsigned"
},
{
"name": "Withheld",
"size": 1,
"type": "unsigned"
},
{
"name": "Overlap",
"size": 1,
"type": "unsigned"
},
{
"name": "ScanAngleRank",
"size": 4,
"type": "floating"
},
{
"name": "UserData",
"size": 1,
"type": "unsigned"
},
{
"name": "PointSourceId",
"size": 2,
"type": "unsigned"
},
{
"name": "GpsTime",
"size": 8,
"type": "floating"
},
{
"name": "ScanChannel",
"size": 1,
"type": "unsigned"
},
{
"name": "Red",
"size": 2,
"type": "unsigned"
},
{
"name": "Green",
"size": 2,
"type": "unsigned"
},
{
"name": "Blue",
"size": 2,
"type": "unsigned"
}
],
"pc:type": "lidar",
"proj:bbox": [
498065.01,
7050995.9,
74.34,
498067.32,
7050997.04,
80.02
],
"proj:geometry": {
"coordinates": [
[
[
498065.01,
7050995.9,
74.34
],
[
498065.01,
7050997.04,
74.34
],
[
498067.32,
7050997.04,
80.02
],
[
498067.32,
7050995.9,
80.02
],
[
498065.01,
7050995.9,
74.34
]
]
],
"type": "Polygon"
},
"proj:wkt2": ""
},
"links": [],
"assets": {
"data": {
"href": "./1-1.copc.laz",
"roles": [
"data"
]
},
"overview": {
"href": "./new-combined-overview.copc.laz",
"roles": [
"overview"
]
}
}
}
]
}