Expand description

Artifacts have a few major components:

  1. Geometry data, e.g. a mesh
  2. Transforms that define how the geometry is positioned
  3. Metadata, e.g. the artifact’s name

To create an artifact within an artifact group, you’ll ultimately need to create an object builder (e.g. Object2Builder), which contains the geometry and transforms, and a UserMetadataBuilder to define the metadata. Once you have these pieces, you can add the artifact to a artifact group using an artifact uploader.

§Creating object builders

To create an object builder, you first need to represent your data as one of our primitive types, e.g. a Polygon2Builder. Once you have it, there are a couple ways to convert it into an object builder:

§Direct creation

All primitives can be converted into an object builder directly using into(). Then, you can add transforms to set the artifact’s position:

use observation_tools_client::artifacts::Object2Builder;
use observation_tools_client::artifacts::Point2Builder;
use observation_tools_client::artifacts::Transform2Builder;

// Create a primitive Point2
let point = Point2Builder::new(5.0, 3.0);
// Convert it into an Object2
let mut point: Object2Builder = point.into();
// Add an identity transform so the point is positioned at (5, 3)
point.add_transform(Transform2Builder::identity());

If you want to display the same geometry at different positions, you can also add multiple transforms to the artifact.

§Implicit creation

If you do not need to set an explicit transform, you skip the object builder conversion:

use observation_tools_client::artifacts::Point2Builder;

// The Point2 will be converted to an Object2 with an identity transform
uploader.create_object2("my-point", Point2Builder::new(5.0, 3.0))?;

§Metadata

The UserMetadataBuilder is used to store the artifact’s name and additional metadata, stored as key-value pairs.

If you do not need to add metadata, UserMetadataBuilder can be created implicitly from a string:

use observation_tools_client::artifacts::Point2Builder;
use observation_tools_client::artifacts::UserMetadataBuilder;

// Creates an artifact with the name "my-point"
uploader.create_object2("my-point", Point2Builder::new(5.0, 3.0))?;

// Create an artifact with additional key-value data
let mut metadata = UserMetadataBuilder::new("point-with-metadata");
metadata.add_metadata("my-key", "my-value");
uploader.create_object2(metadata, Point2Builder::new(5.0, 3.0))?;

§Primitives

Don’t see a primitive you’re looking for? Need conversions from types in another crate? Let us know! File a feature request or email us.

Support for 3D primitives is experimental

Modules§

  • Conversions from nalgebra types.

Structs§