Created
August 1, 2018 10:08
-
-
Save adl1995/4b06d6147615b95ab6d8050fe8f57c99 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <fstream> | |
#include <numeric> | |
#include <boost/chrono.hpp> | |
#include <boost/geometry.hpp> | |
using namespace boost::chrono; | |
using namespace boost::geometry; | |
int main() { | |
// Objects for file reading. | |
std::string line; | |
std::ifstream infile("GeodTest-medium.dat"); | |
// This will hold the resulting distance. | |
std::vector<double> distanceTestData; | |
// These object are required for Boot Geometry tests. | |
typedef model::point | |
<double, 2, cs::spherical_equatorial | |
<degree>> spherical_point; | |
typedef srs::spheroid<double> stype; | |
srs::spheroid<double> spheroidx; | |
// This will temporarily hold the data values. | |
double dataField; | |
spherical_point point1, point2; | |
// Used for benchmarking the execution time. | |
high_resolution_clock::time_point start; | |
high_resolution_clock::time_point end; | |
duration<double, boost::milli> diff; | |
start = high_resolution_clock::now(); | |
typedef formula::karney_direct<double, true, true, true, true, 8> karney_direct_type; | |
formula::result_direct<double> result; | |
while (std::getline(infile, line)) | |
{ | |
std::istringstream iss(line); | |
// Push the space separated values in a vector. | |
std::vector<double> geoData; | |
while (iss >> dataField) { geoData.push_back(dataField); } | |
result = karney_direct_type::apply(geoData[1], geoData[0], geoData[6], geoData[3], spheroidx); | |
} | |
end = high_resolution_clock::now(); | |
diff = end - start; | |
std::cout << "Karney (order 8) | " << duration<double, boost::milli> (diff).count() / 1000. << " sec" << std::endl; | |
// Reset the file buffer. | |
infile.clear(); | |
infile.seekg(0, infile.beg); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment