Skip to content

Commit a338e26

Browse files
committed
Add pre-0.9 migration for sar:polarization & sar:type
1 parent 8cca7ba commit a338e26

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

pystac/extensions/sar.py

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -570,26 +570,42 @@ def migrate(
570570
PREFIX + "platform" in obj["properties"]
571571
and "platform" not in obj["properties"]
572572
):
573-
obj["properties"]["platform"] = obj["properties"][PREFIX + "platform"]
574-
del obj["properties"][PREFIX + "platform"]
573+
obj["properties"]["platform"] = obj["properties"].pop(
574+
PREFIX + "platform"
575+
)
575576

576577
if (
577578
PREFIX + "instrument" in obj["properties"]
578579
and "instruments" not in obj["properties"]
579580
):
580581
obj["properties"]["instruments"] = [
581-
obj["properties"][PREFIX + "instrument"]
582+
obj["properties"].pop(PREFIX + "instrument")
582583
]
583-
del obj["properties"][PREFIX + "instrument"]
584584

585585
if (
586586
PREFIX + "constellation" in obj["properties"]
587587
and "constellation" not in obj["properties"]
588588
):
589-
obj["properties"]["constellation"] = obj["properties"][
589+
obj["properties"]["constellation"] = obj["properties"].pop(
590590
PREFIX + "constellation"
591+
)
592+
593+
# Some SAR fields changed property names
594+
if (
595+
PREFIX + "type" in obj["properties"]
596+
and PRODUCT_TYPE_PROP not in obj["properties"]
597+
):
598+
obj["properties"][PRODUCT_TYPE_PROP] = obj["properties"].pop(
599+
PREFIX + "type"
600+
)
601+
602+
if (
603+
PREFIX + "polarization" in obj["properties"]
604+
and POLARIZATIONS_PROP not in obj["properties"]
605+
):
606+
obj["properties"][POLARIZATIONS_PROP] = [
607+
obj["properties"].pop(PREFIX + "polarization")
591608
]
592-
del obj["properties"][PREFIX + "constellation"]
593609

594610
super().migrate(obj, version, info)
595611

0 commit comments

Comments
 (0)