Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
license=license,
stac_extensions=stac_extensions,
keywords=keywords,
version=version,
providers=providers,
properties=properties,
summaries=summaries)
has_self_link = False
for l in d['links']:
has_self_link |= l['rel'] == 'self'
if l['rel'] == 'root':
# Remove the link that's generated in Catalog's constructor.
collection.remove_links('root')
collection.add_link(Link.from_dict(l))
if not has_self_link and href is not None:
collection.add_link(Link.self_href(href))
return collection
def from_dict(d):
"""Constructs an ItemCollection from a dict.
Returns:
ItemCollection: The ItemCollection deserialized from the JSON dict.
"""
features = [Item.from_dict(feature) for feature in d['features']]
ic = ItemCollection(features)
if 'links' in d.keys():
for link in d['links']:
ic.add_link(Link.from_dict(link))
return ic
if datetime is None:
raise STACError('Item dict is missing a "datetime" property in the "properties" field')
datetime = dateutil.parser.parse(datetime)
item = Item(id=id,
geometry=geometry,
bbox=bbox,
datetime=datetime,
properties=properties,
stac_extensions=stac_extensions,
collection=collection_id)
has_self_link = False
for l in d['links']:
has_self_link |= l['rel'] == 'self'
item.add_link(Link.from_dict(l))
if not has_self_link and href is not None:
item.add_link(Link.self_href(href))
for k, v in d['assets'].items():
asset = Asset.from_dict(v)
asset.set_owner(item)
item.assets[k] = asset
return item
def from_dict(cls, d, href=None, root=None):
id = d['id']
description = d['description']
title = d.get('title')
cat = Catalog(id=id, description=description, title=title)
has_self_link = False
for l in d['links']:
has_self_link |= l['rel'] == 'self'
if l['rel'] == 'root':
# Remove the link that's generated in Catalog's constructor.
cat.remove_links('root')
cat.add_link(Link.from_dict(l))
if not has_self_link and href is not None:
cat.add_link(Link.self_href(href))
return cat