Hướng dẫn import database với 487,000+ OpenStreetMap entities vào CityLens Backend.
- Backend đang chạy (đã chạy
./start.sh) - Database dump file (
.sql) - PostgreSQL container đang hoạt động
Nếu bạn chưa có file dump, liên hệ team để nhận:
- File:
citylens_dump.sql - Dung lượng: khoảng 50-100MB
- Chứa: 487,000+ OSM entities (buildings, roads, POIs)
# Import trực tiếp vào container đang chạy
docker exec -i citylens-postgres-prod psql -U citylens -d citylens_db < citylens_dump.sql# Kiểm tra số lượng entities
docker exec citylens-postgres-prod psql -U citylens -d citylens_db -c "SELECT COUNT(*) FROM osm_entities;"
# Xem breakdown theo type
docker exec citylens-postgres-prod psql -U citylens -d citylens_db -c "SELECT entity_type, COUNT(*) FROM osm_entities GROUP BY entity_type;"Nếu bạn muốn tự import dữ liệu OSM mới:
# Tải Vietnam OSM data
wget https://download.geofabrik.de/asia/vietnam-latest.osm.pbf# Từ backend directory
python scripts/import_osm.py --file vietnam-latest.osm.pbf --area hanoiChi tiết tham số:
--file: Đường dẫn đến file .osm.pbf--area: Khu vực muốn import (hanoi, hochiminhcity, danang, etc.)--entity-types: Loại entities (building, highway, amenity) - mặc định là tất cả
Nếu bạn muốn tạo backup hoặc chia sẻ database:
# Export từ container
docker exec citylens-postgres-prod pg_dump -U citylens citylens_db > citylens_backup_$(date +%Y%m%d).sql
# Hoặc dùng script
./scripts/export_database.sh# Tạo database
docker exec citylens-postgres-prod psql -U citylens -c "CREATE DATABASE citylens_db;"
docker exec citylens-postgres-prod psql -U citylens -d citylens_db -c "CREATE EXTENSION postgis;"# Kiểm tra PostgreSQL đang chạy
docker ps | grep postgres
# Khởi động lại nếu cần
docker-compose up -d postgresFile dump lớn có thể mất thời gian. Theo dõi progress:
# Xem logs PostgreSQL
docker-compose logs -f postgres
# Kiểm tra disk usage
docker exec citylens-postgres-prod df -h# Drop tất cả tables
docker exec citylens-postgres-prod psql -U citylens -d citylens_db -c "DROP SCHEMA public CASCADE; CREATE SCHEMA public;"
# Import lại
docker exec -i citylens-postgres-prod psql -U citylens -d citylens_db < citylens_dump.sqlSau khi import thành công, database sẽ có:
osm_entities: Tất cả entities từ OpenStreetMapcitizen_reports: Báo cáo từ người dânusers: Quản lý người dùngspatial_ref_sys: PostGIS spatial reference systems
- PostGIS: Xử lý dữ liệu địa lý
- pg_trgm: Full-text search
- uuid-ossp: Generate UUIDs
- Tổng entities: 487,000+
- Buildings: ~350,000
- Roads: ~80,000
- POIs: ~57,000
- Dung lượng: ~2-3GB
- GitHub Issues: https://github.com/PKA-Open-Dynamics/CityLens/issues
- Documentation: README.md
Copyright (c) 2025 CityLens Contributors GNU General Public License v3.0