Skip to main content

oxigeo_metadata/
lib.rs

1//! Comprehensive metadata standards support for OxiGeo.
2//!
3//! This crate provides support for multiple geospatial and data catalog metadata standards:
4//!
5//! - **ISO 19115** - Geographic Information - Metadata
6//! - **FGDC** - Federal Geographic Data Committee
7//! - **INSPIRE** - EU INSPIRE Directive
8//! - **DataCite** - DOI metadata for research data
9//! - **DCAT** - W3C Data Catalog Vocabulary
10//!
11//! # Features
12//!
13//! - Metadata extraction from datasets (GeoTIFF, NetCDF, HDF5, STAC)
14//! - Metadata validation and quality scoring
15//! - Cross-standard transformation
16//! - XML and JSON serialization
17//!
18//! # Examples
19//!
20//! ```no_run
21//! use oxigeo_metadata::*;
22//!
23//! # fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
24//! // Create ISO 19115 metadata
25//! let iso = iso19115::Iso19115Metadata::builder()
26//!     .title("Sentinel-2 Imagery")
27//!     .abstract_text("Satellite imagery from Sentinel-2")
28//!     .keywords(vec!["satellite", "sentinel-2"])
29//!     .build()?;
30//!
31//! // Validate
32//! let validation = validate::validate_iso19115(&iso)?;
33//! if !validation.is_complete() {
34//!     println!("Missing fields: {:?}", validation.missing_fields());
35//! }
36//!
37//! # Ok(())
38//! # }
39//! ```
40
41#![cfg_attr(not(feature = "std"), no_std)]
42#![warn(missing_docs)]
43
44#[cfg(feature = "std")]
45extern crate std;
46
47pub mod datacite;
48pub mod dcat;
49pub mod error;
50pub mod extract;
51pub mod extractors;
52pub mod fgdc;
53pub mod inspire;
54pub mod iso19115;
55pub mod transform;
56pub mod validate;
57
58pub use error::{MetadataError, Result};
59
60/// Common metadata types and utilities.
61pub mod common {
62    use serde::{Deserialize, Serialize};
63
64    /// Contact information.
65    #[derive(Debug, Clone, Serialize, Deserialize)]
66    pub struct ContactInfo {
67        /// Individual name
68        pub individual_name: Option<String>,
69        /// Organization name
70        pub organization_name: Option<String>,
71        /// Position name
72        pub position_name: Option<String>,
73        /// Email address
74        pub email: Option<String>,
75        /// Phone number
76        pub phone: Option<String>,
77        /// Address
78        pub address: Option<Address>,
79        /// Online resource
80        pub online_resource: Option<String>,
81    }
82
83    /// Address information.
84    #[derive(Debug, Clone, Serialize, Deserialize)]
85    pub struct Address {
86        /// Delivery point (street address)
87        pub delivery_point: Option<String>,
88        /// City
89        pub city: Option<String>,
90        /// Administrative area (state/province)
91        pub administrative_area: Option<String>,
92        /// Postal code
93        pub postal_code: Option<String>,
94        /// Country
95        pub country: Option<String>,
96    }
97
98    /// Bounding box for geographic extent.
99    #[derive(Debug, Clone, Copy, Serialize, Deserialize)]
100    pub struct BoundingBox {
101        /// West longitude
102        pub west: f64,
103        /// East longitude
104        pub east: f64,
105        /// South latitude
106        pub south: f64,
107        /// North latitude
108        pub north: f64,
109    }
110
111    impl BoundingBox {
112        /// Create a new bounding box.
113        ///
114        /// # Arguments
115        ///
116        /// * `west` - West longitude
117        /// * `east` - East longitude
118        /// * `south` - South latitude
119        /// * `north` - North latitude
120        pub fn new(west: f64, east: f64, south: f64, north: f64) -> Self {
121            Self {
122                west,
123                east,
124                south,
125                north,
126            }
127        }
128
129        /// Check if the bounding box is valid.
130        pub fn is_valid(&self) -> bool {
131            self.west <= self.east
132                && self.south <= self.north
133                && self.west >= -180.0
134                && self.east <= 180.0
135                && self.south >= -90.0
136                && self.north <= 90.0
137        }
138    }
139
140    /// Keyword with optional thesaurus.
141    #[derive(Debug, Clone, Serialize, Deserialize)]
142    pub struct Keyword {
143        /// Keyword text
144        pub keyword: String,
145        /// Thesaurus name
146        pub thesaurus: Option<String>,
147    }
148
149    /// Temporal extent.
150    #[derive(Debug, Clone, Serialize, Deserialize)]
151    pub struct TemporalExtent {
152        /// Start date/time
153        pub start: Option<chrono::DateTime<chrono::Utc>>,
154        /// End date/time
155        pub end: Option<chrono::DateTime<chrono::Utc>>,
156    }
157
158    /// License or usage constraints.
159    #[derive(Debug, Clone, Serialize, Deserialize)]
160    pub struct License {
161        /// License name
162        pub name: String,
163        /// License URL
164        pub url: Option<String>,
165    }
166}