Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue that can cause infinite recursion during full resolve #204

Merged
merged 1 commit into from
Oct 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions pystac/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,14 @@ def set_self_href(self, href):
Overridden for collections so that the root's ResolutionObjectCache can properly
update the HREF cache.
"""
root = self.get_root()
if root is not None:
root._resolved_objects.remove(self)
root_link = self.get_root_link()
if root_link is not None and root_link.is_resolved():
root_link.target._resolved_objects.remove(self)

super().set_self_href(href)

if root is not None:
root._resolved_objects.cache(self)
if root_link is not None and root_link.is_resolved():
root_link.target._resolved_objects.cache(self)

return self

Expand Down
101 changes: 101 additions & 0 deletions tests/data-files/catalogs/planet-example-1.0.0-beta.2/collection.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
{
"id": "planet-disaster-data",
"stac_version": "1.0.0-beta.2",
"description": "[Planet Disaster Data](https://www.planet.com/disasterdata/) makes imagery available directly to the public, volunteers, humanitarian organizations, and other coordinating bodies in support of the International Charter for Space and Major Disasters. Data is released for individual disaster events, providing a 30 day window pre- and post-disaster. Imagery is provided under Creative Commons licenses, free of charge, with either CC-BY-SA or CC-BY-NC.",
"links": [
{
"rel": "root",
"href": "./collection.json",
"type": "application/json"
},
{
"rel": "child",
"href": "./hurricane-harvey/catalog.json",
"title": "Hurricane Harvey"
}
],
"title": "Planet Disaster Data",
"keywords": [
"disaster",
"open"
],
"providers": [
{
"name": "Planet",
"description": "Contact Planet at [planet.com/contact-sales](https://www.planet.com/contact-sales/)",
"roles": [
"producer",
"processor"
],
"url": "http://planet.com"
},
{
"name": "Planet Disaster Team",
"description": "The Planet Disaster Data Team (<disaster-team@planet.com>) has released this data as CC-BY-SA-4.0 to help disaster response",
"roles": [
"licensor"
],
"url": "https://www.planet.com/disasterdata/"
},
{
"name": "GitHub",
"description": "This catalog is hosted in the [sample-stac](https://github.com/cholmes/sample-stac) repository on GitHub",
"roles": [
"host"
],
"url": "https://github.com"
}
],
"summaries": {
"constellation": [
"skysat",
"planetscope"
],
"platform": [
"SS02",
"SSC1",
"101c"
],
"view:off_nadir": {
"min": 0.2,
"max": 27.3
},
"view:sun_elevation": {
"min": 56.3,
"max": 65.1
},
"view:sun_azimuth": {
"min": 122,
"max": 231.9
},
"eo:gsd": {
"min": 0.9,
"max": 3.7
},
"eo:cloud_cover": {
"min": 0,
"max": 24
}
},
"extent": {
"spatial": {
"bbox": [
[
-96,
28,
-93,
31
]
]
},
"temporal": {
"interval": [
[
"2017-08-28T10:00:00-08:00",
null
]
]
}
},
"license": "CC-BY-SA-4.0"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"id": "hurricane-harvey",
"stac_version": "1.0.0-beta.2",
"description": "Planet Disaster Data makes imagery available directly to the public, volunteers, humanitarian organizations, and other coordinating bodies in support of the International Charter for Space and Major Disasters. This catalog of data is released for Hurricane Harvey, providing a 30 day window pre- and post-disaster. Imagery is provided under Creative Commons licenses, free of charge, with either CC-BY-SA or CC-BY-NC. All new Planet scenes are made available each day, immediately after production. ",
"links": [
{
"rel": "root",
"href": "../collection.json",
"type": "application/json"
},
{
"rel": "parent",
"href": "../collection.json",
"type": "application/json"
},
{
"rel": "child",
"href": "./hurricane-harvey-0831/catalog.json",
"title": "8/31"
}
],
"title": "Hurricane Harvey"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
{
"type": "Feature",
"stac_version": "1.0.0-beta.2",
"id": "20170831_162740_ssc1d1",
"properties": {
"datetime": "2017-08-31T16:27:42.176605Z",
"platform": "SSC1",
"constellation": "skysat",
"updated": "2017-11-01T21:09:02Z",
"created": "2017-09-01T19:37:35Z",
"gsd": 0.9,
"eo:cloud_cover": 0,
"view:azimuth": 121.3,
"view:sun_azimuth": 122,
"view:sun_elevation": 56.3,
"view:off_nadir": 27.2,
"pl:ground_control": true,
"pl:item_type": "SkySatScene",
"pl:quality_category": "standard",
"pl:strip_id": "s03_20170831T162740Z"
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
-95.46998977661133,
29.059245820517656
],
[
-95.46990394592285,
29.049491960581708
],
[
-95.44741630554199,
29.03215782622282
],
[
-95.46647071838379,
29.01797318720572
],
[
-95.46561241149902,
29.016997452585333
],
[
-95.46509742736816,
29.017072509421837
],
[
-95.44072151184082,
28.997931250084207
],
[
-95.28116226196289,
28.872261720487128
],
[
-95.26768684387207,
28.87241204397036
],
[
-95.25609970092773,
28.884888134910938
],
[
-95.28794288635254,
28.910737431999245
],
[
-95.27498245239258,
28.924335785215973
],
[
-95.24365425109863,
28.89969215375586
],
[
-95.23927688598633,
28.90405029511776
],
[
-95.23979187011719,
28.929143616007288
],
[
-95.26897430419922,
28.951677350293465
],
[
-95.35978317260742,
29.022626563968657
],
[
-95.4081916809082,
29.061796677850424
],
[
-95.42673110961913,
29.048441489877778
],
[
-95.44741630554199,
29.064872627755797
],
[
-95.46260833740233,
29.06442249447776
],
[
-95.46998977661133,
29.059245820517656
]
]
]
},
"links": [
{
"rel": "collection",
"href": "../../../collection.json"
},
{
"rel": "root",
"href": "../../../collection.json",
"type": "application/json"
},
{
"rel": "parent",
"href": "../catalog.json",
"type": "application/json"
}
],
"assets": {
"thumbnail": {
"href": "https://storage.googleapis.com/pdd-stac/disasters/hurricane-harvey/0831/SkySat_Freeport_s03_20170831T162740Z.png",
"type": "image/png",
"title": "Thumbnail",
"roles": [
"thumbnail"
]
},
"visual": {
"href": "https://storage.googleapis.com/pdd-stac/disasters/hurricane-harvey/0831/SkySat_Freeport_s03_20170831T162740Z.tif",
"type": "image/vnd.stac.geotiff; cloud-optimized=true",
"title": "SkySatScene Visual GeoTIFF",
"pl:type": "https://api.planet.com/data/v1/asset-types/ortho_visual",
"roles": [
"data"
]
}
},
"bbox": [
-95.46998977661133,
28.872261720487128,
-95.23927688598633,
29.064872627755797
],
"stac_extensions": [
"eo",
"view"
],
"collection": "planet-disaster-data"
}
Loading