|
10 | 10 |
|
11 | 11 | using namespace GeoNLP; |
12 | 12 |
|
13 | | -const int GeoNLP::Geocoder::version{ 5 }; |
| 13 | +const int GeoNLP::Geocoder::version{ 6 }; |
14 | 14 | const size_t GeoNLP::Geocoder::num_languages{ 2 }; // 1 (default) + 1 (english) |
15 | 15 |
|
16 | 16 | // typedef boost::geometry::model::point< double, 2, |
@@ -245,12 +245,13 @@ bool Geocoder::search(const std::vector<Postal::ParseResult> &parsed_query, |
245 | 245 | r.type = get_type(r.id); |
246 | 246 | get_features(r); |
247 | 247 |
|
248 | | - sqlite3pp::query qry(m_db, "SELECT latitude, longitude FROM object_primary WHERE id=?"); |
| 248 | + sqlite3pp::query qry( |
| 249 | + m_db, "SELECT latitude, longitude, search_rank FROM object_primary WHERE id=?"); |
249 | 250 | qry.bind(1, r.id); |
250 | 251 | for (auto v : qry) |
251 | 252 | { |
252 | 253 | // only one entry is expected |
253 | | - v.getter() >> r.latitude >> r.longitude; |
| 254 | + v.getter() >> r.latitude >> r.longitude >> r.search_rank; |
254 | 255 | break; |
255 | 256 | } |
256 | 257 | } |
@@ -611,7 +612,8 @@ bool Geocoder::search_nearby(const std::vector<std::string> &name_query, |
611 | 612 | try |
612 | 613 | { |
613 | 614 | std::ostringstream qtxt; |
614 | | - qtxt << "SELECT o.id, o.name, o.name_extra, o.name_en, t.name, o.latitude, o.longitude " |
| 615 | + qtxt << "SELECT o.id, o.name, o.name_extra, o.name_en, t.name, o.latitude, o.longitude, " |
| 616 | + "o.search_rank " |
615 | 617 | << "FROM object_primary o " |
616 | 618 | << "JOIN type t ON o.type_id=t.id " |
617 | 619 | << "JOIN object_primary_rtree ON (o.box_id = object_primary_rtree.id) " |
@@ -649,7 +651,8 @@ bool Geocoder::search_nearby(const std::vector<std::string> &name_query, |
649 | 651 | char const *name, *name_extra, *name_en; |
650 | 652 | std::string type; |
651 | 653 | double lat, lon, distance; |
652 | | - v.getter() >> id >> name >> name_extra >> name_en >> type >> lat >> lon; |
| 654 | + int search_rank; |
| 655 | + v.getter() >> id >> name >> name_extra >> name_en >> type >> lat >> lon >> search_rank; |
653 | 656 |
|
654 | 657 | // check if distance is ok. note that the distance is expected |
655 | 658 | // to be small (on the scale of the planet) |
@@ -701,6 +704,7 @@ bool Geocoder::search_nearby(const std::vector<std::string> &name_query, |
701 | 704 | r.latitude = lat; |
702 | 705 | r.longitude = lon; |
703 | 706 | r.distance = distance; |
| 707 | + r.search_rank = search_rank; |
704 | 708 | r.levels_resolved = 1; // not used in this search |
705 | 709 |
|
706 | 710 | result.push_back(r); |
@@ -799,7 +803,7 @@ bool Geocoder::search_nearby(const std::vector<std::string> &name_query, |
799 | 803 | { |
800 | 804 | std::ostringstream qtxt; |
801 | 805 | qtxt << "SELECT o.id, o.name, o.name_extra, o.name_en, t.name, " |
802 | | - << "o.latitude, o.longitude " |
| 806 | + << "o.latitude, o.longitude, o.search_rank " |
803 | 807 | << "FROM object_primary o " |
804 | 808 | << "JOIN type t ON o.type_id=t.id " |
805 | 809 | << "WHERE "; |
@@ -837,7 +841,9 @@ bool Geocoder::search_nearby(const std::vector<std::string> &name_query, |
837 | 841 | char const *name, *name_extra, *name_en; |
838 | 842 | std::string type; |
839 | 843 | double lat, lon, distance; |
840 | | - v.getter() >> id >> name >> name_extra >> name_en >> type >> lat >> lon; |
| 844 | + int search_rank; |
| 845 | + v.getter() >> id >> name >> name_extra >> name_en >> type >> lat >> lon |
| 846 | + >> search_rank; |
841 | 847 |
|
842 | 848 | // check if distance is ok using earth as a plane approximation around the line |
843 | 849 | { |
@@ -918,6 +924,7 @@ bool Geocoder::search_nearby(const std::vector<std::string> &name_query, |
918 | 924 | r.latitude = lat; |
919 | 925 | r.longitude = lon; |
920 | 926 | r.distance = distance; |
| 927 | + r.search_rank = search_rank; |
921 | 928 | r.levels_resolved = 1; // not used in this search |
922 | 929 |
|
923 | 930 | result.push_back(r); |
|
0 commit comments