Describe the feature
Description
In the Memories section, location-type memories currently display plain geocodes when the image coordinates are not near any of the predefined popular places listed in CITY_COORDINATES within memory_clustering.py.
Instead of showing raw latitude/longitude values, the application can display the nearest local place name (city/town/village) derived from the image’s geocodes.
If the distance to the nearest locality exceeds a configurable threshold (default: 4.0 km), only the state name should be displayed rather than plain geocodes.
Current Problem
- When image geocodes do not match nearby entries in
CITY_COORDINATES, the UI displays raw latitude/longitude values.
- Plain geocodes are not user-friendly and reduce the overall UX quality.
- Users cannot easily interpret the actual location represented by the coordinates.
Expected Feature
- Determine the nearest locality (city/town/village) using reverse geocoding.
- Display the local place name instead of plain geocodes.
- If the nearest locality is farther than the threshold distance (default: 4.0 km):
- Display only the state name.
- Avoid showing raw coordinates.
- Determination of nearest locality using reverse geocoding should be offline.
Implementation
Backend
-
Added GeoCodes.db file. It contains tables for all States and Union Territories, with approximately 500 cities/towns/villages per state. (Currently India)
-The database also includes a classifier table used to determine which state should be searched for a given set of geocodes. (Example: For provided coordinates, the classifier predicts the most probable state where the location belongs.)
- Table Columns:
states: place | latitude | Longitude
classifier: state | latitude | Longitude
-
Implemented the Haversine formula to compute distances and identify the nearest locality (city/town/village) within the predicted state
-
Updated return values of function _reverse_geocode in memories_clustering.py as:
def _reverse_geocode(self, lat: float, lon: float) -> Optional[str]: # added optional return
"""Find nearest city within 50km"""
for city_name, (city_lat, city_lon) in self.CITY_COORDINATES.items():
distance = haversine_distance(lat, lon, city_lat, city_lon)
if distance < 50:
return city_name, True # True -> because city name found
return f"{lat:.4f}°, {lon:.4f}°", False # False -> because of formatted coordinates
- Updated return value in function
_create_simple_memory in memories_clustering.py as:
# Get actual location name using reverse geocoding
location_name, status = self._reverse_geocode(center_lat, center_lon) # status is true if nearest tourist place (actual location) is found
if not status:
# getting place name if no nearest tourist place found
place = get_location_by_geocode(latitude=center_lat, longitude=center_lon, offset=4.0)
else:
place = None
return {
"memory_id": memory_id,
"title": title,
"description": f"{len(images)} photos",
"location_name": location_name,
"place":place, # added key value pair for place
"date_start": date_start,
"date_end": date_end,
"image_count": len(images),
"images": sorted_images,
"thumbnail_image_id": sorted_images[0].get("id", ""),
"center_lat": center_lat,
"center_lon": center_lon,
"type": memory_type,
}
Frontend
- Modified
memories.ts to include the place: string | null field in the Memory interface
- Updated MemoryCard Component:
- Added logic in Memories/MemoryCard.tsx, to override the
displayTitle with the value of place if it is available.
// If "place" is provided (from backend), use it as the main title
if (memory.place) {
displayTitle = memory.place;
}
- Updated MemoryDetail Component:
- Updated the
tempMemory object for the "On This Day" feature to include the place field.
- Synchronized the
displayTitle logic in MemoryDetail.tsx with MemoryCard.tsx to ensure consistency between the list view and the detail view.
Add ScreenShots
Screenshots
Before


After


Record
Describe the feature
Description
In the Memories section, location-type memories currently display plain geocodes when the image coordinates are not near any of the predefined popular places listed in
CITY_COORDINATESwithinmemory_clustering.py.Instead of showing raw latitude/longitude values, the application can display the nearest local place name (city/town/village) derived from the image’s geocodes.
If the distance to the nearest locality exceeds a configurable threshold (default: 4.0 km), only the state name should be displayed rather than plain geocodes.
Current Problem
CITY_COORDINATES, the UI displays raw latitude/longitude values.Expected Feature
Implementation
Backend
Added
GeoCodes.dbfile. It contains tables for all States and Union Territories, with approximately 500 cities/towns/villages per state. (Currently India)-The database also includes a
classifiertable used to determine which state should be searched for a given set of geocodes. (Example: For provided coordinates, the classifier predicts the most probable state where the location belongs.)states: place | latitude | Longitudeclassifier: state | latitude | LongitudeImplemented the Haversine formula to compute distances and identify the nearest locality (city/town/village) within the predicted state
Updated return values of function
_reverse_geocodeinmemories_clustering.pyas:_create_simple_memoryinmemories_clustering.pyas:Updated Memory Schemas in
routes/memories.pyfor new key.added
!GeoCodes.dbin .gitignoreFrontend
memories.tsto include theplace: string | nullfield in theMemoryinterfacedisplayTitlewith the value ofplaceif it is available.tempMemoryobject for the "On This Day" feature to include theplacefield.displayTitlelogic inMemoryDetail.tsxwithMemoryCard.tsxto ensure consistency between the list view and the detail view.Add ScreenShots
Screenshots
Before
After
Record