14 #if !defined(GEOGRAPHICLIB_HAVE_BOOST_SERIALIZATION) 15 #define GEOGRAPHICLIB_HAVE_BOOST_SERIALIZATION 0 18 #if GEOGRAPHICLIB_HAVE_BOOST_SERIALIZATION 20 #include <boost/archive/xml_iarchive.hpp> 21 #include <boost/archive/xml_oarchive.hpp> 43 double operator() (
const pos&
a,
const pos&
b)
const {
60 ifstream is(
"locations.txt");
63 while (is >> sa >> sb) {
64 DMS::DecodeLatLon(sa, sb, lat, lon);
65 locs.push_back(
pos(lat, lon));
79 #if GEOGRAPHICLIB_HAVE_BOOST_SERIALIZATION 80 ifstream is(
"pointset.xml");
82 boost::archive::xml_iarchive ia(is);
83 ia >> BOOST_SERIALIZATION_NVP(pointset);
86 ifstream is(
"pointset.txt");
96 #if GEOGRAPHICLIB_HAVE_BOOST_SERIALIZATION 97 ofstream
os(
"pointset.xml");
100 boost::archive::xml_oarchive oa(os);
101 oa << BOOST_SERIALIZATION_NVP(pointset);
103 ofstream
os(
"pointset.txt");
106 os << pointset <<
"\n";
110 ifstream is(
"queries.txt");
114 while (is >> sa >> sb) {
116 DMS::DecodeLatLon(sa, sb, lat, lon);
117 d = pointset.
Search(locs, distance,
pos(lat, lon), k);
120 cout << k[0] <<
" " << d <<
"\n";
122 int setupcost, numsearches, searchcost, mincost, maxcost;
124 pointset.
Statistics(setupcost, numsearches, searchcost,
125 mincost, maxcost, mean, sd);
127 totcost = setupcost + searchcost,
128 exhaustivecost = count * pointset.
NumPoints();
130 <<
"Number of distance calculations = " << totcost <<
"\n" 131 <<
"With an exhaustive search = " << exhaustivecost <<
"\n" 132 <<
"Ratio = " << double(totcost) / exhaustivecost <<
"\n" 133 <<
"Efficiency improvement = " 134 << 100 * (1 - double(totcost) / exhaustivecost) <<
"%\n";
136 catch (
const exception&
e) {
137 cerr <<
"Caught exception: " << e.what() <<
"\n";
DistanceCalculator(const Geodesic &geod)
Header for GeographicLib::NearestNeighbor class.
Math::real Inverse(real lat1, real lon1, real lat2, real lon2, real &s12, real &azi1, real &azi2, real &m12, real &M12, real &M21, real &S12) const
pos(double lat=0, double lon=0)
Point3 mean(const CONTAINER &points)
mean
Header for GeographicLib::Geodesic class.
Namespace for GeographicLib.
Array< double, 1, 3 > e(1./3., 0.5, 2.)
Exception handling for GeographicLib.
ofstream os("timeSchurFactors.csv")
void Initialize(const std::vector< pos_t > &pts, const distfun_t &dist, int bucket=4)
Nearest-neighbor calculations.
dist_t Search(const std::vector< pos_t > &pts, const distfun_t &dist, const pos_t &query, std::vector< int > &ind, int k=1, dist_t maxdist=std::numeric_limits< dist_t >::max(), dist_t mindist=-1, bool exhaustive=true, dist_t tol=0) const
void Statistics(int &setupcost, int &numsearches, int &searchcost, int &mincost, int &maxcost, double &mean, double &sd) const
Header for GeographicLib::DMS class.