Skip to content

Commit

Permalink
Remove full mimetype from format.json
Browse files Browse the repository at this point in the history
  • Loading branch information
olsen232 committed Apr 20, 2023
1 parent 2511189 commit 2b89c54
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 7 deletions.
17 changes: 14 additions & 3 deletions kart/raster/metadata_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,7 @@ def extract_raster_tile_metadata(raster_tile_path):
is_cog = not errors

format_json = {
# TODO: Maybe the whole mimetype isn't needed here - no more information is conveyed by this mimetype
# than by the string "geotiff"... or maybe there's some benefit to using the mimetype.
"fileType": "image/tiff; application=geotiff",
"fileType": "geotiff",
"profile": "cloud-optimized" if is_cog else None,
}

Expand Down Expand Up @@ -340,3 +338,16 @@ def extract_format(tile_format):
if "format" in tile_format:
return tile_format["format"]
return tile_format


def get_format_summary(format_info):
"""
Given format info as stored in format.json, return a short string summary such as: geotiff/cog
"""
if "format.json" in format_info:
format_info = format_info["format.json"]

format_summary = format_info["fileType"]
if format_info["profile"]:
format_summary += f"/{format_info['profile']}"
return format_summary
Binary file modified tests/data/raster/aerial.tgz
Binary file not shown.
Binary file modified tests/data/raster/elevation.tgz
Binary file not shown.
Binary file modified tests/data/raster/erosion.tgz
Binary file not shown.
8 changes: 4 additions & 4 deletions tests/raster/test_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def test_import_single_non_cog_geotiff(
assert r.stdout.splitlines()[6:] == AERIAL_CRS_DIFF + [
"+++ aerial:meta:format.json",
"+ {",
'+ "fileType": "image/tiff; application=geotiff"',
'+ "fileType": "geotiff"',
"+ }",
] + AERIAL_SCHEMA_DIFF + [
"+++ aerial:tile:aerial",
Expand All @@ -138,7 +138,7 @@ def test_import_single_non_cog_geotiff(
assert r.stdout.splitlines()[6:] == AERIAL_CRS_DIFF + [
"+++ aerial:meta:format.json",
"+ {",
'+ "fileType": "image/tiff; application=geotiff",',
'+ "fileType": "geotiff",',
'+ "profile": "cloud-optimized"',
"+ }",
] + AERIAL_SCHEMA_DIFF + [
Expand Down Expand Up @@ -196,7 +196,7 @@ def test_import_single_cogtiff(
assert r.stdout.splitlines()[6:] == AERIAL_CRS_DIFF + [
"+++ aerial:meta:format.json",
"+ {",
'+ "fileType": "image/tiff; application=geotiff",',
'+ "fileType": "geotiff",',
'+ "profile": "cloud-optimized"',
"+ }",
] + AERIAL_SCHEMA_DIFF + [
Expand Down Expand Up @@ -337,7 +337,7 @@ def test_import_single_geotiff_with_rat(
"+ ",
"+++ erorisk_silcdb4:meta:format.json",
"+ {",
'+ "fileType": "image/tiff; application=geotiff",',
'+ "fileType": "geotiff",',
'+ "profile": "cloud-optimized"',
"+ }",
"+++ erorisk_silcdb4:meta:schema.json",
Expand Down

0 comments on commit 2b89c54

Please sign in to comment.