diff --git a/src/python_module.cpp b/src/python_module.cpp index 7ac21a5..47f38eb 100755 --- a/src/python_module.cpp +++ b/src/python_module.cpp @@ -109,7 +109,8 @@ PYBIND11_MODULE( _viewshed, m ) "saveVisibilityRaster", []( const std::shared_ptr v, const py::object path ) { v->saveVisibilityRaster( get_absolute_path( path, "path" ) ); }, - "Save visibility raster" ); + "Save visibility raster" ) + .def( "calculationTime", &Viewshed::parseLastedSeconds, "Seconds that processing of last operation lasted." ); // inverseviewshed py::class_>( m, "InverseViewshed", @@ -142,5 +143,8 @@ PYBIND11_MODULE( _viewshed, m ) "saveVisibilityRaster", []( const std::shared_ptr v, const py::object path ) { v->saveVisibilityRaster( get_absolute_path( path, "path" ) ); }, - "Save visibility raster" ); + "Save visibility raster" ) + .def( "calculationTime", &InverseViewshed::parseLastedSeconds, + "Seconds that processing of last operation lasted." ); + ; } \ No newline at end of file diff --git a/tests/test_viewshed.py b/tests/test_viewshed.py index 0ce478c..e3df00a 100644 --- a/tests/test_viewshed.py +++ b/tests/test_viewshed.py @@ -83,4 +83,33 @@ def test_viewshed_visibility_raster( v.calculateVisibilityMask() v.saveVisibilityRaster(visibility_raster) - assert visibility_raster.exists() \ No newline at end of file + assert visibility_raster.exists() + +def test_viewshed_calculation_time( + work_folder: Path, + dem: viewshed.ProjectedSquareCellRaster, + viewpoint: viewshed.Point, + mask: viewshed.ProjectedSquareCellRaster, + fn_print_percent_done, + fn_print_timing, + file_messages_percent, + file_messages_timing, +) -> None: + algs = viewshed.VisibilityAlgorithms(False) + + v = viewshed.Viewshed(viewpoint, dem, algs) + assert isinstance(v, viewshed.Viewshed) + + visibility_raster = work_folder / "visibility_raster.tif" + + v.calculateVisibilityMask() + time_visibility_mask = v.calculationTime() + + assert time_visibility_mask < 0.00001 + + v.calculate() + time_visibility = v.calculationTime() + + assert time_visibility < 0.02 + + assert time_visibility > time_visibility_mask \ No newline at end of file