Skip to content

Light pre-calculation based on real data (urban data and sun position) with 3DTiles.

License

Notifications You must be signed in to change notification settings

VCityTeam/pySunlight

Repository files navigation

pySunlight

About The Project

Light pre-calculation based on real data (urban data and sun position) with 3DTiles. pySunlight wrap the Sunlight project using SWIG for its calculations to get the performance of C++ in Python and use py3DTilers, a Python library, to read geospatial datas. Sunlight is present in a git submodule to ensure correct versions between the two projects.

pySunlight is one repository of the Sunlight project, including :

Getting Started

Dependencies

  • Python 3.9, only version supported by our dependency with py3DTilers (a 3DTiles parsers).
  • PostgreSQL / PostGIS, as it's required by py3DTilers even if pySunlight doesn't use any database functionality.
  • Same CMake version as Sunlight 3.27.
  • SWIG 4.0.

For Linux

Prerequisites

  1. Install python 3.9.

    apt-get install python3.9 python3.9-dev
    
  2. Follow the install guide of PostgreSQL / PostGIS.

  3. Install libpq, the client interface with PostgreSQL in C (required by psycopg2 within py3dtilers).

    apt-get install -y libpq-dev
    
  4. Follow the SWIG install for Linux.

Installation

  1. Clone the repository.

    git clone --recursive https://github.com/VCityTeam/pySunlight.git && cd pySunlight/
    
  2. Create your virtual environment.

    python3.9 -m venv venv
    
  3. Enable your virtual environment.

    . venv/bin/activate
    
  4. Install all prerequisites.

    pip install -e .
    

For Mac OS

Prerequisites

brew install python@3.9
brew install swig            # Assert you got version 4.X with "swig -version"

Additionnaly, and because py3dTilers requires it (although pySunlight doesn't),

brew install postgresql@14
brew install postgis

Installation

  1. Clone the repository.

    git clone --recursive https://github.com/VCityTeam/pySunlight.git && cd pySunlight/
    
  2. Create your virtual environment.

    python3.9 -m venv venv
    # Because venv doesn't seem to consider linking to the ad-hoc
    # version of python-config that is required by swig within the
    # cmake context at build time
    ln -s /usr/local/bin/python3.9-config venv/bin/python-config
    
  3. Enable your virtual environment.

    . venv/bin/activate
    
  4. Install all prerequisites.

    pip install -e .
    

For Windows

Prerequisites

  1. Download and install python 3.9 from the official website.

  2. Follow the install guide of PostgreSQL / PostGIS.

  3. Download CMake 3.27.

  4. Follow the SWIG install for Windows.

Installation

  1. Clone the repository.

    git clone --recursive https://github.com/VCityTeam/pySunlight.git && cd pySunlight/
    
  2. Create your virtual environment.

    python3.9 -m venv venv
    
  3. Enable your virtual environment.

    . venv/Scripts/activate
    
  4. Install all prerequisites.

    pip install -e .
    

Usage

  1. You can create 3DTiles Sunlight using arguments, we are compatile with Tileset Reader arguments :

    python3.9 src/main.py -i ./datas/testing/b3dm_tileset --output_dir junk --start-date 403224 --end-date 403248
    

    The result will be the computation of sunlight between two dates and it will be exported in the output directory given.

Here is a full list of all options available :

Arguments Description Example
--file_path, -i Input directory containing 3D Tiles -i "C:\Sunlight\Sample-Datas\Lyon-1_2015"
--output_dir, -o Export directory of Sunlight computation -o "C:\Sunlight\Export\Lyon-1_2015"
--start-date, -s Start date of sunlight computation -s 403224
--end-date, -e End date of sunlight computation -e 403248
--with-aggregate Add aggregate to 3DTiles export, heavely impact performance --with-aggregate
--log-level, -log Provide logging level depending on logging module -log DEBUG

Contributing

Coding Style

  1. Install the additional dev requirements.

    pip install -e .[dev]
  2. To check if the code follows the coding style, run flake8

    flake8 .
  3. To check the program, run at the root folder :

    pytest tests
  4. Configure your IDE with autopep8 formatting extension.
    In VS Code, follow this tutorial by replacing prettier with autopep8.

Pipeline - Activity Chart

Here is the pipeline we follow for pySunlight : Pipeline Activity Chart

Directory Hierarchy

pySunlight (repo)
├── datas                     # Datas use for testing
├── docs                      # Documentations (original charts...)
├── src                       # Source code
├── Sunlight                  # Sunlight repository as git submodule
├── tests                     # Unit tests
├── .flake8                   # Flake8 Configuration
├── .gitignore                # Files/folders ignored by Git
├── .gitmodules               # Sunlight module commit version
├── CMakeLists.txt            # CMake file to create a crossplatform software
├── README.md
├── pySunlight.i              # SWIG interface file to expose Sunlight in python
├── setup.py                  # Install python requirements

License

Distributed under the LGPL-2.1 License. See LICENSE and Libraries Licenses for more information.

Main Contributors

Acknowledgments

About

Light pre-calculation based on real data (urban data and sun position) with 3DTiles.

Resources

License

Stars

Watchers

Forks

Packages

No packages published