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

@@ -24,9 +24,19 @@ return new class extends Migration
$table->string('country');
$table->string('postal_code')->nullable();
// Coordinates
$table->decimal('latitude', 10, 8);
$table->decimal('longitude', 11, 8);
// Enable PostGIS extension if not enabled
DB::statement('CREATE EXTENSION IF NOT EXISTS postgis');
// Location name and type
$table->string('name')->nullable();
$table->string('location_type', 50)->nullable();
// Legacy coordinate fields for backward compatibility
$table->decimal('latitude', 9, 6)->nullable();
$table->decimal('longitude', 9, 6)->nullable();
// Coordinates using PostGIS
$table->point('coordinates')->spatialIndex();
$table->decimal('elevation', 8, 2)->nullable();
// Additional details
@@ -43,9 +53,10 @@ return new class extends Migration
$table->timestamps();
// Indexes
$table->index(['latitude', 'longitude']);
$table->index(['country', 'state', 'city']);
$table->index('postal_code');
$table->index('name');
$table->index('location_type');
});
}