Skip to content

Commit e713adf

Browse files
gadomskijsignell
andauthored
fix: don't set code for None epsg (#1544)
* fix: don't set code for None epsg * chore: update changelog * Update pystac/extensions/projection.py Co-authored-by: Julia Signell <[email protected]> --------- Co-authored-by: Julia Signell <[email protected]>
1 parent 4dc0e0f commit e713adf

File tree

4 files changed

+32
-32
lines changed

4 files changed

+32
-32
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
- `Collection.from_items` for creating a `pystac.Collection` from an `ItemCollection` ([#1522](https://github.com/stac-utils/pystac/pull/1522))
88

99
### Fixed
10+
11+
- `proj:epsg` migration when `None` ([#1544](https://github.com/stac-utils/pystac/pull/1544))
1012
- fixed missing parameter "title" in pystac.extensions.classification.Classification ([#1539](https://github.com/stac-utils/pystac/pull/1539))
1113

1214
## [v1.12.2]

pystac/extensions/projection.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -477,10 +477,8 @@ def migrate(
477477
return
478478

479479
# proj:epsg moved to proj:code
480-
if "proj:epsg" in obj["properties"]:
481-
epsg = obj["properties"]["proj:epsg"]
480+
if epsg := obj["properties"].pop("proj:epsg", None):
482481
obj["properties"]["proj:code"] = f"EPSG:{epsg}"
483-
del obj["properties"]["proj:epsg"]
484482

485483
super().migrate(obj, version, info)
486484

tests/extensions/test_projection.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,3 +662,15 @@ def test_v1_crs_string() -> None:
662662
item = pystac.Item.from_dict(data, migrate=False)
663663
assert item.ext.proj.epsg is not None
664664
assert item.ext.proj.crs_string == "EPSG:32617"
665+
666+
667+
def test_none_epsg(item: Item) -> None:
668+
# https://github.com/stac-utils/pystac/issues/1543
669+
d = item.to_dict(include_self_link=False, transform_hrefs=False)
670+
d["stac_version"] = "1.0.0"
671+
d["stac_extensions"] = [
672+
"https://stac-extensions.github.io/projection/v1.1.0/schema.json"
673+
]
674+
d["properties"]["proj:epsg"] = None
675+
item = Item.from_dict(d, migrate=True)
676+
assert item.ext.proj.code is None

uv.lock

Lines changed: 17 additions & 29 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)