fn build_tab_map<A: tui::backend::Backend>(
    f: &mut tui::Frame<A>,
    chunks: Vec<Rect>,
    settings: &Settings,
    adsb_airplanes: &Airplanes,
) {
    let canvas = Canvas::default()
        .block(Block::default().title("Map").borders(Borders::ALL))
        .x_bounds([MAX_PLOT_LOW, MAX_PLOT_HIGH])
        .y_bounds([MAX_PLOT_LOW, MAX_PLOT_HIGH])
        .paint(|ctx| {
            ctx.layer();

            // draw locations
            draw_locations(ctx, settings);

            // draw ADSB tab airplanes
            for key in adsb_airplanes.0.keys() {
                let value = adsb_airplanes.aircraft_details(*key);
                if let Some((position, _, _)) = value {
                    let (x, y) = settings.to_xy(position.latitude, position.longitude);

                    // draw dot on location
                    ctx.draw(&Points {
                        coords: &[(x, y)],
                        color: Color::White,
                    });

                    let name = if settings.opts.disable_lat_long {
                        format!("{key}").into_boxed_str()
                    } else {
                        format!("{key} ({}, {})", position.latitude, position.longitude)
                            .into_boxed_str()
                    };

                    // draw plane ICAO name
                    ctx.print(
                        x,
                        y,
                        Span::styled(name.to_string(), Style::default().fg(Color::White)),
                    );
                }
            }

            draw_lines(ctx);
        });
    f.render_widget(canvas, chunks[1]);
}
/// Render Map tab for tui display
Render Map tab for tui display
Render Map tab for tui display
fn build_tab_map<A: tui::backend::Backend>(
    f: &mut tui::Frame<A>,
    chunks: Vec<Rect>,
    settings: &Settings,
    adsb_airplanes: &Airplanes,
) {
    let canvas = Canvas::default()
        .block(Block::default().title("Map").borders(Borders::ALL))
        .x_bounds([MAX_PLOT_LOW, MAX_PLOT_HIGH])
        .y_bounds([MAX_PLOT_LOW, MAX_PLOT_HIGH])
        .paint(|ctx| {
            ctx.layer();
            // draw locations
            draw_locations(ctx, settings);
            // draw ADSB tab airplanes
            for key in adsb_airplanes.0.keys() {
                let value = adsb_airplanes.aircraft_details(*key);
                if let Some((position, _, _)) = value {
                    let (x, y) = settings.to_xy(position.latitude, position.longitude);
                    // draw dot on location
                    ctx.draw(&Points {
                        coords: &[(x, y)],
                        color: Color::White,
                    });
                    let name = if settings.opts.disable_lat_long {
                        format!("{key}").into_boxed_str()
                    } else {
                        format!("{key} ({}, {})", position.latitude, position.longitude)
                            .into_boxed_str()
                    };
                    // draw plane ICAO name
                    ctx.print(
                        x,
                        y,
                        Span::styled(name.to_string(), Style::default().fg(Color::White)),
                    );
                }
            }
            draw_lines(ctx);
        });
    f.render_widget(canvas, chunks[1]);
}
fn build_tab_map < A : tui :: backend :: Backend > ( f : & mut tui :: Frame < A > , chunks : Vec < Rect > , settings : & Settings , adsb_airplanes : & Airplanes , ) { let canvas = Canvas :: default ( ) . block ( Block :: default ( ) . title ( " " ) . borders ( Borders :: ALL ) ) . x_bounds ( [ MAX_PLOT_LOW , MAX_PLOT_HIGH ] ) . y_bounds ( [ MAX_PLOT_LOW , MAX_PLOT_HIGH ] ) . paint ( | ctx | { ctx . layer ( ) ; // draw locations draw_locations ( ctx , settings ) ; // draw ADSB tab airplanes for key in adsb_airplanes . 0 . keys ( ) { let value = adsb_airplanes . aircraft_details ( * key ) ; if let Some ( ( position , _ , _ ) ) = value { let ( x , y ) = settings . to_xy ( position . latitude , position . longitude ) ; // draw dot on location ctx . draw ( & Points { coords : & [ ( x , y ) ] , color : Color :: White , } ) ; let name = if settings . opts . disable_lat_long { format ! ( " " ) . into_boxed_str ( ) } else { format ! ( " " position latitude position longitude ) . into_boxed_str ( ) } ; // draw plane ICAO name ctx . print ( x , y , Span :: styled ( name . to_string ( ) , Style :: default ( ) . fg ( Color :: White ) ) , ) ; } } draw_lines ( ctx ) ; } ) ; f . render_widget ( canvas , chunks [ 1 ] ) ; }
Render Map tab for tui display
Render Map tab for tui display
f
&mut tui::Frame<A>
chunks
Vec<Rect>
settings
&Settings
adsb_airplanes
&Airplanes
f
&mut tui::Frame<A>
chunks
Vec<Rect>
settings
&Settings
adsb_airplanes
&Airplanes