File: pack_ostn_data

package info (click to toggle)
libgeo-coordinates-osgb-perl 2.20-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 6,304 kB
  • sloc: perl: 2,483; makefile: 7
file content (35 lines) | stat: -rwxr-xr-x 793 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#! /usr/bin/perl -w

# Toby Thurston -- 02 Nov 2017

use strict;
use warnings;
use List::Util qw/min/;

my $source = shift;
open my $ostn_fh, '<', $source or die "Can't open $source: $!\n";
my $header = <$ostn_fh>;

my @ee;
my @nn;

while (my $line = <$ostn_fh>) {
    chomp($line);
    my ($id, $easting, $northing, $e_shift, $n_shift, $h_shift, $datum) = split ',', $line;
    push @ee, int $e_shift * 1000;
    push @nn, int $n_shift * 1000;
}

my $min_e = min @ee;
my $min_n = min @nn;

my $count = scalar @ee;
open my $east_fh, '>', "ostn_east_shift_$min_e" ;
print $east_fh pack("S<[$count]", map { $_ - $min_e } @ee);
close $east_fh;

$count = scalar @nn;
open my $north_fh, '>', "ostn_north_shift_$min_n";
print $north_fh pack("S<[$count]", map { $_ - $min_n } @nn);
close $north_fh;