From 679aaca258b27b7e5c9d64155b00cb3488cc016c Mon Sep 17 00:00:00 2001 From: Adam Pospisil Date: Mon, 2 Dec 2024 13:20:02 +0100 Subject: [PATCH 1/2] feat: removed coordinates converter service; moved to separate repository --- coordinates_converter/.dockerignore | 1 - coordinates_converter/.gitignore | 6 - coordinates_converter/Dockerfile | 10 - coordinates_converter/README.md | 41 ---- coordinates_converter/__init__.py | 0 coordinates_converter/gltf.py | 190 ------------------ coordinates_converter/main.py | 164 --------------- coordinates_converter/requirements.txt | 5 - coordinates_converter/tests/__init__.py | 0 coordinates_converter/tests/test_geojson.py | 28 --- coordinates_converter/tests/test_gltf.py | 50 ----- coordinates_converter/tests/test_shapefile.py | 63 ------ 12 files changed, 558 deletions(-) delete mode 100644 coordinates_converter/.dockerignore delete mode 100644 coordinates_converter/.gitignore delete mode 100644 coordinates_converter/Dockerfile delete mode 100644 coordinates_converter/README.md delete mode 100644 coordinates_converter/__init__.py delete mode 100644 coordinates_converter/gltf.py delete mode 100644 coordinates_converter/main.py delete mode 100644 coordinates_converter/requirements.txt delete mode 100644 coordinates_converter/tests/__init__.py delete mode 100644 coordinates_converter/tests/test_geojson.py delete mode 100644 coordinates_converter/tests/test_gltf.py delete mode 100644 coordinates_converter/tests/test_shapefile.py diff --git a/coordinates_converter/.dockerignore b/coordinates_converter/.dockerignore deleted file mode 100644 index ed8ebf58..00000000 --- a/coordinates_converter/.dockerignore +++ /dev/null @@ -1 +0,0 @@ -__pycache__ \ No newline at end of file diff --git a/coordinates_converter/.gitignore b/coordinates_converter/.gitignore deleted file mode 100644 index 65ce5257..00000000 --- a/coordinates_converter/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -__pycache__ -*.zip -*.geojson -*.gltf -*.glb -.pytest_cache \ No newline at end of file diff --git a/coordinates_converter/Dockerfile b/coordinates_converter/Dockerfile deleted file mode 100644 index 7150f554..00000000 --- a/coordinates_converter/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM python:3.12 - -WORKDIR /app - -COPY requirements.txt requirements.txt -RUN pip install -r requirements.txt - -COPY . . - -CMD fastapi run main.py \ No newline at end of file diff --git a/coordinates_converter/README.md b/coordinates_converter/README.md deleted file mode 100644 index 9d0b0eb2..00000000 --- a/coordinates_converter/README.md +++ /dev/null @@ -1,41 +0,0 @@ -# Metacity Studio Coordinates Converter Utility - -## Requirements -- Python 3.12 -- pip - -## How to install - -- `pip install -r requirements.txt` to install dependencies - -## How to run - -- `fastapi dev main.py` to run on localhost - -## How to use (Shapefile) - -- example curl - shapefile with projection: - - `curl -F "file=@shapefile.zip" -X POST http://localhost:8000/convert_shapefile?crsTarget=EPSG:4326` -- example curl - shapefile without projection: - - `curl -F "file=@shapefile_noproj.zip" -X POST 'http://localhost:8000/convert_shapefile?crsTarget=EPSG:4326&crsSource=EPSG:5514' --output result.zip` -- `file` - zipped shapefile -- `crsTarget` - EPSG code of coordinate system to convert to -- `crsSource` - EPSG code of initial coordinate system (if shapefile doesn't contain projection info) - -## How to use (GeoJSON) - -- example curl - GeoJSON with projection: - - `curl -F "file=@data.geojson" -X POST http://localhost:8000/convert_geojson?crsTarget=EPSG:4326` -- example curl - GeoJSON without projection: - - `curl -F "file=@data_noproj.geojson" -X POST 'http://localhost:8000/convert_geojson?crsTarget=EPSG:4326&crsSource=EPSG:5514' --output result.geojson` -- `file` - input geojson -- `crsTarget` - EPSG code of coordinate system to convert to -- `crsSource` - EPSG code of initial coordinate system (if geojson doesn't contain projection info) - -## How to use (GLTF) - -- example curl - GLTF: - - `curl -F "file=@input.gltf" -X POST 'http://localhost:8000/convert_gltf?crsTarget=EPSG:5514&crsSource=EPSG:4326' --output result.gltf'` -- `file` - input gltf -- `crsTarget` - EPSG code of coordinate system to convert to -- `crsSource` - EPSG code of initial coordinate system diff --git a/coordinates_converter/__init__.py b/coordinates_converter/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/coordinates_converter/gltf.py b/coordinates_converter/gltf.py deleted file mode 100644 index 25507ec2..00000000 --- a/coordinates_converter/gltf.py +++ /dev/null @@ -1,190 +0,0 @@ -import base64 -import struct - -import numpy as np -import pygltflib -import pyrr -import logging - -logger = logging.getLogger("uvicorn.error") - - -def count_vertices(gltf): - count = 0 - for node in gltf.nodes: - if node.mesh is not None: - mesh = gltf.meshes[node.mesh] - for primitive in mesh.primitives: - count += gltf.accessors[primitive.attributes.POSITION].count - return count - - -def get_vertices(gltf, primitive): - # get the binary data for this mesh primitive from the buffer - accessor = gltf.accessors[primitive.attributes.POSITION] - bufferView = gltf.bufferViews[accessor.bufferView] - buffer = gltf.buffers[bufferView.buffer] - data = gltf.get_data_from_buffer_uri(buffer.uri) - - # pull each vertex from the binary buffer and convert it into a tuple of python floats - vertices = [] - for i in range(accessor.count): - index = ( - bufferView.byteOffset + accessor.byteOffset + i * 12 - ) # the location in the buffer of this vertex - d = data[index : index + 12] # the vertex data - v = struct.unpack(" Date: Mon, 2 Dec 2024 13:26:16 +0100 Subject: [PATCH 2/2] feat: removed converter-related workflows --- .github/workflows/build-converter.yml | 32 --------------------------- .github/workflows/build.yml | 4 ---- .github/workflows/test-converter.yml | 31 -------------------------- .github/workflows/test.yml | 4 ---- 4 files changed, 71 deletions(-) delete mode 100644 .github/workflows/build-converter.yml delete mode 100644 .github/workflows/test-converter.yml diff --git a/.github/workflows/build-converter.yml b/.github/workflows/build-converter.yml deleted file mode 100644 index ca1f6d81..00000000 --- a/.github/workflows/build-converter.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: Build Coordinates Converter - -on: - workflow_call: - -jobs: - build: - name: Build and push Docker image - runs-on: ubuntu-latest - - steps: - - name: Checkout the updated source code - uses: actions/checkout@v4 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Login to container registry - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Build image and push it to the container registry - uses: docker/build-push-action@v5 - with: - push: true - context: ./coordinates_converter - tags: "ghcr.io/metacitytools/coordinates-converter:latest" - cache-from: type=gha - cache-to: type=gha,mode=max diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8996c09d..687a2935 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,7 +7,3 @@ jobs: build-studio: name: Build and push studio Docker image uses: ./.github/workflows/build-studio.yml - - build-converter: - name: Build and push coordinates converter Docker image - uses: ./.github/workflows/build-converter.yml diff --git a/.github/workflows/test-converter.yml b/.github/workflows/test-converter.yml deleted file mode 100644 index 977ccc04..00000000 --- a/.github/workflows/test-converter.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: Test Coordinates Converter - -on: - pull_request: - types: [opened, reopened, synchronize] - paths: - - "coordinates_converter/**" - - ".github/workflows/test-converter.yml" - workflow_call: - -jobs: - test: - name: Run tests - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Setup Python - uses: actions/setup-python@v5 - with: - python-version: 3.12 - - - name: Install dependencies - run: | - cd coordinates_converter - pip install -r requirements.txt - - - name: Run tests - run: | - cd coordinates_converter/tests - pytest -rA diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a64f9183..e705a43b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,7 +7,3 @@ jobs: test-studio: name: Run studio tests uses: ./.github/workflows/test-studio.yml - - test-converter: - name: Run coordinates converter tests - uses: ./.github/workflows/test-converter.yml