21
21
from rasterio .enums import Resampling
22
22
23
23
24
- class CameraType (str , Enum ):
24
+ class _StrChoiceEnum (str , Enum ):
25
+ """String value enumeration class that can be used with a ``click.Choice()`` parameter type."""
26
+
27
+ def __repr__ (self ):
28
+ return self ._value_
29
+
30
+ def __str__ (self ):
31
+ return self ._value_
32
+
33
+
34
+ class CameraType (_StrChoiceEnum ):
25
35
"""Camera model types."""
26
36
27
37
pinhole = 'pinhole'
@@ -31,18 +41,18 @@ class CameraType(str, Enum):
31
41
"""
32
42
Brown-Conrady frame camera model.
33
43
34
- Compatible with `OpenDroneMap / OpenSfM
35
- <https://opensfm.org/docs/geometry.html#camera-models>`__ ``perspective``, ``simple_radial``,
36
- ``radial`` and ``brown`` model parameters, and the 4- and 5-coefficient versions of the
44
+ Compatible with `OpenDroneMap / OpenSfM
45
+ <https://opensfm.org/docs/geometry.html#camera-models>`__ ``perspective``, ``simple_radial``,
46
+ ``radial`` and ``brown`` model parameters, and the 4- and 5-coefficient versions of the
37
47
`OpenCV general model <https://docs.opencv.org/4.x/d9/d0c/group__calib3d.html>`__."""
38
48
39
49
fisheye = 'fisheye'
40
50
"""
41
51
Fisheye frame camera model.
42
52
43
- Compatible with `OpenDroneMap / OpenSfM
44
- <https://opensfm.org/docs/geometry.html#fisheye-camera>`__ ``fisheye``, and `OpenCV
45
- <https://docs.opencv.org/4.x/db/d58/group__calib3d__fisheye.html>`__ fisheye model
53
+ Compatible with `OpenDroneMap / OpenSfM
54
+ <https://opensfm.org/docs/geometry.html#fisheye-camera>`__ ``fisheye``, and `OpenCV
55
+ <https://docs.opencv.org/4.x/db/d58/group__calib3d__fisheye.html>`__ fisheye model
46
56
parameters."""
47
57
48
58
opencv = 'opencv'
@@ -53,12 +63,6 @@ class CameraType(str, Enum):
53
63
rpc = 'rpc'
54
64
"""RPC camera model."""
55
65
56
- def __repr__ (self ):
57
- return self ._name_
58
-
59
- def __str__ (self ):
60
- return self ._name_
61
-
62
66
@classmethod
63
67
def from_odm (cls , cam_type : str ):
64
68
"""Convert from OpenDroneMap / OpenSfM projection type."""
@@ -70,7 +74,7 @@ def from_odm(cls, cam_type: str):
70
74
return cls (cam_type )
71
75
72
76
73
- class Interp (str , Enum ):
77
+ class Interp (_StrChoiceEnum ):
74
78
"""Interpolation types."""
75
79
76
80
nearest = 'nearest'
@@ -84,12 +88,6 @@ class Interp(str, Enum):
84
88
lanczos = 'lanczos'
85
89
"""Lanczos windowed sinc interpolation."""
86
90
87
- def __repr__ (self ):
88
- return self ._name_
89
-
90
- def __str__ (self ):
91
- return self ._name_
92
-
93
91
def to_cv (self ) -> int :
94
92
"""Convert to OpenCV interpolation type."""
95
93
name_to_cv = dict (
@@ -106,7 +104,7 @@ def to_rio(self) -> Resampling:
106
104
return Resampling [self ._name_ ]
107
105
108
106
109
- class Compress (str , Enum ):
107
+ class Compress (_StrChoiceEnum ):
110
108
"""Compression types."""
111
109
112
110
jpeg = 'jpeg'
@@ -116,12 +114,6 @@ class Compress(str, Enum):
116
114
lzw = 'lzw'
117
115
"""LZW compression."""
118
116
119
- def __repr__ (self ):
120
- return self ._name_
121
-
122
- def __str__ (self ):
123
- return self ._name_
124
-
125
117
126
118
class CsvFormat (Enum ):
127
119
"""Type of the position and orientation values in a CSV exterior parameter file."""
@@ -146,31 +138,19 @@ def is_opk(self) -> bool:
146
138
return self is CsvFormat .xyz_opk or self is CsvFormat .lla_opk
147
139
148
140
149
- class RpcRefine (str , Enum ):
141
+ class RpcRefine (_StrChoiceEnum ):
150
142
"""RPC refinement method."""
151
143
152
144
shift = 'shift'
153
145
"""Pixel coordinate translation."""
154
146
shift_drift = 'shift-drift'
155
147
"""Pixel coordinate scale and translation."""
156
148
157
- def __repr__ (self ):
158
- return self ._name_
159
149
160
- def __str__ (self ):
161
- return self ._name_
162
-
163
-
164
- class Driver (str , Enum ):
150
+ class Driver (_StrChoiceEnum ):
165
151
"""Raster format drivers."""
166
152
167
153
gtiff = 'gtiff'
168
154
"""GeoTIFF."""
169
155
cog = 'cog'
170
156
"""Cloud Optimised GeoTIFF."""
171
-
172
- def __repr__ (self ):
173
- return self ._name_
174
-
175
- def __str__ (self ):
176
- return self ._name_
0 commit comments