1 #ifndef OSMSCOUT_LOCATIONINDEX_H 2 #define OSMSCOUT_LOCATIONINDEX_H 27 #include <unordered_set> 56 std::shared_ptr<LocationIndex> index;
59 index(
std::move(index))
62 ScopeCacheCleaner(
const ScopeCacheCleaner&) =
delete;
63 ScopeCacheCleaner(ScopeCacheCleaner&&) =
delete;
64 ScopeCacheCleaner& operator=(
const ScopeCacheCleaner &) =
delete;
65 ScopeCacheCleaner& operator=(ScopeCacheCleaner &&) =
delete;
88 class FileScannerPool:
public ObjectPool<FileScanner>
92 bool memoryMappedData=
false;
98 ~FileScannerPool()
override {
102 Ptr Borrow()
override;
104 FileScanner* MakeNew() noexcept override;
106 void Destroy(FileScanner*) noexcept override;
108 bool IsValid(FileScanner* o) noexcept override;
111 using FileScannerPtr = FileScannerPool::Ptr;
114 mutable FileScannerPool fileScannerPool;
115 uint8_t bytesForNodeFileOffset;
116 uint8_t bytesForAreaFileOffset;
117 uint8_t bytesForWayFileOffset;
118 std::vector<
std::
string> regionIgnoreTokens;
119 std::unordered_set<
std::
string> regionIgnoreTokenSet;
120 std::vector<
std::
string> poiIgnoreTokens;
121 std::unordered_set<
std::
string> poiIgnoreTokenSet;
122 std::vector<
std::
string> locationIgnoreTokens;
123 std::unordered_set<
std::
string> locationIgnoreTokenSet;
124 uint32_t minRegionChars;
125 uint32_t maxRegionChars;
126 uint32_t minRegionWords;
127 uint32_t maxRegionWords;
128 uint32_t maxPOIWords;
129 uint32_t minLocationChars;
130 uint32_t maxLocationChars;
131 uint32_t minLocationWords;
132 uint32_t maxLocationWords;
133 uint32_t maxAddressWords;
137 void Read(FileScanner& scanner,
138 ObjectFileRef&
object) const;
140 bool LoadAdminRegion(FileScanner& scanner,
141 AdminRegion& region) const;
143 AdminRegionVisitor::Action VisitRegionEntries(const AdminRegion& region,
144 FileScanner& scanner,
145 AdminRegionVisitor& visitor) const;
147 bool VisitRegionPOIs(const AdminRegion& region,
148 FileScanner& scanner,
151 bool& stopped) const;
153 bool VisitPostalArea(const AdminRegion& adminRegion,
154 const PostalArea& postalArea,
155 FileScanner& scanner,
156 LocationVisitor& visitor,
158 bool& stopped) const;
160 bool VisitLocations(const AdminRegion& adminRegion,
161 FileScanner& scanner,
162 LocationVisitor& visitor,
164 bool& stopped) const;
166 bool VisitPostalAreaLocations(const AdminRegion& adminRegion,
167 const PostalArea& postalArea,
168 FileScanner& scanner,
169 LocationVisitor& visitor,
170 bool& stopped) const;
172 bool VisitLocation(FileScanner& scanner,
173 const AdminRegion& region,
174 const PostalArea& postalArea,
175 const Location& location,
176 AddressVisitor& visitor,
177 bool& stopped) const;
180 LocationIndex() = default;
181 virtual ~LocationIndex() = default;
183 bool Load(const
std::
string& path,
bool memoryMappedData);
185 const
std::vector<
std::
string>& GetRegionIgnoreTokens()
const 187 return regionIgnoreTokens;
192 return poiIgnoreTokens;
197 return locationIgnoreTokens;
200 bool IsRegionIgnoreToken(
const std::string& token)
const;
201 bool IsLocationIgnoreToken(
const std::string& token)
const;
205 return maxRegionWords;
215 return maxLocationWords;
220 return maxAddressWords;
231 bool VisitAdminRegions(
const AdminRegion& adminRegion,
239 bool recursive=
true)
const;
244 bool VisitLocations(
const AdminRegion& adminRegion,
246 bool recursive=
true)
const;
251 bool VisitLocations(
const AdminRegion& adminRegion,
254 bool recursive=
true)
const;
265 std::map<FileOffset,AdminRegionRef>& refs)
const;
269 void FlushCache()
const;
static const char *const FILENAME_LOCATION_IDX
Definition: LocationIndex.h:50
Definition: Location.h:130
Definition: Location.h:146
Prints details for debugging, if debug flag (performance, data) is set in renderer parameter...
Definition: MapPainter.h:58
uint32_t GetRegionMaxWords() const
Definition: LocationIndex.h:203
const std::vector< std::string > & GetPOIIgnoreTokens() const
Definition: LocationIndex.h:190
Definition: ObjectPool.h:33
~ScopeCacheCleaner()
Definition: LocationIndex.h:67
Definition: Location.h:58
ScopeCacheCleaner(std::shared_ptr< LocationIndex > index)
Definition: LocationIndex.h:58
Definition: Location.h:38
uint32_t GetPOIMaxWords() const
Definition: LocationIndex.h:208
#define OSMSCOUT_API
Definition: CoreImportExport.h:45
Definition: LocationIndex.h:55
Definition: Location.h:163
uint32_t GetLocationMaxWords() const
Definition: LocationIndex.h:213
Definition: Location.h:90
uint64_t FileOffset
Definition: OSMScoutTypes.h:47
const std::vector< std::string > & GetLocationIgnoreTokens() const
Definition: LocationIndex.h:195
Definition: Location.h:198
Definition: LocationIndex.h:47
uint32_t GetAddressMaxWords() const
Definition: LocationIndex.h:218
std::shared_ptr< LocationIndex > LocationIndexRef
Definition: LocationIndex.h:272
std::shared_ptr< AdminRegion > AdminRegionRef
Definition: Location.h:83