From 4a025d39e2a8dd1cc418b831722cb4ba170004f8 Mon Sep 17 00:00:00 2001 From: Matt Fisher Date: Tue, 4 Jun 2024 14:04:56 -0600 Subject: [PATCH 1/5] Simplify conda install instructions --- README.md | 2 +- environment.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 01acc03..163c178 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ This package was developed for the [Permafrost Discovery Gateway](https://permaf ### Conda ```bash -conda env create -n viz_3d --file environment.yml +conda env create conda activate viz_3d ``` diff --git a/environment.yml b/environment.yml index 73f1f67..7e45af4 100644 --- a/environment.yml +++ b/environment.yml @@ -1,5 +1,5 @@ -# usage: conda env create -n viz_3d --file environment.yml -# name: viz_3d +# usage: conda env create +name: viz_3d channels: - conda-forge dependencies: From 18e19e5c35190fc2739889f98b1b459b91ea8061 Mon Sep 17 00:00:00 2001 From: Matt Fisher Date: Tue, 4 Jun 2024 14:14:50 -0600 Subject: [PATCH 2/5] Show imports in usage example --- README.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 163c178..01c42a9 100644 --- a/README.md +++ b/README.md @@ -30,22 +30,23 @@ pip install -r requirements.txt ## Usage -1. Create an instance of the `Cesium3DTile` class. Use `Cesium3DTile.from_file()` to process a `.shp` file into a `.b3dm` 3D model: - ```python +from viz_3dtiles import Cesium3DTile, Cesium3DTileset + +# 1. Create an instance of the `Cesium3DTile` class. Use `Cesium3DTile.from_file()` to +# process a `.shp` file into a `.b3dm` 3D model: tile = Cesium3DTile() tile.save_to="~/my-tilesets/lakes/" tile.from_file(filepath="~/my-data/lakes.shp") -``` -2. Create an instance of the `Cesium3DTileset` class to contain that tile: +# 2. Create an instance of the `Cesium3DTileset` class to contain that tile: -```python tileset = Cesium3DTileset(tiles=[tile]) tileset.save_to="~/my-tilesets/lakes/" tileset.write_file() ``` + ## Demo See [/test/test.py](test/test.py) which creates an example tileset. From 36165e6a5e471b4973e9c60b47f40bc247edf40c Mon Sep 17 00:00:00 2001 From: Matt Fisher Date: Tue, 4 Jun 2024 14:26:06 -0600 Subject: [PATCH 3/5] Fix typo --- viz_3dtiles/Cesium3DTile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/viz_3dtiles/Cesium3DTile.py b/viz_3dtiles/Cesium3DTile.py index c6fe0bb..edb168e 100644 --- a/viz_3dtiles/Cesium3DTile.py +++ b/viz_3dtiles/Cesium3DTile.py @@ -64,7 +64,7 @@ def set_b3dm_name(self, name): def get_all_properties(self): """ - Get all proerties of the Cesium3DTile class as a dictionary. + Get all properties of the Cesium3DTile class as a dictionary. """ return { "z": self.z, @@ -238,4 +238,4 @@ def create_b3dm(self): t.save_as(os.path.join(self.save_to, self.get_filename())) def get_filename(self): - return self.save_as + self.FILE_EXT \ No newline at end of file + return self.save_as + self.FILE_EXT From 5e5c20f9719083767221d4fa04761044016a230c Mon Sep 17 00:00:00 2001 From: Matt Fisher Date: Tue, 4 Jun 2024 14:31:33 -0600 Subject: [PATCH 4/5] Add Dockerfile Update README with info about implicit dependencies --- .github/workflows/publish-docker-image.yml | 45 ++++++++++++++++++++++ Dockerfile | 16 ++++++++ README.md | 14 +++++++ 3 files changed, 75 insertions(+) create mode 100644 .github/workflows/publish-docker-image.yml create mode 100644 Dockerfile diff --git a/.github/workflows/publish-docker-image.yml b/.github/workflows/publish-docker-image.yml new file mode 100644 index 0000000..4dd2feb --- /dev/null +++ b/.github/workflows/publish-docker-image.yml @@ -0,0 +1,45 @@ +name: "Build and publish container image" + +on: + workflow_dispatch: + push: + branches: + - "main" + tags: + - "[0-9]+.[0-9]+.[0-9]+*" + + +env: + REGISTRY: "ghcr.io" + IMAGE_NAME: "${{ github.repository_owner }}/pdg3dtiles" # TODO: Is this the image name we want? + IMAGE_TAG: "${{ github.ref_type == 'tag' && github.ref_name || 'latest' }}" + + +jobs: + + build-and-release-image: + name: "Build and release container image" + runs-on: "ubuntu-latest" + + permissions: + packages: "write" + attestations: "write" + + steps: + - name: "Check out repository" + uses: "actions/checkout@v3" + + - name: "Build container image" + run: | + docker build --tag "${REGISTRY}/${IMAGE_NAME}:${IMAGE_TAG}" . + + - name: "GHCR login" + uses: "docker/login-action@v2" + with: + registry: "${{ env.REGISTRY }}" + username: "${{ github.repository_owner }}" + password: "${{ secrets.GITHUB_TOKEN }}" + + - name: "Push to GHCR" + run: | + docker push "${REGISTRY}/${IMAGE_NAME}:${IMAGE_TAG}" diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..1eb2f3b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +FROM python:3.9-slim + +# Install transitive dependencies +RUN apt-get update \ + && apt-get install -y \ + git \ + libgl1 \ + libgomp1 + +# Install from source +WORKDIR /app +ADD . . +RUN pip install . + + +CMD ["python3"] diff --git a/README.md b/README.md index 01c42a9..0587079 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,20 @@ source .3dtilesenv/bin/activate pip install -r requirements.txt ``` +### Other pre-requesites + +`libgomp` and `libgl` are required on your system. + +```bash +sudo apt install libgomp1 libgl1 +# OR +conda install libgomp +``` + +> ![NOTE] +> `libgomp` can be expressed in `environment.yml`. Do that then combine this section +> with the pip install section? + ## Usage ```python From 74439632e61163969ce4d755e2a2d2cc642fae65 Mon Sep 17 00:00:00 2001 From: Matt Fisher Date: Tue, 4 Jun 2024 14:46:06 -0600 Subject: [PATCH 5/5] Switch example away from shapefile http://switchfromshapefile.org/ --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0587079..8287cda 100644 --- a/README.md +++ b/README.md @@ -48,10 +48,10 @@ conda install libgomp from viz_3dtiles import Cesium3DTile, Cesium3DTileset # 1. Create an instance of the `Cesium3DTile` class. Use `Cesium3DTile.from_file()` to -# process a `.shp` file into a `.b3dm` 3D model: +# process a `.gpkg` file into a `.b3dm` 3D model: tile = Cesium3DTile() tile.save_to="~/my-tilesets/lakes/" -tile.from_file(filepath="~/my-data/lakes.shp") +tile.from_file(filepath="~/my-data/lakes.gpkg") # 2. Create an instance of the `Cesium3DTileset` class to contain that tile: