#!/usr/bin/perl -w # Post-processing of ascii boundary files from # http://www.census.gov/geo/www/tiger/ # Assume the data has previously been processed by # perl -pe 's/\S+\s+\S+\s+\S+//; s/END//' # This script removes close-by points and reduces the number of # significant digits. use strict; my ($line, $close, $x, $prev); my ($resolution) = 0.03; sub dist { my ($p, $q) = @_; my ($s, $t); $s = $p->[0] - $q->[0]; $t = $p->[1] - $q->[1]; return sqrt($s*$s+$t*$t); } while (<>) { if (/^\s*$/) { if (defined $close) { printf "%8.2f %8.2f\n", @$close; undef $close; } undef $prev; print "\n"; next; } $x = [split " "]; if (defined $prev) { next if dist($prev, $x) < $resolution; } else { $close = [@$x]; } printf "%8.2f %8.2f\n", @$x; $prev = $x; }