Exemple #1
0
        /// <summary>
        /// Set the id of the STAC Collection this Item references to
        /// see <seealso href="https://github.com/radiantearth/stac-spec/blob/master/item-spec/item-spec.md#relation-types">collection relation type</seealso>.
        /// </summary>
        /// <param name="stacItem">stacItem to set the collection to</param>
        /// <param name="collectionId">identifier of the collection</param>
        /// <param name="collectionUri">uri to the collection</param>
        /// <param name="collectionTitle">optional title of the collection</param>
        public static void SetCollection(this StacItem stacItem, string collectionId, Uri collectionUri, string collectionTitle = null)
        {
            var existingLink = stacItem.Links.FirstOrDefault(l => l.Uri == collectionUri);

            if (existingLink != null)
            {
                stacItem.Links.Remove(existingLink);
            }
            stacItem.Links.Add(StacLink.CreateCollectionLink(collectionUri));
            stacItem.Collection = collectionId;
        }
Exemple #2
0
 public StacItem(StacItem stacItem) : base(Preconditions.CheckNotNull(stacItem, "stacItem").Geometry,
                                           new Dictionary <string, object>(Preconditions.CheckNotNull(stacItem).Properties),
                                           Preconditions.CheckNotNull(stacItem, "id").Id)
 {
     this.StacExtensions = new SortedSet <string>(stacItem.StacExtensions);
     this.Root           = new StacItemRootPropertyContainer(this);
     this.StacVersion    = stacItem.StacVersion;
     this.Links          = new ObservableCollection <StacLink>(stacItem.Links);
     (Links as ObservableCollection <StacLink>).CollectionChanged += LinksCollectionChanged;
     this.Assets     = new Dictionary <string, StacAsset>(stacItem.Assets);
     this.Collection = stacItem.Collection;
 }
        public static double[] GetBoundingBoxFromGeometryExtent(this StacItem stacItem)
        {
            var boundingBoxes = stacItem.Geometry.GetBoundingBox();

            if (boundingBoxes[0].Altitude.HasValue)
            {
                return new double[] {
                           boundingBoxes[0].Longitude, boundingBoxes[0].Latitude, boundingBoxes[0].Altitude.Value,
                           boundingBoxes[1].Longitude, boundingBoxes[1].Latitude, boundingBoxes[1].Altitude.Value,
                }
            }
            ;
            else
            {
                return new double[] {
                           boundingBoxes[0].Longitude, boundingBoxes[0].Latitude,
                           boundingBoxes[1].Longitude, boundingBoxes[1].Latitude,
                }
            };
        }
 public StacItemRootPropertyContainer(StacItem stacItem)
 {
     this.stacItem = stacItem;
     properties    = new Dictionary <string, object>();
 }
Exemple #5
0
 /// <summary>
 /// Gets the collection of the Item as a StacLink
 /// </summary>
 /// <param name="stacItem"></param>
 /// <returns>a Stac Link</returns>
 public static StacLink GetCollection(this StacItem stacItem)
 {
     return(stacItem.Links.FirstOrDefault(l => l.RelationshipType == "collection"));
 }