#lang plai-typed (require [typed-in racket (asin : (number -> number)) (sqrt : (number -> number)) (expt : (number number -> number)) (sin : (number -> number)) (cos : (number -> number)) (pi : number)]) ;Loc represents a location on a map. ;It stores the name, geographic information, neighbors, ;and the distances in meters to those neighbors. ;Every location will have a unique, unambiguous name. (define-type Loc [loc (name : string) (latitude : number) (longitude : number) (neighbors : (listof Loc)) (distances : (listof number))]) ;Tour ;Stores the name of a tour and a list of its stops' names. (define-type Tour [tour (name : string) (stops : (listof string))]) ;loc-list provides a complete list of all the locations your program will use to find paths. (define loc-list : (listof Loc) (shared ( [The-John-Hay-Library (loc "The John Hay Library" 41.826372 -71.404703 (list The-Rock -X-Waterman/Prospect Van-Wickle-Gates) (list 72.71998611964297 59.120786574188585 33.25298999234115))] [The-Rock (loc "The Rock" 41.825721 -71.404776 (list The-John-Hay-Library Van-Wickle-Gates -X-George/Prospect) (list 72.71998611964297 48.77452257696725 55.01289288338534))] [The-SciLi (loc "The SciLi" 41.826800 -71.400094 (list One-One-Half America-One Soldiers-Arch -X-Manning/Brook -X-Waterman/Thayer) (list 32.303977834684716 31.716490600104866 59.49039226842107 81.64784633906564 64.35514957067745))] [The-John-Carter-Brown-Library (loc "The John Carter Brown Library" 41.825536 -71.402681 (list University-Hall-North University-Hall-South Sayles-South -X-George/Brown) (list 114.92405949603616 86.26946117830566 53.875726103390726 21.6267202406739))] [Andrews (loc "Andrews" 41.830352 -71.402459 (list Pembroke-Green The-Gate -X-Cushing/Brown) (list 65.88057782727354 57.74451147076715 112.15195631224834))] [New-Pembroke (loc "New Pembroke" 41.830194 -71.401500 (list The-Gate -X-E-Cushing/Thayer) (list 57.741069089362846 54.60688717990448))] [Hope (loc "Hope" 41.826629 -71.403693 (list Van-Wickle-Gates University-Hall-North Sayles-North Sayles-South The-Brown-Bear Bridge-Prop) (list 88.855377852582 33.634229296340905 74.41330507989244 99.31284396974198 75.03412172201271 37.31930980125209))] [Littlefield (loc "Littlefield" 41.825631 -71.402075 (list Marcus-Aurelius/Lincoln-Field -X-George/Brown The-Ratty -X-George/Thayer) (list 67.75028008825912 58.706552274155584 87.653111949852915 143.79732433775175))] [Wayland (loc "Wayland" 41.825018 -71.402202 (list Caesar/Wriston The-Ratty -X-George/Brown -X-Benevolent/Brown) (list 68.63726165817734 88.87134661808724 52.807645610602336 62.91325558890378))] [Patriots-Court (loc "Patriot's Court" 41.824369 -71.400639 (list Caesar/Wriston The-Ratty -X-Charlesfield/Thayer) (list 96.29849378678104 105.10839258369845 66.15854023011751))] [Keeney (loc "Keeney" 41.824492 -71.403075 (list -X-Benevolent/Magee -X-Benevolent/Brown) (list 79.51700830912155 32.61020669452627))] [Grad-Center (loc "Grad Center" 41.823375 -71.400261 (list Josiahs -X-Charlesfield/Thayer) (list 69.7704722925973 59.57137853315766))] [The-Ratty (loc "The Ratty" 41.825227 -71.401168 (list Wayland Caesar/Wriston Patriots-Court Littlefield -X-George/Brown -X-George/Thayer) (list 88.87134661808724 27.156578620482364 105.10839258369845 87.65311949852915 125.00149170344949 75.8993352556833))] [The-V-Dub (loc "The V-Dub" 41.829272 -71.401675 (list Pembroke-Steps Walkway-Meeting -X-Meeting/Brown -X-Meeting/Thayer) (list 59.502595527906976 29.895843885619204 144.63229419933333 77.55904294426057))] [The-Gate (loc "The Gate" 41.829914 -71.402086 (list Andrews Pembroke-Steps New-Pembroke Pembroke-Green -X-E-Cushing/Thayer) (list 57.74451147076715 74.0583950854029 57.741069089362846 32.30864878864742 100.19269715947857))] [Josiahs (loc "Josiah's" 41.823419 -71.399422 (list Grad-Center -X-Charlesfield/Thayer) (list 69.7704722925973 80.55986637273925))] [Marcus-Aurelius/Lincoln-Field (loc "Marcus Aurelius/Lincoln Field" 41.826236 -71.401986 (list Soldiers-Arch Sayles-North Sayles-South Littlefield) (list 123.79955337951263 75.84744466687357 75.01243007712452 67.75028008825912))] [Caesar/Wriston (loc "Caesar/Wriston" 41.825038 -71.401375 (list Wayland The-Ratty Patriots-Court) (list 68.63726165817734 27.156578620482364 96.29849378678104))] [The-Brown-Bear (loc "The Brown Bear" 41.826653 -71.402789 (list Hope University-Hall-North University-Hall-South Sayles-North Bridge-Prop Blue-Room/Shearer-Memorial-Fountain -X-Waterman/Brown) (list 75.03412172201271 69.80631394787545 107.0625995449227 37.173230377495734 41.78597282377014 17.06260401659125 45.900479018813236))] [Bridge-Prop (loc "Bridge Prop" 41.826528 -71.403264 (list University-Hall-North University-Hall-South Sayles-North Sayles-South Hope The-Brown-Bear -X-Waterman/Brown) (list 29.309499630959056 74.85604560122913 38.050477790785344 68.09497294604977 37.31930980125209 41.78597282377014 60.82266674895339))] [One-One-Half (loc "1 1/2" 41.826514 -71.400028 (list The-SciLi America-One Soldiers-Arch -X-Manning/Brook) (list 32.303977834684716 39.15782008649647 42.924705649797716 69.19104371332907))] [America-One (loc "America One" 41.826776 -71.399713 (list The-SciLi One-One-Half -X-Manning/Brook) (list 31.716490600104866 39.15782008649647 52.696358893752))] [Blue-Room/Shearer-Memorial-Fountain (loc "Blue Room/Shearer Memorial Fountain" 41.826708 -71.402597 (list The-Brown-Bear) (list 17.06260401659125))] [List-Art (loc "List Art" 41.826150 -71.405392 (list Van-Wickle-Gates) (list 73.45653741287393))] [Pembroke-Green (loc "Pembroke Green" 41.829761 -71.402417 (list Pembroke-Steps Andrews The-Gate -X-Cushing/Brown -X-E-Cushing/Thayer) (list 52.58257524564202 65.88057782727354 32.30864878864742 87.33427925333616 130.1477670842218))] [Pembroke-Steps (loc "Pembroke Steps" 41.829289 -71.402392 (list Pembroke-Green The-V-Dub Walkway-Meeting -X-Meeting/Brown -X-Meeting/Thayer The-Gate) (list 52.58257524564202 59.502595527906976 47.670729675707435 88.36556950147244 136.7528882708475 74.0583950854029))] [University-Hall-North (loc "University Hall North" 41.826353 -71.403528 (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) (list 50.41862161224331 52.82961779522876 69.18810253807376 85.63855305034724 114.92405949603616 29.309499630959056 33.634229296340905 69.80631394787545 133.29107238723824 87.99178297484156))] [University-Hall-South (loc "University Hall South" 41.825903 -71.403597 (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) (list 50.41862161224331 75.22052993800988 64.15823445185605 79.03555821205534 86.26946117830566 74.85604560122913 107.0625995449227 99.25287240478349 135.67870033686583))] [Sayles-North (loc "Sayles North" 41.826328 -71.402892 (list University-Hall-North University-Hall-South Sayles-South Marcus-Aurelius/Lincoln-Field Soldiers-Arch Bridge-Prop Hope The-Brown-Bear -X-Waterman/Brown) (list 52.82961779522876 75.22052993800988 36.143851453421405 75.84744466687357 198.2018385084939 38.050477790785344 74.41330507989244 37.173230377495734 79.26536093325699))] [Sayles-South (loc "Sayles South" 41.826006 -71.402836 (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) (list 99.31284396974198 69.18810253807376 64.15823445185605 36.143851453421405 75.01243007712452 197.51662911805107 53.875726103390726 68.09497294604977 75.23221162277233))] [Soldiers-Arch (loc "Soldiers Arch" 41.826361 -71.400503 (list One-One-Half The-SciLi Marcus-Aurelius/Lincoln-Field Sayles-North Sayles-South -X-Manning/Brook -X-Waterman/Thayer -X-George/Thayer) (list 42.924705649797716 59.49039226842107 123.79955337951263 198.2018385084939 197.51662911805107 109.7260766989915 101.4614643071495 93.62571507166797))] [-X-Manning/Brook (loc "-X-Manning/Brook" 41.826503 -71.399194 (list One-One-Half America-One The-SciLi Soldiers-Arch -X-Waterman/Brook -X-George/Brook) (list 69.19104371332907 52.696358893752 81.64784633906564 109.7260766989915 96.05347603526972 98.50283034565801))] [Walkway-Waterman (loc "Walkway(Waterman)" 41.827164 -71.401753 (list Walkway-Angel -X-Waterman/Brown -X-Waterman/Thayer) (list 89.55512188423202 103.92130403309416 101.16807102875146))] [Walkway-Angel (loc "Walkway(Angel)" 41.827967 -71.401819 (list Walkway-Waterman Walkway-Olive -X-Angel/Brown -X-Angel/Thayer) (list 89.55512188423202 53.679127996574586 111.72826606039511 99.18870807085621))] [Walkway-Olive (loc "Walkway(Olive)" 41.828447 -71.401881 (list Walkway-Angel Walkway-Meeting -X-Olive/Brown -X-Olive/Thayer) (list 53.679127996574586 68.70688829013555 113.51581756134485 98.95630964573525))] [Walkway-Meeting (loc "Walkway(Meeting)" 41.829064 -71.401903 (list The-V-Dub Walkway-Olive Pembroke-Steps -X-Meeting/Brown -X-Meeting/Thayer) (list 29.895843885619204 68.70688829013555 47.670729675707435 122.42992129723945 95.93668182003772))] [-X-Cushing/Brown (loc "-X-Cushing/Brown" 41.829678 -71.403464 (list Andrews Pembroke-Green -X-Meeting/Brown) (list 112.15195631224834 87.33427925333616 77.71679213857283))] [-X-E-Cushing/Thayer (loc "-X-E-Cushing/Thayer" 41.830017 -71.400886 (list The-Gate Pembroke-Green New-Pembroke -X-Meeting/Thayer) (list 100.19269715947857 130.1477670842218 54.60688717990448 96.47682329081638))] [-X-Meeting/Brown (loc "-X-Meeting/Brown" 41.828983 -71.403375 (list The-V-Dub Pembroke-Steps Walkway-Meeting -X-Meeting/Thayer -X-Cushing/Brown -X-Olive/Brown) (list 144.63229419933333 88.36556950147244 122.42992129723945 218.33686385221588 77.71679213857283 78.14680922130171))] [-X-Meeting/Thayer (loc "-X-Meeting/Thayer" 41.829156 -71.400753 (list The-V-Dub Pembroke-Steps Walkway-Meeting -X-Meeting/Brown -X-E-Cushing/Thayer -X-Olive/Thayer) (list 77.55904294426057 136.7528882708475 95.93668182003772 218.33686385221588 96.47682329081638 66.9515873543481))] [-X-Olive/Brown (loc "-X-Olive/Brown" 41.828289 -71.403233 (list Walkway-Olive -X-Olive/Thayer -X-Meeting/Brown -X-Angel/Brown) (list 113.51581756134485 212.44398812194956 78.14680922130171 48.37932173696138))] [-X-Olive/Thayer (loc "-X-Olive/Thayer" 41.828556 -71.400697 (list Walkway-Olive -X-Olive/Brown -X-Meeting/Thayer -X-Angel/Thayer) (list 98.95630964573525 212.44398812194956 66.9515873543481 51.34446888023945))] [-X-Angel/Prospect (loc "-X-Angel/Prospect" 41.827719 -71.404789 (list -X-Angel/Brown -X-Waterman/Prospect) (list 136.1705250531015 91.2127048864669))] [-X-Angel/Brown (loc "-X-Angel/Brown" 41.827858 -71.403158 (list Walkway-Angel -X-Angel/Prospect -X-Angel/Thayer -X-Olive/Brown -X-Waterman/Brown) (list 111.72826606039511 136.1705250531015 210.8797948644964 48.37932173696138 92.5083428730047))] [-X-Angel/Thayer (loc "-X-Angel/Thayer" 41.828097 -71.400636 (list Walkway-Angel -X-Angel/Brown -X-Angel/Brook -X-Olive/Thayer -X-Waterman/Thayer) (list 99.18870807085621 210.8797948644964 100.75441304355273 51.34446888023945 92.16701103012558))] [-X-Angel/Brook (loc "-X-Angel/Brook" 41.828211 -71.399431 (list -X-Angel/Thayer -X-Waterman/Brook) (list 100.75441304355273 95.09087315308366))] [Van-Wickle-Gates (loc "Van Wickle Gates" 41.826111 -71.404508 (list Hope The-Rock The-John-Hay-Library List-Art University-Hall-North University-Hall-South -X-Waterman/Prospect -X-George/Prospect) (list 88.855377852582 48.77452257696725 33.25298999234115 73.45653741287393 85.63855305034724 79.03555821205534 89.43242074658055 93.95295042057707))] [-X-Waterman/Prospect (loc "-X-Waterman/Prospect" 41.826903 -71.404689 (list The-John-Hay-Library Van-Wickle-Gates -X-Angel/Prospect -X-Waterman/Brown) (list 59.120786574188585 89.43242074658055 91.2127048864669 141.37639878498283))] [-X-Waterman/Brown (loc "-X-Waterman/Brown" 41.827036 -71.402994 (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) (list 60.82266674895339 103.92130403309416 87.99178297484156 135.67870033686583 79.26536093325699 45.900479018813236 141.37639878498283 205.08068548810783 92.5083428730047))] [-X-Waterman/Thayer (loc "-X-Waterman/Thayer" 41.827272 -71.400542 (list The-SciLi Walkway-Waterman -X-Waterman/Brown -X-Waterman/Brook -X-Angel/Thayer Soldiers-Arch) (list 64.35514957067745 101.16807102875146 205.08068548810783 102.09416782607381 92.16701103012558 101.4614643071495))] [-X-Waterman/Brook (loc "-X-Waterman/Brook" 41.827361 -71.399317 (list -X-Waterman/Thayer -X-Angel/Brook -X-Manning/Brook) (list 102.09416782607381 95.09087315308366 96.05347603526972))] [-X-George/Prospect (loc "-X-George/Prospect" 41.825267 -71.404514 (list The-Rock Van-Wickle-Gates -X-George/Brown -X-Benevolent/Magee) (list 55.01289288338534 93.95295042057707 153.4386291990271 87.5354646848045))] [-X-George/Brown (loc "-X-George/Brown" 41.825342 -71.402667 (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) (list 52.807645610602336 21.6267202406739 58.706552274155584 125.00149170344949 133.29107238723824 99.25287240478349 75.23221162277233 153.4386291990271 193.55756936303933 83.00094838708665))] [-X-George/Thayer (loc "-X-George/Thayer" 41.825528 -71.400347 (list The-Ratty Littlefield -X-George/Brown -X-George/Brook Soldiers-Arch -X-Benevolent/Thayer) (list 75.8993352556833 143.79732433775175 193.55756936303933 110.88512519345545 93.62571507166797 83.32066694887799))] [-X-George/Brook (loc "-X-George/Brook" 41.825628 -71.399017 (list -X-George/Thayer -X-Manning/Brook -X-Benevolent/Brook) (list 110.88512519345545 98.50283034565801 82.65125344244677))] [-X-Benevolent/Magee (loc "-X-Benevolent/Magee" 41.824569 -71.404028 (list Keeney -X-Benevolent/Brown -X-George/Prospect) (list 79.51700830912155 109.54149977807499 87.5354646848045))] [-X-Benevolent/Brown (loc "-X-Benevolent/Brown" 41.824597 -71.402708 (list Keeney Wayland -X-Benevolent/Magee -X-George/Brown -X-Charlesfield/Brown) (list 32.61020669452627 62.91325558890378 109.54149977807499 83.00094838708665 94.94028921892416))] [-X-Benevolent/Thayer (loc "-X-Benevolent/Thayer" 41.824783 -71.400250 (list -X-Benevolent/Brook -X-George/Thayer -X-Charlesfield/Thayer) (list 105.88874477129403 83.32066694887799 98.35289334413264))] [-X-Benevolent/Brook (loc "-X-Benevolent/Brook" 41.824886 -71.398981 (list -X-Benevolent/Thayer -X-George/Brook -X-Charlesfield/Brook) (list 105.88874477129403 82.65125344244677 101.4574853500092))] [-X-Charlesfield/Brown (loc "-X-Charlesfield/Brown" 41.823747 -71.402614 (list -X-Charlesfield/Thayer -X-Benevolent/Brown) (list 205.62938641336245 94.94028921892416))] [-X-Charlesfield/Thayer (loc "-X-Charlesfield/Thayer" 41.823903 -71.400144 (list Josiahs Grad-Center Patriots-Court -X-Charlesfield/Brown -X-Charlesfield/Brook -X-Benevolent/Thayer) (list 80.55986637273925 59.57137853315766 66.15854023011751 205.62938641336245 108.84966017576355 98.35289334413264))] [-X-Charlesfield/Brook (loc "-X-Charlesfield/Brook" 41.823981 -71.398836 (list -X-Charlesfield/Thayer -X-Benevolent/Brook) (list 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))) ;tours is a list of tours supplied by the Admissions Office. (define tours : (listof Tour) (list (tour "Library Tour" (list "The John Hay Library" "The Rock" "The SciLi" "The John Carter Brown Library")) (tour "Housing Tour" (list "Andrews" "New Pembroke" "Hope" "Littlefield" "Wayland" "Caesar/Wriston" "Patriot's Court" "Keeney" "Grad Center")) (tour "Dining Tour" (list "The Ratty" "The V-Dub" "The Gate" "Josiah's" "Blue Room/Shearer Memorial Fountain")) (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")))) ;get-dist ;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 (get-dist [latA : number] [lonA : number] [latB : number] [lonB : number]) : number (* 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))))))))) ;deg->rad ;Converts an angle in degrees to radians. (define (deg->rad [angle : number]) : number (* angle (/ pi 180))) ;get-loc ;Returns the Loc in loc-list with the given name. (define (get-loc [name : string]) : Loc (first (filter (lambda(loc) (equal? name (loc-name loc))) loc-list)))