3232//!
3333//! // Get extension information
3434//! let mut projection: Projection = item.extension().unwrap().unwrap();
35- //! println!("epsg : {}", projection.epsg .unwrap());
35+ //! println!("code : {}", projection.code.as_ref() .unwrap());
3636//!
3737//! // Set extension information
3838//! projection.centroid = Some(Centroid { lat: 34.595302, lon: -101.344483 });
@@ -112,7 +112,7 @@ pub trait Extensions: Fields {
112112 /// use stac::{Item, extensions::{Projection, Extensions}};
113113 /// let mut item = Item::new("an-id");
114114 /// assert!(!item.has_extension::<Projection>());
115- /// let projection = Projection { epsg : Some(4326), ..Default::default() };
115+ /// let projection = Projection { code : Some("EPSG: 4326".to_string() ), ..Default::default() };
116116 /// item.set_extension(projection).unwrap();
117117 /// assert!(item.has_extension::<Projection>());
118118 /// ```
@@ -132,7 +132,7 @@ pub trait Extensions: Fields {
132132 /// use stac::{Item, extensions::{Projection, Extensions}};
133133 /// let item: Item = stac::read("examples/extensions-collection/proj-example/proj-example.json").unwrap();
134134 /// let projection: Projection = item.extension().unwrap().unwrap();
135- /// assert_eq!(projection.epsg .unwrap(), 32614);
135+ /// assert_eq!(projection.code .unwrap(), "EPSG: 32614" );
136136 /// ```
137137 fn extension < E : Extension > ( & self ) -> Result < Option < E > > {
138138 if self . has_extension :: < E > ( ) {
@@ -165,7 +165,7 @@ pub trait Extensions: Fields {
165165 /// ```
166166 /// use stac::{Item, extensions::{Projection, Extensions}};
167167 /// let mut item = Item::new("an-id");
168- /// let projection = Projection { epsg : Some(4326), ..Default::default() };
168+ /// let projection = Projection { code : Some("EPSG: 4326".to_string() ), ..Default::default() };
169169 /// item.set_extension(projection).unwrap();
170170 /// ```
171171 fn set_extension < E : Extension > ( & mut self , extension : E ) -> Result < ( ) > {
@@ -229,31 +229,17 @@ mod tests {
229229 assert ! ( asset. has_extension:: <Raster >( ) ) ;
230230 let mut item = Item :: new ( "an-id" ) ;
231231 let _ = item. assets . insert ( "data" . to_string ( ) , asset) ;
232-
233- // TODO how do we let items know about what their assets are doing?
234- // Maybe we don't?
235- // assert!(item.has_extension::<Raster>());
236- // let item = serde_json::to_value(item).unwrap();
237- // assert_eq!(
238- // item.as_object()
239- // .unwrap()
240- // .get("stac_extensions")
241- // .unwrap()
242- // .as_array()
243- // .unwrap(),
244- // &vec!["https://stac-extensions.github.io/raster/v1.1.0/schema.json"]
245- // );
246232 }
247233
248234 #[ test]
249235 fn remove_extension ( ) {
250236 let mut item = Item :: new ( "an-id" ) ;
251237 item. extensions
252- . push ( "https://stac-extensions.github.io/projection/v1.1 .0/schema.json" . to_string ( ) ) ;
238+ . push ( "https://stac-extensions.github.io/projection/v2.0 .0/schema.json" . to_string ( ) ) ;
253239 let _ = item
254240 . properties
255241 . additional_fields
256- . insert ( "proj:epsg " . to_string ( ) , json ! ( 4326 ) ) ;
242+ . insert ( "proj:code " . to_string ( ) , json ! ( "EPSG: 4326" ) ) ;
257243 assert ! ( item. has_extension:: <Projection >( ) ) ;
258244 item. remove_extension :: < Projection > ( ) ;
259245 assert ! ( !item. has_extension:: <Projection >( ) ) ;
0 commit comments