How to use the pystac.link.LinkType.ABSOLUTE function in pystac

To help you get started, we’ve selected a few pystac examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github azavea / pystac / pystac / link.py View on Github external
    def collection(c, link_type=LinkType.ABSOLUTE):
        """Creates a link to an item's Collection."""
        return Link('collection',
                    c,
                    media_type='application/json',
                    link_type=link_type)
github azavea / pystac / pystac / catalog.py View on Github external
    def set_root(self, root, link_type=LinkType.ABSOLUTE):
        STACObject.set_root(self, root, link_type)
        if root is not None:
            root._resolved_objects = ResolvedObjectCache.merge(root._resolved_objects,
                                                               self._resolved_objects)
github azavea / pystac / pystac / link.py View on Github external
def __init__(self,
                 rel,
                 target,
                 media_type=None,
                 title=None,
                 properties=None,
                 link_type=LinkType.ABSOLUTE):
        self.rel = rel
        self.target = target  # An object or an href
        self.media_type = media_type
        self.title = title
        self.properties = properties
        self.link_type = link_type
        self.owner = None
github azavea / pystac / pystac / stac_object.py View on Github external
def set_parent(self, parent, link_type=None):
        """Sets the parent :class:`~pystac.Catalog` or :class:`~pystac.Collection`
        for this object.

        Args:
            parent (Catalog, Collection or None): The parent
                object to set. Passing in None will clear the parent.
            link_type (str): The link type (see :class:`~pystac.LinkType`)
        """
        if not link_type:
            prev = self.get_single_link('parent')
            if prev is not None:
                link_type = prev.link_type
            else:
                link_type = LinkType.ABSOLUTE

        self.remove_links('parent')
        if parent is not None:
            self.add_link(Link.parent(parent, link_type=link_type))
        return self
github azavea / pystac / pystac / link.py View on Github external
def make_absolute(self):
        """Sets the link type of this link to absolute"""
        self.link_type = LinkType.ABSOLUTE
        return self
github azavea / pystac / pystac / stac_object.py View on Github external
root (Catalog, Collection or None): The root
                object to set. Passing in None will clear the root.
            link_type (str): The link type (see :class:`~pystac.LinkType`)
        """
        # Remove from old root resolution cache
        root_link = self.get_root_link()
        if root_link is not None:
            if root_link.is_resolved():
                root_link.target._resolved_objects.remove(self)

        if not link_type:
            prev = self.get_single_link('root')
            if prev is not None:
                link_type = prev.link_type
            else:
                link_type = LinkType.ABSOLUTE

        self.remove_links('root')
        if root is not None:
            self.add_link(Link.root(root, link_type=link_type))
            root._resolved_objects.cache(self)
        return self
github azavea / pystac / pystac / link.py View on Github external
Returns:
            Link: Link instance constructed from the dict.
        """
        d = copy(d)
        rel = d.pop('rel')
        href = d.pop('href')
        media_type = d.pop('type', None)
        title = d.pop('title', None)

        properties = None
        if any(d):
            properties = d

        if rel == 'self' or is_absolute_href(href):
            link_type = LinkType.ABSOLUTE
        else:
            link_type = LinkType.RELATIVE

        return Link(rel=rel,
                    target=href,
                    media_type=media_type,
                    title=title,
                    properties=properties,
                    link_type=link_type)
github azavea / pystac / pystac / item.py View on Github external
this item.

        Args:
            collection (Collection): The collection to set as this item's collection.
            link_type (str): the link type to use for the collection link.
                One of :class:`~pystac.LinkType`.

        Returns:
            Item: self
        """
        if not link_type:
            prev = self.get_single_link('collection')
            if prev is not None:
                link_type = prev.link_type
            else:
                link_type = LinkType.ABSOLUTE
        self.remove_links('collection')
        self.add_link(Link.collection(collection, link_type=link_type))
        self.collection_id = collection.id
        return self
github azavea / pystac / pystac / link.py View on Github external
def self_href(href):
        """Creates a self link to a file's location."""
        return Link('self',
                    href,
                    media_type='application/json',
                    link_type=LinkType.ABSOLUTE)