Skip to content

Commit

Permalink
Merge pull request #10 from stactools-packages/initial
Browse files Browse the repository at this point in the history
Fixes asset HREF parsing; release 0.1.1
  • Loading branch information
fredliporace authored Jun 23, 2023
2 parents 2f22c31 + b194d17 commit 97a3a26
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,31 @@ number as needed.

- Nothing.

## [0.1.1] - 2023-06-23

### Added

- Nothing.

### Deprecated

- Nothing.

### Removed

- Nothing.

### Fixed

- Fixed HREF asset parsing ([#9](https://github.com/stactools-packages/amazonia-1/issues/9)).

## [0.1.0] - 2023-06-01

### Changed

- First version

[0.1.1]: <https://github.com/stactools-packages/amazonia-1/compare/v0.1.0..v0.1.1>
[0.1.0]: <https://github.com/stactools-packages/amazonia-1/releases/tag/v0.1.0>

<!-- markdownlint-disable-file MD024 -->
12 changes: 6 additions & 6 deletions src/stactools/amazonia_1/stac.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from pystac.extensions.sat import OrbitState, SatExtension
from pystac.extensions.view import ViewExtension
from pystac.summaries import Summaries
from stactools.core.io import read_text

from stactools.amazonia_1.constants import (
BASE_CAMERA,
Expand Down Expand Up @@ -75,7 +76,7 @@ def _get_keys_from_cbers_am(cb_am_metadata: str) -> Dict[str, Any]:
"""Extract keys from Amazonia-1 INPE's metadata.
Args:
cb_am_metadata: CBERS/AM metadata file location
cb_am_metadata: CBERS/AM metadata HREF
Returns:
Item: STAC Item object
Expand All @@ -87,19 +88,18 @@ def _get_keys_from_cbers_am(cb_am_metadata: str) -> Dict[str, Any]:
match = TIF_XML_REGEX.match(cb_am_metadata.split("/")[-1])
assert match, f"Can't match {cb_am_metadata}"

tree = ET.parse(cb_am_metadata)
original_root = tree.getroot()
tree = ET.fromstring(text=read_text(href=cb_am_metadata))

# satellite node information, checking for CBERS-04A/AMAZONIA1 WFI
# special case
left_root = original_root.find("x:leftCamera", nsp)
left_root = tree.find("x:leftCamera", nsp)
if left_root:
right_root = original_root.find("x:rightCamera", nsp)
right_root = tree.find("x:rightCamera", nsp)
# We use the left camera for fields that are not camera
# specific or are not used for STAC fields computation
root = left_root
else:
root = original_root
root = tree

satellite = root.find("x:satellite", nsp)

Expand Down

0 comments on commit 97a3a26

Please sign in to comment.