Skip to content

Commit

Permalink
Check extension of the item href
Browse files Browse the repository at this point in the history
  • Loading branch information
inigo-cobian committed Feb 12, 2025
1 parent c1540ab commit 8793b39
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,17 @@ public class STACAssetParser {
"image/tiff;application=geotiff;profile=cloud-optimized", "image/vnd.stac.geotiff;profile=cloud-optimized",
"image/vnd.stac.geotiff;cloud-optimized=true", "application/geo+json");

final private static Set<String> SUPPORTED_MEDIA_EXTENSION = Set.of(".tif", ".tiff");

/**
* Check if the MIME value is supported.
* @param asset as JSON
* @return true if the media type is supported.
*/
public static boolean isSupportedMediaType(JSONObject asset) {
if (!asset.has("type")) {
return false;
String href = asset.getString("href");
return SUPPORTED_MEDIA_EXTENSION.stream().anyMatch(ex -> href.toLowerCase().endsWith(ex));
}
return SUPPORTED_MEDIA_TYPE.contains(asset.getString("type").replace(" ", "").toLowerCase());
}
Expand Down

0 comments on commit 8793b39

Please sign in to comment.