Skip to content

Commit

Permalink
Merge branch 'sparserecon' into classified-dems
Browse files Browse the repository at this point in the history
  • Loading branch information
pierotofy committed Jan 18, 2018
2 parents 73d75d7 + f4328ac commit 37e5824
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 6 deletions.
17 changes: 12 additions & 5 deletions modules/odm_25dmeshing/src/Odm25dMeshing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,10 @@ void Odm25dMeshing::buildMesh(){
const float NODATA = -9999;

double *bounds = polydataToProcess->GetBounds();
double *center = polydataToProcess->GetCenter();

double centerX = polydataToProcess->GetCenter()[0];
double centerY = polydataToProcess->GetCenter()[1];
double centerZ = polydataToProcess->GetCenter()[2];

double extentX = bounds[1] - bounds[0];
double extentY = bounds[3] - bounds[2];
Expand All @@ -152,13 +155,18 @@ void Odm25dMeshing::buildMesh(){
log << "Plane extentX: " << extentX <<
", extentY: " << extentY << "\n";

double planeCenter[3];
planeCenter[0] = centerX;
planeCenter[1] = centerY;
planeCenter[2] = centerZ;

vtkSmartPointer<vtkPlaneSource> plane =
vtkSmartPointer<vtkPlaneSource>::New();
plane->SetResolution(width, height);
plane->SetOrigin(0.0, 0.0, 0.0);
plane->SetPoint1(extentX, 0.0, 0.0);
plane->SetPoint2(0.0, extentY, 0);
plane->SetCenter(center);
plane->SetCenter(planeCenter);
plane->SetNormal(0.0, 0.0, 1.0);

vtkSmartPointer<vtkShepardKernel> shepardKernel =
Expand Down Expand Up @@ -253,12 +261,11 @@ void Odm25dMeshing::buildMesh(){
terrain->SetInputData(medianFilter->GetOutput());
terrain->BoundaryVertexDeletionOn();


log << "OK\nTransform... ";
vtkSmartPointer<vtkTransform> transform =
vtkSmartPointer<vtkTransform>::New();
transform->Translate(-extentX / 2.0 + center[0],
-extentY / 2.0 + center[1], 0);
transform->Translate(-extentX / 2.0 + centerX,
-extentY / 2.0 + centerY, 0);
transform->Scale(extentX / width, extentY / height, 1);

vtkSmartPointer<vtkTransformFilter> transformFilter =
Expand Down
22 changes: 21 additions & 1 deletion opendm/cropper.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,28 @@ def create_bounds_geojson(self, pointcloud_path, buffer_distance = 0):
log.ODM_WARNING('Point cloud does not exist, cannot generate shapefile bounds {}'.format(pointcloud_path))
return ''

# Do basic outlier removal prior to extracting boundary information
filtered_pointcloud_path = self.path('filtered.las')

run("pdal translate -i \"{}\" "
"-o \"{}\" "
"decimation outlier range "
"--filters.decimation.step=40 "
"--filters.outlier.method=radius "
"--filters.outlier.radius=20 "
"--filters.outlier.min_k=2 "
"--filters.range.limits='Classification![7:7]'".format(pointcloud_path, filtered_pointcloud_path))

if not os.path.exists(filtered_pointcloud_path):
log.ODM_WARNING('Could not filter point cloud, cannot generate shapefile bounds {}'.format(filtered_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_length=1 --filters.hexbin.threshold=0 {0} > {1}'.format(pointcloud_path, boundary_file_path))
run('pdal info --boundary --filters.hexbin.edge_length=1 --filters.hexbin.threshold=0 {0} > {1}'.format(filtered_pointcloud_path, boundary_file_path))

pc_geojson_boundary_feature = None

Expand Down Expand Up @@ -138,6 +154,10 @@ def create_bounds_geojson(self, pointcloud_path, buffer_distance = 0):
# Save and close data sources
out_ds = ds = None

# Remove filtered point cloud
if os.path.exists(filtered_pointcloud_path):
os.remove(filtered_pointcloud_path)

return bounds_geojson_path


Expand Down

0 comments on commit 37e5824

Please sign in to comment.