Skip to main content

Python 3 library to write CZML

Project description

czml3

pypi conda Python codecov pypi-downloads conda-downloads workflow-status Documentation Status

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
  • Cooercion of data to their required format
  • Forbidding unrecognised properties
  • Creating minimal CZML files
  • Performant JSON serialisation

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 CZML_VERSION, Document, Packet
from czml3.properties import (
    Box,
    BoxDimensions,
    Color,
    Material,
    Position,
    SolidColorMaterial,
)
from czml3.types import Cartesian3Value
packet_box = Packet(
    id="my_id",
    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=[Packet(id="document", name="box", version=CZML_VERSION), packet_box]
)
print(doc)
[
    {
        "id": "document",
        "name": "box",
        "version": "1.0"
    },
    {
        "id": "my_id",
        "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 is able to coerce data to their right 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
    ]
}

Contributing

You want to contribute? Awesome! There are lots of CZML properties and validations that we still did not implement, which can be found here.

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.3.0.tar.gz (114.5 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.3.0-py3-none-any.whl (26.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for czml3-2.3.0.tar.gz
Algorithm Hash digest
SHA256 8a671e0b876ad6d8a231b3887dbff88d7eb2b9e710474817bea9f52b359f9feb
MD5 4f6375d35e11ff615ef13ae41c9479d0
BLAKE2b-256 c8caf9ccb8d25432af11b2978df25468bd87298e055805ceb266874b749cea6d

See more details on using hashes here.

Provenance

The following attestation bundles were made for czml3-2.3.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.3.0-py3-none-any.whl.

File metadata

  • Download URL: czml3-2.3.0-py3-none-any.whl
  • Upload date:
  • Size: 26.1 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.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bd1b6ff63ebbd1d75e3b9a66a99d0e4ed71e28f2b29b1aa8eef9517f8e3b140a
MD5 b14700377339d16ec78a3612ec8665a0
BLAKE2b-256 8f998f1578e3e6004a8706860fa5c8ae082cd3ee99933ee34dd125bccaafedca

See more details on using hashes here.

Provenance

The following attestation bundles were made for czml3-2.3.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