fix(geocoding): fix query param string parsing, location field mismatch, and distance_km normalization

- controller: @Query() params arrive as strings in NestJS - now explicitly
  parseFloat() all numeric params (lat, lng, radius) before passing to service.
  Also validates against NaN before hitting PostGIS.
- controller: reverse geocode now validates and throws 400 on invalid lat/lng.
- service: searchPlaces now normalizes all results to include:
    - location: { lat, lng } nested object (frontend was crashing on place.location.lat)
    - distance_km: pre-computed string field (frontend was reading undefined distance_km)
    - latitude/longitude as actual floats (not decimal strings from DB)
- frontend (App.tsx): fixed map.flyTo() to read place.latitude/place.longitude
  instead of the non-existent place.location.lat/lng.
- frontend (App.tsx): fixed search result click handler same way.
- frontend (App.tsx): fixed distance display to compute from res.distance (meters).
- entity: added missing source column to BasePlace entity.
This commit is contained in:
Hamza-Ayed
2026-03-29 23:30:12 +03:00
parent ca043b67a8
commit c136cee04f
4 changed files with 84 additions and 31 deletions
@@ -39,6 +39,9 @@ export abstract class BasePlace {
@CreateDateColumn()
created_at: Date;
@Column({ nullable: true })
source: string;
@Column({ type: 'geometry', spatialFeatureType: 'Point', srid: 4326, nullable: true })
@Index({ spatial: true })
location: any;