campbell@maynard.UUCP (Larry Campbell) (08/30/86)
Here's a little hack I wrote to draw the UUCP map on your screen (or plotter or whatever). It doesn't draw links -- just nodes -- but it's a fun demo when someone asks you what the net is and where it goes. #--------------------------------cut here----------------------------- #! /bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #! /bin/sh line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create: # README # uplot.c # uplot.sed # uplot.sh # Makefile # This archive created: Sat Aug 30 11:38:43 1986 export PATH; PATH=/bin:/usr/bin:$PATH if test -f 'README' then echo shar: "will not over-write existing file 'README'" else cat << \SHAR_EOF > 'README' The enclosed files are a crude little hack that extract geographical data from the UUCP map '#L' lines and draw a map, in plot(3) form, on the standard output. Only small modifications are required to map other parts of the world. This is very quick and dirty (if it was any good, I'd post it to mod.sources instead of net.sources). No allowance is made for the curvature of the earth, so the larger the area you plot, the worse it gets in terms of accuracy. The names and locations of cities that are plotted as reference points are wired in to the code. And the method for scanning the '#L' lines is very crude (it does, however, work for almost all the bizarre formats I've seen in the map). Oh -- color() is a VENIX-specific routine that sets the color for the output display. You can probably just remove the calls to it if you don't have one. Feel free to hack this -- I would appreciate receiving copies of improved versions. It makes a nifty little demo when you're trying to explain the net to someone. -- Larry Campbell The Boston Software Works, Inc. ARPA: campbell%maynard.uucp@harvard.ARPA 120 Fulton Street, Boston MA 02109 UUCP: {alliant,wjh12}!maynard!campbell (617) 367-6846 SHAR_EOF fi if test -f 'uplot.c' then echo shar: "will not over-write existing file 'uplot.c'" else cat << \SHAR_EOF > 'uplot.c' /* * uplot.c * * Crude hack for drawing a map of the UUCP net - reads on standard * input a highly massaged version of the '#L' lines from the UUCP map, * processed by uplot.sed and sorted, and writes plot(3) instructions * on standard output. * * Released to the public domain August, 1986. * Larry Campbell (maynard!campbell) * The Boston Software Works, Inc. * 120 Fulton Street, Boston, MA 02109 */ #include <stdio.h> /* These defines set the bounds of the rectangle being drawn */ #define MINLAT 25 #define MAXLAT 50 #define MINLON (-125) #define MAXLON (-60) struct { int deg; int min; } lat, lon; int n, x, y, lastx, lasty, weight, col, maxweight, goodpoints, badpoints, outpoints, uniques, debug; char buf[256]; main(argc, argv) char *argv[]; { if (argc > 1) debug++; openpl(); erase(); space(MINLON*60, MINLAT*60, (MAXLON-30)*60, MAXLAT*60); city("Boston", 42, - 71); city("Chicago", 42, - 88); city("Dallas", 33, - 97); city("DC", 39, - 77); city("Denver", 40, -105); city("Houston", 30, - 95); city("LA", 34, -118); city("Miami", 26, - 80); city("NYC", 41, - 74); city("SF", 38, -122); city("Seattle", 47, -123); city("Toronto", 43, - 79); city("Vancouver", 49, -124); lastx = lasty = 0; while (gets(buf) != NULL) { n = sscanf(buf, "%d %d N / %d %d W", &lat.deg, &lat.min, &lon.deg, &lon.min); if (n != 4) n = sscanf(buf, "%d %d %*d N / %d %d %*d W", &lat.deg, &lat.min, &lon.deg, &lon.min); if (n != 4) n = sscanf(buf, "%d %d N %d %d W", &lat.deg, &lat.min, &lon.deg, &lon.min); if (n != 4) n = sscanf(buf, "%d %d %*d N %d %d %*d W", &lat.deg, &lat.min, &lon.deg, &lon.min); if (n != 4) n = sscanf(buf, "%d %d %*d %*d N / %d %d %*d %*d W", &lat.deg, &lat.min, &lon.deg, &lon.min); if (n != 4) n = sscanf(buf, "%d %d W / %d %d N", &lon.deg, &lon.min, &lat.deg, &lat.min); if (n != 4) n = sscanf(buf, "%d %d %*d W / %d %d %*d N", &lon.deg, &lon.min, &lat.deg, &lat.min); if (n != 4) n = sscanf(buf, "%d %d W %d %d N", &lon.deg, &lon.min, &lat.deg, &lat.min); if (n != 4) n = sscanf(buf, "%d %d %*d W %d %d %*d N", &lon.deg, &lon.min, &lat.deg, &lat.min); if (n != 4) n = sscanf(buf, "%d %d %*d %*d W / %d %d %*d %*d N", &lon.deg, &lon.min, &lat.deg, &lat.min); if (n != 4) { n = sscanf(buf, "%d N / %d W", &lat.deg, &lon.deg) + 2; lat.min = lon.min = 0; } if (n != 4) { n = sscanf(buf, "%d W / %d N", &lon.deg, &lat.deg) + 2; lat.min = lon.min = 0; } if (n != 4) { badpoints++; if (debug) printf("bad: %s\n", buf); } else { goodpoints++; lon.deg = -lon.deg; lon.min = -lon.min; if (lat.deg >= MAXLAT || lat.deg < MINLAT || lon.deg >= MAXLON || lon.deg < MINLON) { outpoints++; continue; } x = lon.deg * 60 + lon.min; y = lat.deg * 60 + lat.min; if (x == lastx && y == lasty) weight++; else { uniques++; if (weight > maxweight) maxweight = weight; switch (weight) { case 0: col = 1; break; case 1: col = 2; break; default: col = 3; break; } if (debug) printf("lastx = %d, lasty = %d, weight = %d, color = %d\n", lastx, lasty, weight, col); if (lastx && lasty) { color(col); point(lastx, lasty); } weight = 0; lastx = x; lasty = y; } } } printf("Good: %d, bad: %d, out of range: %d, max: %d, uniques: %d\n", goodpoints, badpoints, outpoints, maxweight, uniques); } city(s, lat, lon) char *s; int lat, lon; { char buf[80]; if (lat < MINLAT || lat >= MAXLAT) return; if (lon < MINLON || lon >= MAXLON) return; color(2); move(lon*60, lat*60); sprintf(buf, ".%s", s); label(buf); } SHAR_EOF fi if test -f 'uplot.sed' then echo shar: "will not over-write existing file 'uplot.sed'" else cat << \SHAR_EOF > 'uplot.sed' s/^.*:#L// s/ / /g s/[Ll]at./ /g s/[Ll]at/ /g s/[Ll]ong./ /g s/[Ll]ong/ /g s/[Ll]on./ /g s/[Ll]on/ /g s/[Dd]eg./ /g s/[Dd]eg/ /g s/'/ /g s/"/ /g s/:/ /g s/\./ /g s/ / /g s/ / /g s/ / /g s/ / /g s/^ //g s/ $//g s/[Cc]ity$// s/(.*)$// s/West/W/ s/East/E/ s/North/N/ s/South/S/ s/o //g s| x | / | s|,|/| s|N/|N /| s/ / /g s/ / /g /^$/d SHAR_EOF fi if test -f 'uplot.sh' then echo shar: "will not over-write existing file 'uplot.sh'" else cat << \SHAR_EOF > 'uplot.sh' : plot uucp map on graphics gizmo MAPDIR=/usr/lib/uucp/map grep '^#L' $MAPDIR/u.usa.* | sed -f uplot.sed | sort | uplot SHAR_EOF fi if test -f 'Makefile' then echo shar: "will not over-write existing file 'Makefile'" else cat << \SHAR_EOF > 'Makefile' # # Makefile for compiling uplot on a DEC Rainbow running VENIX/86 # For other machines you will likely want LDFLAGS = -lplot, or something # CFLAGS = -z -i LDFLAGS= -ltrb SHARFILES = README uplot.c uplot.sed uplot.sh Makefile uplot: uplot.c cc -o uplot $(CFLAGS) uplot.c $(LDFLAGS) uplot.shar: $(SHARFILES) shar $(SHARFILES) >uplot.shar SHAR_EOF fi exit 0 # End of shell archive -- Larry Campbell The Boston Software Works, Inc. ARPA: campbell%maynard.uucp@harvard.ARPA 120 Fulton Street, Boston MA 02109 UUCP: {alliant,wjh12}!maynard!campbell (617) 367-6846