Skip to content

Commit ad46c8a

Browse files
authored
Merge pull request #7 from IGNF/dev
dev dans master
2 parents 0398c50 + 9b9d01a commit ad46c8a

File tree

16 files changed

+3455
-32
lines changed

16 files changed

+3455
-32
lines changed

.github/workflows/cicd_deploy.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,13 @@ jobs:
2828
id: build
2929
uses: docker/build-push-action@v6
3030
with:
31+
context: .
32+
file: ./Dockerfile.pdal
3133
load: true
3234
tags: ${{ env.TEST_TAG }}
35+
build-args: |
36+
GITHUB_REPOSITORY=alavenant/PDAL
37+
GITHUB_SHA=master_28_05_25
3338
3439
# run the test on the docker image
3540
- name: Run tests in docker image
@@ -102,7 +107,7 @@ jobs:
102107

103108
- name: Run tests with pytest
104109
shell: micromamba-shell {0}
105-
run: python -m pytest ./test -s --log-cli-level DEBUG
110+
run: python -m pytest ./test -s --log-cli-level DEBUG -m "not pdal_custom"
106111

107112
- name: Build pip package
108113
shell: micromamba-shell {0}

.github/workflows/cicd_full.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,13 @@ jobs:
3333
id: build
3434
uses: docker/build-push-action@v6
3535
with:
36+
context: .
37+
file: ./Dockerfile.pdal
3638
load: true
3739
tags: ${{ env.TEST_TAG }}
40+
build-args: |
41+
GITHUB_REPOSITORY=alavenant/PDAL
42+
GITHUB_SHA=master_28_05_25
3843
3944
# run the test on the docker image
4045
- name: Run tests in docker image
@@ -72,6 +77,6 @@ jobs:
7277
shell: micromamba-shell {0}
7378
run: >
7479
python -m pytest -s
75-
--log-cli-level=DEBUG
80+
--log-cli-level=DEBUG -m "not pdal_custom"
7681
--log-format="%(asctime)s %(levelname)s %(message)s"
7782
--log-date-format="%Y-%m-%d %H:%M:%S"

.github/workflows/cicd_light.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
shell: micromamba-shell {0}
3333
run: >
3434
python -m pytest -s
35-
--log-cli-level=DEBUG
35+
--log-cli-level=DEBUG -m "not pdal_custom"
3636
--log-format="%(asctime)s %(levelname)s %(message)s"
3737
--log-date-format="%Y-%m-%d %H:%M:%S"
3838

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# v2.1.0
2+
Custom PDAL: in the docker image, compile custom PDAL (waiting for PDAL 2.9)
3+
fix run_extract_z_virtual_lines_from_raster: output geometries are only LineString (no more MultiLineString)
4+
15
# v2.0.0
26
Rename produit_derive_lidar to las_digital_models
37

Dockerfile.pdal

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# code from https://github.com/PDAL/PDAL/blob/master/scripts/docker/ubuntu/Dockerfile
2+
FROM condaforge/mambaforge:latest AS mamba_pdal
3+
4+
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
5+
6+
RUN conda create -n las_digital_models -y
7+
ARG GITHUB_SHA
8+
ARG GITHUB_REPOSITORY="PDAL/PDAL"
9+
ARG GITHUB_SERVER_URL="https://github.com"
10+
11+
SHELL ["conda", "run", "-n", "las_digital_models", "/bin/bash", "-c"]
12+
13+
RUN mamba install -c conda-forge git compilers conda-pack cmake make ninja sysroot_linux-64=2.17 && \
14+
mamba install --yes -c conda-forge pdal --only-deps
15+
16+
RUN mamba install numpy requests gdal cgal geopandas pytest pip pyproj hydra-core hydra-colorlog rasterio fiona parallel
17+
18+
RUN rm -rf /opt/conda/envs/las_digital_models/lib/libpdal*
19+
RUN rm -rf /opt/conda/envs/las_digital_models/lib/libpdal_plugin*
20+
21+
RUN git clone "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}" pdal && \
22+
cd pdal ; \
23+
git checkout ${GITHUB_SHA}
24+
25+
RUN mkdir -p pdal/build && \
26+
cd pdal/build && \
27+
CXXFLAGS="-Werror=strict-aliasing" LDFLAGS="-Wl,-rpath-link,$CONDA_PREFIX/lib" cmake -G Ninja \
28+
-DCMAKE_BUILD_TYPE=Release \
29+
-DCMAKE_LIBRARY_PATH:FILEPATH="$CONDA_PREFIX/lib" \
30+
-DCMAKE_INCLUDE_PATH:FILEPATH="$CONDA_PREFIX/include" \
31+
-DCMAKE_INSTALL_PREFIX="$CONDA_PREFIX" \
32+
-DBUILD_PLUGIN_CPD=OFF \
33+
-DBUILD_PLUGIN_PGPOINTCLOUD=ON \
34+
-DBUILD_PLUGIN_NITF=ON \
35+
-DBUILD_PLUGIN_ICEBRIDGE=ON \
36+
-DBUILD_PLUGIN_HDF=ON \
37+
-DBUILD_PLUGIN_TILEDB=ON \
38+
-DBUILD_PLUGIN_E57=ON \
39+
-DBUILD_PGPOINTCLOUD_TESTS=OFF \
40+
-DWITH_ZSTD=ON \
41+
..
42+
43+
RUN cd pdal/build && \
44+
ninja
45+
46+
RUN cd pdal/build && \
47+
ctest -V
48+
49+
RUN cd pdal/build && \
50+
ninja install
51+
52+
RUN git clone https://github.com/PDAL/python.git
53+
54+
RUN mamba install --yes -c conda-forge pybind11
55+
56+
RUN mkdir -p python/build && \
57+
cd python/build && \
58+
CXXFLAGS="-Werror=strict-aliasing" LDFLAGS="-Wl,-rpath-link,$CONDA_PREFIX/lib" cmake -G Ninja \
59+
-DCMAKE_BUILD_TYPE=Release \
60+
-DCMAKE_LIBRARY_PATH:FILEPATH="$CONDA_PREFIX/lib" \
61+
-DCMAKE_INCLUDE_PATH:FILEPATH="$CONDA_PREFIX/include" \
62+
-DCMAKE_INSTALL_PREFIX="$CONDA_PREFIX/lib/python3.13/site-packages/" \
63+
..
64+
65+
RUN cd python/build && ninja
66+
67+
RUN cd python/build && ctest -V
68+
69+
RUN cd python/build && ninja install
70+
71+
RUN git clone https://github.com/PDAL/python-plugins.git pdal-python && \
72+
cd pdal-python && git checkout 1.6.5 && \
73+
pip install -vv . --no-deps
74+
75+
76+
# Add our environment
77+
RUN pip install laspy[lazrs]
78+
RUN pip install ign-pdal-tools
79+
RUN pip install rasterstats
80+
81+
FROM debian:bullseye-slim
82+
83+
# install PDAL
84+
COPY --from=mamba_pdal /opt/conda/envs/las_digital_models/bin/pdal /opt/conda/envs/las_digital_models/bin/pdal
85+
COPY --from=mamba_pdal /opt/conda/envs/las_digital_models/bin/python /opt/conda/envs/las_digital_models/bin/python
86+
COPY --from=mamba_pdal /opt/conda/envs/las_digital_models/lib/ /opt/conda/envs/las_digital_models/lib/
87+
COPY --from=mamba_pdal /opt/conda/envs/las_digital_models/bin/ /opt/conda/envs/las_digital_models/bin/
88+
COPY --from=mamba_pdal /opt/conda/envs/las_digital_models/share/gdal/ /opt/conda/envs/las_digital_models/share/gdal/
89+
COPY --from=mamba_pdal /opt/conda/envs/las_digital_models/ssl /opt/conda/envs/las_digital_models/ssl
90+
COPY --from=mamba_pdal /opt/conda/envs/las_digital_models/share/proj/proj.db /opt/conda/envs/las_digital_models/share/proj/proj.db
91+
92+
ENV PATH=$PATH:/opt/conda/envs/las_digital_models/bin/:/opt/conda/envs/las_digital_models/
93+
ENV PROJ_LIB=/opt/conda/envs/las_digital_models/share/proj/
94+
ENV GDAL_DATA=/opt/conda/envs/las_digital_models/share/gdal/
95+
96+
WORKDIR /las-digital-models
97+
RUN mkdir tmp
98+
COPY las_digital_models las_digital_models
99+
COPY test test
100+
COPY configs configs
101+
COPY run.sh run.sh

Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,15 @@ FULL_IMAGE_NAME=${REGISTRY}/${NAMESPACE}/${IMAGE_NAME}:${VERSION}
6060
docker-build:
6161
docker build -t ${IMAGE_NAME}:${VERSION} -f Dockerfile .
6262

63+
docker-build-pdal: clean
64+
docker build --build-arg GITHUB_REPOSITORY=alavenant/PDAL --build-arg GITHUB_SHA=master_28_05_25 -t ${IMAGE_NAME}:${VERSION} -f Dockerfile.pdal .
65+
66+
docker-test-pdal-version: clean
67+
docker run --rm -t ${IMAGE_NAME}:${VERSION} pdal --version
68+
69+
docker-test-pdal-custom: clean
70+
docker run --rm -t ${IMAGE_NAME}:${VERSION} python -m pytest -s -m "pdal_custom"
71+
6372
docker-test:
6473
docker run --rm ${IMAGE_NAME}:${VERSION} python -m pytest -s -m "not functional_test"
6574

environment.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ dependencies:
1717
- pdal>=2.6
1818
- python-pdal>=3.2.1
1919
- geopandas
20+
- parallel
2021
# --------- hydra configs --------- #
2122
- hydra-core==1.2.*
2223
- hydra-colorlog==1.2.*
@@ -29,7 +30,6 @@ dependencies:
2930
- isort
3031
- pre-commit
3132
- pip:
32-
- startinpy==0.8.0
33-
- ign-pdal-tools==1.8.1
34-
- rasterstats==0.20.0
33+
- ign-pdal-tools
34+
- rasterstats
3535

las_digital_models/extract_stat_from_raster/extract_z_virtual_lines_from_raster.py

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -94,30 +94,19 @@ def run_extract_z_virtual_lines_from_raster(config: DictConfig):
9494
create_vrt(dir_list_raster, output_vrt)
9595

9696
# Read the input GeoJSON
97-
lines_gdf = gpd.read_file(input_geometry)
97+
geom_gdf = gpd.read_file(input_geometry)
9898
polygons_gdf = gpd.read_file(input_clip_geometry)
9999

100-
if lines_gdf.crs is None:
101-
lines_gdf.set_crs(epsg=spatial_ref, inplace=True)
100+
# Convert geometries to LineString (no more MultiLineString)
101+
mask = geom_gdf.geometry.geom_type.isin(['LineString', 'MultiLineString'])
102+
lines_gdf = geom_gdf.loc[mask].explode(index_parts=False).reset_index(drop=True)
103+
104+
if geom_gdf.crs is None:
105+
geom_gdf.set_crs(epsg=spatial_ref, inplace=True)
102106

103107
if polygons_gdf.crs is None:
104108
polygons_gdf.set_crs(epsg=spatial_ref, inplace=True)
105109

106-
# Convert geometries to LineString if possible
107-
def to_linestring(geom):
108-
if geom.geom_type == "LineString":
109-
return geom
110-
elif geom.geom_type == "MultiLineString":
111-
return list(geom.geoms)[0]
112-
else:
113-
raise ValueError(f"Unsupported geometry type: {geom.geom_type}")
114-
115-
lines_gdf["geometry"] = lines_gdf.geometry.apply(to_linestring)
116-
117-
# Check lines are only LineString
118-
if not all(lines_gdf.geometry.geom_type.isin(["LineString"])):
119-
raise ValueError("Only LineString or MultiLineString geometries are supported.")
120-
121110
# Keep lines inside raster (VRT created)
122111
lines_gdf_clip = clip_lines_by_raster(lines_gdf, output_vrt, spatial_ref)
123112

@@ -133,7 +122,11 @@ def to_linestring(geom):
133122
raise ValueError("All geometries returned None. Abort.")
134123

135124
# Clip lines by bridges
136-
lines_gdf_min_z_clip = clip_lines_by_polygons(lines_gdf_min_z, polygons_gdf)
125+
geoms_gdf_min_z_clip = clip_lines_by_polygons(lines_gdf_min_z, polygons_gdf)
126+
127+
# Convert geometries to LineString (no more MultiLineString)
128+
mask = geoms_gdf_min_z_clip.geometry.geom_type.isin(['LineString', 'MultiLineString'])
129+
lines_gdf_min_z_clip = geoms_gdf_min_z_clip.loc[mask].explode(index_parts=False).reset_index(drop=True)
137130

138131
lines_gdf_min_z_clip.to_file(output_geometry, driver="GeoJSON")
139132

las_digital_models/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "2.0.0"
1+
__version__ = "2.1.0"
22

33

44
if __name__ == "__main__":

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,5 @@ profile = "black"
3434
[tool.pytest.ini_options]
3535
markers = [
3636
"functional_test: marks functional tests, not to run inside the docker image",
37+
"pdal_custom: marks tests that only work with PDAL compiled on a custom fork and branch",
3738
]

0 commit comments

Comments
 (0)