Homework help, Your task is to write a program that reads the list of trajectory records and outputs statistics
'= Task 1 Due: four:00pm Wednesday 30th September 2020 1 Studying Outcomes On this project you'll exhibit your understanding of loops and if statements by writing a program that sequentially processes a file of enter information. You might be additionally anticipated to utilize features and arrays. 2 The Story... Contact tracing is a crucial measure to stop a virus from spreading by means of the group. In coping with the COVID-19 pandemic, many nations, together with Australia, have taken numerous contact tracing measures. A core element involved tracing is to trace individuals’s journey trajectories, from which individuals who've been in shut contact with a brand new case could be recognized rapidly. On this project, we're given a set of trajectory information that data individuals’s places at totally different occasions. The intention is to examine whether or not there may be anybody who has violated the 5-km from dwelling journey zone restrict, and whether or not there have been people who find themselves in shut contact for an prolonged time frame. Under is a pattern checklist of trajectory data of a sure day (the precise date is omitted for simplicity). Every line of the checklist comprises the knowledge of a location visited by a person as separated by areas (‘ ’), together with: • the visited location latitude (an actual quantity with 6 digits after the decimal level); • the visited location longitude (an actual quantity with 6 digits after the decimal level); • the person’s dwelling location latitude (an actual quantity with 6 digits after the decimal level); • the person’s dwelling location longitude (an actual quantity with 6 digits after the decimal level); • the beginning time of the go to (an integer between 1 and 24 × 3600 = 86400; that is the second from the begin of the day, for instance, 31144 = eight × 3600 + 39 × 60 + four, that's, 31144 means 08:39:04); • the tip time of the go to (an integer between 1 and 86400, and higher than the beginning time of the go to); • the person ID (a string with eight digit or lowercase characters). -37.817365 144.968783 -37.797329 144.965705 31144 32144 8oz05szh -37.810009 144.962800 -37.797329 144.965705 33867 44877 8oz05szh -37.809657 144.965221 -37.797329 144.965705 85646 85746 8oz05szh -37.822464 144.968863 -37.810256 145.002215 41497 42511 jon362ft -37.742099 144.964337 -37.837977 144.975683 00145 02159 kwhb16v7 -37.810019 144.962800 -37.837977 144.975683 43000 55079 kwhb16v7 -37.822464 144.968863 -37.837977 144.975683 60270 61284 kwhb16v7 -37.822464 144.968873 -37.837977 144.975683 61285 82281 kwhb16v7 -37.845590 144.971467 -37.773574 144.968853 52475 52591 wuucozwj -37.817368 144.968786 -37.798875 144.943082 30144 65032 y4tqqn2s For instance, the primary line of the checklist represents that Consumer #8oz05szh visited <-37.817365, 144.968783> at time 31144 (08:39:04) and left at time 32144 (08:55:44). The person’s house is at <-37.797329, 144.965705>. Chances are you'll assume that the checklist will at all times be accurately formatted and comprise at the very least 2 and at most 99 data. The checklist is sorted by the person ID after which by the go to begin time, in ascending order. 1 three Your Activity Your activity is to write down a program that reads the checklist of trajectory data and outputs statistics calculated on it. The project consists of the next 4 levels (Stage four is for a problem and is non-compulsory). three.1 Stage 1 - Processing the First File (Marks as much as 5/10) Write a program that reads the primary line of the enter information, and prints out for the primary report: the person ID, the latitude and the longitude of the visited location, the beginning and finish occasions of the go to, and the space (in kilometres, 2 digits earlier than and after decimal level) from the house location to the visited location. Given the coordinates of two factors p1 = hlat1, long1i and p2 = hlat2, long2i, the place lati and longi (i = 1, 2) characterize the latitude and the longitude, the space (in kilometres) between p1 and p2, represented by dist(p1, p2), is calculated based mostly on the haversine components as follows. dist(p1, p2) = 6371 · angle distance, the place angle distance = 2 · atan2 sqrt(chord size), sqrt(1 − chord size) , chord size = sin2 toRadian(lat2 − lat1)/2 + cos toRadian(lat1) · cos toRadian(lat2) · sin2 toRadian(long2 − long1)/2 (1) Within the equation above, toRadian(x) = x · (three.14159/180) is a operate that converts a latitude or longitude coordinate x to its radian worth. You'll want to implement this operate and outline the constants correctly in your code. Notice that you shouldn't use the fixed M_PI offered by the maths.h library as it isn't supported by the project submission system beneath the project compilation settings. The features atan2(), sqrt(), sin(), and cos() are offered by the maths.h library. In case you use this library, be certain so as to add the “-lm” flag to the “gcc” command at compilation by yourself machine. The output of this stage given the above pattern enter ought to be (the place “mac:” is the command immediate): mac: ./program < test0.txt Stage 1 ========== Consumer: #8oz05szh Visited location: <-37.817365, 144.968783> Begin time: 31144 Finish time: 32144 Distance from dwelling: 02.24 km Right here, 02.24 is the space between the visited location of the primary report, <-37.817365, 144.968783>, and the house location, <-37.797329, 144.965705>, as calculated utilizing the haversine components above. Trace: To make sure the consequence accuracy, use double’s for storing the coordinates and calculating the space worth. Use %05.2f for the space output formatting. You may additionally learn all enter information earlier than printing out for Stage 1. As this instance illustrates, one of the best ways to get information into your program is to reserve it in a textual content file (with a “.txt” extension, jEdit can do that), after which execute your program from the command line, feeding the information in by way of enter redirection (utilizing <). In your program, you'll nonetheless use the usual enter features similar to scanf() or getchar() to learn the information. Enter redirection will direct these features to learn the information from the file, as a substitute of asking you to sort it in by hand. This will probably be extra handy than typing out the take a look at circumstances manually each time you take a look at your program. Our auto-testing system will feed enter information into your submissions on this manner as properly. To simplify the marking, your program mustn't print something apart from the information requested to be output (as proven within the output instance). We are going to present a pattern take a look at file “test0.txt” on Canvas. Chances are you'll obtain this file straight and use it to check your code earlier than submission. This file is created beneath MacOS. Below Home windows techniques, your complete file could also be displayed in a single line if opened within the Notepad app. You do not want to edit this file so as to add line breaks. The ‘n’ characters are already contained within the file. They aren't displayed correctly however the scanf() and getchar() features in C can nonetheless recognise them correctl three.2 Stage 2 - Processing the Remainder of the Data (Marks as much as 7/10) Now modify your program in order that the space from the house location to every visited location is computed and visualised. Chances are you'll assume that the space values are inside the vary of (zero, 15). On the identical pattern enter information, the extra output for this stage ought to be: Stage 2 ========== #8oz05szh, distance from dwelling: 02.24 |--- #8oz05szh, distance from dwelling: 01.43 |-- #8oz05szh, distance from dwelling: 01.37 |-- #jon362ft, distance from dwelling: 03.23 |---- #kwhb16v7, distance from dwelling: 10.71 |----+----+- #kwhb16v7, distance from dwelling: 03.31 |---- #kwhb16v7, distance from dwelling: 01.83 |-- #kwhb16v7, distance from dwelling: 01.83 |-- #wuucozwj, distance from dwelling: 08.01 |----+---- #y4tqqn2s, distance from dwelling: 03.05 |---- You'll want to work out how the visualisation works based mostly on this instance. You need to write features to course of this stage the place applicable. three.three Stage three - General Reporting (Marks as much as 10/10) On this stage, your activity is to seek out out the close-contact pairs, that are location go to report pairs from totally different customers with a distance smaller than 2 metres, and the go to occasions overlap for greater than 15 minutes (that's, 900 seconds). The extra output from this stage is the entire variety of close-contact pairs, and the close-contact pair with the longest overlap time. Chances are you'll assume that there won't be a tie on the longest overlap time. Stage three ========== Variety of close-contact pairs: 2 Longest overlap time: zero1877 seconds #8oz05szh @ <-37.810009, 144.962800> #kwhb16v7 @ <-37.810019, 144.962800> /* The alphabetically smaller ID ought to be printed first; theres is at the very least one close-contact pair within the enter information; there's a ultimate newline ‘n’ on the finish of Stage three output. */ Within the pattern enter, there are two close-contact pairs: (1) #8oz05szh @ <-37.810009, 144.962800> and #kwhb16v7 @ <-37.810019, 144.962800>, with a distance of 1.11 metres for 1877 seconds, and (2) #8oz05szh @ <-37.817365, 144.968783> and #y4tqqn2s @ <-37.817368 144.968786>, with a distance of zero.43 metres for 1000 seconds. The primary pair is printed as its overlap time is longer. Trace: Chances are you'll want to make use of two arrays of double’s to maintain monitor of the visited location coordinates, two arrays of int’s to maintain monitor of the go to occasions, and an array of strings to maintain monitor of the person IDs. Wherever applicable, code ought to be shared between levels by means of the usage of features. Specifically, there shouldn't be lengthy stretches of repeated code showing in other places in your program. Additional examples exhibiting the complete output that's required are offered on Canvas. three.four Stage four - For a Problem (and Not for Submission) In Stage three, you could have checked each pair of location go to data to seek out all of the close-contact pairs. Given n location go to data, there are n 2 pairs to be checked, a lot of that are non-close-contact pairs. For a problem, are you able to consider a technique to cut back the variety of pairs to be checked with out lacking any close-contact pairs? However no must submit these packages. three four Submission and Evaluation This project is value 10% of the ultimate mark. An in depth marking scheme will probably be offered on Canvas. You'll want to submit your code in Grok Studying (https://groklearning.com) for evaluation. Submission won't be executed by way of Canvas. As a substitute, you will want to: 1. Log in to Grok Studying utilizing your pupil login particulars. 2. Navigate to the Task 1 module of our topic COMP20005 2020 S2: Engineering Computation. three. Write your code in this system.c tab window. four. Compile your code by clicking on the Compile button. 5. As soon as the compilation is profitable, click on on the Mark button to submit your code. (You'll be able to submit as many occasions as you need to. Solely the final submission made earlier than the deadline will probably be marked.) 6. Two pattern exams will probably be run mechanically after you make a submission. Guarantee that your submission passes these pattern exams. 7. Two hidden exams will probably be run for marking objective. Outcomes of those exams will probably be launched after our marking is finished. You'll be able to (and will) submit each early and sometimes – to examine that your program compiles accurately on our take a look at system, which can have some totally different traits to your individual machines. You can be given a pattern take a look at file test0.txt and the pattern output test0-output.txt. You'll be able to take a look at your code by yourself machine with the next command and evaluate the output with test0-output.txt: mac: ./program < test0.txt /* Right here ‘<’ feeds the information from test0.txt into program */ Notice that we're utilizing the next command to compile your code on the submission system (we title the supply code file program.c). gcc -Wall -lm -std=c99 -o program program.c The flag “-std=c99” allows the compiler to make use of a contemporary customary of the C language – C99. To make sure that your submission works correctly on the submission system, it's best to use this command to compile your code in your native machine as properly. Chances are you'll focus on your work with others, however what will get typed into your program have to be particular person work, not from anybody else. Don't give (arduous or mushy) copy of your work to anybody else; don't “lend” your reminiscence follow others; and don't ask others to provide you their packages “simply in order that I can have a look and get some concepts, I received’t copy, sincere”. The easiest way to assist your pals on this regard is to say a very agency “no” once they ask for a duplicate of, or to see, your program, mentioning that your “no”, and their acceptance of that call, is the one factor that can protect your friendship. A complicated program that undertakes deep structural evaluation of C code figuring out areas of similarity will probably be run over all submissions in “evaluate each pair” mode. See https://academichonesty.unimelb.edu.au for extra info. Deadline: Packages not submitted by four:00pm Wednesday 30th September 2020 will lose penalty marks on the price of 1.5 marks per day or half day late. Late submissions after four:00pm Friday 2nd October 2020 won't be accepted. College students searching for extensions for medical or different “outdoors my management” causes ought to electronic mail the lecturer at jianzhong.qi@unimelb.edu.au. In case you attend a GP or different well being care skilled because of sickness, remember to take a Well being Skilled Report (HRP) kind with you (get it from the Particular Consideration part of the Pupil Portal), you will want this type to be crammed out if your sickness develops into one thing that later requires a Particular Consideration utility to be lodged. You need to scan the HPR kind and ship it in reference to any non-Particular Consideration project extension requests. Particular consideration as a result of COVID-19: Please discuss with the “Particular Consideration” part on this web page: https://college students.unimelb.edu.au/student-support/coronavirus/exams-special-consideration-and-WAM And bear in mind, C programming is enjoyable! c 2020 The College of Melbourne Ready by Jianzhong Qi four