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> 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.
pos(double lat=0, double lon=0)
Double_ distance(const OrientedPlane3_ &p)
static const Vector2 mean(20, 40)
Header for GeographicLib::Geodesic class.
void Statistics(int &setupcost, int &numsearches, int &searchcost, int &mincost, int &maxcost, double &mean, double &sd) const
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
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.
internal::enable_if< internal::valid_indexed_view_overload< RowIndices, ColIndices >::value &&internal::traits< typename EIGEN_INDEXED_VIEW_METHOD_TYPE< RowIndices, ColIndices >::type >::ReturnAsIndexedView, typename EIGEN_INDEXED_VIEW_METHOD_TYPE< RowIndices, ColIndices >::type >::type operator()(const RowIndices &rowIndices, const ColIndices &colIndices) EIGEN_INDEXED_VIEW_METHOD_CONST
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
Header for GeographicLib::DMS class.