Skip to main content

Python 3 library to write CZML

Project description

czml3

pypi conda Python codecov pypi-downloads conda-downloads workflow-status license

From the official CZML Guide:

CZML is a JSON format for describing a time-dynamic graphical scene, primarily for display in a web browser running Cesium. It describes lines, points, billboards, models, and other graphical primitives, and specifies how they change with time.

czml3 aims to make the process of writing CZML files in Python easy by:

  • Type checking properties
  • Conversion of properties to their expected format

Insallation

You can install czml3 using pip:

pip install czml3

or conda:

conda install czml3 --channel conda-forge

Examples

A CZML document is a list of packets, which have several properties. Recreating the blue box from Cesium sandcastle's CZML Box:

from czml3 import Document, Packet, Preamble
from czml3.properties import (
    Box,
    BoxDimensions,
    Cartesian3Value,
    Color,
    Material,
    Position,
    SolidColorMaterial,
)
packet_box = Packet(
    position=Position(cartographicDegrees=[-114.0, 40.0, 300000.0]),
    box=Box(
        dimensions=BoxDimensions(
            cartesian=Cartesian3Value(values=[400000.0, 300000.0, 500000.0])
        ),
        material=Material(
            solidColor=SolidColorMaterial(color=Color(rgba=[0, 0, 255, 255]))
        ),
    ),
)
doc = Document(packets=[Preamble(name="box"), packet_box])
print(doc)
[
    {
        "id": "document",
        "version": "1.0",
        "name": "box"
    },
    {
        "id": "b9f211b1-6e9d-45b2-b484-516d127ffa22",
        "position": {
            "cartographicDegrees": [
                -114.0,
                40.0,
                300000.0
            ]
        },
        "box": {
            "dimensions": {
                "cartesian": [
                    400000.0,
                    300000.0,
                    500000.0
                ]
            },
            "material": {
                "solidColor": {
                    "color": {
                        "rgba": [
                            0.0,
                            0.0,
                            255.0,
                            255.0
                        ]
                    }
                }
            }
        }
    }
]

czml3 uses pydantic for all classes. As such czml3 automatically converts some properties to their appropriate type. For example, the following creates a Position property of doubles using a numpy array of interger type:

import numpy as np
from czml3.properties import Position
print(Position(cartographicDegrees=np.array([-114, 40, 300000], dtype=int)))
{
    "cartographicDegrees": [
        -114.0,
        40.0,
        300000.0
    ]
}

Jupyter Widget

You can easily display your CZML document using our interactive widget:

from czml3.examples import simple
from czml3.widget import CZMLWidget
CZMLWidget(simple)

Widget

Contributing

You want to contribute? Awesome! There are lots of CZML properties that we still did not implement. All ideas welcome!

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

czml3-2.1.0.tar.gz (100.7 kB view details)

Uploaded Source

Built Distribution

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

czml3-2.1.0-py3-none-any.whl (29.6 kB view details)

Uploaded Python 3

File details

Details for the file czml3-2.1.0.tar.gz.

File metadata

  • Download URL: czml3-2.1.0.tar.gz
  • Upload date:
  • Size: 100.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for czml3-2.1.0.tar.gz
Algorithm Hash digest
SHA256 99609d86cbd2616590a491c76b3daaac99ff70e2588fac85dcb68e5c0fafae64
MD5 4d4bf0b5af7e95370286254dedbb6696
BLAKE2b-256 1e706e9f33b3f747b5f884966d3d3aeb0a986fbb62dffff73caf75c73052ec2f

See more details on using hashes here.

Provenance

The following attestation bundles were made for czml3-2.1.0.tar.gz:

Publisher: publish-to-pypi.yml on Stoops-ML/czml3

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

File details

Details for the file czml3-2.1.0-py3-none-any.whl.

File metadata

  • Download URL: czml3-2.1.0-py3-none-any.whl
  • Upload date:
  • Size: 29.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for czml3-2.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0f6da077abfe431c84c9b1f6c1b7b520153ec7d7a9413bf5895d4a2bb393cc3f
MD5 7e5b2fffa650ecb92c6d14ef030fdd26
BLAKE2b-256 8e04ef17989d50f7145ee068c7246ca3c2b7a67955165408155848463d6a76a0

See more details on using hashes here.

Provenance

The following attestation bundles were made for czml3-2.1.0-py3-none-any.whl:

Publisher: publish-to-pypi.yml on Stoops-ML/czml3

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