#!/usr/bin/perl

############################################################################
## fixplaces creates places.lst from  places.txt downloaded from          ##
## ftp://ftp.census.gov:/pub/tiger/tms/gazetteer for use with astrolog.cgi##
############################################################################
## fixplaces is copyright 1998 Tom Lear <tom@trap.mountain-view.ca.us>    ##
## and is released under the Gnu GPL.                                     ##
############################################################################

open INFILE,"places.txt";
open OUTFILE,">places.lst";
while (<INFILE>) {
	s/^.{9}(.{67})(..).{43}(...)(..).{5}(...)(..).*$//;
	$city=$1;
	$state=$2;
	$lat="$3.$4";
	$long="$5.$6";
	$city=~s/^(.*)( city| town| borough| village| CDP| comunidad| zona urbana| \(remainder\)).*$/\1/;
	print OUTFILE "$lat $long $state $city\n" if ("$city" ne "");
}
close OUTFILE;
close INFILE;
