Spaces:
Running
Running
Improve error messages
Browse files- maploc/demo.py +6 -4
maploc/demo.py
CHANGED
@@ -96,9 +96,9 @@ def read_input_image(
|
|
96 |
raise ValueError("geocoding unavailable, install geopy.")
|
97 |
location = geolocator.geocode(prior_address)
|
98 |
if location is None:
|
99 |
-
logger.info("Could not find any location for %s.", prior_address)
|
100 |
else:
|
101 |
-
logger.info("Using prior address
|
102 |
latlon = (location.latitude, location.longitude)
|
103 |
if latlon is None:
|
104 |
geo = exif.extract_geo()
|
@@ -107,9 +107,11 @@ def read_input_image(
|
|
107 |
latlon = (geo["latitude"], geo["longitude"], alt)
|
108 |
logger.info("Using prior location from EXIF.")
|
109 |
else:
|
110 |
-
logger.info("Could not find any prior location in EXIF.")
|
111 |
if latlon is None:
|
112 |
-
raise ValueError(
|
|
|
|
|
113 |
latlon = np.array(latlon)
|
114 |
|
115 |
proj = Projection(*latlon)
|
|
|
96 |
raise ValueError("geocoding unavailable, install geopy.")
|
97 |
location = geolocator.geocode(prior_address)
|
98 |
if location is None:
|
99 |
+
logger.info("Could not find any location for address '%s.'", prior_address)
|
100 |
else:
|
101 |
+
logger.info("Using prior address '%s'", location.address)
|
102 |
latlon = (location.latitude, location.longitude)
|
103 |
if latlon is None:
|
104 |
geo = exif.extract_geo()
|
|
|
107 |
latlon = (geo["latitude"], geo["longitude"], alt)
|
108 |
logger.info("Using prior location from EXIF.")
|
109 |
else:
|
110 |
+
logger.info("Could not find any prior location in the image EXIF metadata.")
|
111 |
if latlon is None:
|
112 |
+
raise ValueError(
|
113 |
+
"No location prior given: maybe provide the name of a street, building or neighborhood?"
|
114 |
+
)
|
115 |
latlon = np.array(latlon)
|
116 |
|
117 |
proj = Projection(*latlon)
|