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: fall back to epsg #1505

Merged
merged 2 commits into from
Jan 25, 2025
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## [Unreleased]

### Fixed

- Fall back to `epsg` when `code` is not present in the Projection extension ([#1505](https://github.com/stac-utils/pystac/pull/1505))

## [v1.12.0]

### Added
Expand Down
4 changes: 4 additions & 0 deletions pystac/extensions/projection.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ def epsg(self) -> int | None:
"""
if self.code is not None and self.code.startswith("EPSG:"):
return int(self.code.replace("EPSG:", ""))
elif epsg := self._get_property(
EPSG_PROP, int
): # In case the dictionary was not migrated
return epsg
return None

@epsg.setter
Expand Down
9 changes: 9 additions & 0 deletions tests/extensions/test_projection.py
Original file line number Diff line number Diff line change
Expand Up @@ -647,3 +647,12 @@ def test_ext_syntax_remove(projection_landsat8_item: pystac.Item) -> None:
def test_ext_syntax_add(item: pystac.Item) -> None:
item.ext.add("proj")
assert isinstance(item.ext.proj, ProjectionExtension)


def test_v1_from_dict() -> None:
with open(
TestCases.get_path("data-files/projection/example-with-version-1.1.json")
) as f:
data = json.load(f)
item = pystac.Item.from_dict(data, migrate=False)
assert item.ext.proj.epsg is not None
46 changes: 23 additions & 23 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading