' Program to display John Snow's Data ' Based on data digitized by R. Dodson at NCGIA. ' W. Tobler 12/93, revised 1/9/93 ' I have randomized the sequence of cases. ' DECLARE SUB PlotSize (Xmin!, Xmax!, Ymin!, Ymax!) DECLARE FUNCTION MAX! (A!, B!) DECLARE FUNCTION MIN! (A!, B!) CLOSE CLS OPEN "I", 1, "STREETS" OPEN "I", 2, "DEATHS" OPEN "I", 3, "PUMPS" OPEN "I", 4, "TESNEDGE.DAT" Xmin = 3! Xmax = 20! Ymin = 3! Ymax = 20! CALL PlotSize(Xmin, Xmax, Ymin, Ymax) Radius = (Xmax - Xmin) / (300) COLOR 7 PRINT " The location of "; COLOR 5 PRINT "deaths"; COLOR 7 PRINT " from cholera"; PRINT ", London 1854, as mapped by Dr. John Snow." 'GOTO skip ' To test program; deactivate when done 'Read the streets COLOR 8 DO WHILE NOT EOF(1) INPUT #1, K, N FOR I = 1 TO N INPUT #1, X, Y IF I = 1 THEN PSET (X, Y) ELSE LINE -(X, Y) ' Solid line streets 'LINE -(X, Y), , , &H1111 ' Dotted line streets END IF NEXT I LOOP skip: 'Read the death locations 'GOTO skip2 ' To test program; deactivate when done RANDOMIZE TIMER ' Random time interval between cases Speed = 100 'A larger number (like 1000 or 5000) slows the display of 'the cholera cases allowing one to ponder the cause. '1 <= Slow% <= Speed M = 578 FOR I = 1 TO M Slow% = FIX(RND * Speed) + 1 FOR J = 1 TO Slow%: NEXT J INPUT #2, X, Y PSET (X, Y), 5 CIRCLE (X, Y), Radius, 5 NEXT I skip2: 'GOTO skip4 ' To test program; deactivate when done COLOR 7 PRINT " Look at this pattern, then press a key to see the location of the water"; COLOR 10 PRINT " pumps"; COLOR 7 PRINT "." DO WHILE INKEY$ = "": LOOP N = 13 Radius = 1.1 * Radius 'Read the pump coordinates. FOR I = 1 TO N INPUT #3, X, Y CIRCLE (X, Y), Radius, 10 PAINT (X, Y), 10, 10 NEXT I skip4: PRINT " Study, then press a key to see the Thiessen polygons around the pumps. " DO WHILE INKEY$ = "": LOOP COLOR 10 'Read and show the Thiessen polygon edges DO WHILE NOT EOF(4) INPUT #4, V, X, Y IF V = 0 THEN PSET (X, Y) ELSE LINE -(X, Y), , , &H1111 'Dotted line 'LINE -(X, Y) 'Solid line END IF LOOP COLOR 7 DO WHILE INKEY$ = "": LOOP CLOSE 4 OPEN "I", 4, "TESNEDGE.DAT" COLOR 0 'Read and erase the Thiessen polygon edges DO WHILE NOT EOF(4) INPUT #4, V, X, Y IF V = 0 THEN PSET (X, Y) ELSE LINE -(X, Y), , , &H1111 'Dotted line 'LINE -(X, Y) 'Solid line END IF LOOP DO WHILE INKEY$ = "": LOOP 'Erase the streets CLOSE 1 OPEN "I", 1, "STREETS" COLOR O DO WHILE NOT EOF(1) INPUT #1, K, N FOR I = 1 TO N INPUT #1, X, Y IF I = 1 THEN PSET (X, Y) ELSE LINE -(X, Y) ' Solid line streets 'LINE -(X, Y), , , &H1111 ' Dotted line streets END IF NEXT I LOOP DO WHILE INKEY$ = "": LOOP 'Erase the pumps, leaving the deaths 'Radius = Radius * 3.5 N = 13 CLOSE 3 OPEN "I", 3, "PUMPS" 'Read the pump coordinates. FOR I = 1 TO N INPUT #3, X, Y PAINT (X, Y), 0, 10 CIRCLE (X, Y), Radius, 0 PAINT (X, Y), 0, 0 NEXT I 'Fix a glitch Radius = Radius * 3.5 CIRCLE (8.8644161#, 12.75354#), Radius, 8 PAINT (8.8644161#, 12.75354#), 0, 8 CIRCLE (8.8644161#, 12.75354#), Radius, 0 CIRCLE (8.9994402#, 5.1010232#), Radius, 8 PAINT (8.9994402#, 5.1010232#), 0, 8 CIRCLE (8.9994402#, 5.1010232#), Radius, 0 DO WHILE INKEY$ = "": LOOP CLS CLOSE PRINT PRINT COLOR 10 PRINT " THANKS to Rusty Dodson for digitizing John Snow's map!" COLOR 7 PRINT PRINT PRINT " Source:" PRINT " Snow, J., 1936, Snow on Cholera ..., Oxford Univ. Press, London." PRINT PRINT " Program by Waldo Tobler" PRINT " National Center for Geographic Information and Analysis" PRINT " Department of Geography" PRINT " University of California" PRINT " Santa Barbara, CA 93106-4060" PRINT PRINT " tobler@geog.ucsb.edu" DO WHILE INKEY$ = "": LOOP COLOR 8 END FUNCTION MAX! (A, B) MAX! = A IF B > A THEN MAX! = B EXIT FUNCTION END FUNCTION FUNCTION MIN! (A, B) MIN! = A IF B < A THEN MIN! = B EXIT FUNCTION END FUNCTION SUB PlotSize (Xmin, Xmax, Ymin, Ymax) ' Size the data for a drawing SCREEN 9 Dx = Xmax - Xmin Dy = Ymax - Ymin Range = MAX!(Dx, Dy) Xmid = Xmin + Dx / 2 Ymid = Ymin + Dy / 2 Range = Range / 1.3 Xn = Xmid - Range Xx = Xmid + Range Yn = Ymid - .75 * Range Yx = Ymid + .75 * Range Yn = Yn + .1 * Range Yx = Yx + .1 * Range WINDOW (Xn, Yn)-(Xx, Yx) EXIT SUB END SUB