@@ -433,12 +433,16 @@ pub fn print_geo_table(records: &[GeoRecord]) {
433433 let mut w_country = "Country" . len ( ) ;
434434 let mut w_region = "Region" . len ( ) ;
435435 let mut w_city = "City" . len ( ) ;
436+ let mut w_lat = "Latitude" . len ( ) ;
437+ let mut w_lon = "Longitude" . len ( ) ;
436438
437439 for r in records {
438440 w_ip = w_ip. max ( r. ip . to_string ( ) . len ( ) ) ;
439441 w_country = w_country. max ( r. country . len ( ) ) ;
440442 w_region = w_region. max ( r. region . len ( ) ) ;
441443 w_city = w_city. max ( r. city . len ( ) ) ;
444+ w_lat = w_lat. max ( format ! ( "{:.6}" , r. latitude) . len ( ) ) ;
445+ w_lon = w_lon. max ( format ! ( "{:.6}" , r. longitude) . len ( ) ) ;
442446 }
443447
444448 // Print Header
@@ -448,14 +452,14 @@ pub fn print_geo_table(records: &[GeoRecord]) {
448452 format!( "{:>width$}" , "Country" , width = w_country) . bold( ) ,
449453 format!( "{:>width$}" , "Region" , width = w_region) . bold( ) ,
450454 format!( "{:>width$}" , "City" , width = w_city) . bold( ) ,
451- format!( "{:>10 }" , "Latitude" ) . bold( ) ,
452- format!( "{:>10 }" , "Longitude" ) . bold( ) ,
455+ format!( "{:>width$ }" , "Latitude" , width = w_lat ) . bold( ) ,
456+ format!( "{:>width$ }" , "Longitude" , width = w_lon ) . bold( ) ,
453457 ) ;
454458
455459 // Print Rows
456460 for r in records {
457461 println ! (
458- "{:<w_ip$} | {:>w_country$} | {:>w_region$} | {:>w_city$} | {:>10 .6} | {:>10 .6}" ,
462+ "{:<w_ip$} | {:>w_country$} | {:>w_region$} | {:>w_city$} | {:>w_lat$ .6} | {:>w_lon$ .6}" ,
459463 r. ip,
460464 r. country,
461465 r. region,
@@ -465,7 +469,9 @@ pub fn print_geo_table(records: &[GeoRecord]) {
465469 w_ip = w_ip,
466470 w_country = w_country,
467471 w_region = w_region,
468- w_city = w_city
472+ w_city = w_city,
473+ w_lat = w_lat,
474+ w_lon = w_lon
469475 ) ;
470476 }
471477}
0 commit comments