254 lines
11 KiB
Python
254 lines
11 KiB
Python
import asyncio
|
|
import sys
|
|
import os
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
from sqlalchemy.future import select
|
|
from geoalchemy2.shape import from_shape
|
|
from shapely.geometry import Point, LineString, shape
|
|
|
|
# Add backend directory to path so we can import app
|
|
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
|
|
from app.core.database import SessionLocal
|
|
from app.models.peak import Peak
|
|
from app.models.route import Route
|
|
from app.models.camp import Camp
|
|
|
|
# Data for 14 Eight-thousanders
|
|
# Coordinates are [longitude, latitude] for Point geometry
|
|
EIGHT_THOUSANDERS_DATA = [
|
|
{
|
|
"name_en": "Mount Everest",
|
|
"name_cn": "珠穆朗玛峰",
|
|
"elevation_m": 8848,
|
|
"prominence_m": 8848,
|
|
"location": Point(86.9250, 27.9881), # Nepal/China border
|
|
"first_ascent_year": 1953,
|
|
"description": "Earth's highest mountain above sea level, located in the Mahalangur Himal sub-range of the Himalayas.",
|
|
"thumbnail_url": "https://upload.wikimedia.org/wikipedia/commons/thumb/f/f6/Everest_North_Face_HR.jpg/640px-Everest_North_Face_HR.jpg"
|
|
},
|
|
{
|
|
"name_en": "K2",
|
|
"name_cn": "乔戈里峰",
|
|
"elevation_m": 8611,
|
|
"prominence_m": 4020,
|
|
"location": Point(76.5150, 35.8814), # Pakistan/China border
|
|
"first_ascent_year": 1954,
|
|
"description": "The second highest mountain in the world, located in the Karakoram mountain range.",
|
|
"thumbnail_url": "https://upload.wikimedia.org/wikipedia/commons/thumb/c/c0/K2_peak.jpg/640px-K2_peak.jpg"
|
|
},
|
|
{
|
|
"name_en": "Kangchenjunga",
|
|
"name_cn": "干城章嘉峰",
|
|
"elevation_m": 8586,
|
|
"prominence_m": 3922,
|
|
"location": Point(88.1472, 27.7025), # Nepal/India border
|
|
"first_ascent_year": 1955,
|
|
"description": "The third highest mountain in the world, meaning 'The Five Treasures of Snow'.",
|
|
"thumbnail_url": "https://upload.wikimedia.org/wikipedia/commons/thumb/2/2f/Kangchenjunga_south-west_face_from_Nepal.jpg/640px-Kangchenjunga_south-west_face_from_Nepal.jpg"
|
|
},
|
|
{
|
|
"name_en": "Lhotse",
|
|
"name_cn": "洛子峰",
|
|
"elevation_m": 8516,
|
|
"prominence_m": 610,
|
|
"location": Point(86.9333, 27.9617), # Nepal/China border, near Everest
|
|
"first_ascent_year": 1956,
|
|
"description": "The fourth highest mountain in the world, connected to Mount Everest via the South Col.",
|
|
"thumbnail_url": "https://upload.wikimedia.org/wikipedia/commons/thumb/7/77/Lhotse_and_Nuptse_from_Everest.jpg/640px-Lhotse_and_Nuptse_from_Everest.jpg"
|
|
},
|
|
{
|
|
"name_en": "Makalu",
|
|
"name_cn": "马卡鲁峰",
|
|
"elevation_m": 8485,
|
|
"prominence_m": 2386,
|
|
"location": Point(87.0875, 27.8892), # Nepal/China border, southeast of Everest
|
|
"first_ascent_year": 1955,
|
|
"description": "The fifth highest mountain in the world, an isolated peak.",
|
|
"thumbnail_url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/d1/Makalu.jpg/640px-Makalu.jpg"
|
|
},
|
|
{
|
|
"name_en": "Cho Oyu",
|
|
"name_cn": "卓奥友峰",
|
|
"elevation_m": 8201,
|
|
"prominence_m": 1050,
|
|
"location": Point(86.6617, 28.0933), # Nepal/China border, west of Everest
|
|
"first_ascent_year": 1954,
|
|
"description": "The sixth highest mountain, considered one of the 'easier' eight-thousanders.",
|
|
"thumbnail_url": "https://upload.wikimedia.org/wikipedia/commons/thumb/1/1b/Cho_Oyu_from_Gokyo.jpg/640px-Cho_Oyu_from_Gokyo.jpg"
|
|
},
|
|
{
|
|
"name_en": "Dhaulagiri I",
|
|
"name_cn": "道拉吉里峰",
|
|
"elevation_m": 8167,
|
|
"prominence_m": 3357,
|
|
"location": Point(83.4933, 28.7000), # Nepal
|
|
"first_ascent_year": 1960,
|
|
"description": "The seventh highest mountain, meaning 'White Mountain'.",
|
|
"thumbnail_url": "https://upload.wikimedia.org/wikipedia/commons/thumb/1/13/Dhaulagiri_Himal_range_Nepal_from_Poon_Hill.jpg/640px-Dhaulagiri_Himal_range_Nepal_from_Poon_Hill.jpg"
|
|
},
|
|
{
|
|
"name_en": "Manaslu",
|
|
"name_cn": "马纳斯鲁峰",
|
|
"elevation_m": 8163,
|
|
"prominence_m": 3092,
|
|
"location": Point(84.5597, 28.5500), # Nepal
|
|
"first_ascent_year": 1956,
|
|
"description": "The eighth highest mountain, 'Mountain of the Spirit'.",
|
|
"thumbnail_url": "https://upload.wikimedia.org/wikipedia/commons/thumb/8/87/Manaslu_from_above.jpg/640px-Manaslu_from_above.jpg"
|
|
},
|
|
{
|
|
"name_en": "Nanga Parbat",
|
|
"name_cn": "南迦帕尔巴特峰",
|
|
"elevation_m": 8126,
|
|
"prominence_m": 4609,
|
|
"location": Point(74.5881, 35.2372), # Pakistan
|
|
"first_ascent_year": 1953,
|
|
"description": "The ninth highest mountain, known as 'Killer Mountain'.",
|
|
"thumbnail_url": "https://upload.wikimedia.org/wikipedia/commons/thumb/1/1e/Nanga_Parbat_from_Fairy_Meadows.jpg/640px-Nanga_Parbat_from_Fairy_Meadows.jpg"
|
|
},
|
|
{
|
|
"name_en": "Annapurna I",
|
|
"name_cn": "安娜普尔那峰",
|
|
"elevation_m": 8091,
|
|
"prominence_m": 2984,
|
|
"location": Point(83.8200, 28.5967), # Nepal
|
|
"first_ascent_year": 1950,
|
|
"description": "The tenth highest mountain, the first 8000m peak to be successfully climbed.",
|
|
"thumbnail_url": "https://upload.wikimedia.org/wikipedia/commons/thumb/f/f6/Annapurna_I_view.jpg/640px-Annapurna_I_view.jpg"
|
|
},
|
|
{
|
|
"name_en": "Gasherbrum I",
|
|
"name_cn": "迦舒布鲁姆I峰",
|
|
"elevation_m": 8080,
|
|
"prominence_m": 2155,
|
|
"location": Point(76.6969, 35.7228), # Pakistan/China border, Karakoram
|
|
"first_ascent_year": 1958,
|
|
"description": "The eleventh highest mountain, also known as Hidden Peak.",
|
|
"thumbnail_url": "https://upload.wikimedia.org/wikipedia/commons/thumb/3/36/Gasherbrum_I_from_Baltoro_Glacier.jpg/640px-Gasherbrum_I_from_Baltoro_Glacier.jpg"
|
|
},
|
|
{
|
|
"name_en": "Broad Peak",
|
|
"name_cn": "布洛阿特峰",
|
|
"elevation_m": 8051,
|
|
"prominence_m": 1701,
|
|
"location": Point(76.5597, 35.8019), # Pakistan/China border, Karakoram
|
|
"first_ascent_year": 1957,
|
|
"description": "The twelfth highest mountain, located in the Karakoram mountain range.",
|
|
"thumbnail_url": "https://upload.wikimedia.org/wikipedia/commons/thumb/a/ae/Broad_Peak_from_Concordia.jpg/640px-Broad_Peak_from_Concordia.jpg"
|
|
},
|
|
{
|
|
"name_en": "Gasherbrum II",
|
|
"name_cn": "迦舒布鲁姆II峰",
|
|
"elevation_m": 8035,
|
|
"prominence_m": 1524,
|
|
"location": Point(76.6558, 35.7597), # Pakistan/China border, Karakoram
|
|
"first_ascent_year": 1956,
|
|
"description": "The thirteenth highest mountain, known for its relative ease of ascent.",
|
|
"thumbnail_url": "https://upload.wikimedia.org/wikipedia/commons/thumb/6/67/Gasherbrum_II.jpg/640px-Gasherbrum_II.jpg"
|
|
},
|
|
{
|
|
"name_en": "Shishapangma",
|
|
"name_cn": "希夏邦马峰",
|
|
"elevation_m": 8027,
|
|
"prominence_m": 2897,
|
|
"location": Point(85.7875, 28.3536), # China (Tibet)
|
|
"first_ascent_year": 1964,
|
|
"description": "The fourteenth highest mountain, and the only 8000m peak located entirely within Tibet.",
|
|
"thumbnail_url": "https://upload.wikimedia.org/wikipedia/commons/thumb/4/41/Shishapangma_from_Langtang.jpg/640px-Shishapangma_from_Langtang.jpg"
|
|
},
|
|
]
|
|
|
|
async def seed_peaks(session: AsyncSession):
|
|
for peak_data in EIGHT_THOUSANDERS_DATA:
|
|
result = await session.execute(
|
|
select(Peak).filter_by(name_en=peak_data["name_en"])
|
|
)
|
|
existing_peak = result.scalars().first()
|
|
|
|
if not existing_peak:
|
|
peak_data["location"] = from_shape(peak_data["location"], srid=4326)
|
|
new_peak = Peak(**peak_data)
|
|
session.add(new_peak)
|
|
print(f"Added {new_peak.name_en}")
|
|
else:
|
|
print(f"{existing_peak.name_en} already exists. Skipping.")
|
|
await session.commit()
|
|
|
|
async def seed_everest_routes(session: AsyncSession):
|
|
# Find Everest
|
|
result = await session.execute(select(Peak).filter_by(name_en="Mount Everest"))
|
|
everest = result.scalars().first()
|
|
|
|
if not everest:
|
|
print("Everest not found, cannot seed routes.")
|
|
return
|
|
|
|
# Check if route exists
|
|
route_name = "South Col Route"
|
|
result = await session.execute(select(Route).filter_by(peak_id=everest.id, name=route_name))
|
|
existing_route = result.scalars().first()
|
|
|
|
if existing_route:
|
|
print(f"Route '{route_name}' already exists. Skipping.")
|
|
return
|
|
|
|
# Create Route Geometry (Simplified LineString with Z coords)
|
|
# Coordinates: BC -> C1 -> C2 -> C3 -> C4 -> Summit
|
|
# [lon, lat, ele]
|
|
route_coords = [
|
|
[86.8594, 28.0030, 5364], # Base Camp
|
|
[86.8767, 27.9833, 5943], # Khumbu Icefall top
|
|
[86.8950, 27.9750, 6065], # Camp 1
|
|
[86.9100, 27.9700, 6400], # Camp 2 (Western Cwm)
|
|
[86.9250, 27.9650, 7200], # Camp 3 (Lhotse Face)
|
|
[86.9333, 27.9617, 7906], # South Col (Camp 4)
|
|
[86.9250, 27.9881, 8848], # Summit
|
|
]
|
|
|
|
# Note: for PostGIS LINESTRINGZ, format is just X Y Z. Shapely handles this.
|
|
route_geom = LineString(route_coords)
|
|
|
|
new_route = Route(
|
|
peak_id=everest.id,
|
|
name=route_name,
|
|
difficulty="Extreme",
|
|
description="The most popular climbing route on Mount Everest, starting from Nepal.",
|
|
is_standard_route=True,
|
|
path_geometry=from_shape(route_geom, srid=4326)
|
|
)
|
|
session.add(new_route)
|
|
await session.flush() # Flush to get route ID for camps
|
|
print(f"Added route '{route_name}'")
|
|
|
|
# Create Camps
|
|
camps_data = [
|
|
{"name": "Base Camp", "elevation_m": 5364, "location": Point(86.8594, 28.0030), "camp_type": "BaseCamp"},
|
|
{"name": "Camp 1", "elevation_m": 6065, "location": Point(86.8950, 27.9750), "camp_type": "Camp"},
|
|
{"name": "Camp 2", "elevation_m": 6400, "location": Point(86.9100, 27.9700), "camp_type": "Camp"},
|
|
{"name": "Camp 3", "elevation_m": 7200, "location": Point(86.9250, 27.9650), "camp_type": "Camp"},
|
|
{"name": "South Col (Camp 4)", "elevation_m": 7906, "location": Point(86.9333, 27.9617), "camp_type": "Camp"},
|
|
{"name": "Summit", "elevation_m": 8848, "location": Point(86.9250, 27.9881), "camp_type": "Summit"},
|
|
]
|
|
|
|
for camp in camps_data:
|
|
new_camp = Camp(
|
|
route_id=new_route.id,
|
|
name=camp["name"],
|
|
elevation_m=camp["elevation_m"],
|
|
location=from_shape(camp["location"], srid=4326),
|
|
camp_type=camp["camp_type"]
|
|
)
|
|
session.add(new_camp)
|
|
|
|
await session.commit()
|
|
print("Added camps for South Col Route.")
|
|
|
|
async def main():
|
|
async with SessionLocal() as session:
|
|
await seed_peaks(session)
|
|
await seed_everest_routes(session)
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(main())
|