Metadata-Version: 2.1
Name: cjdb
Version: 1.0.0
Summary: Import city.json files to postgreSQL
License: MIT
Author: Gina Stavropoulou
Author-email: ginastavropoulou@gmail.com
Requires-Python: >=3.11,<4.0
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Requires-Dist: GeoAlchemy (>=0.7.2,<0.8.0)
Requires-Dist: numpy (>=1.24.2,<2.0.0)
Requires-Dist: pyproj (>=3.5.0,<4.0.0)
Requires-Dist: requests (>=2.28.2,<3.0.0)
Requires-Dist: shapely (>=2.0.1,<3.0.0)
Description-Content-Type: text/markdown

# cjdb
[![MIT badge](https://img.shields.io/pypi/l/cjdb)](LICENSE) &nbsp; [![PyPI](https://img.shields.io/pypi/v/cjdb)](https://pypi.org/project/cjdb)

CJDB is a tool for enabling CityJSON integration with a PostgreSQL database.

Authors: Cynthia Cai, Lan Yan, Yitong Xia, Chris Poon, Siebren Meines, Leon Powalka

## Table of Contents  
### [1. Data model](#model)
### [2. Installation & running](#install)
### [3. Local development](#local)
### [4. Local CLI development](#cli)
---
## 1. Data model <a name="model"></a>
For the underlying data model see [model/README.md](model/README.md)

Based on this model, there are 2 software components available:

### cj2pgsql
See [cj2pgsql/README.md](cj2pgsql/README.md)

## 2. Installation & running <a name="install"></a>
### Using pip

It is recommended to install it in an isolated environment, because of fragile external library dependencies for CQL filter parsing.

```
pip install cjdb
```


### Using the repository code
Another option is to clone the repository and build the CLI from the code.
From repository root, run:
```
pip3 install build wheel
python3 -m build
```

Then install the .whl file with pip:
```
pip3 install dist/*.whl --force-reinstall
```

### Using docker
Build:
```
docker build -t cjdb:latest .
```

Run: **cj2pgsql**
```
docker run --rm -it cjdb cj2pgsql --help
```

To import some files, the `-v` option is needed to mount our local file directory in the container.
```
docker run -v {MYDIRECTORY}:/data --rm -it --network=host cjdb cj2pgsql -H localhost -U postgres -d postgres -W postgres /data/5870_ext.jsonl 
```

For instructions on running the software check specific READMEs.


## 3. Local development <a name="local"></a>
Make sure pipenv is installed:
```
pip install pipenv
```
Create the environment:
```
pipenv install
```

## 4. Local CLI development <a name="cli"></a>
---
To build the CLI app (so that it can be called as a command line tool from anywhere):


1. Sync the pipenv requirements with the setup.py file:
```
pipenv run pipenv-setup sync
```

2. Create a venv just for testing the CLI build.

**Note**: This is not the pipenv/development environment.
```
virtualenv venv
```
3. Activate environment (note: this is not the pipenv environment. This is a separate environment just to test the CLI build)
```
. venv/bin/activate

```

4. Build the CLI:
```
python setup.py develop
```

5. The cj2pgsql importer should now work as a command inside this environment:
```
cj2pgsql --help
```

