1 #ifndef OSMSCOUT_IMPORT_GENLOCATIONINDEX_H 2 #define OSMSCOUT_IMPORT_GENLOCATIONINDEX_H 25 #include <unordered_map> 26 #include <unordered_set> 42 class LocationIndexGenerator
CLASS_FINAL :
public ImportModule
87 const ObjectFileRef&
object)
96 return object.GetFileOffset()<other.object.GetFileOffset();
103 ObjectFileRef object;
106 const ObjectFileRef&
object)
115 return object.GetFileOffset()<other.object.GetFileOffset();
121 std::unordered_map<std::string,
127 std::string GetName()
const;
132 typedef std::shared_ptr<Region> RegionRef;
146 void AddLocationObject(
const std::string& name,
147 const ObjectFileRef& objectRef);
162 std::vector<GeoBox> boundingBoxes;
164 std::vector<GeoCoord> probePoints;
177 std::vector<std::vector<GeoCoord>>
areas;
187 void CalculateMinMax();
188 bool CouldContain(
const GeoBox& boundingBox)
const;
189 bool CouldContain(
const Region& region,
bool strict)
const;
191 bool Contains(Region& child)
const;
200 return boundingBoxes;
203 void AddLocationObject(
const std::string& name,
204 const std::string& postalCode,
205 const ObjectFileRef& objectRef);
208 void CalculateProbePoints();
209 void CalculateProbePointsForArea(
size_t areaIndex,
210 size_t refinement=0);
216 std::map<Pixel,std::list<RegionRef> >
index;
221 RegionRef GetRegionForNode(RegionRef& rootRegion,
222 const GeoCoord& coord)
const;
226 uint8_t bytesForNodeFileOffset;
227 uint8_t bytesForAreaFileOffset;
228 uint8_t bytesForWayFileOffset;
233 void Write(FileWriter& writer,
234 const ObjectFileRef&
object);
236 void AnalyseStringForIgnoreTokens(
const std::string&
string,
237 std::unordered_map<std::string,size_t>& ignoreTokens,
238 std::unordered_set<std::string>& blacklist);
240 void CalculateRegionNameIgnoreTokens(
const Region& parent,
241 std::unordered_map<std::string,size_t>& ignoreTokens,
242 std::unordered_set<std::string>& blacklist);
244 void CalculatePOINameIgnoreTokens(
const Region& parent,
245 std::unordered_map<std::string,size_t>& ignoreTokens,
246 std::unordered_set<std::string>& blacklist);
248 void CalculateLocationNameIgnoreTokens(
const Region& parent,
249 std::unordered_map<std::string,size_t>& ignoreTokens,
250 std::unordered_set<std::string>& blacklist);
252 bool CalculateIgnoreTokens(
const Region& rootRegion,
253 std::list<std::string>& regionTokens,
254 std::list<std::string>& poiTokens,
255 std::list<std::string>& locationTokens);
258 void CalculateRegionMetrics(
const Region& region,
259 RegionMetrics& metrics);
261 void DumpRegion(
const Region& parent,
265 void DumpRegionAndData(
const Region& parent,
269 bool DumpRegionTree(
Progress& progress,
270 const Region& rootRegion,
271 const std::string& filename);
273 bool DumpLocationTree(
Progress& progress,
274 const Region& rootRegion,
275 const std::string& filename);
277 bool DumpLocationMetrics(
Progress& progress,
278 const std::string& filename,
279 const LocationIndexGenerator::RegionMetrics& metrics,
280 const std::list<std::string>& regionIgnoreTokens,
281 const std::list<std::string>& poiIgnoreTokens,
282 const std::list<std::string>& locationIgnoreTokens);
284 bool AddRegion(Region& parent,
285 const RegionRef& region,
286 bool assume_contains=
true);
288 bool GetBoundaryAreas(
const ImportParameter& parameter,
291 const TypeInfoSet& boundaryTypes,
292 std::vector<std::list<RegionRef>>& boundaryAreas);
294 void SortInBoundaries(
Progress& progress,
296 std::list<RegionRef>& boundaryAreas);
298 bool GetRegionAreas(
const TypeConfig& typeConfig,
299 const ImportParameter& parameter,
301 std::list<RegionRef>& regionAreas);
303 bool SortInRegionAreas(
Progress& progress,
305 std::list<RegionRef>& regionAreas);
307 void SortInRegion(RegionRef& area,
308 std::vector<std::list<RegionRef> >& regionTree,
309 unsigned long level);
311 unsigned long GetRegionTreeDepth(
const Region& rootRegion);
313 void IndexRegions(
const std::vector<std::list<RegionRef> >& regionTree,
314 RegionIndex& regionIndex);
316 void AddAliasToRegion(Region& region,
317 const RegionAlias& location,
318 const GeoCoord& node);
321 const ImportParameter& parameter,
323 RegionRef& rootRegion,
324 const RegionIndex& regionIndex);
326 bool AddLocationAreaToRegion(Region& region,
328 const std::vector<Point>& nodes,
329 const std::string& name,
330 const std::string& postalCode,
331 const GeoBox& boundingBox);
333 void AddLocationAreaToRegion(RegionRef& rootRegion,
335 const Area::Ring& ring,
336 const std::string& name,
337 const std::string& postalCode,
338 const RegionIndex& regionIndex);
340 bool IndexLocationAreas(
const TypeConfig& typeConfig,
341 const ImportParameter& parameter,
343 RegionRef& rootRegion,
344 const RegionIndex& regionIndex);
346 bool AddLocationWayToRegion(Region& region,
348 const std::string& name,
349 const std::string& postalCode,
350 const GeoBox& boundingBox);
352 bool IndexLocationWays(
const TypeConfig& typeConfig,
353 const ImportParameter& parameter,
355 RegionRef& rootRegion,
356 const RegionIndex& regionIndex);
358 void AddAddressToRegion(
Progress& progress,
360 const ObjectFileRef&
object,
361 const std::string& location,
362 const std::string& address,
363 const std::string &postalCode,
364 bool allowDuplicates,
367 void AddAddressAreaToRegion(
Progress& progress,
370 const std::string& location,
371 const std::string& address,
372 const std::string &postalCode,
373 const std::vector<Point>& nodes,
374 const GeoBox& boundingBox,
377 void AddPOIAreaToRegion(
Progress& progress,
380 const std::string& name,
381 const std::vector<Point>& nodes,
382 const GeoBox& boundingBox,
385 bool IndexAddressAreas(
const TypeConfig& typeConfig,
386 const ImportParameter& parameter,
388 RegionRef& rootRegion,
389 const RegionIndex& regionIndex);
391 bool AddAddressWayToRegion(
Progress& progress,
394 const std::string& location,
395 const std::string& address,
396 const std::vector<Point>& nodes,
397 const GeoBox& boundingBox,
400 bool AddPOIWayToRegion(
Progress& progress,
403 const std::string& name,
404 const std::vector<Point>& nodes,
405 const GeoBox& boundingBox,
408 bool IndexAddressWays(
const TypeConfig& typeConfig,
409 const ImportParameter& parameter,
411 RegionRef& rootRegion,
412 const RegionIndex& regionIndex);
426 std::map<std::string,RegionLocation>::iterator FindLocation(
Progress& progress,
429 const std::string &locationName);
431 void AddAddressNodeToRegion(
Progress& progress,
434 const std::string& location,
435 const std::string& address,
436 const std::string& postalCode,
439 void AddPOINodeToRegion(Region& region,
441 const std::string& name,
444 bool IndexAddressNodes(
const TypeConfig& typeConfig,
445 const ImportParameter& parameter,
447 RegionRef& rootRegion,
448 const RegionIndex& regionIndex);
450 void CleanupPostalAreas(Region& region);
452 void WriteIgnoreTokens(FileWriter& writer,
453 const std::list<std::string>& regionIgnoreTokens,
454 const std::list<std::string>& poiIgnoreTokens,
455 const std::list<std::string>& locationIgnoreTokens);
457 void WriteRegionMetrics(FileWriter& writer,
458 const RegionMetrics& metrics);
460 void WriteRegionIndexEntry(FileWriter& writer,
461 const Region& parentRegion,
464 void WriteRegionIndex(FileWriter& writer,
467 void WriteRegionDataEntry(FileWriter& writer,
470 void WriteRegionData(FileWriter& writer,
473 void WritePostalArea(FileWriter& writer,
476 void WriteAddressDataEntry(FileWriter& writer,
479 void WriteAddressData(FileWriter& writer,
483 void GetDescription(
const ImportParameter& parameter,
484 ImportModuleDescription& description)
const override;
487 const ImportParameter& parameter,
GeoBox GetBoundingBox() const
Checks whether child is within this.
Definition: GenLocationIndex.h:193
uint32_t minLocationWords
Definition: GenLocationIndex.h:59
FileOffset indexOffset
Offset into the index file.
Definition: GenLocationIndex.h:167
PostalAreaMap::iterator defaultPostalArea
PostalArea for postal code "".
Definition: GenLocationIndex.h:180
std::shared_ptr< ImportErrorReporter > ImportErrorReporterRef
Definition: ImportErrorReporter.h:137
std::list< RegionRef > regions
A list of sub regions.
Definition: GenLocationIndex.h:182
std::map< std::string, RegionLocation > locations
list of indexed objects in this region
Definition: GenLocationIndex.h:138
double cellWidth
Definition: GenLocationIndex.h:217
std::map< Pixel, std::list< RegionRef > > index
Definition: GenLocationIndex.h:216
bool operator<(const RegionPOI &other) const
Definition: GenLocationIndex.h:94
std::list< RegionAddress > addresses
Addresses at this location.
Definition: GenLocationIndex.h:125
std::list< RegionPOI > pois
A list of POIs in this region.
Definition: GenLocationIndex.h:178
uint32_t maxRegionChars
Definition: GenLocationIndex.h:53
std::string altName
Definition: GenLocationIndex.h:75
uint32_t maxRegionWords
Definition: GenLocationIndex.h:55
const std::vector< GeoBox > GetAreaBoundingBoxes() const
Definition: GenLocationIndex.h:198
uint32_t minRegionChars
Definition: GenLocationIndex.h:52
RegionAddress(const std::string &name, const ObjectFileRef &object)
Definition: GenLocationIndex.h:105
RegionPOI(const std::string &name, const ObjectFileRef &object)
Definition: GenLocationIndex.h:86
ObjectFileRef object
Object.
Definition: GenLocationIndex.h:84
static const char *const FILENAME_LOCATION_REGION_TXT
Definition: GenLocationIndex.h:45
Definition: Location.h:38
uint32_t minLocationChars
Definition: GenLocationIndex.h:57
double cellHeight
Definition: GenLocationIndex.h:218
std::unordered_map< std::string, PostalArea > PostalAreaMap
Definition: GenLocationIndex.h:159
static const char *const FILENAME_LOCATION_METRICS_TXT
Definition: GenLocationIndex.h:47
bool operator<(const RegionAddress &other) const
Definition: GenLocationIndex.h:113
FileOffset dataOffsetOffset
Offset of place where the address list offset is stored.
Definition: GenLocationIndex.h:123
uint32_t maxPOIWords
Definition: GenLocationIndex.h:56
#define CLASS_FINAL
Definition: Compiler.h:26
Definition: LaneAgent.h:60
std::string isIn
Name of the parent region as stated in OSM (is_in tag)
Definition: GenLocationIndex.h:173
FileOffset reference
Reference to the node that is the alias.
Definition: GenLocationIndex.h:73
ObjectFileRef reference
Reference to the object this area is based on.
Definition: GenLocationIndex.h:170
std::unordered_map< std::string, size_t > names
map of names in different case used for this location and their use count
Definition: GenLocationIndex.h:122
uint32_t minRegionWords
Definition: GenLocationIndex.h:54
uint64_t FileOffset
Definition: OSMScoutTypes.h:47
uint32_t maxLocationChars
Definition: GenLocationIndex.h:58
uint32_t maxAddressWords
Definition: GenLocationIndex.h:61
std::list< RegionAlias > aliases
Location that are represented by this region.
Definition: GenLocationIndex.h:174
Definition: Progress.h:34
std::list< ObjectFileRef > objects
Objects that represent this location.
Definition: GenLocationIndex.h:124
std::shared_ptr< TypeConfig > TypeConfigRef
Definition: TypeConfig.h:1227
PostalArea(const std::string &name)
Definition: GenLocationIndex.h:140
FileOffset dataOffset
Offset into the index file.
Definition: GenLocationIndex.h:168
std::vector< std::vector< GeoCoord > > areas
the geometric area of this region
Definition: GenLocationIndex.h:177
PostalAreaMap postalAreas
Collection of objects without a postal code.
Definition: GenLocationIndex.h:179
static const char *const FILENAME_LOCATION_FULL_TXT
Definition: GenLocationIndex.h:46
uint32_t maxLocationWords
Definition: GenLocationIndex.h:60