stac_extensions/electro_optical.rs
1//! The [electro-optical](https://github.com/stac-extensions/eo) extension.
2
3use crate::Extension;
4use serde::{Deserialize, Serialize};
5
6/// EO data is considered to be data that represents a snapshot of the Earth for
7/// a single date and time.
8///
9/// It could consist of multiple spectral bands in any part of the
10/// electromagnetic spectrum. Examples of EO data include sensors with visible,
11/// short-wave and mid-wave IR bands (e.g., the OLI instrument on Landsat-8),
12/// long-wave IR bands (e.g. TIRS aboard Landsat-8).
13#[derive(Debug, Serialize, Deserialize)]
14pub struct ElectroOptical {
15 /// An array of available bands where each object is a [Band].
16 ///
17 /// If given, requires at least one band.
18 #[serde(skip_serializing_if = "Vec::is_empty", default)]
19 pub bands: Vec<Band>,
20
21 /// Estimate of cloud cover, in %.
22 #[serde(skip_serializing_if = "Option::is_none")]
23 pub cloud_cover: Option<f64>,
24
25 /// Estimate of snow and ice cover, in %.
26 #[serde(skip_serializing_if = "Option::is_none")]
27 pub snow_cover: Option<f64>,
28}
29
30/// [Spectral
31/// bands](https://www.sciencedirect.com/topics/earth-and-planetary-sciences/spectral-band)
32/// in an [Asset](stac::Asset).
33#[derive(Debug, Serialize, Deserialize)]
34pub struct Band {
35 /// The name of the band (e.g., "B01", "B8", "band2", "red").
36 #[serde(skip_serializing_if = "Option::is_none")]
37 pub name: Option<String>,
38
39 /// The name commonly used to refer to the band to make it easier to search for bands across instruments.
40 ///
41 /// See the list of [accepted common names](https://github.com/stac-extensions/eo#common-band-names).
42 #[serde(skip_serializing_if = "Option::is_none")]
43 pub common_name: Option<String>,
44
45 /// Description to fully explain the band.
46 ///
47 /// [CommonMark 0.29](http://commonmark.org/) syntax MAY be used for rich text representation.
48 #[serde(skip_serializing_if = "Option::is_none")]
49 pub description: Option<String>,
50
51 /// The center wavelength of the band, in micrometers (μm).
52 #[serde(skip_serializing_if = "Option::is_none")]
53 pub center_wavelength: Option<f64>,
54
55 /// Full width at half maximum (FWHM).
56 ///
57 /// The width of the band, as measured at half the maximum transmission, in
58 /// micrometers (μm).
59 #[serde(skip_serializing_if = "Option::is_none")]
60 pub full_width_half_max: Option<f64>,
61
62 /// The solar illumination of the band, as measured at half the maximum transmission, in W/m2/micrometers.
63 #[serde(skip_serializing_if = "Option::is_none")]
64 pub solar_illumination: Option<f64>,
65}
66
67impl Extension for ElectroOptical {
68 const IDENTIFIER: &'static str = "https://stac-extensions.github.io/eo/v1.1.0/schema.json";
69 const PREFIX: &'static str = "eo";
70}
71
72#[cfg(test)]
73mod tests {
74 use super::ElectroOptical;
75 use crate::{Extensions, Item};
76
77 #[test]
78 fn item() {
79 let item: Item = stac::read("data/eo/item.json").unwrap();
80 let _: ElectroOptical = item.extension().unwrap();
81 }
82}