Skip to content

Commit 0b59daa

Browse files
Merge pull request #93 from SenteraLLC/altitude-source
Parse altitude source
2 parents 6012f56 + 2cf4605 commit 0b59daa

6 files changed

Lines changed: 31 additions & 6 deletions

File tree

.pre-commit-config.yaml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
11
repos:
22
- repo: https://github.com/pycqa/isort
3-
rev: 7.0.0
3+
rev: 9.0.0a3
44
hooks:
55
- id: isort
66
args: ["--profile", "black"]
77
- repo: https://github.com/ambv/black
8-
rev: 24.4.0
8+
rev: 26.3.1
99
hooks:
1010
- id: black
1111
- repo: https://github.com/pycqa/flake8
12-
rev: '7.0.0'
12+
rev: '7.3.0'
1313
hooks:
1414
- id: flake8
1515
exclude: (tests)
1616
additional_dependencies: [
1717
'flake8-docstrings',
1818
'flake8-builtins',
19-
'flake8-rst-docstrings',
20-
'pygments',
2119
'pep8-naming'
2220
]
2321
- repo: local

imgparse/cli.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,3 +250,18 @@ def create_metadata_csv(imagery_path: str) -> None: # noqa: D301
250250
)
251251

252252
logger.info("Metadata csv saved at: %s", metadata_csv)
253+
254+
255+
@cli.command()
256+
@click.argument("imagery_path", required=True)
257+
def get_xmp(imagery_path: str) -> None:
258+
"""Parse the raw XMP metadata."""
259+
for key, value in MetadataParser(imagery_path).xmp_data.items():
260+
print(f"{key}: {value}")
261+
262+
263+
@cli.command()
264+
@click.argument("imagery_path")
265+
def get_altitude_source(imagery_path: str) -> None:
266+
"""Parse the source of the altitude data."""
267+
print("Altitude source:", MetadataParser(imagery_path).altitude_source())

imgparse/parser.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,15 @@ def gsd(
476476

477477
return alt / focal_length
478478

479+
def altitude_source(self) -> str:
480+
"""Get the source of the altitude data."""
481+
try:
482+
return str(self.xmp_data[self.xmp_tags.ALTITUDE_SOURCE])
483+
except KeyError:
484+
raise ParsingError(
485+
"Couldn't parse altitude source. Sensor might not be supported"
486+
)
487+
479488
def autoexposure(self) -> float:
480489
"""
481490
Get the autoexposure value of the sensor when the image was taken.

imgparse/xmp_tags.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class XMPTags:
3232
X_ACCURACY_M: str = ""
3333
Y_ACCURACY_M: str = ""
3434
Z_ACCURACY_M: str = ""
35+
ALTITUDE_SOURCE: str = ""
3536

3637

3738
class SenteraTags(XMPTags):
@@ -53,6 +54,7 @@ class SenteraTags(XMPTags):
5354
X_ACCURACY_M: str = "Camera:GPSXYAccuracy"
5455
Y_ACCURACY_M: str = "Camera:GPSXYAccuracy"
5556
Z_ACCURACY_M: str = "Camera:GPSZAccuracy"
57+
ALTITUDE_SOURCE: str = "Sentera:AboveGroundAltitudeSource"
5658

5759

5860
class DJITags(XMPTags):

mypy.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ namespace_packages = True
44
explicit_package_bases = True
55
scripts_are_modules = True
66
strict = True
7+
warn_unused_ignores = False

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "imgparse"
3-
version = "2.0.11"
3+
version = "2.0.12"
44
description = "Python image-metadata-parser utilities"
55
authors = []
66
include = [

0 commit comments

Comments
 (0)