diff --git a/.gitignore b/.gitignore index 42d7854..e33d003 100644 --- a/.gitignore +++ b/.gitignore @@ -138,5 +138,6 @@ dmypy.json cython_debug/ .vscode/ +.idea *.csv \ No newline at end of file diff --git a/README.md b/README.md index 281eb5d..6b78ee8 100644 --- a/README.md +++ b/README.md @@ -4,10 +4,11 @@ ## Installation -You need to install all dependencies first: +Install the package from the repository: ``` -pip install -r requirements.txt +cd urban-morphology-3d +pip install . ``` Then take your time and install [pymesh](https://pymesh.readthedocs.io/en/latest/installation.html). @@ -74,7 +75,7 @@ python cityPlot.py [file_path] 1) Download or `git clone` this repository. -2) Install all dependencies: `pip install -r requirements.txt`. +2) Install the package from the source directory: `pip install .`. To install for development: `pip install -e ".[dev]"` 3) Download a tile from 3D BAG: `wget --header='Accept-Encoding: gzip' https://data.3dbag.nl/cityjson/v210908_fd2cee53/3dbag_v210908_fd2cee53_5910.json` diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..20d4867 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,50 @@ +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" + +[project] +name = "3d-building-metrics" +version = "2024.1006" +description = "3D Building Metrics" +readme = "README.md" +requires-python = ">=3.8" +license = { text = "MIT" } +urls = { github = "https://github.com/tudelft3d/3d-building-metrics" } +dependencies = [ + "click==8.1.6", + "Cython==3.0.0", + "geopandas==0.13.2", + "ipygany", + "jupyter", + "mapbox-earcut==1.0.1", + "miniball==1.2.0", + "numpy==1.24.4", + "pandas==2.0.3", + "pymesh", + "pymeshfix==0.16.2", + "python-polylabel", + "pyvista==0.36.1", + "Rtree==1.0.1", + "scikit-learn==1.3.0", + "scipy==1.10.1", + "shapely==1.8.5", + "tqdm==4.65.0", +] +optional-dependencies = { dev = ["bumpver", "tox", "pytest", "pytest-cov"] } + +[tool.setuptools.packages.find] +where = ["src"] + +[tool.bumpver] +current_version = "2024.1006" +version_pattern = "YYYY.BUILD" +commit_message = "bump version {old_version} -> {new_version}" +commit = true +tag = true +push = false + +[tool.bumpver.file_patterns] +"pyproject.toml" = [ + 'version = "{version}"', +] + diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index d0fae06..0000000 --- a/requirements.txt +++ /dev/null @@ -1,19 +0,0 @@ -numpy -pyvista===0.36.1 -scipy -cython -pymeshfix -click -pandas -geopandas -tqdm -shapely===1.8.5 -jupyter -mapbox-earcut -python-polylabel -miniball -ipygany -rtree -scikit-learn -pytest -pytest-cov diff --git a/__init__.py b/src/building_metrics_3d/__init__.py similarity index 100% rename from __init__.py rename to src/building_metrics_3d/__init__.py diff --git a/cityCompare.py b/src/building_metrics_3d/cityCompare.py similarity index 97% rename from cityCompare.py rename to src/building_metrics_3d/cityCompare.py index aba3b42..b004e4f 100644 --- a/cityCompare.py +++ b/src/building_metrics_3d/cityCompare.py @@ -2,8 +2,8 @@ import json import numpy as np from tqdm import tqdm -import cityjson -from helpers.mesh import difference, symmetric_difference, to_pymesh, to_pyvista, intersect +from building_metrics_3d import cityjson +from building_metrics_3d.helpers.mesh import difference, symmetric_difference, to_pymesh, to_pyvista, intersect import pyvista as pv import pandas as pd import pymesh diff --git a/cityPlot.py b/src/building_metrics_3d/cityPlot.py similarity index 95% rename from cityPlot.py rename to src/building_metrics_3d/cityPlot.py index 86cf576..67dfb8f 100644 --- a/cityPlot.py +++ b/src/building_metrics_3d/cityPlot.py @@ -1,7 +1,7 @@ import click import json import numpy as np -from cityjson import to_triangulated_polydata +from building_metrics_3d.cityjson import to_triangulated_polydata import pyvista as pv from tqdm import tqdm diff --git a/cityStats.py b/src/building_metrics_3d/cityStats.py similarity index 100% rename from cityStats.py rename to src/building_metrics_3d/cityStats.py diff --git a/cityjson.py b/src/building_metrics_3d/cityjson.py similarity index 96% rename from cityjson.py rename to src/building_metrics_3d/cityjson.py index 711e1b9..a237a0b 100644 --- a/cityjson.py +++ b/src/building_metrics_3d/cityjson.py @@ -2,7 +2,7 @@ import numpy as np from shapely.geometry import Polygon, MultiPolygon -from helpers.geometry import project_2d, surface_normal, triangulate, triangulate_polygon +from building_metrics_3d.helpers.geometry import project_2d, surface_normal, triangulate, triangulate_polygon import pyvista as pv def get_surface_boundaries(geom): diff --git a/extractLod.py b/src/building_metrics_3d/extractLod.py similarity index 100% rename from extractLod.py rename to src/building_metrics_3d/extractLod.py diff --git a/geometry.py b/src/building_metrics_3d/geometry.py similarity index 98% rename from geometry.py rename to src/building_metrics_3d/geometry.py index 6696998..85a6576 100644 --- a/geometry.py +++ b/src/building_metrics_3d/geometry.py @@ -2,7 +2,7 @@ import numpy as np import pyvista as pv -from helpers.geometry import plane_params, project_mesh, to_3d +from building_metrics_3d.helpers.geometry import plane_params, project_mesh, to_3d from scipy.spatial import distance_matrix from sklearn.cluster import AgglomerativeClustering diff --git a/helpers/__init__.py b/src/building_metrics_3d/helpers/__init__.py similarity index 100% rename from helpers/__init__.py rename to src/building_metrics_3d/helpers/__init__.py diff --git a/helpers/geometry.py b/src/building_metrics_3d/helpers/geometry.py similarity index 100% rename from helpers/geometry.py rename to src/building_metrics_3d/helpers/geometry.py diff --git a/helpers/mesh.py b/src/building_metrics_3d/helpers/mesh.py similarity index 100% rename from helpers/mesh.py rename to src/building_metrics_3d/helpers/mesh.py diff --git a/helpers/minimumBoundingBox.py b/src/building_metrics_3d/helpers/minimumBoundingBox.py similarity index 100% rename from helpers/minimumBoundingBox.py rename to src/building_metrics_3d/helpers/minimumBoundingBox.py diff --git a/helpers/smallestenclosingcircle.py b/src/building_metrics_3d/helpers/smallestenclosingcircle.py similarity index 100% rename from helpers/smallestenclosingcircle.py rename to src/building_metrics_3d/helpers/smallestenclosingcircle.py diff --git a/shape_index.py b/src/building_metrics_3d/shape_index.py similarity index 99% rename from shape_index.py rename to src/building_metrics_3d/shape_index.py index 4d7e36d..2a6213b 100644 --- a/shape_index.py +++ b/src/building_metrics_3d/shape_index.py @@ -2,9 +2,9 @@ import math from shapely.geometry import Point, MultiPoint, Polygon -from helpers.geometry import surface_normal +from building_metrics_3d.helpers.geometry import surface_normal try: - from helpers.mesh import to_pymesh, to_pyvista, intersect + from building_metrics_3d.helpers.mesh import to_pymesh, to_pyvista, intersect pymesh_exists = True except: print("WARNING: pymesh not found! Exchange index calculation will be omitted...") diff --git a/volume.py b/src/building_metrics_3d/volume.py similarity index 100% rename from volume.py rename to src/building_metrics_3d/volume.py diff --git a/tests/test_shape_index.py b/tests/test_shape_index.py index 0036906..82b09f9 100644 --- a/tests/test_shape_index.py +++ b/tests/test_shape_index.py @@ -1,4 +1,4 @@ -import shape_index +from building_metrics_3d import shape_index import pyvista as pv from pytest import approx from shapely.geometry import Point diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..977a935 --- /dev/null +++ b/tox.ini @@ -0,0 +1,3 @@ +[tox] +envlist = py311 +isolated_build = True \ No newline at end of file