Files
maps-saas/fix_exact_border.sh
T

74 lines
2.1 KiB
Bash
Executable File

#!/usr/bin/env bash
set -e
# ==============================================================================
# Script: fix_exact_border.sh
# Purpose: Clean rogue lines and set exact straight border segment:
# From (36.839237, 32.311852) to (38.793024, 33.371104)
# ==============================================================================
echo "================================================================="
echo "🇯🇴 Applying Exact Jordan-Syria Border Fix..."
echo "================================================================="
if [ -f .env ]; then
export $(grep -v '^#' .env | xargs)
fi
DB_USER=${POSTGRES_USER:-postgres}
DB_NAME=${POSTGRES_DB:-gis}
docker exec -i map-db psql -U "$DB_USER" -d "$DB_NAME" << 'EOF'
BEGIN;
-- 1. Remove all dummy / experimental lines previously added
DELETE FROM planet_osm_line WHERE osm_id >= 900000;
DELETE FROM planet_osm_polygon WHERE osm_id >= 900000;
-- 2. Remove any rogue lines north of the border line in the desert area
-- (Bounding box covering the false upper lines in Syria)
DELETE FROM planet_osm_line
WHERE boundary = 'administrative'
AND admin_level IN ('2', '3', '4', '5')
AND ST_Intersects(
way,
ST_Transform(
ST_MakeEnvelope(36.80, 32.35, 38.85, 33.70, 4326),
3857
)
)
AND NOT ST_Intersects(
way,
ST_Transform(
ST_MakeEnvelope(35.5, 31.0, 36.80, 33.0, 4326),
3857
)
);
-- 3. Insert the EXACT official straight border segment from user coordinates:
-- Point A: (36.839237, 32.311852) -> Point B: (38.793024, 33.371104)
INSERT INTO planet_osm_line (osm_id, boundary, admin_level, name, way)
VALUES (
999555,
'administrative',
'2',
'Jordan - Syria International Border',
ST_Transform(
ST_Segmentize(
ST_GeomFromText('LINESTRING(36.839237 32.311852, 38.793024 33.371104)', 4326),
1000
),
3857
)
);
COMMIT;
EOF
echo "Restarting Martin..."
docker compose restart martin
echo "================================================================="
echo "✅ Exact border fixed and applied successfully!"
echo "================================================================="