pub struct Item {
pub version: Version,
pub extensions: Vec<String>,
pub id: String,
pub geometry: Option<Geometry>,
pub bbox: Option<Bbox>,
pub properties: Properties,
pub links: Vec<Link>,
pub assets: IndexMap<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§
§version: Version
The STAC version the Item
implements.
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<Bbox>
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: IndexMap<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("examples/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].try_into().unwrap());
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".parse().unwrap());
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".parse().unwrap());
let (start, end) = stac::datetime::parse("2023-07-11T00:00:00Z/2023-07-12T00:00:00Z").unwrap();
assert!(item.intersects_datetimes(start, end).unwrap());
Sourcepub fn into_flat_item(self, drop_invalid_attributes: bool) -> Result<FlatItem>
pub fn into_flat_item(self, drop_invalid_attributes: bool) -> Result<FlatItem>
Converts this item into a FlatItem.
If drop_invalid_attributes
is True
, any properties that conflict
with top-level field names will be discarded with a warning. If it is
False
, and error will be raised. The same is true for any top-level
fields that are not part of the spec.
§Examples
use stac::Item;
let mut item = Item::new("an-id");
let flat_item = item.into_flat_item(true).unwrap();
Trait Implementations§
Source§impl Assets for Item
impl Assets for Item
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 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 FromGeoparquet for Item
Available on crate feature geoparquet
only.
impl FromGeoparquet for Item
geoparquet
only.Source§impl FromIterator<Item> for ItemCollection
impl FromIterator<Item> for ItemCollection
Source§impl FromNdjson for Item
impl FromNdjson for Item
Source§impl IntoGeoparquet for Item
Available on crate feature geoparquet
only.
impl IntoGeoparquet for Item
geoparquet
only.Source§fn into_geoparquet_writer(
self,
writer: impl Write + Send,
compression: Option<Compression>,
) -> Result<()>
fn into_geoparquet_writer( self, writer: impl Write + Send, compression: Option<Compression>, ) -> Result<()>
Source§fn into_geoparquet_vec(
self,
compression: Option<Compression>,
) -> Result<Vec<u8>>
fn into_geoparquet_vec( self, compression: Option<Compression>, ) -> Result<Vec<u8>>
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_links_absolute(&mut self) -> Result<()>
fn make_links_absolute(&mut self) -> Result<()>
Source§fn make_links_relative(&mut self) -> Result<()>
fn make_links_relative(&mut self) -> 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 SelfHref for Item
impl SelfHref for Item
Source§fn self_href_mut(&mut self) -> &mut Option<String>
fn self_href_mut(&mut self) -> &mut Option<String>
Source§fn set_self_href(&mut self, href: impl ToString)
fn set_self_href(&mut self, href: impl ToString)
Source§fn clear_self_href(&mut self)
fn clear_self_href(&mut self)
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FromJson for Twhere
T: DeserializeOwned,
impl<T> FromJson for Twhere
T: DeserializeOwned,
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