libosmscout  1.1.1
Location.h
Go to the documentation of this file.
1 #ifndef OSMSCOUT_LOCATION_H
2 #define OSMSCOUT_LOCATION_H
3 
4 /*
5  This source is part of the libosmscout library
6  Copyright (C) 2009 Tim Teulings
7 
8  This library is free software; you can redistribute it and/or
9  modify it under the terms of the GNU Lesser General Public
10  License as published by the Free Software Foundation; either
11  version 2.1 of the License, or (at your option) any later version.
12 
13  This library is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  Lesser General Public License for more details.
17 
18  You should have received a copy of the GNU Lesser General Public
19  License along with this library; if not, write to the Free Software
20  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22 
23 #include <list>
24 #include <memory>
25 #include <vector>
26 
27 #include <osmscout/ObjectRef.h>
28 #include <osmscout/TypeConfig.h>
29 
30 namespace osmscout {
39  {
40  public:
41  std::string name;
43  };
44 
45  using PostalAreaRef = std::shared_ptr<PostalArea>;
46 
59  {
60  public:
62  {
63  public:
64  std::string name;
65  std::string altName;
67  };
68 
72  std::string name;
73  std::string altName;
74  ObjectFileRef object;
75  std::vector<RegionAlias> aliases;
76  std::vector<PostalArea> postalAreas; //<! The list of postal areas
77  std::vector<FileOffset> childrenOffsets;
78 
79  public:
80  bool Match(const ObjectFileRef& object) const;
81  };
82 
83  using AdminRegionRef = std::shared_ptr<AdminRegion>;
84 
91  {
92  public:
93  enum Action {
101  error
102  };
103 
104  public:
105  virtual ~AdminRegionVisitor() = default;
106 
107  virtual Action Visit(const AdminRegion& region) = 0;
108  };
109 
116  {
117  public:
119  std::string name;
120  ObjectFileRef object;
121  };
122 
123  using POIRef = std::shared_ptr<POI>;
124 
131  {
132  public:
133  virtual ~POIVisitor() = default;
134 
135  virtual bool Visit(const AdminRegion& adminRegion,
136  const POI &poi) = 0;
137  };
138 
147  {
148  public:
152  std::string name;
153  std::vector<ObjectFileRef> objects;
154  };
155 
156  using LocationRef = std::shared_ptr<Location>;
157 
164  {
165  public:
166  virtual ~LocationVisitor() = default;
167 
171  virtual bool Visit(const AdminRegion& adminRegion,
172  const PostalArea& postalArea,
173  const Location &location) = 0;
174  };
175 
182  {
183  public:
187  std::string name;
188  ObjectFileRef object;
189  };
190 
191  using AddressRef = std::shared_ptr<Address>;
192 
199  {
200  public:
201  virtual ~AddressVisitor() = default;
202 
203  virtual bool Visit(const AdminRegion& adminRegion,
204  const PostalArea& postalArea,
205  const Location& location,
206  const Address& address) = 0;
207  };
208 
213  {
214  public:
216  {
217  public:
222  };
223 
224  private:
225  size_t limit;
226 
227  public:
228  std::list<AddressResult> results;
230 
231  public:
232  explicit AddressListVisitor(size_t limit);
233 
234  bool Visit(const AdminRegion& adminRegion,
235  const PostalArea& postalArea,
236  const Location& location,
237  const Address& address) override;
238  };
239 
254  {
255  private:
256  ObjectFileRef object;
257  FeatureValueBufferRef objectFeatures;
258  AdminRegionRef adminRegion;
259  PostalAreaRef postalArea;
260  POIRef poi;
261  LocationRef location;
262  AddressRef address;
263 
264  public:
265  Place(const ObjectFileRef& object,
266  const FeatureValueBufferRef& objectFeatureBuff,
267  const AdminRegionRef& adminRegion,
268  const PostalAreaRef& postalArea,
269  const POIRef& poi,
270  const LocationRef& location,
271  const AddressRef& address);
272 
273  inline ObjectFileRef GetObject() const
274  {
275  return object;
276  }
277 
279  {
280  return objectFeatures;
281  }
282 
284  {
285  return adminRegion;
286  }
287 
289  {
290  return postalArea;
291  }
292 
293  inline POIRef GetPOI() const
294  {
295  return poi;
296  }
297 
298  inline LocationRef GetLocation() const
299  {
300  return location;
301  }
302 
303 
304  inline AddressRef GetAddress() const
305  {
306  return address;
307  }
308 
309  std::string GetDisplayString() const;
310  };
311 }
312 
313 #endif
FileOffset dataOffset
Offset of the data part of this entry.
Definition: Location.h:70
PostalAreaRef GetPostalArea() const
Definition: Location.h:288
FileOffset addressesOffset
Offset to the list of addresses.
Definition: Location.h:151
Do not visit child regions, but continue with traversal.
Definition: Location.h:95
ObjectFileRef GetObject() const
Definition: Location.h:273
Definition: Location.h:115
std::string name
Alias.
Definition: Location.h:64
std::string name
Name of the postal area.
Definition: Location.h:41
std::string name
name of the POI
Definition: Location.h:119
bool limitReached
Definition: Location.h:229
std::string name
name of the region
Definition: Location.h:72
Definition: Location.h:130
std::vector< FileOffset > childrenOffsets
The list of child region offset.
Definition: Location.h:77
Definition: Location.h:146
Definition: Location.h:61
std::list< AddressResult > results
Definition: Location.h:228
std::string name
name of the location
Definition: Location.h:152
Definition: Location.h:181
Stop.
Definition: Location.h:99
std::vector< RegionAlias > aliases
The list of alias for this region.
Definition: Location.h:75
FileOffset addressOffset
Offset of the address entry.
Definition: Location.h:184
FileOffset locationOffset
Offset to location.
Definition: Location.h:149
AddressRef address
The address itself.
Definition: Location.h:221
Visit child regions.
Definition: Location.h:97
LocationRef GetLocation() const
Definition: Location.h:298
Definition: Location.h:58
AdminRegionRef GetAdminRegion() const
Definition: Location.h:283
std::vector< ObjectFileRef > objects
List of objects that build up this location.
Definition: Location.h:153
std::vector< PostalArea > postalAreas
Definition: Location.h:76
std::shared_ptr< Address > AddressRef
Definition: Location.h:191
FeatureValueBufferRef GetObjectFeatures() const
Definition: Location.h:278
std::shared_ptr< FeatureValueBuffer > FeatureValueBufferRef
Definition: TypeConfig.h:871
Definition: Area.h:38
Action
Definition: Location.h:93
std::shared_ptr< PostalArea > PostalAreaRef
Definition: Location.h:45
std::string altName
Definition: Location.h:65
Definition: Location.h:38
std::string altName
Definition: Location.h:73
std::string name
name of the address
Definition: Location.h:187
Definition: Location.h:212
#define OSMSCOUT_API
Definition: CoreImportExport.h:45
FileOffset regionOffset
Offset of this entry in the index.
Definition: Location.h:69
FileOffset objectOffset
Offset of the postal area data.
Definition: Location.h:42
LocationRef location
The location the address belongs to.
Definition: Location.h:220
AddressRef GetAddress() const
Definition: Location.h:304
ObjectFileRef object
Reference to the object.
Definition: Location.h:120
Definition: Location.h:163
ObjectFileRef object
Object that represents the address.
Definition: Location.h:188
FileOffset regionOffset
Offset of the admin region this location is in.
Definition: Location.h:186
FileOffset parentRegionOffset
Offset of the parent region index entry.
Definition: Location.h:71
FileOffset regionOffset
Offset of the admin region this location is in.
Definition: Location.h:150
std::shared_ptr< POI > POIRef
Definition: Location.h:123
Definition: Location.h:90
uint64_t FileOffset
Definition: OSMScoutTypes.h:47
FileOffset locationOffset
Offset to location.
Definition: Location.h:185
Definition: Location.h:198
AdminRegionRef adminRegion
The admin region the address is contained by.
Definition: Location.h:218
Definition: Location.h:253
FileOffset objectOffset
Node data offset of the alias.
Definition: Location.h:66
FileOffset regionOffset
Offset of the region this location is in.
Definition: Location.h:118
POIRef GetPOI() const
Definition: Location.h:293
ObjectFileRef object
The object that represents this region.
Definition: Location.h:74
std::shared_ptr< AdminRegion > AdminRegionRef
Definition: Location.h:83
std::shared_ptr< Location > LocationRef
Definition: Location.h:156
PostalAreaRef postalArea
The postal area.
Definition: Location.h:219