use crate::prelude::StringStorage;
use std::fmt::{Display, Formatter};
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct BBox {
values: [f64; 6],
}
impl BBox {
#[must_use]
pub fn new(min_x: f64, min_y: f64, min_z: f64, max_x: f64, max_y: f64, max_z: f64) -> Self {
Self {
values: [min_x, min_y, min_z, max_x, max_y, max_z],
}
}
#[must_use]
pub fn as_slice(&self) -> &[f64] {
&self.values
}
#[must_use]
pub fn min_x(&self) -> f64 {
self.values[0]
}
#[must_use]
pub fn min_y(&self) -> f64 {
self.values[1]
}
#[must_use]
pub fn min_z(&self) -> f64 {
self.values[2]
}
#[must_use]
pub fn max_x(&self) -> f64 {
self.values[3]
}
#[must_use]
pub fn max_y(&self) -> f64 {
self.values[4]
}
#[must_use]
pub fn max_z(&self) -> f64 {
self.values[5]
}
#[must_use]
pub fn width(&self) -> f64 {
self.max_x() - self.min_x()
}
#[must_use]
pub fn length(&self) -> f64 {
self.max_y() - self.min_y()
}
#[must_use]
pub fn height(&self) -> f64 {
self.max_z() - self.min_z()
}
}
impl Default for BBox {
fn default() -> Self {
Self {
values: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
}
}
}
impl From<[f64; 6]> for BBox {
fn from(values: [f64; 6]) -> Self {
Self { values }
}
}
impl From<BBox> for [f64; 6] {
fn from(bbox: BBox) -> Self {
bbox.values
}
}
impl Display for BBox {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(
f,
"[{}, {}, {}, {}, {}, {}]",
self.min_x(),
self.min_y(),
self.min_z(),
self.max_x(),
self.max_y(),
self.max_z()
)
}
}
#[repr(C)]
#[derive(Clone, Debug, Default, PartialEq, PartialOrd, Ord, Eq, Hash)]
pub struct CityModelIdentifier<SS: StringStorage>(SS::String);
impl<SS: StringStorage> CityModelIdentifier<SS> {
pub fn new(value: SS::String) -> Self {
Self(value)
}
pub fn into_inner(self) -> SS::String {
self.0
}
}
impl<SS: StringStorage> Display for CityModelIdentifier<SS> {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.0)
}
}
#[repr(C)]
#[derive(Clone, Debug, Default, PartialEq, PartialOrd, Ord, Eq, Hash)]
pub struct Date<SS: StringStorage>(SS::String);
impl<SS: StringStorage> Date<SS> {
pub fn new(value: SS::String) -> Self {
Self(value)
}
pub fn into_inner(self) -> SS::String {
self.0
}
}
impl<SS: StringStorage> Display for Date<SS> {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.0)
}
}
#[repr(C)]
#[derive(Clone, Debug, Default, PartialEq, PartialOrd, Ord, Eq, Hash)]
pub struct CRS<SS: StringStorage>(SS::String);
impl<SS: StringStorage> CRS<SS> {
pub fn new(value: SS::String) -> Self {
Self(value)
}
pub fn into_inner(self) -> SS::String {
self.0
}
}
impl<SS: StringStorage> Display for CRS<SS> {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.0)
}
}