| 1 |
#! /usr/bin/perl -w |
| 2 |
|
| 3 |
# Toby Thurston -- 02 Nov 2017 |
| 4 |
|
| 5 |
use strict; |
| 6 |
use warnings; |
| 7 |
use List::Util qw/min/; |
| 8 |
|
| 9 |
my $source = shift; |
| 10 |
open my $ostn_fh, '<', $source or die "Can't open $source: $!\n"; |
| 11 |
my $header = <$ostn_fh>; |
| 12 |
|
| 13 |
my @ee; |
| 14 |
my @nn; |
| 15 |
|
| 16 |
while (my $line = <$ostn_fh>) { |
| 17 |
chomp($line); |
| 18 |
my ($id, $easting, $northing, $e_shift, $n_shift, $h_shift, $datum) = split ',', $line; |
| 19 |
push @ee, int $e_shift * 1000; |
| 20 |
push @nn, int $n_shift * 1000; |
| 21 |
} |
| 22 |
|
| 23 |
my $min_e = min @ee; |
| 24 |
my $min_n = min @nn; |
| 25 |
|
| 26 |
my $count = scalar @ee; |
| 27 |
open my $east_fh, '>', "ostn_east_shift_$min_e" ; |
| 28 |
print $east_fh pack("S<[$count]", map { $_ - $min_e } @ee); |
| 29 |
close $east_fh; |
| 30 |
|
| 31 |
$count = scalar @nn; |
| 32 |
open my $north_fh, '>', "ostn_north_shift_$min_n"; |
| 33 |
print $north_fh pack("S<[$count]", map { $_ - $min_n } @nn); |
| 34 |
close $north_fh; |
| 35 |
|