Changeset 673 for trunk


Ignore:
Timestamp:
Dec 29, 2008, 11:50:49 AM (11 years ago)
Author:
sheldon
Message:

Handle error with postcode and output message to stderr rather than truncating the output

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/npemap.org.uk/scripts/exporter/export.pl

    r672 r673  
    3737#   -npeonly
    3838#       Only export NPE sourced postcodes, averaged if several for a postcode
     39#   -postboxonly
     40#       Only export dracos postbox data
    3941#   -all
    4042#       Outputs all postcodes, averaged if several for a postcode, along
     
    9193        }
    9294       
    93         # Generate lat+long
    94         my ($lat,$long) = eastingNorthingToLatLong($e,$n,$grid);
    95         # Generate 2+6 NGR
    96         my $ngr = eastingNorthingToNGR($e,$n,$grid);
    97 
    98         # Make e+n look nicer
    99         $e =~ s/^(\d+)\.\d+$/$1/;
    100         $n =~ s/^(\-?\d+)\.\d+$/$1/;
    101 
    102         # Make lat+long look nicer
    103         $lat = sprintf("%0.6f", $lat);
    104         $long = sprintf("%0.6f", $long);
    105 
    106         # Make Source Nicer
    107         $source =~ s/^\{//;
    108         $source =~ s/\}$//;
    109         $source =~ s/\"//g;
    110         $source =~ s/,/;/g;
    111 
    112         print "$outer,$inner,$e,$n,$lat,$long,$ngr,$grid,$source\n";
     95        eval {
     96                # Generate lat+long
     97                my ($lat,$long) = eastingNorthingToLatLong($e,$n,$grid);
     98                # Generate 2+6 NGR
     99                my $ngr = eastingNorthingToNGR($e,$n,$grid);
     100
     101                # Make e+n look nicer
     102                $e =~ s/^(\d+)\.\d+$/$1/;
     103                $n =~ s/^(\-?\d+)\.\d+$/$1/;
     104
     105                # Make lat+long look nicer
     106                $lat = sprintf("%0.6f", $lat);
     107                $long = sprintf("%0.6f", $long);
     108
     109                # Make Source Nicer
     110                $source =~ s/^\{//;
     111                $source =~ s/\}$//;
     112                $source =~ s/\"//g;
     113                $source =~ s/,/;/g;
     114
     115                print "$outer,$inner,$e,$n,$lat,$long,$ngr,$grid,$source\n";
     116        };
     117        if ($@) {
     118           print STDERR "Error processing $outer $inner\n";
     119        };
    113120}
    114121
     
    131138                } elsif($mode eq "-postboxonly") {
    132139                        $source = getSource("Dracos.co.uk Postbox Importer", $conn);
    133                 } elsif($mode eq "-npeonly") {
     140                } else {
    134141                        $source = getSource("NPE Postcode web submission", $conn);
    135142                }
Note: See TracChangeset for help on using the changeset viewer.