1#ifndef OSMSCOUT_IMPORT_GENLOCATIONINDEX_H
2#define OSMSCOUT_IMPORT_GENLOCATIONINDEX_H
25#include <unordered_map>
26#include <unordered_set>
85 const ObjectFileRef&
object)
94 return object.GetFileOffset()<other.object.GetFileOffset();
104 ObjectFileRef object;
107 const ObjectFileRef&
object)
116 return object.GetFileOffset()<other.object.GetFileOffset();
126 std::unordered_map<std::string,
151 const ObjectFileRef& objectRef);
180 std::vector<GeoBox> boundingBoxes;
182 std::vector<GeoCoord> probePoints;
195 std::vector<std::vector<GeoCoord>>
areas;
218 return boundingBoxes;
222 const GeoCoord& node);
225 const std::string&
name,
229 const std::string&
name,
230 const std::vector<Point>& nodes,
231 const GeoBox& boundingBox,
235 const std::string&
name,
236 const std::vector<Point>& nodes,
237 const GeoBox& boundingBox,
241 const std::string& postalCode,
242 const ObjectFileRef& objectRef);
245 const std::vector<Point>& nodes,
246 const std::string&
name,
247 const std::string& postalCode,
248 const GeoBox& boundingBox);
251 const std::string&
name,
252 const std::string& postalCode,
253 const GeoBox& boundingBox);
256 bool assume_contains=
true);
259 void CalculateProbePoints();
260 void CalculateProbePointsForArea(
size_t areaIndex,
261 size_t refinement=0);
269 std::map<Pixel,std::list<RegionRef> > index;
275 void IndexRegions(
const std::vector<std::list<locidx::RegionRef> >& regionTree);
278 const GeoCoord& coord)
const;
291 uint8_t bytesForNodeFileOffset;
292 uint8_t bytesForAreaFileOffset;
293 uint8_t bytesForWayFileOffset;
301 void CalculateRegionMetrics(
const locidx::Region& region,
302 locidx::RegionMetrics& metrics)
const;
304 void DumpRegion(
const locidx::Region& parent,
306 std::ostream&
out)
const;
308 void DumpRegionAndData(
const locidx::Region& parent,
310 std::ostream&
out)
const;
312 bool DumpRegionTree(
Progress& progress,
313 const locidx::Region& rootRegion,
314 const std::string& filename)
const;
316 bool DumpLocationTree(
Progress& progress,
317 const locidx::Region& rootRegion,
318 const std::string& filename)
const;
320 bool DumpLocationMetrics(
Progress& progress,
321 const std::string& filename,
322 const locidx::RegionMetrics& metrics,
323 const std::list<std::string>& regionIgnoreTokens,
324 const std::list<std::string>& poiIgnoreTokens,
325 const std::list<std::string>& locationIgnoreTokens)
const;
331 std::vector<std::list<locidx::RegionRef>>& boundaryAreas)
const;
333 void SortInBoundaries(
Progress& progress,
334 locidx::Region& rootRegion,
335 const std::list<locidx::RegionRef>& boundaryAreas);
337 bool GetRegionAreas(
const TypeConfig& typeConfig,
340 std::list<locidx::RegionRef>& regionAreas)
const;
342 bool SortInRegionAreas(
Progress& progress,
343 locidx::Region& rootRegion,
344 std::list<locidx::RegionRef>& regionAreas);
347 std::vector<std::list<locidx::RegionRef> >& regionTree,
348 unsigned long level);
350 unsigned long GetRegionTreeDepth(
const locidx::Region& rootRegion)
const;
355 const locidx::RegionIndex& regionIndex,
358 bool IndexLocationAreas(
const TypeConfig& typeConfig,
361 const locidx::RegionIndex& regionIndex,
364 bool IndexLocationWays(
const TypeConfig& typeConfig,
367 const locidx::RegionIndex& regionIndex,
372 const Area::Ring& ring,
373 const std::string& name,
374 const std::string& postalCode,
375 const locidx::RegionIndex& regionIndex);
377 void AddAddressToRegion(
Progress& progress,
378 locidx::Region& region,
380 const std::string& location,
381 const std::string& address,
382 const std::string &postalCode,
383 bool allowDuplicates,
386 void AddAddressAreaToRegion(
Progress& progress,
387 locidx::Region& region,
389 const std::string& location,
390 const std::string& address,
391 const std::string &postalCode,
392 const std::vector<Point>&
nodes,
393 const GeoBox& boundingBox,
396 bool IndexAddressAreas(
const TypeConfig& typeConfig,
400 const locidx::RegionIndex& regionIndex);
402 bool AddAddressWayToRegion(
Progress& progress,
403 locidx::Region& region,
405 const std::string& location,
406 const std::string& address,
407 const std::vector<Point>&
nodes,
408 const GeoBox& boundingBox,
411 bool IndexAddressWays(
const TypeConfig& typeConfig,
415 const locidx::RegionIndex& regionIndex);
429 std::map<std::string,locidx::RegionLocation>::iterator FindLocation(
Progress& progress,
430 const locidx::Region& region,
431 locidx::PostalArea& postalArea,
432 const std::string &locationName)
const;
434 void AddAddressNodeToRegion(
Progress& progress,
435 locidx::Region& region,
437 const std::string& location,
438 const std::string& address,
439 const std::string& postalCode,
442 bool IndexAddressNodes(
const TypeConfig& typeConfig,
446 const locidx::RegionIndex& regionIndex);
448 void CleanupPostalAreasAdresses(locidx::Region& region);
449 void CleanupPostalAreasLocations(locidx::Region& region);
450 void CleanupPostalAreas(locidx::Region& region);
452 void SortLocationTree(locidx::Region& region);
454 void ValidateIsIn(locidx::Region& region);
457 const std::list<std::string>& regionIgnoreTokens,
458 const std::list<std::string>& poiIgnoreTokens,
459 const std::list<std::string>& locationIgnoreTokens)
const;
462 const locidx::RegionMetrics& metrics)
const;
464 void WriteRegionIndexEntry(
FileWriter& writer,
465 const locidx::Region& parentRegion,
466 locidx::Region& region);
469 locidx::Region& region);
472 locidx::Region& region);
475 locidx::Region& region);
478 locidx::PostalArea& postalArea)
const;
480 void WriteAddressDataEntry(
FileWriter& writer,
481 const locidx::Region& region);
484 const locidx::Region& region);
488 ImportModuleDescription& description)
const override;
void GetDescription(const ImportParameter ¶meter, ImportModuleDescription &description) const override
static const char *const FILENAME_LOCATION_REGION_TXT
Definition GenLocationIndex.h:286
std::vector< Point > nodes
List of nodes.
Definition Way.h:57
void Write(const TypeConfig &typeConfig, FileWriter &writer) const
static const char *const FILENAME_LOCATION_METRICS_TXT
Definition GenLocationIndex.h:288
bool Import(const TypeConfigRef &typeConfig, const ImportParameter ¶meter, Progress &progress) override
@ out
Definition WaterIndexProcessor.h:270
static const char *const FILENAME_LOCATION_FULL_TXT
Definition GenLocationIndex.h:287
Definition ImportModule.h:101
uint64_t FileOffset
Definition OSMScoutTypes.h:46
std::shared_ptr< TypeConfig > TypeConfigRef
Definition TypeConfig.h:1396
Definition GenLocationIndex.h:42
std::shared_ptr< Region > RegionRef
Definition GenLocationIndex.h:156
std::shared_ptr< ImportErrorReporter > ImportErrorReporterRef
Definition ImportErrorReporter.h:137
Definition GenLocationIndex.h:49
uint32_t maxAddressWords
Definition GenLocationIndex.h:59
bool CouldContain(const Region ®ion, bool strict) const
bool AddPOIWay(const FileOffset &fileOffset, const std::string &name, const std::vector< Point > &nodes, const GeoBox &boundingBox, bool &added)
void AddPOINode(const FileOffset &fileOffset, const std::string &name, bool &added)
FileOffset reference
Reference to the node that is the alias.
Definition GenLocationIndex.h:71
bool AddRegion(const RegionRef ®ion, bool assume_contains=true)
bool AddLocationArea(const Area &area, const std::vector< Point > &nodes, const std::string &name, const std::string &postalCode, const GeoBox &boundingBox)
std::unordered_map< std::string, PostalArea > PostalAreaMap
Definition GenLocationIndex.h:177
ObjectFileRef object
Object.
Definition GenLocationIndex.h:82
std::vector< GeoBox > GetAreaBoundingBoxes() const
Definition GenLocationIndex.h:216
uint32_t minLocationChars
Definition GenLocationIndex.h:55
RegionAddress(const std::string &name, const ObjectFileRef &object)
Definition GenLocationIndex.h:106
void AddAlias(const RegionAlias &location, const GeoCoord &node)
FileOffset dataOffsetOffset
Offset of place where the address list offset is stored.
Definition GenLocationIndex.h:128
uint32_t minLocationWords
Definition GenLocationIndex.h:57
bool CouldContain(const GeoBox &boundingBox) const
std::list< RegionAlias > aliases
Location that are represented by this region.
Definition GenLocationIndex.h:192
bool operator<(const RegionAddress &other) const
Definition GenLocationIndex.h:114
FileOffset dataOffset
Offset into the index file.
Definition GenLocationIndex.h:186
bool Contains(Region &child) const
PostalArea(const std::string &name)
Definition GenLocationIndex.h:144
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:127
bool operator<(const RegionPOI &other) const
Definition GenLocationIndex.h:92
void AddPOIArea(const FileOffset &fileOffset, const std::string &name, const std::vector< Point > &nodes, const GeoBox &boundingBox, bool &added)
uint32_t maxPOIWords
Definition GenLocationIndex.h:54
uint32_t maxRegionChars
Definition GenLocationIndex.h:51
uint32_t minRegionWords
Definition GenLocationIndex.h:52
RegionIndex(double cellWidth, double cellheight)
void IndexRegions(const std::vector< std::list< locidx::RegionRef > > ®ionTree)
void AddLocationObject(const std::string &name, const ObjectFileRef &objectRef)
GeoBox GetBoundingBox() const
Checks whether child is within this.
Definition GenLocationIndex.h:211
std::map< std::string, RegionLocation > locations
list of indexed objects in this region
Definition GenLocationIndex.h:142
RegionPOI(const std::string &name, const ObjectFileRef &object)
Definition GenLocationIndex.h:84
std::string name
The alias itself.
Definition GenLocationIndex.h:72
void AddLocationObject(const std::string &name, const std::string &postalCode, const ObjectFileRef &objectRef)
std::list< RegionPOI > pois
A list of POIs in this region.
Definition GenLocationIndex.h:196
std::vector< std::vector< GeoCoord > > areas
the geometric area of this region
Definition GenLocationIndex.h:195
uint32_t minRegionChars
Definition GenLocationIndex.h:50
RegionRef GetRegionForNode(const RegionRef &rootRegion, const GeoCoord &coord) const
FileOffset indexOffset
Offset into the index file.
Definition GenLocationIndex.h:185
uint32_t maxLocationWords
Definition GenLocationIndex.h:58
uint32_t maxLocationChars
Definition GenLocationIndex.h:56
bool AddLocationWay(const Way &way, const std::string &name, const std::string &postalCode, const GeoBox &boundingBox)
int8_t level
Admin level or -1 if not set.
Definition GenLocationIndex.h:193
std::string GetName() const
std::list< RegionRef > regions
A list of sub regions.
Definition GenLocationIndex.h:200
std::list< ObjectFileRef > objects
Objects that represent this location.
Definition GenLocationIndex.h:129
PostalAreaMap postalAreas
Collection of objects without a postal code.
Definition GenLocationIndex.h:197
std::list< RegionAddress > addresses
Addresses at this location.
Definition GenLocationIndex.h:130
uint32_t maxRegionWords
Definition GenLocationIndex.h:53
std::string altName
Definition GenLocationIndex.h:73
std::string isIn
Name of the parent region as stated in OSM (is_in tag).
Definition GenLocationIndex.h:191
PostalAreaMap::iterator defaultPostalArea
PostalArea for postal code "".
Definition GenLocationIndex.h:198