File tree Expand file tree Collapse file tree 3 files changed +39
-1
lines changed Expand file tree Collapse file tree 3 files changed +39
-1
lines changed Original file line number Diff line number Diff line change 11
11
- Migration for ` sar:type ` -> ` sar:product_type ` and ` sar:polarization ` ->
12
12
` sar:polarizations ` for pre-0.9 catalogs
13
13
([ #556 ] ( https://github.com/stac-utils/pystac/pull/556 ) )
14
+ - Migration from ` eo:epsg ` -> ` proj:epsg ` for pre-0.9 catalogs ([ #557 ] ( https://github.com/stac-utils/pystac/pull/557 ) )
14
15
- Collection summaries for Point Cloud Extension ([ #558 ] ( https://github.com/stac-utils/pystac/pull/558 ) )
15
16
- ` PhenomenologyType ` enum for recommended values of ` pc:type ` & ` SchemaType ` enum for
16
17
valid values of ` type ` in [ Point Cloud Schema
Original file line number Diff line number Diff line change 24
24
SummariesExtension ,
25
25
)
26
26
from pystac .extensions .hooks import ExtensionHooks
27
- from pystac .extensions import view
27
+ from pystac .extensions import view , projection
28
28
from pystac .serialization .identify import STACJSONDescription , STACVersionID
29
29
from pystac .utils import get_required , map_opt
30
30
@@ -557,6 +557,22 @@ def migrate(
557
557
]
558
558
del obj ["properties" ]["eo:{}" .format (field )]
559
559
560
+ # eo:epsg became proj:epsg
561
+ eo_epsg = PREFIX + "epsg"
562
+ proj_epsg = projection .PREFIX + "epsg"
563
+ if eo_epsg in obj ["properties" ] and proj_epsg not in obj ["properties" ]:
564
+ obj ["properties" ][proj_epsg ] = obj ["properties" ].pop (eo_epsg )
565
+ obj ["stac_extensions" ] = obj .get ("stac_extensions" , [])
566
+ if (
567
+ projection .ProjectionExtension .get_schema_uri ()
568
+ not in obj ["stac_extensions" ]
569
+ ):
570
+ obj ["stac_extensions" ].append (
571
+ projection .ProjectionExtension .get_schema_uri ()
572
+ )
573
+ if not any (prop .startswith (PREFIX ) for prop in obj ["properties" ]):
574
+ obj ["stac_extensions" ].remove (EOExtension .get_schema_uri ())
575
+
560
576
if version < "1.0.0-beta.1" and info .object_type == pystac .STACObjectType .ITEM :
561
577
# gsd moved from eo to common metadata
562
578
if "eo:gsd" in obj ["properties" ]:
Original file line number Diff line number Diff line change 6
6
from pystac .summaries import RangeSummary
7
7
from pystac .utils import get_opt
8
8
from pystac .extensions .eo import EOExtension , Band
9
+ from pystac .extensions .projection import ProjectionExtension
9
10
from tests .utils import TestCases , assert_to_from_dict
10
11
11
12
@@ -325,3 +326,23 @@ def test_should_raise_exception_when_passing_invalid_extension_object(
325
326
EOExtension .ext ,
326
327
object (),
327
328
)
329
+
330
+
331
+ class EOMigrationTest (unittest .TestCase ):
332
+ def setUp (self ) -> None :
333
+ self .maxDiff = None
334
+ self .item_0_8_path = TestCases .get_path (
335
+ "data-files/examples/0.8.1/item-spec/examples/sentinel2-sample.json"
336
+ )
337
+
338
+ def test_migration (self ) -> None :
339
+ with open (self .item_0_8_path ) as src :
340
+ item_dict = json .load (src )
341
+
342
+ self .assertIn ("eo:epsg" , item_dict ["properties" ])
343
+
344
+ item = Item .from_file (self .item_0_8_path )
345
+
346
+ self .assertNotIn ("eo:epsg" , item .properties )
347
+ self .assertIn ("proj:epsg" , item .properties )
348
+ self .assertIn (ProjectionExtension .get_schema_uri (), item .stac_extensions )
You can’t perform that action at this time.
0 commit comments