Data entry handling
This module focuses on image and metadata entry:
- UI elements to upload an image and populate the metadata (or edit the auto-discovered metadata)
- a container class for an observation
InputObservation
A class to hold an input observation and associated metadata
Attributes:
Name | Type | Description |
---|---|---|
image |
Any
|
The image associated with the observation. |
latitude |
float
|
The latitude where the observation was made. |
longitude |
float
|
The longitude where the observation was made. |
author_email |
str
|
The email of the author of the observation. |
date |
str
|
The date when the observation was made. |
time |
str
|
The time when the observation was made. |
date_option |
str
|
Additional date option for the observation. |
time_option |
str
|
Additional time option for the observation. |
uploaded_filename |
Any
|
The uploaded filename associated with the observation. |
Methods:
Name | Description |
---|---|
__str__ |
Returns a string representation of the observation. |
__repr__ |
Returns a string representation of the observation. |
__eq__ |
Checks if two observations are equal. |
__ne__ |
Checks if two observations are not equal. |
__hash__ |
Returns the hash of the observation. |
to_dict |
Converts the observation to a dictionary. |
from_dict |
Creates an observation from a dictionary. |
from_input |
Creates an observation from another input observation. |
Source code in src/input_handling.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
|
get_image_datetime(image_file)
Extracts the original date and time from the EXIF metadata of an uploaded image file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
image_file
|
UploadedFile
|
The uploaded image file from which to extract the date and time. |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str | None
|
The original date and time as a string if available, otherwise None. |
Raises:
Type | Description |
---|---|
Warning
|
If the date and time could not be extracted from the image metadata. |
Source code in src/input_handling.py
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 |
|
is_valid_email(email)
Validates if the provided email address is in a correct format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
email
|
str
|
The email address to validate. |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if the email address is valid, False otherwise. |
Source code in src/input_handling.py
157 158 159 160 161 162 163 164 165 166 167 168 |
|
is_valid_number(number)
Check if the given string is a valid number (int or float, sign ok)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
number
|
str
|
The string to be checked. |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if the string is a valid number, False otherwise. |
Source code in src/input_handling.py
142 143 144 145 146 147 148 149 150 151 152 153 |
|
setup_input(viewcontainer=None, _allowed_image_types=None)
Sets up the input interface for uploading an image and entering metadata.
It provides input fields for an image upload, lat/lon, author email, and date-time. In the ideal case, the image metadata will be used to populate location and datetime.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
viewcontainer
|
DeltaGenerator
|
The Streamlit container to use for the input interface. Defaults to st.sidebar. |
None
|
_allowed_image_types
|
list
|
List of allowed image file types for upload. Defaults to allowed_image_types. |
None
|
Returns:
Name | Type | Description |
---|---|---|
InputObservation |
InputObservation
|
An object containing the uploaded image and entered metadata. |
Source code in src/input_handling.py
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 |
|