Skip to main content

A procedural modeling engine for OpenStreetMap building generation.

Project description

OCGA: Procedural 3D Buildings for OpenStreetMap

Creating detailed 3D buildings in OSM by manually adding building:part's and moving nodes back and forth is tedious and slow.

OCGA (OSM Computer-Generated Architecture) is built on a key insight: much like music, architecture is often based on the repetition of common elements and patterns.

Because architecture is inherently rule-based, we can leverage a different approach: procedural generation. Instead of building models by hand, you define these architectural patterns using a simple .ocga language, and let the engine execute the repetitive work of generating the complex geometry for you.

To achieve this, we have developed a new, unique domain-specific language: OCGA. This project provides both the OCGA language specification and a simple command-line tool that interprets this new language, enabling rapid creation of detailed building models.

While certain ideas were adopted from ESRI's CityEngine, OCGA is not its clone, and many things are implemented differently.

Installation

Install the package from PyPI:

pip install ocga

Workflow

The intended cycle for using OCGA is as follows:

  1. Create an Outline: Start by saving a building's footprint/outline into its own .osm file.

  2. Define the Rules: Write a corresponding .ocga rules file tailored to that building's architecture. This is where you describe how to procedurally generate the model's parts.

  3. Generate the Model: Run the ocga command-line tool, providing it with your outline and rules files.

    ocga -i <path/to/your_building.osm> -r <path/to/your_rules.ocga> -o <path/to/generated_model.osm>
    
  4. Verify Before Uploading! Before you upload the data to OpenStreetMap, it is crucial to visually inspect the generated model.

    • Primary Method (JOSM): The easiest way is to open the generated .osm file in JOSM and use the UrbanEye3D plugin viewer.
    • Alternative Method: You can use osm2world to export the model to a .gltf file, which can then be opened in any standard 3D viewer (like the built-in Windows 3D Viewer or f3d on Linux).
  5. Upload to OpenStreetMap: Once you are satisfied, you can upload the data from JOSM. You may need to merge the layer containing the generated model with your main data layer before uploading.

Usage as a Library

While the primary use case for OCGA is the command-line tool, its core engine can be imported and used directly in your own Python projects, as permitted by the MIT license.

The main entry point function is ocga_process2, which can be imported from the top-level package. Its function is analogous to the CLI tool:

from ocga import ocga_process2

input_file = "path/to/building.osm"
rules_file = "path/to/rules.ocga"
output_file = "path/to/generated.osm"

# The other arguments are optional
ocga_process2(input_file, output_file, rules_file)

Other functions from the engine modules (e.g., from ocga.ocga_engine) can also be imported, but their APIs are not guaranteed to be stable and may change. Use them at your own risk.

Language and Examples

  • For a complete guide to the syntax and operations, see the OCGA Language Reference.
  • A collection of sample .osm and .ocga files can be found in the docs/ocga_samples directory.
  • The example.bat and example.sh scripts in the root directory demonstrate how to run the tool on these samples.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ocga_cli-0.1.0.tar.gz (203.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ocga_cli-0.1.0-py3-none-any.whl (62.9 kB view details)

Uploaded Python 3

File details

Details for the file ocga_cli-0.1.0.tar.gz.

File metadata

  • Download URL: ocga_cli-0.1.0.tar.gz
  • Upload date:
  • Size: 203.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ocga_cli-0.1.0.tar.gz
Algorithm Hash digest
SHA256 79c4967516225bdfb8395483dc88de245997a1303bb64a0beaaadaf5b2e090b6
MD5 de70f18ce271e6d15361ef8cb4862ecd
BLAKE2b-256 863251bb689b558c7e96067f487bce7c480fbf256048b6651d73744fb68398cc

See more details on using hashes here.

Provenance

The following attestation bundles were made for ocga_cli-0.1.0.tar.gz:

Publisher: pypi-publish.yml on Zkir/ocga

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ocga_cli-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: ocga_cli-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 62.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ocga_cli-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9201c961411280a3328f4cd205e057ebcd0918095c5d127ddc76df68645b5b4a
MD5 fa0ac850f2179ddf19a0b39c545806ac
BLAKE2b-256 cb83ebb873a65d84e6ecaf471e910c608200f344c182b9ecbd7020c9e63aad8c

See more details on using hashes here.

Provenance

The following attestation bundles were made for ocga_cli-0.1.0-py3-none-any.whl:

Publisher: pypi-publish.yml on Zkir/ocga

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page