MCPcopy Create free account
hub / github.com/ecto/muni / create_map_from_session

Function create_map_from_session

depot/mapper/src/main.rs:595–659  ·  view source on GitHub ↗

Create a new map from a session

(
    state: SharedState,
    session: &Session,
)

Source from the content-addressed store, hash-verified

593
594/// Create a new map from a session
595async fn create_map_from_session(
596 state: SharedState,
597 session: &Session,
598) -> Result<Uuid, MapperError> {
599 let map_id = Uuid::new_v4();
600 let now = Utc::now();
601
602 // Generate map name from GPS center or rover ID + date
603 let name = if let Some(ref bounds) = session.gps_bounds {
604 let (lat, lon) = bounds.center();
605 format!("map_{:.4}_{:.4}", lat, lon)
606 } else {
607 format!("map_{}_{}", session.rover_id, now.format("%Y%m%d"))
608 };
609
610 let bounds = session.gps_bounds.clone().unwrap_or_default();
611
612 // Create map directory
613 let maps_dir = {
614 let state = state.read().await;
615 state.maps_dir.clone()
616 };
617 let map_dir = maps_dir.join(&name);
618 tokio::fs::create_dir_all(&map_dir).await?;
619
620 // Run splatting pipeline (placeholder: just copy/reference source data)
621 // TODO: Invoke actual Gaussian splatting when implemented
622 let splat_path = run_splat_pipeline(&session.path, &map_dir).await?;
623
624 let manifest = MapManifest {
625 id: map_id,
626 name: name.clone(),
627 description: Some(format!("Generated from session {}", session.id)),
628 bounds,
629 version: 1,
630 created_at: now,
631 updated_at: now,
632 assets: MapAssets {
633 splat: splat_path,
634 pointcloud: None,
635 mesh: None,
636 thumbnail: None,
637 },
638 sessions: vec![MapSessionRef {
639 session_id: session.id,
640 rover_id: session.rover_id.clone(),
641 date: session.started_at,
642 }],
643 stats: MapStats {
644 total_points: session.lidar_frames as u64 * 200_000, // Estimate
645 total_splats: 0,
646 coverage_pct: 0.0,
647 },
648 };
649
650 // Save manifest and update state
651 {
652 let mut state = state.write().await;

Callers 1

process_sessionFunction · 0.85

Calls 5

run_splat_pipelineFunction · 0.85
centerMethod · 0.80
writeMethod · 0.80
save_manifestMethod · 0.80
insertMethod · 0.80

Tested by

no test coverage detected