libosmscout 1.1.1
Loading...
Searching...
No Matches
AreaIndex.h
Go to the documentation of this file.
1#ifndef LIBOSMSCOUT_AREAYINDEX_H
2#define LIBOSMSCOUT_AREAYINDEX_H
3/*
4 This source is part of the libosmscout library
5 Copyright (C) 2011 Tim Teulings
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20*/
21
22#include <memory>
23#include <mutex>
24#include <unordered_set>
25#include <vector>
26
27#include <osmscout/TypeConfig.h>
29
31
33
34namespace osmscout {
35
41 {
42 protected:
43 struct TypeData
44 {
46 MagnificationLevel indexLevel;
47
50
51 TileIdBox tileBox;
52
54
56
58 FileOffset GetCellOffset(size_t x, size_t y) const;
59 };
60
61 private:
62 std::string indexFileName;
63 std::string fullIndexFileName;
64
65 std::vector<TypeData> typeData;
66
67 mutable std::mutex lookupMutex;
68
69 protected:
70 mutable FileScanner scanner;
71
72 protected:
73 void GetOffsets(const TypeData& typeData,
74 const GeoBox& boundingBox,
75 std::unordered_set<FileOffset>& offsets) const;
76
77 explicit AreaIndex(const std::string &indexFileName);
78
79 virtual void ReadTypeData(const TypeConfigRef& typeConfig,
80 TypeData &data) = 0;
81
82 public:
83 AreaIndex() = default;
84
85 // disable copy and move
86 AreaIndex(const AreaIndex&) = delete;
87 AreaIndex(AreaIndex&&) = delete;
88 AreaIndex& operator=(const AreaIndex&) = delete;
90
91 virtual ~AreaIndex();
92
93 void Close();
94 bool Open(const TypeConfigRef& typeConfig,
95 const std::string& path,
96 bool memoryMappedData);
97
98 bool IsOpen() const
99 {
100 return scanner.IsOpen();
101 }
102
103 std::string GetFilename() const
104 {
105 return fullIndexFileName;
106 }
107
108 bool GetOffsets(const GeoBox& boundingBox,
109 const TypeInfoSet& types,
110 std::vector<FileOffset>& offsets,
111 TypeInfoSet& loadedTypes) const;
112 };
113}
114
115#endif //LIBOSMSCOUT_AREAYINDEX_H
#define OSMSCOUT_API
Definition CoreImportExport.h:45
AreaIndex(const AreaIndex &)=delete
FileScanner scanner
Scanner instance for reading this file.
Definition AreaIndex.h:70
std::string GetFilename() const
Definition AreaIndex.h:103
virtual void ReadTypeData(const TypeConfigRef &typeConfig, TypeData &data)=0
AreaIndex & operator=(const AreaIndex &)=delete
bool IsOpen() const
Definition AreaIndex.h:98
AreaIndex(const std::string &indexFileName)
AreaIndex(AreaIndex &&)=delete
bool Open(const TypeConfigRef &typeConfig, const std::string &path, bool memoryMappedData)
AreaIndex & operator=(AreaIndex &&)=delete
bool GetOffsets(const GeoBox &boundingBox, const TypeInfoSet &types, std::vector< FileOffset > &offsets, TypeInfoSet &loadedTypes) const
void GetOffsets(const TypeData &typeData, const GeoBox &boundingBox, std::unordered_set< FileOffset > &offsets) const
uint64_t FileOffset
Definition OSMScoutTypes.h:46
std::shared_ptr< TypeConfig > TypeConfigRef
Definition TypeConfig.h:1396
Definition Area.h:39
std::shared_ptr< TypeInfo > TypeInfoRef
Definition TypeConfig.h:61
Definition AreaIndex.h:44
FileOffset GetDataOffset() const
FileOffset GetCellOffset(size_t x, size_t y) const
uint8_t dataOffsetBytes
Definition AreaIndex.h:48
TypeInfoRef type
Definition AreaIndex.h:45
MagnificationLevel indexLevel
Definition AreaIndex.h:46
GeoBox boundingBox
Definition AreaIndex.h:53
FileOffset bitmapOffset
Definition AreaIndex.h:49
TileIdBox tileBox
Definition AreaIndex.h:51