Skip to content

Commit

Permalink
Remove some additional pre-0.8 logic
Browse files Browse the repository at this point in the history
  • Loading branch information
duckontheweb committed Jun 5, 2021
1 parent 91ea500 commit 51a9c3d
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 42 deletions.
31 changes: 0 additions & 31 deletions pystac/extensions/eo.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
https://github.com/stac-extensions/eo
"""

import re
from typing import (
Any,
Dict,
Expand Down Expand Up @@ -488,36 +487,6 @@ class EOExtensionHooks(ExtensionHooks):
def migrate(
self, obj: Dict[str, Any], version: STACVersionID, info: STACJSONDescription
) -> None:
if version < "0.5":
if "eo:crs" in obj["properties"]:
# Try to pull out the EPSG code.
# Otherwise, just leave it alone.
wkt = obj["properties"]["eo:crs"]
matches = list(re.finditer(r'AUTHORITY\[[^\]]*\"(\d+)"\]', wkt))
if len(matches) > 0:
epsg_code = matches[-1].group(1)
obj["properties"].pop("eo:crs")
obj["properties"]["eo:epsg"] = int(epsg_code)

if version < "0.6":
# Change eo:bands from a dict to a list. eo:bands on an asset
# is an index instead of a dict key. eo:bands is in properties.
bands_dict = obj["eo:bands"]
keys_to_indices: Dict[str, int] = {}
bands: List[Dict[str, Any]] = []
for i, (k, band) in enumerate(bands_dict.items()):
keys_to_indices[k] = i
bands.append(band)

obj.pop("eo:bands")
obj["properties"]["eo:bands"] = bands
for k, asset in obj["assets"].items():
if "eo:bands" in asset:
asset_band_indices: List[int] = []
for bk in asset["eo:bands"]:
asset_band_indices.append(keys_to_indices[bk])
asset["eo:bands"] = sorted(asset_band_indices)

if version < "0.9":
# Some eo fields became common_metadata
if (
Expand Down
11 changes: 0 additions & 11 deletions pystac/serialization/migrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,9 @@
from pystac import STACObjectType as STACObjectType_Type


def _migrate_links(d: Dict[str, Any], version: STACVersionID) -> None:
if version < "0.6":
if "links" in d:
if isinstance(d["links"], dict):
d["links"] = list(d["links"].values())


def _migrate_catalog(
d: Dict[str, Any], version: STACVersionID, info: STACJSONDescription
) -> None:
_migrate_links(d, version)

if version < "0.8":
d["stac_extensions"] = list(info.extensions)

Expand All @@ -38,8 +29,6 @@ def _migrate_collection(
def _migrate_item(
d: Dict[str, Any], version: STACVersionID, info: STACJSONDescription
) -> None:
_migrate_links(d, version)

if version < "0.8":
d["stac_extensions"] = list(info.extensions)

Expand Down

0 comments on commit 51a9c3d

Please sign in to comment.