head     1.4;
access   ;
symbols  ;
locks    ; strict;
comment  @# @;


1.4
date     92.07.14.16.16.46;  author reid;  state Exp;
branches ;
next     1.3;

1.3
date     91.09.19.08.36.38;  author reid;  state Exp;
branches ;
next     1.2;

1.2
date     91.07.13.10.33.49;  author reid;  state Exp;
branches ;
next     1.1;

1.1
date     90.03.23.16.37.15;  author reid;  state Exp;
branches ;
next     ;


desc
@@


1.4
log
@Clear #L field at start of new entry (this avoids re-using
it accidentally when there is a syntax error)
@
text
@#! /bin/sh
#
# getxy: extract lat and long from usenet maps, to prepare a hostname file
#	for the "netmap" program.
#
#
# usage: cd /usr/local/lib/news/maps; cat {d,u}.[a-z]* | getxy > mapXYdata
#
#  Brian Reid, as part of netmap, August 1986
#	revised to cope with d.* files, April 1988
#
PATH=:/usr/local/bin:/usr/bin:/usr/ucb:/bin:

egrep '^#N|^#L|^#U|^$|^[0-9a-zA-Z]' $1 |\
	sed -e 's/	/ /g' \
	    -e '/^#N/s/,/ /g' |\
awk '
BEGIN {Nflag=0; Lfield=""; Ufield=""; ncount=0}
/^#N/ { Nflag=1
	Ufield="";
	Lfield="";
	if (NF>1) {
	   for (j=2; j<=NF; j++) {
		ncount++;
		names[ncount] = $j;
	   }
	}
       }

/^#L/ {if (NF>1) {
	Lfield="";
	for (i=2;i<=NF;i++) {
	    if ($i != "city") Lfield=Lfield " " $i;
	}
       }
      }
/^#U/ {if (NF>1) {
	if (length(Ufield)>128) {
	   for (j=1; j<=ncount; j++) {
	    printf "%-13s%-27s%s\n", names[j] " H",Lfield,Ufield
	   }
	   Ufield=""
	}
	for (i=2;i<=NF;i++) {Ufield=Ufield " " $i " U";}
       }
      }

/^#/  {next}

$2 == "=" {
	    if (ncount == 0) {next;}
	    for (j=1; j<=ncount; j++) {
	       if ($1 == names[j]) {
	           for (k=3; k<=NF; k++) {
		      thisField = $k
		      if (substr(thisField,length(thisField)-1,1)==",") {
		          thisField=substr(thisField,0,length(thisField)-1);
		      }
		      ncount++;
		      names[ncount] = thisField;
		      next;
		   }
	       }
	    }
	}

NF == 2 && $2 == names[1]	{
	if (Nflag == 0) next;
	ncount++;
	names[ncount] = $1
	next
	}


/^$/ {if (Nflag!=0) {
	for (j=1; j<=ncount; j++) {
	 printf "%-13s%-27s%s\n", names[j] " H",Lfield,Ufield
	}
      }
      Lfield=""; Ufield=""; name=""; Nflag = 0; ncount=0;
     }
' | sort -f +0 -1 | \
    sed -e 's/West/W/g' \
	-e 's/North/N/g' \
	-e 's/South/S/g' \
	-e 's/East/E/g' \
	-e 's/\([0-9]\)\([NSEW]\) /\1 \2 /g' \
	-e 's/ *(.*)//' \
	-e 's/,/ /g'  -e 's/://g' \
	-e 's/ \. / /g' \
	-e 's/\([0-9]\)\.\([0-9]\)/\1 \2/g' \
	-e 's/[Ll][Aa][Tt]\.*//g' \
	-e 's/[Ll][Oo][Nn][Gg]\.*//g' \
	-e 's/[Dd][Ee][Gg][Rr][Ee][Ee][Ss]//g' \
	-e 's/[Dd][Ee][Gg]//g' \
	-e 's/"//g' \
	-e 's|/| |g' \
	-e "s/\'/ /g" 
@


1.3
log
@Now looks for all names defined on the #N line, not just the first
@
text
@d21 1
@


1.2
log
@Too many recent changes; need a checkin.
@
text
@d19 1
a19 1
/^#N/ {Nflag=1
d21 6
a26 3
	ncount++;
	names[ncount] = $2;

@


1.1
log
@Initial revision
@
text
@d18 1
a18 1
BEGIN {Nflag=0; Lfield=""; Ufield=""}
d21 3
a23 9
	name = $2
	if (substr(name,0,1)==".") {
	    for (i=3;i<=NF;i++) {
		if (substr($i,0,1) != ".") {
		    name=$i;
		    break;
		}
	    }
	}
d31 1
a31 1
	}
d35 4
a38 2
	    printf "%-13s%-27s%s\n", name " H",Lfield,Ufield
	    Ufield=""
d46 18
a63 1
NF == 2 && $2 == name	{
d65 2
a66 2
	if (substr(name,0,1) != ".") next;
	name = $1;
d72 2
a73 3
	if (substr(name,0,1) != ".") {
	 
	 printf "%-13s%-27s%s\n", name " H",Lfield,Ufield
d76 1
a76 1
      Lfield=""; Ufield=""; name=""; Nflag = 0;
a78 1
    sed -e 's/38 53 40 5 N   77 04 34 5 W/38 53 40 N   77 04 34 W/' | \
@
