Add automatic geocoding for site addresses to improve GPS accuracy
Integrate Nominatim API via a new backend endpoint and frontend button to automatically convert site addresses into GPS coordinates, enhancing accuracy for the mobile planning map. Replit-Commit-Author: Agent Replit-Commit-Session-Id: e5565357-90e1-419f-b9a8-6ee8394636df Replit-Commit-Checkpoint-Type: intermediate_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/6d543d2c-20b9-4ea6-93fe-70fe9b1d9f80/e5565357-90e1-419f-b9a8-6ee8394636df/TFybNy5
This commit is contained in:
parent
0c702f4dbf
commit
db67aa9f61
19
replit.md
19
replit.md
@ -54,6 +54,22 @@ The database includes tables for `users`, `guards`, `certifications`, `sites`, `
|
|||||||
To prevent timezone-related bugs, especially when assigning shifts, dates should always be constructed from components (`new Date(year, month-1, day)`) and never parsed from ISO strings directly using `parseISO()` or `new Date(string ISO)`. Date validation should use regex instead of `parseISO()`.
|
To prevent timezone-related bugs, especially when assigning shifts, dates should always be constructed from components (`new Date(year, month-1, day)`) and never parsed from ISO strings directly using `parseISO()` or `new Date(string ISO)`. Date validation should use regex instead of `parseISO()`.
|
||||||
|
|
||||||
## Recent Changes (October 2025)
|
## Recent Changes (October 2025)
|
||||||
|
### Automatic Geocoding Integration (October 23, 2025)
|
||||||
|
- **Issue**: Users had to manually find and enter GPS coordinates for sites, which was time-consuming and error-prone
|
||||||
|
- **Solution**:
|
||||||
|
- **Backend (`server/routes.ts`)**:
|
||||||
|
- Created POST `/api/geocode` endpoint integrating Nominatim API (OpenStreetMap)
|
||||||
|
- Implemented in-memory rate limiter enforcing 1 request/second to comply with Nominatim usage policy
|
||||||
|
- Added compliant User-Agent header: "VigilanzaTurni/1.0 (Security Shift Management System; contact: support@vigilanzaturni.it)"
|
||||||
|
- Returns latitude, longitude, displayName, and full address object
|
||||||
|
- **Frontend (`client/src/pages/sites.tsx`)**:
|
||||||
|
- Added "📍 Trova Coordinate" button in both create and edit site dialogs
|
||||||
|
- Button auto-populates latitude/longitude fields from address
|
||||||
|
- Disabled state when address missing or geocoding in progress
|
||||||
|
- Toast notifications for success (with found address) and error handling
|
||||||
|
- Dedicated section with bg-muted/50 highlighting for GPS coordinates
|
||||||
|
- **Impact**: Users can now automatically geocode site addresses with a single click, ensuring accurate GPS positioning for Planning Mobile map without manual coordinate lookup
|
||||||
|
|
||||||
### Planning Mobile - Leaflet Map Integration (October 23, 2025)
|
### Planning Mobile - Leaflet Map Integration (October 23, 2025)
|
||||||
- **Issue**: Planning Mobile page had errors in backend endpoints and lacked interactive map functionality
|
- **Issue**: Planning Mobile page had errors in backend endpoints and lacked interactive map functionality
|
||||||
- **Solution**:
|
- **Solution**:
|
||||||
@ -88,4 +104,5 @@ To prevent timezone-related bugs, especially when assigning shifts, dates should
|
|||||||
- **TanStack Query**: For data fetching and state management.
|
- **TanStack Query**: For data fetching and state management.
|
||||||
- **Wouter**: For client-side routing.
|
- **Wouter**: For client-side routing.
|
||||||
- **date-fns**: For date manipulation and formatting.
|
- **date-fns**: For date manipulation and formatting.
|
||||||
- **Leaflet**: Interactive map library with react-leaflet bindings and OpenStreetMap tiles (free).
|
- **Leaflet**: Interactive map library with react-leaflet bindings and OpenStreetMap tiles (free).
|
||||||
|
- **Nominatim**: OpenStreetMap geocoding API for automatic address-to-coordinates conversion (free, rate limited to 1 req/sec).
|
||||||
Loading…
Reference in New Issue
Block a user