Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make a python package #17

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -138,5 +138,6 @@ dmypy.json
cython_debug/

.vscode/
.idea

*.csv
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down Expand Up @@ -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`

Expand Down
50 changes: 50 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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}"',
]

19 changes: 0 additions & 19 deletions requirements.txt

This file was deleted.

File renamed without changes.
4 changes: 2 additions & 2 deletions cityCompare.py → src/building_metrics_3d/cityCompare.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion cityPlot.py → src/building_metrics_3d/cityPlot.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion cityjson.py → src/building_metrics_3d/cityjson.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion geometry.py → src/building_metrics_3d/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions shape_index.py → src/building_metrics_3d/shape_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -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...")
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/test_shape_index.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 3 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[tox]
envlist = py311
isolated_build = True