Skip to content

Commit

Permalink
Merge pull request Framstag#1534 from Karry/location-search-improvements
Browse files Browse the repository at this point in the history
Location search improvements
  • Loading branch information
Framstag authored Dec 9, 2023
2 parents df98776 + e675073 commit b55efc9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Demos/src/LocationLookup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ int main(int argc, char* argv[])
args.repeat=value;
}),
"repeat",
"Cout of repeat for performance test");
"Count of repeat for performance test");

argParser.AddOption(osmscout::CmdLineFlag([&args](const bool& value) {
args.transliterate=value;
Expand Down Expand Up @@ -435,7 +435,7 @@ int main(int argc, char* argv[])
}

osmscout::DatabaseParameter databaseParameter;
osmscout::DatabaseRef database(new osmscout::Database(databaseParameter));
osmscout::DatabaseRef database=std::make_shared<osmscout::Database>(databaseParameter);

if (!database->Open(args.databaseDirectory)) {
std::cerr << "Cannot open db" << std::endl;
Expand Down
14 changes: 12 additions & 2 deletions libosmscout/src/osmscout/location/LocationService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1088,7 +1088,7 @@ namespace osmscout {
* @param tokenString
* Token to remove
* @param tokens
* List to rmeove token parameter from
* List to remove token parameter from
* @return
* New list
*/
Expand Down Expand Up @@ -1379,9 +1379,19 @@ namespace osmscout {
locationIgnoreTokenSet.insert(UTF8StringToUpper(token));
}

// Locations are streets in town usually. But for small villages without named streets,
// village name (region) is added as virtual location to our location index.
// Address points are linked by "addr:place" tag to the place (region).
//
// So, to be able lookup address points just by phrase "Village 123",
// we add region name to location search patterns.
// We would force users to use pattern "Village Village 123" otherwise.
std::list<std::string> extendedLocationTokens=locationTokens;
extendedLocationTokens.push_back(regionMatch.name);

// Build Location search patterns

std::list<TokenStringRef> locationSearchPatterns=GenerateSearchPatterns(locationTokens,
std::list<TokenStringRef> locationSearchPatterns=GenerateSearchPatterns(extendedLocationTokens,
locationIgnoreTokenSet,
locationIndex->GetLocationMaxWords());

Expand Down

0 comments on commit b55efc9

Please sign in to comment.