mirror of
https://code.it4i.cz/sccs/easyconfigs-it4i.git
synced 2025-04-07 23:42:12 +01:00

new file: i/IRODS/IRODS-0.7.3.eb new file: l/libxc/libxc-5.1.5-intel-2020a.eb new file: n/NodeODM/NodeODM-2.2.0-GCCcore-11.3.0.eb new file: o/ODM/ODM-2.8.7/.dockerignore new file: o/ODM/ODM-2.8.7/.github/workflows/publish-docker-and-wsl.yaml new file: o/ODM/ODM-2.8.7/.github/workflows/publish-docker-gpu.yaml new file: o/ODM/ODM-2.8.7/.github/workflows/publish-snap.yml new file: o/ODM/ODM-2.8.7/.github/workflows/publish-windows.yml new file: o/ODM/ODM-2.8.7/.github/workflows/test-build-prs.yaml new file: o/ODM/ODM-2.8.7/.gitignore new file: o/ODM/ODM-2.8.7/.gitmodules new file: o/ODM/ODM-2.8.7/CNAME new file: o/ODM/ODM-2.8.7/CONTRIBUTING.md new file: o/ODM/ODM-2.8.7/Dockerfile new file: o/ODM/ODM-2.8.7/LICENSE new file: o/ODM/ODM-2.8.7/README.md new file: o/ODM/ODM-2.8.7/SuperBuild/CMakeLists.txt new file: o/ODM/ODM-2.8.7/SuperBuild/cmake/External-Ceres.cmake new file: o/ODM/ODM-2.8.7/SuperBuild/cmake/External-Entwine.cmake new file: o/ODM/ODM-2.8.7/SuperBuild/cmake/External-FPCFilter.cmake new file: o/ODM/ODM-2.8.7/SuperBuild/cmake/External-GFlags.cmake new file: o/ODM/ODM-2.8.7/SuperBuild/cmake/External-Hexer.cmake new file: o/ODM/ODM-2.8.7/SuperBuild/cmake/External-LASzip.cmake new file: o/ODM/ODM-2.8.7/SuperBuild/cmake/External-MvsTexturing.cmake new file: o/ODM/ODM-2.8.7/SuperBuild/cmake/External-Obj2Tiles.cmake new file: o/ODM/ODM-2.8.7/SuperBuild/cmake/External-OpenCV.cmake new file: o/ODM/ODM-2.8.7/SuperBuild/cmake/External-OpenMVS.cmake new file: o/ODM/ODM-2.8.7/SuperBuild/cmake/External-OpenSfM.cmake new file: o/ODM/ODM-2.8.7/SuperBuild/cmake/External-PCL.cmake new file: o/ODM/ODM-2.8.7/SuperBuild/cmake/External-PDAL.cmake new file: o/ODM/ODM-2.8.7/SuperBuild/cmake/External-PyPopsift.cmake new file: o/ODM/ODM-2.8.7/SuperBuild/cmake/External-Untwine.cmake new file: o/ODM/ODM-2.8.7/SuperBuild/cmake/ExternalProject-Setup.cmake new file: o/ODM/ODM-2.8.7/VERSION new file: o/ODM/ODM-2.8.7/code_of_conduct.md new file: o/ODM/ODM-2.8.7/configure.py new file: o/ODM/ODM-2.8.7/configure.sh new file: o/ODM/ODM-2.8.7/console.bat new file: o/ODM/ODM-2.8.7/contrib/blender/README.md new file: o/ODM/ODM-2.8.7/contrib/blender/common.py new file: o/ODM/ODM-2.8.7/contrib/blender/odm_photo.py new file: o/ODM/ODM-2.8.7/contrib/blender/odm_video.py new file: o/ODM/ODM-2.8.7/contrib/blender/photo_360.blend new file: o/ODM/ODM-2.8.7/contrib/blender/photo_vr.blend new file: o/ODM/ODM-2.8.7/contrib/grass/README.md new file: o/ODM/ODM-2.8.7/contrib/grass/odm_grass.py new file: o/ODM/ODM-2.8.7/contrib/mergepreview/README.md new file: o/ODM/ODM-2.8.7/contrib/mergepreview/mergepreview.py new file: o/ODM/ODM-2.8.7/contrib/ndvi/README.md new file: o/ODM/ODM-2.8.7/contrib/ndvi/agricultural_indices.py new file: o/ODM/ODM-2.8.7/contrib/ndvi/ndvi.py new file: o/ODM/ODM-2.8.7/contrib/ndvi/rename_sentera_agx710_multispectral_tif.py new file: o/ODM/ODM-2.8.7/contrib/orthorectify/README.md new file: o/ODM/ODM-2.8.7/contrib/orthorectify/orthorectify.py new file: o/ODM/ODM-2.8.7/contrib/orthorectify/run.sh new file: o/ODM/ODM-2.8.7/contrib/pc2dem/README.md new file: o/ODM/ODM-2.8.7/contrib/pc2dem/pc2dem.py new file: o/ODM/ODM-2.8.7/contrib/resize/README.md new file: o/ODM/ODM-2.8.7/contrib/resize/requirements.txt new file: o/ODM/ODM-2.8.7/contrib/resize/resize.py new file: o/ODM/ODM-2.8.7/contrib/shell/odm_exif2utm.sh new file: o/ODM/ODM-2.8.7/contrib/visveg/readme.md new file: o/ODM/ODM-2.8.7/contrib/visveg/vegind.py new file: o/ODM/ODM-2.8.7/docker/README new file: o/ODM/ODM-2.8.7/docker/g++ new file: o/ODM/ODM-2.8.7/docker/gcc new file: o/ODM/ODM-2.8.7/docs/issue_template.md new file: o/ODM/ODM-2.8.7/gpu.Dockerfile new file: o/ODM/ODM-2.8.7/innosetup.iss new file: o/ODM/ODM-2.8.7/licenses/libext_copyright.txt new file: o/ODM/ODM-2.8.7/licenses/libx11_copyright.txt new file: o/ODM/ODM-2.8.7/licenses/license.md new file: o/ODM/ODM-2.8.7/odm_docker_readme.txt new file: o/ODM/ODM-2.8.7/opendm/__init__.py new file: o/ODM/ODM-2.8.7/opendm/boundary.py new file: o/ODM/ODM-2.8.7/opendm/camera.py new file: o/ODM/ODM-2.8.7/opendm/cogeo.py new file: o/ODM/ODM-2.8.7/opendm/concurrency.py new file: o/ODM/ODM-2.8.7/opendm/config.py new file: o/ODM/ODM-2.8.7/opendm/context.py new file: o/ODM/ODM-2.8.7/opendm/cropper.py new file: o/ODM/ODM-2.8.7/opendm/cutline.py new file: o/ODM/ODM-2.8.7/opendm/dem/__init__.py new file: o/ODM/ODM-2.8.7/opendm/dem/commands.py new file: o/ODM/ODM-2.8.7/opendm/dem/ground_rectification/__init__.py new file: o/ODM/ODM-2.8.7/opendm/dem/ground_rectification/bounds/__init__.py new file: o/ODM/ODM-2.8.7/opendm/dem/ground_rectification/bounds/types.py new file: o/ODM/ODM-2.8.7/opendm/dem/ground_rectification/bounds/utils.py new file: o/ODM/ODM-2.8.7/opendm/dem/ground_rectification/extra_dimensions/__init__.py new file: o/ODM/ODM-2.8.7/opendm/dem/ground_rectification/extra_dimensions/dimension.py new file: o/ODM/ODM-2.8.7/opendm/dem/ground_rectification/extra_dimensions/distance_dimension.py new file: o/ODM/ODM-2.8.7/opendm/dem/ground_rectification/extra_dimensions/extended_dimension.py new file: o/ODM/ODM-2.8.7/opendm/dem/ground_rectification/extra_dimensions/partition_dimension.py new file: o/ODM/ODM-2.8.7/opendm/dem/ground_rectification/grid/__init__.py new file: o/ODM/ODM-2.8.7/opendm/dem/ground_rectification/grid/builder.py new file: o/ODM/ODM-2.8.7/opendm/dem/ground_rectification/io/__init__.py new file: o/ODM/ODM-2.8.7/opendm/dem/ground_rectification/io/las_io.py new file: o/ODM/ODM-2.8.7/opendm/dem/ground_rectification/partition/__init__.py new file: o/ODM/ODM-2.8.7/opendm/dem/ground_rectification/partition/one_partition.py new file: o/ODM/ODM-2.8.7/opendm/dem/ground_rectification/partition/partition_plan.py new file: o/ODM/ODM-2.8.7/opendm/dem/ground_rectification/partition/quad_partitions.py new file: o/ODM/ODM-2.8.7/opendm/dem/ground_rectification/partition/selector.py new file: o/ODM/ODM-2.8.7/opendm/dem/ground_rectification/partition/surrounding_partitions.py new file: o/ODM/ODM-2.8.7/opendm/dem/ground_rectification/point_cloud.py new file: o/ODM/ODM-2.8.7/opendm/dem/ground_rectification/rectify.py new file: o/ODM/ODM-2.8.7/opendm/dem/merge.py new file: o/ODM/ODM-2.8.7/opendm/dem/pdal.py new file: o/ODM/ODM-2.8.7/opendm/dem/utils.py new file: o/ODM/ODM-2.8.7/opendm/dls.py new file: o/ODM/ODM-2.8.7/opendm/entwine.py new file: o/ODM/ODM-2.8.7/opendm/gcp.py new file: o/ODM/ODM-2.8.7/opendm/geo.py new file: o/ODM/ODM-2.8.7/opendm/get_image_size.py new file: o/ODM/ODM-2.8.7/opendm/gpu.py new file: o/ODM/ODM-2.8.7/opendm/gsd.py new file: o/ODM/ODM-2.8.7/opendm/io.py new file: o/ODM/ODM-2.8.7/opendm/location.py new file: o/ODM/ODM-2.8.7/opendm/log.py new file: o/ODM/ODM-2.8.7/opendm/loghelpers.py new file: o/ODM/ODM-2.8.7/opendm/mesh.py new file: o/ODM/ODM-2.8.7/opendm/multispectral.py new file: o/ODM/ODM-2.8.7/opendm/nvm.py new file: o/ODM/ODM-2.8.7/opendm/ogctiles.py new file: o/ODM/ODM-2.8.7/opendm/orthophoto.py new file: o/ODM/ODM-2.8.7/opendm/osfm.py new file: o/ODM/ODM-2.8.7/opendm/photo.py new file: o/ODM/ODM-2.8.7/opendm/point_cloud.py new file: o/ODM/ODM-2.8.7/opendm/progress.py new file: o/ODM/ODM-2.8.7/opendm/pseudogeo.py new file: o/ODM/ODM-2.8.7/opendm/remote.py new file: o/ODM/ODM-2.8.7/opendm/report/dsm_gradient.png new file: o/ODM/ODM-2.8.7/opendm/report/overlap_color_map.txt new file: o/ODM/ODM-2.8.7/opendm/report/overlap_diagram_legend.png new file: o/ODM/ODM-2.8.7/opendm/rollingshutter.py new file: o/ODM/ODM-2.8.7/opendm/shots.py new file: o/ODM/ODM-2.8.7/opendm/system.py new file: o/ODM/ODM-2.8.7/opendm/thermal.py new file: o/ODM/ODM-2.8.7/opendm/thermal_tools/__init__.py new file: o/ODM/ODM-2.8.7/opendm/thermal_tools/dji_unpack.py new file: o/ODM/ODM-2.8.7/opendm/thermal_tools/flir_unpack.py new file: o/ODM/ODM-2.8.7/opendm/thermal_tools/thermal_utils.py new file: o/ODM/ODM-2.8.7/opendm/tiles/color_relief.txt new file: o/ODM/ODM-2.8.7/opendm/tiles/gdal2tiles.py new file: o/ODM/ODM-2.8.7/opendm/tiles/hsv_merge.py new file: o/ODM/ODM-2.8.7/opendm/tiles/tiler.py new file: o/ODM/ODM-2.8.7/opendm/types.py new file: o/ODM/ODM-2.8.7/opendm/utils.py new file: o/ODM/ODM-2.8.7/opendm/vendor/__init__.py new file: o/ODM/ODM-2.8.7/opendm/vendor/gdal_fillnodata.py new file: o/ODM/ODM-2.8.7/portable.Dockerfile new file: o/ODM/ODM-2.8.7/requirements.txt new file: o/ODM/ODM-2.8.7/run.bat new file: o/ODM/ODM-2.8.7/run.py new file: o/ODM/ODM-2.8.7/run.sh new file: o/ODM/ODM-2.8.7/snap/snapcraft.yaml new file: o/ODM/ODM-2.8.7/snap/snapcraft21.yaml new file: o/ODM/ODM-2.8.7/stages/__init__.py new file: o/ODM/ODM-2.8.7/stages/dataset.py new file: o/ODM/ODM-2.8.7/stages/mvstex.py new file: o/ODM/ODM-2.8.7/stages/odm_app.py new file: o/ODM/ODM-2.8.7/stages/odm_dem.py new file: o/ODM/ODM-2.8.7/stages/odm_filterpoints.py new file: o/ODM/ODM-2.8.7/stages/odm_georeferencing.py new file: o/ODM/ODM-2.8.7/stages/odm_meshing.py new file: o/ODM/ODM-2.8.7/stages/odm_orthophoto.py new file: o/ODM/ODM-2.8.7/stages/odm_postprocess.py new file: o/ODM/ODM-2.8.7/stages/odm_report.py new file: o/ODM/ODM-2.8.7/stages/openmvs.py new file: o/ODM/ODM-2.8.7/stages/run_opensfm.py new file: o/ODM/ODM-2.8.7/stages/splitmerge.py new file: o/ODM/ODM-2.8.7/start-dev-env.sh new file: o/ODM/ODM-2.8.7/test.sh new file: o/ODM/ODM-2.8.7/tests/assets/.gitignore new file: o/ODM/ODM-2.8.7/tests/assets/gcp_extras.txt new file: o/ODM/ODM-2.8.7/tests/assets/gcp_latlon_south.txt new file: o/ODM/ODM-2.8.7/tests/assets/gcp_latlon_valid.txt new file: o/ODM/ODM-2.8.7/tests/assets/gcp_michigan_feet_valid.txt new file: o/ODM/ODM-2.8.7/tests/assets/gcp_utm_north_valid.txt new file: o/ODM/ODM-2.8.7/tests/assets/images/DJI_0002.JPG new file: o/ODM/ODM-2.8.7/tests/assets/reconstruction.json new file: o/ODM/ODM-2.8.7/tests/assets/sample.json new file: o/ODM/ODM-2.8.7/tests/test_camera.py new file: o/ODM/ODM-2.8.7/tests/test_gcp.py new file: o/ODM/ODM-2.8.7/tests/test_osfm.py new file: o/ODM/ODM-2.8.7/tests/test_remote.py new file: o/ODM/ODM-2.8.7/tests/test_types.py new file: o/ODM/ODM-2.8.7/vcpkg-requirements.txt new file: o/ODM/ODM-2.8.7/win32env.bat new file: o/ODM/ODM-2.8.7/winrun.bat new file: o/ODM/v2.8.7.tar.gz new file: y/Yambo/Yambo-5.1.0-intel-2020a.eb new file: y/Yambo/Yambo-5.1.0-intel-2020a.eb.bak_20220715124556_61837 new file: y/Yambo/Yambo-5.1.0-intel-2021a.eb.old deleted: y/Yambo/Yambo-5.1.0-intel-2021a.eb
270 lines
9.7 KiB
Python
270 lines
9.7 KiB
Python
from opendm import context
|
|
from opendm.system import run
|
|
from opendm import log
|
|
from opendm.point_cloud import export_summary_json
|
|
from osgeo import ogr
|
|
import json, os
|
|
from opendm.concurrency import get_max_memory
|
|
from opendm.utils import double_quote
|
|
|
|
class Cropper:
|
|
def __init__(self, storage_dir, files_prefix = "crop"):
|
|
self.storage_dir = storage_dir
|
|
self.files_prefix = files_prefix
|
|
|
|
def path(self, suffix):
|
|
"""
|
|
@return a path relative to storage_dir and prefixed with files_prefix
|
|
"""
|
|
return os.path.join(self.storage_dir, '{}.{}'.format(self.files_prefix, suffix))
|
|
|
|
@staticmethod
|
|
def crop(gpkg_path, geotiff_path, gdal_options, keep_original=True, warp_options=[]):
|
|
if not os.path.exists(gpkg_path) or not os.path.exists(geotiff_path):
|
|
log.ODM_WARNING("Either {} or {} does not exist, will skip cropping.".format(gpkg_path, geotiff_path))
|
|
return geotiff_path
|
|
|
|
log.ODM_INFO("Cropping %s" % geotiff_path)
|
|
|
|
# Rename original file
|
|
# path/to/odm_orthophoto.tif --> path/to/odm_orthophoto.original.tif
|
|
|
|
path, filename = os.path.split(geotiff_path)
|
|
# path = path/to
|
|
# filename = odm_orthophoto.tif
|
|
|
|
basename, ext = os.path.splitext(filename)
|
|
# basename = odm_orthophoto
|
|
# ext = .tif
|
|
|
|
original_geotiff = os.path.join(path, "{}.original{}".format(basename, ext))
|
|
os.replace(geotiff_path, original_geotiff)
|
|
|
|
try:
|
|
kwargs = {
|
|
'gpkg_path': double_quote(gpkg_path),
|
|
'geotiffInput': double_quote(original_geotiff),
|
|
'geotiffOutput': double_quote(geotiff_path),
|
|
'options': ' '.join(map(lambda k: '-co {}={}'.format(k, gdal_options[k]), gdal_options)),
|
|
'warpOptions': ' '.join(warp_options),
|
|
'max_memory': get_max_memory()
|
|
}
|
|
|
|
run('gdalwarp -cutline {gpkg_path} '
|
|
'-crop_to_cutline '
|
|
'{options} '
|
|
'{warpOptions} '
|
|
'{geotiffInput} '
|
|
'{geotiffOutput} '
|
|
'--config GDAL_CACHEMAX {max_memory}%'.format(**kwargs))
|
|
|
|
if not keep_original:
|
|
os.remove(original_geotiff)
|
|
|
|
except Exception as e:
|
|
log.ODM_WARNING('Something went wrong while cropping: {}'.format(e))
|
|
|
|
# Revert rename
|
|
os.replace(original_geotiff, geotiff_path)
|
|
|
|
return geotiff_path
|
|
|
|
@staticmethod
|
|
def merge_bounds(input_bound_files, output_bounds, buffer_distance = 0):
|
|
"""
|
|
Merge multiple bound files into a single bound computed from the convex hull
|
|
of all bounds (minus a buffer distance in meters)
|
|
"""
|
|
geomcol = ogr.Geometry(ogr.wkbGeometryCollection)
|
|
|
|
driver = ogr.GetDriverByName('GPKG')
|
|
srs = None
|
|
|
|
for input_bound_file in input_bound_files:
|
|
ds = driver.Open(input_bound_file, 0) # ready-only
|
|
|
|
layer = ds.GetLayer()
|
|
srs = layer.GetSpatialRef()
|
|
|
|
# Collect all Geometry
|
|
for feature in layer:
|
|
geomcol.AddGeometry(feature.GetGeometryRef())
|
|
|
|
ds = None
|
|
|
|
# Calculate convex hull
|
|
convexhull = geomcol.ConvexHull()
|
|
|
|
# If buffer distance is specified
|
|
# Create two buffers, one shrunk by
|
|
# N + 3 and then that buffer expanded by 3
|
|
# so that we get smooth corners. \m/
|
|
BUFFER_SMOOTH_DISTANCE = 3
|
|
|
|
if buffer_distance > 0:
|
|
convexhull = convexhull.Buffer(-(buffer_distance + BUFFER_SMOOTH_DISTANCE))
|
|
convexhull = convexhull.Buffer(BUFFER_SMOOTH_DISTANCE)
|
|
|
|
# Save to a new file
|
|
if os.path.exists(output_bounds):
|
|
driver.DeleteDataSource(output_bounds)
|
|
|
|
out_ds = driver.CreateDataSource(output_bounds)
|
|
layer = out_ds.CreateLayer("convexhull", srs=srs, geom_type=ogr.wkbPolygon)
|
|
|
|
feature_def = layer.GetLayerDefn()
|
|
feature = ogr.Feature(feature_def)
|
|
feature.SetGeometry(convexhull)
|
|
layer.CreateFeature(feature)
|
|
feature = None
|
|
|
|
# Save and close output data source
|
|
out_ds = None
|
|
|
|
def create_bounds_geojson(self, pointcloud_path, buffer_distance = 0, decimation_step=40):
|
|
"""
|
|
Compute a buffered polygon around the data extents (not just a bounding box)
|
|
of the given point cloud.
|
|
|
|
@return filename to GeoJSON containing the polygon
|
|
"""
|
|
if not os.path.exists(pointcloud_path):
|
|
log.ODM_WARNING('Point cloud does not exist, cannot generate bounds {}'.format(pointcloud_path))
|
|
return ''
|
|
|
|
# Do decimation prior to extracting boundary information
|
|
decimated_pointcloud_path = self.path('decimated.las')
|
|
|
|
run("pdal translate -i \"{}\" "
|
|
"-o \"{}\" "
|
|
"decimation "
|
|
"--filters.decimation.step={} ".format(pointcloud_path, decimated_pointcloud_path, decimation_step))
|
|
|
|
if not os.path.exists(decimated_pointcloud_path):
|
|
log.ODM_WARNING('Could not decimate point cloud, thus cannot generate GPKG bounds {}'.format(decimated_pointcloud_path))
|
|
return ''
|
|
|
|
# Use PDAL to dump boundary information
|
|
# then read the information back
|
|
|
|
boundary_file_path = self.path('boundary.json')
|
|
|
|
run('pdal info --boundary --filters.hexbin.edge_size=1 --filters.hexbin.threshold=0 "{0}" > "{1}"'.format(decimated_pointcloud_path, boundary_file_path))
|
|
|
|
pc_geojson_boundary_feature = None
|
|
|
|
with open(boundary_file_path, 'r') as f:
|
|
json_f = json.loads(f.read())
|
|
pc_geojson_boundary_feature = json_f['boundary']['boundary_json']
|
|
|
|
if pc_geojson_boundary_feature is None: raise RuntimeError("Could not determine point cloud boundaries")
|
|
|
|
# Write bounds to GeoJSON
|
|
tmp_bounds_geojson_path = self.path('tmp-bounds.geojson')
|
|
with open(tmp_bounds_geojson_path, "w") as f:
|
|
f.write(json.dumps({
|
|
"type": "FeatureCollection",
|
|
"features": [{
|
|
"type": "Feature",
|
|
"geometry": pc_geojson_boundary_feature
|
|
}]
|
|
}))
|
|
|
|
# Create a convex hull around the boundary
|
|
# as to encompass the entire area (no holes)
|
|
driver = ogr.GetDriverByName('GeoJSON')
|
|
ds = driver.Open(tmp_bounds_geojson_path, 0) # ready-only
|
|
layer = ds.GetLayer()
|
|
|
|
# Collect all Geometry
|
|
geomcol = ogr.Geometry(ogr.wkbGeometryCollection)
|
|
for feature in layer:
|
|
geomcol.AddGeometry(feature.GetGeometryRef())
|
|
|
|
# Calculate convex hull
|
|
convexhull = geomcol.ConvexHull()
|
|
|
|
# If buffer distance is specified
|
|
# Create two buffers, one shrunk by
|
|
# N + 3 and then that buffer expanded by 3
|
|
# so that we get smooth corners. \m/
|
|
BUFFER_SMOOTH_DISTANCE = 3
|
|
|
|
if buffer_distance > 0:
|
|
# For small areas, check that buffering doesn't obliterate
|
|
# our hull
|
|
tmp = convexhull.Buffer(-(buffer_distance + BUFFER_SMOOTH_DISTANCE))
|
|
tmp = tmp.Buffer(BUFFER_SMOOTH_DISTANCE)
|
|
if tmp.Area() > 0:
|
|
convexhull = tmp
|
|
else:
|
|
log.ODM_WARNING("Very small crop area detected, we will not smooth it.")
|
|
|
|
# Save to a new file
|
|
bounds_geojson_path = self.path('bounds.geojson')
|
|
if os.path.exists(bounds_geojson_path):
|
|
os.remove(bounds_geojson_path)
|
|
|
|
out_ds = driver.CreateDataSource(bounds_geojson_path)
|
|
layer = out_ds.CreateLayer("convexhull", geom_type=ogr.wkbPolygon)
|
|
|
|
feature_def = layer.GetLayerDefn()
|
|
feature = ogr.Feature(feature_def)
|
|
feature.SetGeometry(convexhull)
|
|
layer.CreateFeature(feature)
|
|
feature = None
|
|
|
|
# Save and close data sources
|
|
out_ds = ds = None
|
|
|
|
# Remove decimated point cloud
|
|
if os.path.exists(decimated_pointcloud_path):
|
|
os.remove(decimated_pointcloud_path)
|
|
|
|
# Remove tmp bounds
|
|
if os.path.exists(tmp_bounds_geojson_path):
|
|
os.remove(tmp_bounds_geojson_path)
|
|
|
|
return bounds_geojson_path
|
|
|
|
|
|
def create_bounds_gpkg(self, pointcloud_path, buffer_distance = 0, decimation_step=40):
|
|
"""
|
|
Compute a buffered polygon around the data extents (not just a bounding box)
|
|
of the given point cloud.
|
|
|
|
@return filename to Geopackage containing the polygon
|
|
"""
|
|
if not os.path.exists(pointcloud_path):
|
|
log.ODM_WARNING('Point cloud does not exist, cannot generate GPKG bounds {}'.format(pointcloud_path))
|
|
return ''
|
|
|
|
bounds_geojson_path = self.create_bounds_geojson(pointcloud_path, buffer_distance, decimation_step)
|
|
|
|
summary_file_path = os.path.join(self.storage_dir, '{}.summary.json'.format(self.files_prefix))
|
|
export_summary_json(pointcloud_path, summary_file_path)
|
|
|
|
pc_proj4 = None
|
|
with open(summary_file_path, 'r') as f:
|
|
json_f = json.loads(f.read())
|
|
pc_proj4 = json_f['summary']['srs']['proj4']
|
|
|
|
if pc_proj4 is None: raise RuntimeError("Could not determine point cloud proj4 declaration")
|
|
|
|
bounds_gpkg_path = os.path.join(self.storage_dir, '{}.bounds.gpkg'.format(self.files_prefix))
|
|
|
|
if os.path.isfile(bounds_gpkg_path):
|
|
os.remove(bounds_gpkg_path)
|
|
|
|
# Convert bounds to GPKG
|
|
kwargs = {
|
|
'input': double_quote(bounds_geojson_path),
|
|
'output': double_quote(bounds_gpkg_path),
|
|
'proj4': pc_proj4
|
|
}
|
|
|
|
run('ogr2ogr -overwrite -f GPKG -a_srs "{proj4}" {output} {input}'.format(**kwargs))
|
|
|
|
return bounds_gpkg_path
|
|
|