|
@@ -6,7 +6,7 @@
|
6
|
6
|
![main1.png](images/main1.png)
|
7
|
7
|
![main2.png](images/main2.png)
|
8
|
8
|
|
9
|
|
-[Verano 2016 - Ive]
|
|
9
|
+[Verano 2016 - Ive- Tatiana]
|
10
|
10
|
|
11
|
11
|
|
12
|
12
|
Arrays help us to store and work with groups of data of the same type. The data is stored in consecutive memory spaces which can be accessed by using the name of the array and indexes or subscripts that indicate the position where the data is stored. Repetition structures provide us a simple way of accessing the data within an array.
|
|
@@ -79,7 +79,7 @@ Working with arrays of objects is a very common task in programming with C++. On
|
79
|
79
|
|
80
|
80
|
|
81
|
81
|
|
82
|
|
-In this laboratory experience, you will be working with *georeferenced* data about the cities in Puerto Rico. When a data is *georeferenced* it simply means that it has an associated location in physical space. Typically this **location** are latitude and longitude coordinates. For example, the following is part of a file that contains georeferenced data for some Puerto Rican cities:
|
|
82
|
+In this laboratory experience, you will be working with *georeferenced* data of the cities in Puerto Rico. When data is *georeferenced* it simply means that it has an associated location in physical space. Typically this **location** is defined in latitude and longitude coordinates. For example, the following is part of a file that contains georeferenced data for some Puerto Rican cities:
|
83
|
83
|
|
84
|
84
|
|
85
|
85
|
---
|
|
@@ -103,7 +103,7 @@ Fajardo 18.3258 -65.6525
|
103
|
103
|
###Orthodromic Distance
|
104
|
104
|
|
105
|
105
|
|
106
|
|
-To calculate the distance between two points in the Euclidean plane, you trace the straight line segment that joins the points and compute its length using the distance formula you studied in your Pre-Calculus course. To calculate the distance between two points in the surface of a sphere you don't use the straight line segment that joins them, you use the shortest distance between these points measured over the sphere. This distance is called the *orthodromic distance*. To calculate the orthodromic distance between two points in the earth globe, the latitude and longitude coordinates are used.
|
|
106
|
+To calculate the distance between two points in the Euclidean plane, you to trace the straight line segment that joins these points and compute its length using the distance formula you studied in your Pre-Calculus course. To calculate the distance between two points in the surface of a sphere you don't use the straight line segment that joins them, you use the shortest distance between these points measured over the sphere. This distance is called the *orthodromic distance*. To calculate the orthodromic distance between two points in the earth globe, you have to use the latitude and longitude coordinates.
|
107
|
107
|
|
108
|
108
|
|
109
|
109
|
|
|
@@ -158,7 +158,7 @@ In this laboratory experience, you are provided a `GPOI` class with the followin
|
158
|
158
|
This laboratory experience requires you to read data from a text file. You can skip the next section if you feel that your file reading skills are competent. Otherwise, read on...
|
159
|
159
|
|
160
|
160
|
|
161
|
|
-C++ provides functions to read and write data to/from files. In this laboratory experience you will be using one of the most rudimentary file input/output schemes provided in C++ to read/write from **text** files. Text files consist exclusively of ASCII characters which represent data in any of the primitive types provided by C++. Typically, the values are separated by spaces. For instance lets asumme that the file `nameAge.txt` contains some data about names and ages.
|
|
161
|
+C++ provides functions to read and write data to/from files. In this laboratory experience you will be using one of the most rudimentary file input/output schemes provided in C++ to read/write from **text** files. Text files consist exclusively of ASCII characters which represent data in any of the primitive types provided by C++. Typically, the values are separated by spaces. For instance let's assume that the file `nameAge.txt` contains some data about names and ages.
|
162
|
162
|
|
163
|
163
|
```
|
164
|
164
|
Tomas 34
|
|
@@ -321,7 +321,7 @@ Here are some code snippets for common reading tasks. Observe that all of them:
|
321
|
321
|
|
322
|
322
|
6. `double cycleDistance(GISPOI A[], int size, int P[])`: Given an array of cities `A`, the size of the array, and an array `P` with a permutation of the integers in `[0, size-1]`, computes and returns the distance to travel the cycle of cities `A[P[0]]` $$\rightarrow$$ `A[P[1]]` $$\rightarrow \cdots \rightarrow$$ `A[P[size-1]]`. Remember that the distance you will calculate is the *orthodromic* distance.
|
323
|
323
|
|
324
|
|
- For example, if the cities read from the file where Mayaguez, Ponce, Yauco and San Juan (in that order) and the permutation `P` is $$(3, 1, 0, 2$$, the function should compute the distance of a cycle from San Juan $$\rightarrow$$ Ponce $$\rightarrow$$ Mayaguez $$\rightarrow$$ Yauco $$\rightarrow$$ San Juan. **This is a function you will implement.**
|
|
324
|
+ For example, if the cities read from the file where Mayagüez, Ponce, Yauco and San Juan (in that order) and the permutation `P` is $$(3, 1, 0, 2$$, the function should compute the distance of a cycle from San Juan $$\rightarrow$$ Ponce $$\rightarrow$$ Mayagüez $$\rightarrow$$ Yauco $$\rightarrow$$ San Juan. **This is a function you will implement.**
|
325
|
325
|
|
326
|
326
|
|
327
|
327
|
There are two additional functions that you need to know:
|
|
@@ -338,7 +338,7 @@ There are two additional functions that you need to know:
|
338
|
338
|
Remember that you will only be changing code in the `main.cpp` file. Your first task will be to add code to read the entire contents of a file into an array of `GISPOI` objects.
|
339
|
339
|
|
340
|
340
|
|
341
|
|
-1. In the `main()` function, add the necessary instructions to open the file that contains the georeferenced city information. The file that you will use first is `pr10.txt` and it is in the `data` directory. You need to provide the complete `path` to the file as a parameter to the `open()` method of your `ifstream` object. As always, when using files you should verify if the entered name is a file that can be successfully opened for reading.
|
|
341
|
+1. In the `main()` function, add the necessary instructions to open the file that contains the georeferenced city information. The file that you will use first is `pr10.txt` that is in the `data` directory. You need to provide the complete `path` to the file as a parameter to the `open()` method of your `ifstream` object. As always, when using files you should verify if the entered name is a file that can be successfully opened for reading.
|
342
|
342
|
|
343
|
343
|
|
344
|
344
|
2. Invoke the `int countLinesInFile(ifstream &inFile)` function to obtain the number of lines in the file. You may print out the number obtained so that you can validate is your program is working correctly.
|
|
@@ -409,7 +409,7 @@ Once you have the information of georeferenced cities in the array of objects, y
|
409
|
409
|
### Exercise 4 - More fun!
|
410
|
410
|
|
411
|
411
|
|
412
|
|
-1. Change your code so that it now opens the `pr.txt` file. Validate your results and wonder at your great achievement!
|
|
412
|
+1. Change your code so that it now opens the `pr.txt` file. Validate your results and marvel at your great achievement!
|
413
|
413
|
|
414
|
414
|
|
415
|
415
|
|
|
@@ -438,3 +438,6 @@ Use "Deliverable" in Moodle to hand in the `main.cpp` file. Remember to use good
|
438
|
438
|
|
439
|
439
|
|
440
|
440
|
[1] https://en.wikipedia.org/wiki/Great-circle_distance
|
|
441
|
+
|
|
442
|
+
|
|
443
|
+
|