-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix grid decimation (code and test) + add gitignore
- Loading branch information
Showing
8 changed files
with
109 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
./xcode | ||
./install | ||
__pycache__ | ||
./test/__pycache__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/bin/sh | ||
|
||
FILE=~/anaconda3/etc/profile.d/conda.sh | ||
if [ -e ~/anaconda3/etc/profile.d/conda.sh ] | ||
then | ||
source ~/anaconda3/etc/profile.d/conda.sh | ||
elif [ -e ~/miniconda3/etc/profile.d/conda.sh ] | ||
then | ||
source ~/miniconda3/etc/profile.d/conda.sh | ||
elif [ -e ~/miniforge3/etc/profile.d/conda.sh ] | ||
then | ||
source ~/miniforge3/etc/profile.d/conda.sh | ||
elif [[ -z "${CONDASH}" ]]; then | ||
echo ERROR: Failed to load conda.sh : ~/anaconda3/etc/profile.d/conda.sh or ~/miniforge3/etc/profile.d/conda.sh or env CONDASH | ||
exit 1 # terminate and indicate error | ||
else | ||
echo DEBUG "$FILE does not exist, using env CONDASH." | ||
source $CONDASH | ||
fi | ||
|
||
conda activate pdal_ign_plugin | ||
|
||
export PDAL_DRIVER_PATH=./install/lib | ||
echo $PDAL_DRIVER_PATH | ||
|
||
python -m pytest | ||
|
||
conda deactivate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,69 @@ | ||
import pytest | ||
import csv | ||
import json | ||
import pdal | ||
import math | ||
import os | ||
import tempfile | ||
|
||
from test import utils | ||
|
||
import pdal | ||
import pdaltools.las_info as li | ||
import pytest | ||
import shapely | ||
|
||
|
||
def test_grid_decimation(): | ||
ini_las = "test/data/4_6.las" | ||
resolution = 10 | ||
|
||
tmp_out_las = tempfile.NamedTemporaryFile(suffix='.las').name | ||
tmp_out_las = tempfile.NamedTemporaryFile(suffix=".las").name | ||
tmp_out_wkt = tempfile.NamedTemporaryFile(suffix=".wkt").name | ||
|
||
filter = 'filters.grid_decimation' | ||
filter = "filters.grid_decimation" | ||
utils.pdal_has_plugin(filter) | ||
|
||
bounds = li.las_get_xy_bounds(ini_las) | ||
|
||
d_width = math.floor((bounds[0][1] - bounds[0][0]) / resolution) + 1 | ||
d_height = math.floor((bounds[1][1] - bounds[1][0]) / resolution) + 1 | ||
nb_dalle = d_width * d_height | ||
print("size of the grid", nb_dalle) | ||
|
||
PIPELINE = [ | ||
{"type": "readers.las", "filename": ini_las}, | ||
{ | ||
"type":"readers.las", | ||
"filename":"test/data/4_6.las" | ||
"type": filter, | ||
"resolution": resolution, | ||
"output_type": "max", | ||
"output_name_attribut": "grid", | ||
"output_wkt": tmp_out_wkt, | ||
}, | ||
{ | ||
"type":filter, | ||
"resolution":1, | ||
"output_type":"max", | ||
"output_name_attribut":"grid" | ||
"type": "writers.las", | ||
"extra_dims": "all", | ||
"filename": tmp_out_las, | ||
"where": "grid==1", | ||
}, | ||
{ | ||
"type":"writers.las", | ||
"extra_dims":"all", | ||
"filename":tmp_out_las | ||
} | ||
] | ||
|
||
pipeline = pdal.Pipeline(json.dumps(PIPELINE)) | ||
|
||
# execute the pipeline | ||
pipeline.execute() | ||
arrays = pipeline.arrays | ||
array = arrays[0] | ||
|
||
nb_pts_grid = 0 | ||
for pt in array: | ||
if pt["grid"] > 0: | ||
nb_pts_grid += 1 | ||
|
||
assert nb_pts_grid == 3196 | ||
assert nb_pts_grid <= nb_dalle | ||
|
||
NbPtsGrid = 0 | ||
for pt in arrays: | ||
if pt[grid] > 0: | ||
NbPtsGrid += 1 | ||
data = [] | ||
with open(tmp_out_wkt, "r") as f: | ||
reader = csv.reader(f, delimiter="\t") | ||
for i, line in enumerate(reader): | ||
data.append(line[0]) | ||
|
||
assert nbThreadPts == 65067 | ||
assert len(data) == nb_dalle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
import pdal | ||
import os | ||
import subprocess | ||
|
||
import pdal | ||
|
||
|
||
def pdal_has_plugin(name_filter): | ||
os.environ["PDAL_DRIVER_PATH"] = os.path.abspath('./install/lib') | ||
print("init pdal driver : ", os.environ["PDAL_DRIVER_PATH"]) | ||
result = subprocess.run(['pdal', '--drivers'], stdout=subprocess.PIPE) | ||
if name_filter not in result.stdout.decode('utf-8'): | ||
result = subprocess.run(["pdal", "--drivers"], stdout=subprocess.PIPE) | ||
if name_filter not in result.stdout.decode("utf-8"): | ||
raise ValueError("le script " + name_filter + " n'est pas visible") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ | |
|
||
|
||
if __name__ == "__main__": | ||
print(__version__) | ||
print(__version__) |