libosmscout
0.1
|
Representation of an (complex/multipolygon) area. More...
#include <Area.h>
Classes | |
class | Ring |
Public Types | |
using | RingVisitor = std::function< bool(size_t i, const Ring &, const TypeInfoRef &)> |
Public Member Functions | |
Area ()=default | |
GeoBox | GetBoundingBox () const |
bool | GetCenter (GeoCoord ¢er) const |
const FeatureValueBuffer & | GetFeatureValueBuffer () const |
FileOffset | GetFileOffset () const |
FileOffset | GetNextFileOffset () const |
ObjectFileRef | GetObjectFileRef () const |
TypeInfoRef | GetRingType (const Ring &ring) const |
TypeInfoRef | GetType () const |
bool | Intersects (const GeoBox &boundingBox) const |
Returns true if the bounding box of the object intersects the given bounding box. More... | |
bool | IsSimple () const |
void | Read (const TypeConfig &typeConfig, FileScanner &scanner) |
Read the area as written by Write(). More... | |
void | ReadImport (const TypeConfig &typeConfig, FileScanner &scanner) |
Read the area as written by WriteImport(). More... | |
void | ReadOptimized (const TypeConfig &typeConfig, FileScanner &scanner) |
Read the area as stored by WriteOptimized(). More... | |
void | VisitClippingRings (size_t index, const RingVisitor &visitor) const |
Visit possible clippings of ring specified by index. More... | |
void | VisitRings (const RingVisitor &visitor) const |
Visit rings in breadth-first manner. More... | |
void | Write (const TypeConfig &typeConfig, FileWriter &writer) const |
Write the area with all data required in the standard db. More... | |
void | WriteImport (const TypeConfig &typeConfig, FileWriter &writer) const |
Write the area with all data required during import, certain optimizations done on the final data are not done here to not loose information. More... | |
void | WriteOptimized (const TypeConfig &typeConfig, FileWriter &writer) const |
Write the area with all data required by the OptimizeLowZoom index, dropping all ids. More... | |
Public Attributes | |
std::vector< Ring > | rings |
Static Public Attributes | |
static const uint8_t | masterRingId =0 |
static const uint8_t | outerRingId =1 |
Representation of an (complex/multipolygon) area.
It consists from hierarchy of rings:
This hierarchy may be presented as a tree, where ring number represent depth. Master ring is first and the rest of rings are ordered deep-first fashion in Area::rings vector (top-level outer rings are on the top of the tree).
When object consists just from single outline (simple building for example), Area contains just one (top level) outer ring
When area is multipolygon relation (in OSM words), type and features of such relation are stored in master ring. Every outer ring may have its own type and features.
When outer ring has not type (GetType()->GetIgnore()), type of relation (master ring) should be used. But OSM documentation is not clear what type should be used when outer ring has different type than relation. For example this relation: https://www.openstreetmap.org/relation/7826515
When inner ring has no type (GetType()->GetIgnore()) it is used as simple clipping of containing (upper) outer ring.
For example this ruin: https://www.openstreetmap.org/relation/7281899 Will have seven rings: [0] master (number 0) with type "building", without nodes [1] outer (number 1) without type, OSM id 295845013 [2] inner (number 2) without type, OSM id 495919001 [3] outer (number 3) without type, OSM id 495919003 [4] outer (number 3) without type, OSM id 495919002 [5] inner (number 2) without type, OSM id 495919008 [6] inner (number 2) without type, OSM id 495919006
Nested relations (member type=relation, role=inner|outer) are not supported for areas now. See RelAreaDataGenerator::ResolveMultipolygonMembers code for the details. For example relation https://www.openstreetmap.org/relation/7751062 will be created just with master and one outer ring. Its nested relation (inner role) https://www.openstreetmap.org/relation/7074095 will be imported as a separate Area.
using osmscout::Area::RingVisitor = std::function<bool(size_t i, const Ring&, const TypeInfoRef&)> |
|
default |
GeoBox osmscout::Area::GetBoundingBox | ( | ) | const |
References osmscout::GeoBox::Include(), and rings.
Referenced by osmscout::DescriptionService::GetDescription(), and osmscout::PolygonCenter().
bool osmscout::Area::GetCenter | ( | GeoCoord & | center | ) | const |
References rings, and osmscout::GeoCoord::Set().
|
inline |
|
inline |
|
inline |
|
inline |
References osmscout::refArea.
Referenced by osmscout::DescriptionService::GetDescription().
|
inline |
References osmscout::Area::Ring::GetType(), osmscout::Area::Ring::IsOuter(), and osmscout::Area::Ring::IsTopOuter().
Referenced by VisitClippingRings(), and VisitRings().
|
inline |
Referenced by Read().
|
inline |
Returns true if the bounding box of the object intersects the given bounding box.
boundingBox | bounding box to test for intersection |
References osmscout::GetBoundingBox().
|
inline |
void osmscout::Area::Read | ( | const TypeConfig & | typeConfig, |
FileScanner & | scanner | ||
) |
Read the area as written by Write().
Reads data from the given Filescanner.
Node ids will only be read if not thought to be required for this area.
IOException |
References osmscout::TypeConfig::GetAreaTypeIdBytes(), osmscout::TypeConfig::GetAreaTypeInfo(), osmscout::FileScanner::GetPos(), GetType(), osmscout::FileScanner::Read(), osmscout::FeatureValueBuffer::Read(), osmscout::FileScanner::ReadCoord(), osmscout::FileScanner::ReadTypeId(), osmscout::FileScanner::ReadUInt32Number(), osmscout::FileScanner::ReadUInt8(), rings, osmscout::FeatureValueBuffer::SetType(), and osmscout::typeIgnore.
void osmscout::Area::ReadImport | ( | const TypeConfig & | typeConfig, |
FileScanner & | scanner | ||
) |
Read the area as written by WriteImport().
Reads data from the given FileScanner.
All data available will be read.
IOException |
References osmscout::TypeConfig::GetAreaTypeIdBytes(), osmscout::TypeConfig::GetAreaTypeInfo(), osmscout::FileScanner::GetPos(), outerRingId, osmscout::FileScanner::Read(), osmscout::FeatureValueBuffer::Read(), osmscout::FileScanner::ReadTypeId(), osmscout::FileScanner::ReadUInt32Number(), osmscout::FileScanner::ReadUInt8(), rings, osmscout::FeatureValueBuffer::SetType(), and osmscout::typeIgnore.
void osmscout::Area::ReadOptimized | ( | const TypeConfig & | typeConfig, |
FileScanner & | scanner | ||
) |
Read the area as stored by WriteOptimized().
Reads data to the given FileScanner.
No node ids will be read.
IOException |
References osmscout::TypeConfig::GetAreaTypeIdBytes(), osmscout::TypeConfig::GetAreaTypeInfo(), osmscout::FileScanner::GetPos(), osmscout::FileScanner::Read(), osmscout::FeatureValueBuffer::Read(), osmscout::FileScanner::ReadCoord(), osmscout::FileScanner::ReadTypeId(), osmscout::FileScanner::ReadUInt32Number(), osmscout::FileScanner::ReadUInt8(), rings, osmscout::FeatureValueBuffer::SetType(), and osmscout::typeIgnore.
void osmscout::Area::VisitClippingRings | ( | size_t | index, |
const RingVisitor & | visitor | ||
) | const |
Visit possible clippings of ring specified by index.
We only take into account rings of the next level.
References osmscout::Area::Ring::GetRing(), GetRingType(), and rings.
void osmscout::Area::VisitRings | ( | const RingVisitor & | visitor | ) | const |
Visit rings in breadth-first manner.
When visitor return true for some ring, algorithm will continue deeper in hierarchy.
References osmscout::Area::Ring::GetRing(), GetRingType(), outerRingId, and rings.
Referenced by osmscout::PolygonCenter().
void osmscout::Area::Write | ( | const TypeConfig & | typeConfig, |
FileWriter & | writer | ||
) | const |
Write the area with all data required in the standard db.
Writes data to the given FileWriter.
Node ids will only be written if not thought to be required for this area.
IOException |
References osmscout::TypeConfig::GetAreaTypeIdBytes(), rings, osmscout::typeIgnore, osmscout::FileWriter::Write(), osmscout::FileWriter::WriteCoord(), osmscout::FileWriter::WriteNumber(), and osmscout::FileWriter::WriteTypeId().
void osmscout::Area::WriteImport | ( | const TypeConfig & | typeConfig, |
FileWriter & | writer | ||
) | const |
Write the area with all data required during import, certain optimizations done on the final data are not done here to not loose information.
Writes data to the given FileWriter.
All data available will be written.
IOException |
References osmscout::TypeConfig::GetAreaTypeIdBytes(), outerRingId, rings, osmscout::typeIgnore, osmscout::FileWriter::Write(), osmscout::FileWriter::WriteNumber(), and osmscout::FileWriter::WriteTypeId().
void osmscout::Area::WriteOptimized | ( | const TypeConfig & | typeConfig, |
FileWriter & | writer | ||
) | const |
Write the area with all data required by the OptimizeLowZoom index, dropping all ids.
Writes data to the given FileWriter.
No node ids will be written.
IOException |
References osmscout::TypeConfig::GetAreaTypeIdBytes(), rings, osmscout::typeIgnore, osmscout::FileWriter::Write(), osmscout::FileWriter::WriteCoord(), osmscout::FileWriter::WriteNumber(), and osmscout::FileWriter::WriteTypeId().
|
static |
|
static |
Referenced by ReadImport(), VisitRings(), and WriteImport().
std::vector<Ring> osmscout::Area::rings |