#![deny(
elided_lifetimes_in_paths,
explicit_outlives_requirements,
keyword_idents,
macro_use_extern_crate,
meta_variable_misuse,
missing_abi,
missing_debug_implementations,
missing_docs,
non_ascii_idents,
noop_method_call,
rust_2021_incompatible_closure_captures,
rust_2021_incompatible_or_patterns,
rust_2021_prefixes_incompatible_syntax,
rust_2024_prelude_collisions,
single_use_lifetimes,
trivial_casts,
trivial_numeric_casts,
unreachable_pub,
unsafe_code,
unsafe_op_in_unsafe_fn,
unused_crate_dependencies,
unused_extern_crates,
unused_import_braces,
unused_lifetimes,
unused_qualifications,
unused_results,
warnings
)]
pub mod colors;
mod format_info;
pub mod geo_referencing;
mod notes;
pub mod objects;
pub mod omap;
pub mod parts;
pub mod symbols;
pub mod templates;
mod utils;
pub mod view;
use std::{fmt::Debug, io::BufWriter};
pub use omap::Omap;
pub use utils::{Code, NonNegativeF64, UnitF64};
type Result<T> = std::result::Result<T, Error>;
use thiserror::Error;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum OmapSection {
XmlDeclaration,
Map,
Georeferencing,
Colors,
Symbols,
Parts,
Tags,
PointObject,
LineObject,
AreaObject,
TextObject,
PointSymbol,
LineSymbol,
AreaSymbol,
TextSymbol,
CombinedAreaSymbol,
Element,
FillPattern,
FillPatternPoint,
PrivatePart,
SkippedPart,
ColorSet,
Color,
Templates,
Template,
TemplateTransformations,
PassPoint,
Matrix,
CoordinateWrapper,
MapPart,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum CoordinateComponent {
X,
Y,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ObjectKind {
Point,
Text,
}
#[derive(Debug, Error)]
pub enum Error {
#[error("An error when converting from str")]
FromStrError,
#[error(transparent)]
XmlError(#[from] quick_xml::Error),
#[error(transparent)]
IoError(#[from] std::io::Error),
#[error(transparent)]
IntoInnerError(#[from] std::io::IntoInnerError<BufWriter<Vec<u8>>>),
#[error("unsupported OMAP XML namespace")]
UnsupportedOmapNamespace,
#[error("missing OMAP version")]
MissingOmapVersion,
#[error("unsupported OMAP version {0}")]
UnsupportedOmapVersion(u8),
#[error("unsupported XML version")]
UnsupportedXmlVersion,
#[error("missing coordinate component {0:?}")]
MissingCoordinateComponent(CoordinateComponent),
#[error(transparent)]
AttrError(#[from] quick_xml::events::attributes::AttrError),
#[error(transparent)]
StrUtf8Error(#[from] std::str::Utf8Error),
#[error(transparent)]
StringUtf8Error(#[from] std::string::FromUtf8Error),
#[error(transparent)]
EncodingError(#[from] quick_xml::encoding::EncodingError),
#[error(transparent)]
EscapeError(#[from] quick_xml::escape::EscapeError),
#[error("Could not merge map parts. Check that the indices are different and in range")]
MapPartMergeError,
#[error("missing XML encoding")]
MissingXmlEncoding,
#[error("unsupported XML encoding")]
UnsupportedXmlEncoding,
#[error(transparent)]
ParseIntError(#[from] std::num::ParseIntError),
#[error(transparent)]
ParseFloatError(#[from] std::num::ParseFloatError),
#[error("unexpected EOF while parsing {0:?}")]
UnexpectedEof(OmapSection),
#[error("missing required OMAP section {0:?}")]
MissingRequiredSection(OmapSection),
#[error("OMAP section {section:?} appeared before required section {required_before:?}")]
SectionOutOfOrder {
section: OmapSection,
required_before: OmapSection,
},
#[error("missing georeferencing map scale")]
MissingMapScale,
#[error("invalid georeferencing")]
InvalidGeoreferencing,
#[error("missing object type")]
MissingObjectType,
#[error("unknown object symbol id {0}")]
UnknownObjectSymbolId(i32),
#[error("missing {0:?} object geometry")]
MissingObjectGeometry(ObjectKind),
#[error("missing text object coordinates")]
MissingTextObjectCoordinates,
#[error("missing symbol id")]
MissingSymbolId,
#[error("unknown symbol type {0}")]
UnknownSymbolType(u8),
#[error("unknown point-symbol element symbol type {0}")]
UnknownElementSymbolType(u8),
#[error("unknown point-symbol element object type {0}")]
UnknownElementObjectType(u8),
#[error("point-symbol element symbol/object type mismatch")]
ElementSymbolObjectMismatch,
#[error("point-symbol element object appeared before symbol")]
ElementObjectBeforeSymbol,
#[error("point-symbol element is missing symbol or object data")]
MissingElementData,
#[error("point-symbol element is missing a point symbol part")]
MissingPointSymbolElementPart,
#[error("symbol id {0} is outside the declared symbol count")]
SymbolIdOutOfRange(usize),
#[error("duplicate symbol id {0}")]
DuplicateSymbolId(usize),
#[error("symbol count does not match parsed symbols")]
SymbolCountMismatch,
#[error("components found in non-combined symbol")]
ComponentsInNonCombinedSymbol,
#[error("unknown fill pattern type {0}")]
UnknownFillPatternType(u8),
#[error("missing point symbol in point fill pattern")]
MissingPointPatternSymbol,
#[error("unknown private part symbol type {0}")]
UnknownPrivatePartSymbolType(u8),
#[error("empty private combined-symbol part")]
EmptyPrivatePart,
#[error("missing color id")]
MissingColorId,
#[error(transparent)]
BorrowError(#[from] std::cell::BorrowError),
#[error(transparent)]
BorrowMutError(#[from] std::cell::BorrowMutError),
#[error(transparent)]
BezierConversionError(#[from] linestring2bezier::Error),
#[error("Color definition error")]
ColorError,
#[error("cyclic symbol definition")]
CyclicSymbolDefinition,
#[error("cannot borrow symbol during cycle check")]
SymbolCycleBorrow,
#[error("symbol set index {0} out of range")]
SymbolSetIndexOutOfRange(usize),
#[error("combined area symbol contains a point or text symbol")]
CombinedSymbolContainsPointOrText,
#[error("combined line symbol contains a non-line symbol")]
CombinedLineSymbolContainsNonLine,
#[error("unknown clipping option")]
UnknownClippingOption,
#[error("unknown line cap style")]
UnknownCapStyle,
#[error("unknown line join style")]
UnknownJoinStyle,
#[error("unknown mid-symbol placement")]
UnknownMidSymbolPlacement,
#[error("Template error")]
TemplateError,
#[error(transparent)]
TryFromIntError(#[from] std::num::TryFromIntError),
#[error("View error")]
ViewError,
#[error("Object error")]
ObjectError,
#[error("The value is not in the unit interval and cannot be converted to a UnitF64")]
NotInUnitInterval,
#[error("The value is not non-negative and cannot be converted to a NonNegativeF64")]
NotNonNegativeF64,
#[error(transparent)]
Infallible(#[from] std::convert::Infallible),
#[error("A provided map coordinate is outside the range for writing")]
MapCoordOutOfBounds,
#[error("Tried to parse a Code from an empty string")]
EmptyCode,
#[cfg(feature = "geo_ref")]
#[error(transparent)]
WmmError(#[from] world_magnetic_model::Error),
#[cfg(feature = "geo_ref")]
#[error(transparent)]
ProjError(#[from] proj_core::Error),
#[cfg(feature = "geo_ref")]
#[error(transparent)]
ProjParseError(#[from] proj_wkt::ParseError),
#[cfg(feature = "geo_ref")]
#[error(
"Encountered a tolerence error when calculating the scale factor during geo referencing"
)]
ProjScaleToleranceError,
#[error(
"Affine transforms are only available between changed geo referencing within the same projection"
)]
CannotGetAffineTransformBetweenDifferentProjections,
#[error("Tried to call try into on non-compatible symbols")]
SymbolConversionError,
}