diff --git a/GEMINI.md b/GEMINI.md index e4618d5..4840b13 100644 --- a/GEMINI.md +++ b/GEMINI.md @@ -68,6 +68,17 @@ --- +## 📊 Data Management +The project includes a compressed dataset of ~68,000 cities from Natural Earth. + +| Action | Command | +| :--- | :--- | +| **Import/Refresh Data** | `./import-cities.sh` | + +*Note: The script will truncate the `cities` table and perform a fresh import of the global dataset stored in `docker/data/cities.csv.gz`.* + +--- + ## 📝 Roadmap Highlights - [ ] Implement real ST_DWithin() PostGIS queries in the backend. - [ ] Import full Natural Earth/GeoNames datasets into the `cities` table. diff --git a/docker/data/cities.csv.gz b/docker/data/cities.csv.gz new file mode 100644 index 0000000..eb1f43e Binary files /dev/null and b/docker/data/cities.csv.gz differ diff --git a/import-cities.sh b/import-cities.sh new file mode 100755 index 0000000..a3956bc --- /dev/null +++ b/import-cities.sh @@ -0,0 +1,66 @@ +#!/bin/bash + +# Configuration +CONTAINER_NAME="line-of-sight-db" +DB_USER="line_of_sight" +DB_NAME="line_of_sight" +DATA_FILE="./docker/data/cities.csv.gz" + +# Check if docker is available using the known path +DOCKER_BIN="/usr/local/bin/docker" +if [ ! -f "$DOCKER_BIN" ]; then + DOCKER_BIN=$(which docker) +fi + +if [ -z "$DOCKER_BIN" ]; then + echo "Error: docker command not found." + exit 1 +fi + +# Check if data file exists +if [ ! -f "$DATA_FILE" ]; then + echo "Error: Data file $DATA_FILE not found." + exit 1 +fi + +# Check if container is running +if ! "$DOCKER_BIN" ps | grep -q "$CONTAINER_NAME"; then + echo "Error: Container $CONTAINER_NAME is not running." + echo "Please run 'docker-compose up -d' first." + exit 1 +fi + +echo "🚀 Starting database initialization..." + +# Use a HEREDOC to execute multi-line SQL +# We load into a temp table first to handle the WKT -> Geography conversion +IMPORT_SQL=$(cat <