pub struct Item {
pub extensions: Vec<String>,
pub id: String,
pub geometry: Option<Geometry>,
pub bbox: Option<Vec<f64>>,
pub properties: Properties,
pub links: Vec<Link>,
pub assets: HashMap<String, Asset>,
pub collection: Option<String>,
pub additional_fields: Map<String, Value>,
/* private fields */
}
Expand description
An Item
is a GeoJSON Feature augmented with foreign members relevant to a
STAC object.
These include fields that identify the time range and assets of the Item
. An
Item
is the core object in a STAC catalog, containing the core metadata that
enables any client to search or crawl online catalogs of spatial ‘assets’
(e.g., satellite imagery, derived data, DEMs).
Fields§
§extensions: Vec<String>
A list of extensions the Item
implements.
id: String
Provider identifier.
The ID should be unique within the Collection that contains the Item
.
geometry: Option<Geometry>
Defines the full footprint of the asset represented by this item, formatted according to RFC 7946, section 3.1.
The footprint should be the default GeoJSON geometry, though additional geometries can be included. Coordinates are specified in Longitude/Latitude or Longitude/Latitude/Elevation based on WGS 84.
bbox: Option<Vec<f64>>
Bounding Box of the asset represented by this Item
, formatted according
to RFC 7946, section 5.
REQUIRED if geometry
is not null
.
properties: Properties
A dictionary of additional metadata for the Item
.
links: Vec<Link>
List of link objects to resources and related URLs.
assets: HashMap<String, Asset>
Dictionary of asset objects that can be downloaded, each with a unique key.
collection: Option<String>
The id
of the STAC Collection this Item
references to.
This field is required if such a relation type is present and is not
allowed otherwise. This field provides an easy way for a user to search
for any Item
s that belong in a specified Collection
. Must be a non-empty
string.
additional_fields: Map<String, Value>
Additional fields not part of the Item specification.
Implementations§
source§impl Item
impl Item
sourcepub fn new(id: impl ToString) -> Item
pub fn new(id: impl ToString) -> Item
Creates a new Item
with the given id
.
The item properties’ datetime
field is set to the object creation
time.
§Examples
use stac::Item;
let item = Item::new("an-id");
assert_eq!(item.id, "an-id");
sourcepub fn collection(self, id: impl ToString) -> Item
pub fn collection(self, id: impl ToString) -> Item
Sets this item’s collection id in the builder pattern.
§Examples
use stac::Item;
let item = Item::new("an-id").collection("a-collection");
assert_eq!(item.collection.unwrap(), "a-collection");
sourcepub fn collection_link(&self) -> Option<&Link>
pub fn collection_link(&self) -> Option<&Link>
Returns this item’s collection link.
This is the first link with a rel=“collection”.
§Examples
use stac::Item;
let item: Item = stac::read("data/simple-item.json").unwrap();
let link = item.collection_link().unwrap();
sourcepub fn set_geometry(
&mut self,
geometry: impl Into<Option<Geometry>>
) -> Result<()>
Available on crate feature geo
only.
pub fn set_geometry( &mut self, geometry: impl Into<Option<Geometry>> ) -> Result<()>
geo
only.Sets this item’s geometry.
Also sets this item’s bounding box.
§Examples
use stac::Item;
use geojson::{Geometry, Value};
let mut item = Item::new("an-id");
item.set_geometry(Some(Geometry::new(Value::Point(vec![-105.1, 41.1]))));
assert_eq!(item.bbox.unwrap(), vec![-105.1, 41.1, -105.1, 41.1]);
sourcepub fn intersects<T>(&self, intersects: &T) -> Result<bool>where
T: Intersects<Geometry>,
Available on crate feature geo
only.
pub fn intersects<T>(&self, intersects: &T) -> Result<bool>where
T: Intersects<Geometry>,
geo
only.Returns true if this item’s geometry intersects the provided geojson geometry.
§Examples
use stac::Item;
use geojson::{Geometry, Value};
use geo::{Rect, coord};
let mut item = Item::new("an-id");
item.set_geometry(Some(Geometry::new(Value::Point(vec![-105.1, 41.1]))));
let intersects = Rect::new(
coord! { x: -106.0, y: 40.0 },
coord! { x: -105.0, y: 42.0 },
);
assert!(item.intersects(&intersects).unwrap());
sourcepub fn intersects_bbox(&self, bbox: Rect) -> Result<bool>
👎Deprecated since 0.5.2: Use intersects insteadAvailable on crate feature geo
only.
pub fn intersects_bbox(&self, bbox: Rect) -> Result<bool>
geo
only.Returns true if this item’s geometry intersects the provided bounding box.
DEPRECATED Use intersects
instead.
§Examples
use stac::Item;
use geojson::{Geometry, Value};
let mut item = Item::new("an-id");
item.set_geometry(Some(Geometry::new(Value::Point(vec![-105.1, 41.1]))));
let bbox = stac::geo::bbox(&vec![-106.0, 41.0, -105.0, 42.0]).unwrap();
assert!(item.intersects_bbox(bbox).unwrap());
sourcepub fn intersects_datetime_str(&self, datetime: &str) -> Result<bool>
pub fn intersects_datetime_str(&self, datetime: &str) -> Result<bool>
Returns true if this item’s datetime (or start and end datetime) intersects the provided datetime string.
§Examples
use stac::Item;
let mut item = Item::new("an-id");
item.properties.datetime = Some("2023-07-11T12:00:00Z".to_string());
assert!(item.intersects_datetime_str("2023-07-11T00:00:00Z/2023-07-12T00:00:00Z").unwrap());
sourcepub fn intersects_datetimes(
&self,
start: Option<DateTime<FixedOffset>>,
end: Option<DateTime<FixedOffset>>
) -> Result<bool>
pub fn intersects_datetimes( &self, start: Option<DateTime<FixedOffset>>, end: Option<DateTime<FixedOffset>> ) -> Result<bool>
Returns true if this item’s datetime (or start and end datetimes) intersects the provided datetime.
§Examples
use stac::Item;
let mut item = Item::new("an-id");
item.properties.datetime = Some("2023-07-11T12:00:00Z".to_string());
let (start, end) = stac::datetime::parse("2023-07-11T00:00:00Z/2023-07-12T00:00:00Z").unwrap();
assert!(item.intersects_datetimes(start, end).unwrap());
Trait Implementations§
source§impl<'de> Deserialize<'de> for Item
impl<'de> Deserialize<'de> for Item
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl Extensions for Item
impl Extensions for Item
source§fn extensions(&self) -> &Vec<String>
fn extensions(&self) -> &Vec<String>
source§fn extensions_mut(&mut self) -> &mut Vec<String>
fn extensions_mut(&mut self) -> &mut Vec<String>
source§fn has_extension<E: Extension>(&self) -> bool
fn has_extension<E: Extension>(&self) -> bool
source§fn add_extension<E: Extension>(&mut self)
fn add_extension<E: Extension>(&mut self)
source§fn set_extension<E: Extension>(&mut self, extension: E) -> Result<()>
fn set_extension<E: Extension>(&mut self, extension: E) -> Result<()>
extensions
. Read moresource§fn remove_extension<E: Extension>(&mut self)
fn remove_extension<E: Extension>(&mut self)
source§impl Fields for Item
impl Fields for Item
source§fn fields_mut(&mut self) -> &mut Map<String, Value>
fn fields_mut(&mut self) -> &mut Map<String, Value>
source§fn set_field<S: Serialize>(
&mut self,
key: impl ToString,
value: S
) -> Result<Option<Value>>
fn set_field<S: Serialize>( &mut self, key: impl ToString, value: S ) -> Result<Option<Value>>
source§fn fields_with_prefix<D: DeserializeOwned>(&self, prefix: &str) -> Result<D>
fn fields_with_prefix<D: DeserializeOwned>(&self, prefix: &str) -> Result<D>
source§fn set_fields_with_prefix<S: Serialize>(
&mut self,
prefix: &str,
value: S
) -> Result<()>
fn set_fields_with_prefix<S: Serialize>( &mut self, prefix: &str, value: S ) -> Result<()>
source§fn remove_fields_with_prefix(&mut self, prefix: &str)
fn remove_fields_with_prefix(&mut self, prefix: &str)
source§impl FromIterator<Item> for ItemCollection
impl FromIterator<Item> for ItemCollection
source§impl Links for Item
impl Links for Item
source§fn links_mut(&mut self) -> &mut Vec<Link>
fn links_mut(&mut self) -> &mut Vec<Link>
source§fn link(&self, rel: &str) -> Option<&Link>
fn link(&self, rel: &str) -> Option<&Link>
source§fn iter_child_links(&self) -> Box<dyn Iterator<Item = &Link> + '_>
fn iter_child_links(&self) -> Box<dyn Iterator<Item = &Link> + '_>
source§fn iter_item_links(&self) -> Box<dyn Iterator<Item = &Link> + '_>
fn iter_item_links(&self) -> Box<dyn Iterator<Item = &Link> + '_>
source§fn make_relative_links_absolute(&mut self, href: impl ToString) -> Result<()>
fn make_relative_links_absolute(&mut self, href: impl ToString) -> Result<()>
source§fn make_absolute_links_relative(&mut self, href: impl ToString) -> Result<()>
fn make_absolute_links_relative(&mut self, href: impl ToString) -> Result<()>
source§fn remove_relative_links(&mut self)
fn remove_relative_links(&mut self)
source§fn remove_structural_links(&mut self)
fn remove_structural_links(&mut self)
source§impl PartialEq for Item
impl PartialEq for Item
impl StructuralPartialEq for Item
Auto Trait Implementations§
impl Freeze for Item
impl RefUnwindSafe for Item
impl Send for Item
impl Sync for Item
impl Unpin for Item
impl UnwindSafe for Item
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more