Refactor Location model to integrate PostGIS for spatial data, add legacy coordinate fields for compatibility, and enhance documentation for geocoding service implementation.

This commit is contained in:
pacnpal
2025-02-23 20:06:27 -05:00
parent 7e5d15eb46
commit f15392806a
8 changed files with 723 additions and 109 deletions

View File

@@ -19,9 +19,8 @@ The Location model provides polymorphic location management for parks, areas, an
- `country` (string) - Country name
- `postal_code` (string, nullable) - Postal/ZIP code
- **Coordinates**
- `latitude` (decimal, 10,8) - Latitude coordinate
- `longitude` (decimal, 11,8) - Longitude coordinate
- **Spatial Data**
- `coordinates` (point) - PostGIS point geometry with SRID 4326
- `elevation` (decimal, 8,2, nullable) - Elevation in meters
- **Additional Details**
@@ -35,10 +34,17 @@ The Location model provides polymorphic location management for parks, areas, an
- `geocoded_at` (timestamp, nullable) - Last geocoding timestamp
### Indexes
- Coordinates: `(latitude, longitude)`
- Spatial: `coordinates` (spatial index for efficient queries)
- Location: `(country, state, city)`
- Postal: `postal_code`
### PostGIS Integration
- Uses PostGIS point type for coordinates
- SRID 4326 (WGS 84) for global coordinates
- Spatial indexing for efficient queries
- Native distance calculations
- Geographic vs Geometric operations
## Relationships
### Polymorphic