#lang planet dyoo/whalesong (require (planet dyoo/whalesong/web-world) (planet dyoo/whalesong/resource)) (provide (all-defined-out)) ;loc : string, string, number, number, number, adjacency list, (list-of number) (define-struct loc (name desc latitude longitude radius neighbors distances) #:transparent #:mutable) ;Stores the name, description, and geographic information of a location, including its visitation radius in meters, neighbors, and the distances in meters to those neighbors. Every location will have a unique, unambiguous name. ;loc-list : (list-of loc) ;loc-list provides a complete list of all the locations your program will use to find paths. (define loc-list (shared ( [The-John-Hay-Library (make-loc "The John Hay Library" "" 41.826372 -71.404703 15 (list The-Rock -X-Waterman/Prospect Van-Wickle-Gates) '(72.71998611964297 59.120786574188585 33.25298999234115))] [The-Rock (make-loc "The Rock" "" 41.825721 -71.404776 10 (list The-John-Hay-Library Van-Wickle-Gates -X-George/Prospect) '(72.71998611964297 48.77452257696725 55.01289288338534))] [The-SciLi (make-loc "The SciLi" "" 41.826800 -71.400094 10 (list One-One-Half America-One Soldiers-Arch -X-Manning/Brook -X-Waterman/Thayer) '(32.303977834684716 31.716490600104866 59.49039226842107 81.64784633906564 64.35514957067745))] [The-John-Carter-Brown-Library (make-loc "The John Carter Brown Library" "" 41.825536 -71.402681 10 (list University-Hall-North University-Hall-South Sayles-South -X-George/Brown) '(114.92405949603616 86.26946117830566 53.875726103390726 21.6267202406739))] [Andrews (make-loc "Andrews" "" 41.830352 -71.402459 20 (list Pembroke-Green The-Gate -X-Cushing/Brown) '(65.88057782727354 57.74451147076715 112.15195631224834))] [New-Pembroke (make-loc "New Pembroke" "" 41.830194 -71.401500 15 (list The-Gate -X-E-Cushing/Thayer) '(57.741069089362846 54.60688717990448))] [Hope (make-loc "Hope" "" 41.826629 -71.403693 15 (list Van-Wickle-Gates University-Hall-North Sayles-North Sayles-South The-Brown-Bear Bridge-Prop) '(88.855377852582 33.634229296340905 74.41330507989244 99.31284396974198 75.03412172201271 37.31930980125209))] [Littlefield (make-loc "Littlefield" "" 41.825631 -71.402075 15 (list Marcus-Aurelius/Lincoln-Field -X-George/Brown The-Ratty -X-George/Thayer) '(67.75028008825912 58.706552274155584 87.653111949852915 143.79732433775175))] [Wayland (make-loc "Wayland" "" 41.825018 -71.402202 10 (list Caesar/Wriston The-Ratty -X-George/Brown -X-Benevolent/Brown) '(68.63726165817734 88.87134661808724 52.807645610602336 62.91325558890378))] [Patriots-Court (make-loc "Patriot's Court" "" 41.824369 -71.400639 15 (list Caesar/Wriston The-Ratty -X-Charlesfield/Thayer) '(96.29849378678104 105.10839258369845 66.15854023011751))] [Keeney (make-loc "Keeney" "" 41.824492 -71.403075 10 (list -X-Benevolent/Magee -X-Benevolent/Brown) '(79.51700830912155 32.61020669452627))] [Grad-Center (make-loc "Grad Center" "" 41.823375 -71.400261 15 (list Josiahs -X-Charlesfield/Thayer) '(69.7704722925973 59.57137853315766))] [The-Ratty (make-loc "The Ratty" "" 41.825227 -71.401168 10 (list Wayland Caesar/Wriston Patriots-Court Littlefield -X-George/Brown -X-George/Thayer) '(88.87134661808724 27.156578620482364 105.10839258369845 87.65311949852915 125.00149170344949 75.8993352556833))] [The-V-Dub (make-loc "The V-Dub" "" 41.829272 -71.401675 10 (list Pembroke-Steps Walkway-Meeting -X-Meeting/Brown -X-Meeting/Thayer) '(59.502595527906976 29.895843885619204 144.63229419933333 77.55904294426057))] [The-Gate (make-loc "The Gate" "" 41.829914 -71.402086 10 (list Andrews Pembroke-Steps New-Pembroke Pembroke-Green -X-E-Cushing/Thayer) '(57.74451147076715 74.0583950854029 57.741069089362846 32.30864878864742 100.19269715947857))] [Josiahs (make-loc "Josiah's" "" 41.823419 -71.399422 15 (list Grad-Center -X-Charlesfield/Thayer) '(69.7704722925973 80.55986637273925))] [Marcus-Aurelius/Lincoln-Field (make-loc "Marcus Aurelius/Lincoln Field" "" 41.826236 -71.401986 25 (list Soldiers-Arch Sayles-North Sayles-South Littlefield) '(123.79955337951263 75.84744466687357 75.01243007712452 67.75028008825912))] [Caesar/Wriston (make-loc "Caesar/Wriston" "" 41.825038 -71.401375 20 (list Wayland The-Ratty Patriots-Court) '(68.63726165817734 27.156578620482364 96.29849378678104))] [The-Brown-Bear (make-loc "The Brown Bear" "" 41.826653 -71.402789 15 (list Hope University-Hall-North University-Hall-South Sayles-North Bridge-Prop Blue-Room/Shearer-Memorial-Fountain -X-Waterman/Brown) '(75.03412172201271 69.80631394787545 107.0625995449227 37.173230377495734 41.78597282377014 17.06260401659125 45.900479018813236))] [Bridge-Prop (make-loc "Bridge Prop" "" 41.826528 -71.403264 15 (list University-Hall-North University-Hall-South Sayles-North Sayles-South Hope The-Brown-Bear -X-Waterman/Brown) '(29.309499630959056 74.85604560122913 38.050477790785344 68.09497294604977 37.31930980125209 41.78597282377014 60.82266674895339))] [One-One-Half (make-loc "1 1/2" "" 41.826514 -71.400028 10 (list The-SciLi America-One Soldiers-Arch -X-Manning/Brook) '(32.303977834684716 39.15782008649647 42.924705649797716 69.19104371332907))] [America-One (make-loc "America One" "" 41.826776 -71.399713 10 (list The-SciLi One-One-Half -X-Manning/Brook) '(31.716490600104866 39.15782008649647 52.696358893752))] [Blue-Room/Shearer-Memorial-Fountain (make-loc "Blue Room/Shearer Memorial Fountain" "" 41.826708 -71.402597 15 (list The-Brown-Bear) '(17.06260401659125))] [List-Art (make-loc "List Art" "" 41.826150 -71.405392 15 (list Van-Wickle-Gates) '(73.45653741287393))] [Pembroke-Green (make-loc "Pembroke Green" "" 41.829761 -71.402417 20 (list Pembroke-Steps Andrews The-Gate -X-Cushing/Brown -X-E-Cushing/Thayer) '(52.58257524564202 65.88057782727354 32.30864878864742 87.33427925333616 130.1477670842218))] [Pembroke-Steps (make-loc "Pembroke Steps" "" 41.829289 -71.402392 10 (list Pembroke-Green The-V-Dub Walkway-Meeting -X-Meeting/Brown -X-Meeting/Thayer The-Gate) '(52.58257524564202 59.502595527906976 47.670729675707435 88.36556950147244 136.7528882708475 74.0583950854029))] [University-Hall-North (make-loc "University Hall North" "" 41.826353 -71.403528 10 (list University-Hall-South Sayles-North Sayles-South Van-Wickle-Gates The-John-Carter-Brown-Library Bridge-Prop Hope The-Brown-Bear -X-George/Brown -X-Waterman/Brown) '(50.41862161224331 52.82961779522876 69.18810253807376 85.63855305034724 114.92405949603616 29.309499630959056 33.634229296340905 69.80631394787545 133.29107238723824 87.99178297484156))] [University-Hall-South (make-loc "University Hall South" "" 41.825903 -71.403597 10 (list University-Hall-North Sayles-North Sayles-South Van-Wickle-Gates The-John-Carter-Brown-Library Bridge-Prop The-Brown-Bear -X-George/Brown -X-Waterman/Brown) '(50.41862161224331 75.22052993800988 64.15823445185605 79.03555821205534 86.26946117830566 74.85604560122913 107.0625995449227 99.25287240478349 135.67870033686583))] [Sayles-North (make-loc "Sayles North" "" 41.826328 -71.402892 10 (list University-Hall-North University-Hall-South Sayles-South Marcus-Aurelius/Lincoln-Field Soldiers-Arch Bridge-Prop Hope The-Brown-Bear -X-Waterman/Brown) '(52.82961779522876 75.22052993800988 36.143851453421405 75.84744466687357 198.2018385084939 38.050477790785344 74.41330507989244 37.173230377495734 79.26536093325699))] [Sayles-South (make-loc "Sayles South" "" 41.826006 -71.402836 10 (list Hope University-Hall-North University-Hall-South Sayles-North Marcus-Aurelius/Lincoln-Field Soldiers-Arch The-John-Carter-Brown-Library Bridge-Prop -X-George/Brown) '(99.31284396974198 69.18810253807376 64.15823445185605 36.143851453421405 75.01243007712452 197.51662911805107 53.875726103390726 68.09497294604977 75.23221162277233))] [Soldiers-Arch (make-loc "Soldiers Arch" "" 41.826361 -71.400503 20 (list One-One-Half The-SciLi Marcus-Aurelius/Lincoln-Field Sayles-North Sayles-South -X-Manning/Brook -X-Waterman/Thayer -X-George/Thayer) '(42.924705649797716 59.49039226842107 123.79955337951263 198.2018385084939 197.51662911805107 109.7260766989915 101.4614643071495 93.62571507166797))] [-X-Manning/Brook (make-loc "-X-Manning/Brook" "" 41.826503 -71.399194 15 (list One-One-Half America-One The-SciLi Soldiers-Arch -X-Waterman/Brook -X-George/Brook) ' (69.19104371332907 52.696358893752 81.64784633906564 109.7260766989915 96.05347603526972 98.50283034565801))] [Walkway-Waterman (make-loc "Walkway(Waterman)" "" 41.827164 -71.401753 15 (list Walkway-Angel -X-Waterman/Brown -X-Waterman/Thayer) '(89.55512188423202 103.92130403309416 101.16807102875146))] [Walkway-Angel (make-loc "Walkway(Angel)" "" 41.827967 -71.401819 15 (list Walkway-Waterman Walkway-Olive -X-Angel/Brown -X-Angel/Thayer) '(89.55512188423202 53.679127996574586 111.72826606039511 99.18870807085621))] [Walkway-Olive (make-loc "Walkway(Olive)" "" 41.828447 -71.401881 15 (list Walkway-Angel Walkway-Meeting -X-Olive/Brown -X-Olive/Thayer) '(53.679127996574586 68.70688829013555 113.51581756134485 98.95630964573525))] [Walkway-Meeting (make-loc "Walkway(Meeting)" "" 41.829064 -71.401903 15 (list The-V-Dub Walkway-Olive Pembroke-Steps -X-Meeting/Brown -X-Meeting/Thayer) '(29.895843885619204 68.70688829013555 47.670729675707435 122.42992129723945 95.93668182003772))] [-X-Cushing/Brown (make-loc "-X-Cushing/Brown" "" 41.829678 -71.403464 15 (list Andrews Pembroke-Green -X-Meeting/Brown) '(112.15195631224834 87.33427925333616 77.71679213857283))] [-X-E-Cushing/Thayer (make-loc "-X-E-Cushing/Thayer" "" 41.830017 -71.400886 15 (list The-Gate Pembroke-Green New-Pembroke -X-Meeting/Thayer) '(100.19269715947857 130.1477670842218 54.60688717990448 96.47682329081638))] [-X-Meeting/Brown (make-loc "-X-Meeting/Brown" "" 41.828983 -71.403375 15 (list The-V-Dub Pembroke-Steps Walkway-Meeting -X-Meeting/Thayer -X-Cushing/Brown -X-Olive/Brown) '(144.63229419933333 88.36556950147244 122.42992129723945 218.33686385221588 77.71679213857283 78.14680922130171))] [-X-Meeting/Thayer (make-loc "-X-Meeting/Thayer" "" 41.829156 -71.400753 15 (list The-V-Dub Pembroke-Steps Walkway-Meeting -X-Meeting/Brown -X-E-Cushing/Thayer -X-Olive/Thayer) '(77.55904294426057 136.7528882708475 95.93668182003772 218.33686385221588 96.47682329081638 66.9515873543481))] [-X-Olive/Brown (make-loc "-X-Olive/Brown" "" 41.828289 -71.403233 15 (list Walkway-Olive -X-Olive/Thayer -X-Meeting/Brown -X-Angel/Brown) '(113.51581756134485 212.44398812194956 78.14680922130171 48.37932173696138))] [-X-Olive/Thayer (make-loc "-X-Olive/Thayer" "" 41.828556 -71.400697 15 (list Walkway-Olive -X-Olive/Brown -X-Meeting/Thayer -X-Angel/Thayer) '(98.95630964573525 212.44398812194956 66.9515873543481 51.34446888023945))] [-X-Angel/Prospect (make-loc "-X-Angel/Prospect" "" 41.827719 -71.404789 15 (list -X-Angel/Brown -X-Waterman/Prospect) '(136.1705250531015 91.2127048864669))] [-X-Angel/Brown (make-loc "-X-Angel/Brown" "" 41.827858 -71.403158 15 (list Walkway-Angel -X-Angel/Prospect -X-Angel/Thayer -X-Olive/Brown -X-Waterman/Brown) '(111.72826606039511 136.1705250531015 210.8797948644964 48.37932173696138 92.5083428730047))] [-X-Angel/Thayer (make-loc "-X-Angel/Thayer" "" 41.828097 -71.400636 15 (list Walkway-Angel -X-Angel/Brown -X-Angel/Brook -X-Olive/Thayer -X-Waterman/Thayer) '(99.18870807085621 210.8797948644964 100.75441304355273 51.34446888023945 92.16701103012558))] [-X-Angel/Brook (make-loc "-X-Angel/Brook" "" 41.828211 -71.399431 15 (list -X-Angel/Thayer -X-Waterman/Brook) '(100.75441304355273 95.09087315308366))] [Van-Wickle-Gates (make-loc "Van Wickle Gates" "" 41.826111 -71.404508 15 (list Hope The-Rock The-John-Hay-Library List-Art University-Hall-North University-Hall-South -X-Waterman/Prospect -X-George/Prospect) '(88.855377852582 48.77452257696725 33.25298999234115 73.45653741287393 85.63855305034724 79.03555821205534 89.43242074658055 93.95295042057707))] [-X-Waterman/Prospect (make-loc "-X-Waterman/Prospect" "" 41.826903 -71.404689 15 (list The-John-Hay-Library Van-Wickle-Gates -X-Angel/Prospect -X-Waterman/Brown) '(59.120786574188585 89.43242074658055 91.2127048864669 141.37639878498283))] [-X-Waterman/Brown (make-loc "-X-Waterman/Brown" "" 41.827036 -71.402994 15 (list Bridge-Prop Walkway-Waterman University-Hall-North University-Hall-South Sayles-North The-Brown-Bear -X-Waterman/Prospect -X-Waterman/Thayer -X-Angel/Brown) '(60.82266674895339 103.92130403309416 87.99178297484156 135.67870033686583 79.26536093325699 45.900479018813236 141.37639878498283 205.08068548810783 92.5083428730047))] [-X-Waterman/Thayer (make-loc "-X-Waterman/Thayer" "" 41.827272 -71.400542 15 (list The-SciLi Walkway-Waterman -X-Waterman/Brown -X-Waterman/Brook -X-Angel/Thayer Soldiers-Arch) '(64.35514957067745 101.16807102875146 205.08068548810783 102.09416782607381 92.16701103012558 101.4614643071495))] [-X-Waterman/Brook (make-loc "-X-Waterman/Brook" "" 41.827361 -71.399317 15 (list -X-Waterman/Thayer -X-Angel/Brook -X-Manning/Brook) '(102.09416782607381 95.09087315308366 96.05347603526972))] [-X-George/Prospect (make-loc "-X-George/Prospect" "" 41.825267 -71.404514 15 (list The-Rock Van-Wickle-Gates -X-George/Brown -X-Benevolent/Magee) '(55.01289288338534 93.95295042057707 153.4386291990271 87.5354646848045))] [-X-George/Brown (make-loc "-X-George/Brown" "" 41.825342 -71.402667 15 (list Wayland The-John-Carter-Brown-Library Littlefield The-Ratty University-Hall-North University-Hall-South Sayles-South -X-George/Prospect -X-George/Thayer -X-Benevolent/Brown) '(52.807645610602336 21.6267202406739 58.706552274155584 125.00149170344949 133.29107238723824 99.25287240478349 75.23221162277233 153.4386291990271 193.55756936303933 83.00094838708665))] [-X-George/Thayer (make-loc "-X-George/Thayer" "" 41.825528 -71.400347 15 (list The-Ratty Littlefield -X-George/Brown -X-George/Brook Soldiers-Arch -X-Benevolent/Thayer) '(75.8993352556833 143.79732433775175 193.55756936303933 110.88512519345545 93.62571507166797 83.32066694887799))] [-X-George/Brook (make-loc "-X-George/Brook" "" 41.825628 -71.399017 15 (list -X-George/Thayer -X-Manning/Brook -X-Benevolent/Brook) '(110.88512519345545 98.50283034565801 82.65125344244677))] [-X-Benevolent/Magee (make-loc "-X-Benevolent/Magee" "" 41.824569 -71.404028 15 (list Keeney -X-Benevolent/Brown -X-George/Prospect) '(79.51700830912155 109.54149977807499 87.5354646848045))] [-X-Benevolent/Brown (make-loc "-X-Benevolent/Brown" "" 41.824597 -71.402708 15 (list Keeney Wayland -X-Benevolent/Magee -X-George/Brown -X-Charlesfield/Brown) '(32.61020669452627 62.91325558890378 109.54149977807499 83.00094838708665 94.94028921892416))] [-X-Benevolent/Thayer (make-loc "-X-Benevolent/Thayer" "" 41.824783 -71.400250 15 (list -X-Benevolent/Brook -X-George/Thayer -X-Charlesfield/Thayer) '(105.88874477129403 83.32066694887799 98.35289334413264))] [-X-Benevolent/Brook (make-loc "-X-Benevolent/Brook" "" 41.824886 -71.398981 15 (list -X-Benevolent/Thayer -X-George/Brook -X-Charlesfield/Brook) '(105.88874477129403 82.65125344244677 101.4574853500092))] [-X-Charlesfield/Brown (make-loc "-X-Charlesfield/Brown" "" 41.823747 -71.402614 15 (list -X-Charlesfield/Thayer -X-Benevolent/Brown) '(205.62938641336245 94.94028921892416))] [-X-Charlesfield/Thayer (make-loc "-X-Charlesfield/Thayer" "" 41.823903 -71.400144 15 (list Josiahs Grad-Center Patriots-Court -X-Charlesfield/Brown -X-Charlesfield/Brook -X-Benevolent/Thayer) '(80.55986637273925 59.57137853315766 66.15854023011751 205.62938641336245 108.84966017576355 98.35289334413264))] [-X-Charlesfield/Brook (make-loc "-X-Charlesfield/Brook" "" 41.823981 -71.398836 15 (list -X-Charlesfield/Thayer -X-Benevolent/Brook) '(108.84966017576355 101.4574853500092))]) (list The-John-Hay-Library The-Rock The-SciLi The-John-Carter-Brown-Library Andrews New-Pembroke Hope Littlefield Wayland Patriots-Court Keeney Grad-Center The-Ratty The-V-Dub The-Gate Josiahs Marcus-Aurelius/Lincoln-Field Caesar/Wriston The-Brown-Bear Bridge-Prop One-One-Half America-One Blue-Room/Shearer-Memorial-Fountain List-Art Pembroke-Green Pembroke-Steps University-Hall-North University-Hall-South Sayles-North Sayles-South Soldiers-Arch -X-Manning/Brook Walkway-Waterman Walkway-Angel Walkway-Olive Walkway-Meeting -X-Cushing/Brown -X-E-Cushing/Thayer -X-Meeting/Brown -X-Meeting/Thayer -X-Olive/Brown -X-Olive/Thayer -X-Angel/Prospect -X-Angel/Brown -X-Angel/Thayer -X-Angel/Brook Van-Wickle-Gates -X-Waterman/Prospect -X-Waterman/Brown -X-Waterman/Thayer -X-Waterman/Brook -X-George/Prospect -X-George/Brown -X-George/Thayer -X-George/Brook -X-Benevolent/Magee -X-Benevolent/Brown -X-Benevolent/Thayer -X-Benevolent/Brook -X-Charlesfield/Brown -X-Charlesfield/Thayer -X-Charlesfield/Brook))) ;tour-dist : number, number, number, number -> number ;Given the latitude and longitude of two locations, returns the approximate distance in meters between them. Note that the argument order is latitude1, longitude1, latitude2, longitude2. (define (tour-dist latA lonA latB lonB) (unless (number? latA) (raise-type-error 'tour-dist 'number latA)) (* 6378000 (* 2 (asin (min 1 (sqrt (+ (expt (sin (/ (- (deg->rad latA) (deg->rad latB)) 2)) 2) (* (cos (deg->rad latA)) (cos (deg->rad latB)) (expt (sin (/ (- (deg->rad lonA) (deg->rad lonB)) 2)) 2))))))))) (define (deg->rad angle) (* angle (/ pi 180))) ;tour-head : number, number, number, number -> string ;Given the latitude and longitude of two locations as above, returns the approximate heading of the path from the first location to the second asa string such as "North" or "Southwest." (define (get-dir-string latA lonA latB lonB) (local [(define angle (direction latA lonA latB lonB))] (cond [(or (> (/ pi 8) angle) (< (* 1.875 pi) angle)) "North"] [(> (* 3 (/ pi 8)) angle) "North-East"] [(> (* 5 (/ pi 8)) angle) "East"] [(> (* 7 (/ pi 8)) angle) "South-East"] [(> (* 9 (/ pi 8)) angle ) "South"] [(> (* 11 (/ pi 8)) angle ) "South-West"] [(> (* 13 (/ pi 8)) angle ) "West"] [(> (* 15 (/ pi 8)) angle ) "North-West"]))) (define (ext-modulo num1 num2) (- num1 (* num2 (floor (/ num1 num2))))) (define (direction latA lonA latB lonB) (cond [(= (cos (deg->rad latA)) 0) (if (latA > 0) pi (* 2 pi))] [(and (= latA latB) (= lonA lonB)) -1] [else (ext-modulo (+ pi (atan (* (sin (- (deg->rad lonB) (deg->rad lonA))) (cos (deg->rad latB))) (- (* (cos (deg->rad latA)) (sin (deg->rad latB))) (* (sin (deg->rad latA)) (cos (deg->rad latB)) (cos (- (deg->rad lonB) (deg->rad lonA))))))) (* 2 pi))])) ;tour : string, (list-of string) (define-struct tour (name stops) #:transparent) ;Stores the name of a tour (which your program will need to display) and its stops. ;create-tour : name, (list-of string) -> tour ;takes a name and a list of loc-names and returns a tour with that name and those locations (define create-tour make-tour) ;tours : (list-of tour) (define tours (list (create-tour "Library Tour" (list "The John Hay Library" "The Rock" "The SciLi" "The John Carter Brown Library")) (create-tour "Housing Tour" (list "Andrews" "New Pembroke" "Hope" "Littlefield" "Wayland" "Caesar/Wriston" "Patriot's Court" "Keeney" "Grad Center")) (create-tour "Dining Tour" (list "The Ratty" "The V-Dub" "The Gate" "Josiah's" "Blue Room/Shearer Memorial Fountain")) (create-tour "Campus Art Tour" (list "Marcus Aurelius/Lincoln Field" "Caesar/Wriston" "The Brown Bear" "Bridge Prop" "1 1/2" "America One" "Blue Room/Shearer Memorial Fountain" "List Art"))))