A Terminal-based application to calculate the distance among points provided by Geographic coordinate system see countries.geojson.
- cmake 3.15 and above
- JSON for Modern C++
- c++17
At first, it's needed to change the path in parser.hpp to point to the json files and check if names are written correctly.
To compile the project, navigate into the folder where the project has been downloaded then write the following:
mkdir build && cd build
cmake ..
make
Now, we need to execute the application in terminal as follwoing:
./bss -c [ISO_A3] -t [border/center]
ISO_A3 : country of interest {Default: All} [not case-sensitive]
border/center : type of calculation {Default: border} [not case-sensitive]
for instances:
$ ./bss -c AZE -t cable
{
"cable": 797773.9204358519,
"iso_a3": "AZE",
"name": "Azerbaijan"
}
$ ./bss -c AZE -t border
{
"border": 2710587.9890285926,
"iso_a3": "AZE",
"name": "Azerbaijan"
}
After the application is terminated it will output corresponding data into a json file info.json
in the same directory where it's executed. In order to print the content of the file out type the following:
$ cat where/code/executed/info.json
for calcuating border
's length or sensing cable
's length of the all countries at once, the following commends should be executed.
./bss -t border (for borders calculating)
./bss -t cable (for cables calculating)
./cat info.json (for printing all values in terminal)
The distance among two points in this project is calculated by applying Haversine Formula since the Earth isn't flat ¯\_(ツ)_/¯
.
d : distance between the two points
r : radius of the sphere (of Earth in our case)
Theta(1), Theta(2) : are the latitude of point 1, point 2 (in radians)
lamda(1), lamda(2) : are the longitude of point 1, point 2 (in radians)