diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 908e416..1ad4abb 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,23 +1,21 @@ repos: - repo: https://github.com/pycqa/isort - rev: 7.0.0 + rev: 9.0.0a3 hooks: - id: isort args: ["--profile", "black"] - repo: https://github.com/ambv/black - rev: 24.4.0 + rev: 26.3.1 hooks: - id: black - repo: https://github.com/pycqa/flake8 - rev: '7.0.0' + rev: '7.3.0' hooks: - id: flake8 exclude: (tests) additional_dependencies: [ 'flake8-docstrings', 'flake8-builtins', - 'flake8-rst-docstrings', - 'pygments', 'pep8-naming' ] - repo: local diff --git a/imgparse/cli.py b/imgparse/cli.py index 3f3718b..0f321ae 100644 --- a/imgparse/cli.py +++ b/imgparse/cli.py @@ -250,3 +250,18 @@ def create_metadata_csv(imagery_path: str) -> None: # noqa: D301 ) logger.info("Metadata csv saved at: %s", metadata_csv) + + +@cli.command() +@click.argument("imagery_path", required=True) +def get_xmp(imagery_path: str) -> None: + """Parse the raw XMP metadata.""" + for key, value in MetadataParser(imagery_path).xmp_data.items(): + print(f"{key}: {value}") + + +@cli.command() +@click.argument("imagery_path") +def get_altitude_source(imagery_path: str) -> None: + """Parse the source of the altitude data.""" + print("Altitude source:", MetadataParser(imagery_path).altitude_source()) diff --git a/imgparse/parser.py b/imgparse/parser.py index 2678b0a..49e3796 100644 --- a/imgparse/parser.py +++ b/imgparse/parser.py @@ -476,6 +476,15 @@ def gsd( return alt / focal_length + def altitude_source(self) -> str: + """Get the source of the altitude data.""" + try: + return str(self.xmp_data[self.xmp_tags.ALTITUDE_SOURCE]) + except KeyError: + raise ParsingError( + "Couldn't parse altitude source. Sensor might not be supported" + ) + def autoexposure(self) -> float: """ Get the autoexposure value of the sensor when the image was taken. diff --git a/imgparse/xmp_tags.py b/imgparse/xmp_tags.py index b168d76..8b3f219 100644 --- a/imgparse/xmp_tags.py +++ b/imgparse/xmp_tags.py @@ -32,6 +32,7 @@ class XMPTags: X_ACCURACY_M: str = "" Y_ACCURACY_M: str = "" Z_ACCURACY_M: str = "" + ALTITUDE_SOURCE: str = "" class SenteraTags(XMPTags): @@ -53,6 +54,7 @@ class SenteraTags(XMPTags): X_ACCURACY_M: str = "Camera:GPSXYAccuracy" Y_ACCURACY_M: str = "Camera:GPSXYAccuracy" Z_ACCURACY_M: str = "Camera:GPSZAccuracy" + ALTITUDE_SOURCE: str = "Sentera:AboveGroundAltitudeSource" class DJITags(XMPTags): diff --git a/mypy.ini b/mypy.ini index 99a46de..a6b71af 100644 --- a/mypy.ini +++ b/mypy.ini @@ -4,3 +4,4 @@ namespace_packages = True explicit_package_bases = True scripts_are_modules = True strict = True +warn_unused_ignores = False diff --git a/pyproject.toml b/pyproject.toml index e6cec92..e4f9561 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "imgparse" -version = "2.0.11" +version = "2.0.12" description = "Python image-metadata-parser utilities" authors = [] include = [