libosmscout  0.1
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules
osmscout::Area Class Referencefinal

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 &center) const
 
const FeatureValueBufferGetFeatureValueBuffer () 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< Ringrings
 

Static Public Attributes

static const uint8_t masterRingId =0
 
static const uint8_t outerRingId =1
 

Detailed Description

Representation of an (complex/multipolygon) area.

It consists from hierarchy of rings:

  • optional master ring (ring number 0)
  • outer ring(s) (odd ring number) – top level outer rings (ring number == 1) – nested outer rings (odd ring number >= 3)
  • inner ring(s) (even ring number)

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

  • master ring has type "leisure_park" and outer ring "place_islet". OSM Scout library don't support multiple types for object, so in such cases, we are using relation type for top-level outer ring and ring type for nested outer rings.

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.

Member Typedef Documentation

◆ RingVisitor

using osmscout::Area::RingVisitor = std::function<bool(size_t i, const Ring&, const TypeInfoRef&)>

Constructor & Destructor Documentation

◆ Area()

osmscout::Area::Area ( )
default

Member Function Documentation

◆ GetBoundingBox()

GeoBox osmscout::Area::GetBoundingBox ( ) const

◆ GetCenter()

bool osmscout::Area::GetCenter ( GeoCoord center) const

References rings, and osmscout::GeoCoord::Set().

◆ GetFeatureValueBuffer()

const FeatureValueBuffer& osmscout::Area::GetFeatureValueBuffer ( ) const
inline

◆ GetFileOffset()

FileOffset osmscout::Area::GetFileOffset ( ) const
inline

◆ GetNextFileOffset()

FileOffset osmscout::Area::GetNextFileOffset ( ) const
inline

◆ GetObjectFileRef()

ObjectFileRef osmscout::Area::GetObjectFileRef ( ) const
inline

◆ GetRingType()

TypeInfoRef osmscout::Area::GetRingType ( const Ring ring) const
inline

◆ GetType()

TypeInfoRef osmscout::Area::GetType ( ) const
inline

Referenced by Read().

◆ Intersects()

bool osmscout::Area::Intersects ( const GeoBox boundingBox) const
inline

Returns true if the bounding box of the object intersects the given bounding box.

Parameters
boundingBoxbounding box to test for intersection
Returns
true on intersection, else false

References osmscout::GetBoundingBox().

◆ IsSimple()

bool osmscout::Area::IsSimple ( ) const
inline

◆ Read()

◆ ReadImport()

◆ ReadOptimized()

◆ VisitClippingRings()

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.

◆ VisitRings()

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().

◆ Write()

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.

Exceptions
IOException

References osmscout::TypeConfig::GetAreaTypeIdBytes(), rings, osmscout::typeIgnore, osmscout::FileWriter::Write(), osmscout::FileWriter::WriteCoord(), osmscout::FileWriter::WriteNumber(), and osmscout::FileWriter::WriteTypeId().

◆ WriteImport()

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.

Exceptions
IOException

References osmscout::TypeConfig::GetAreaTypeIdBytes(), outerRingId, rings, osmscout::typeIgnore, osmscout::FileWriter::Write(), osmscout::FileWriter::WriteNumber(), and osmscout::FileWriter::WriteTypeId().

◆ WriteOptimized()

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.

Exceptions
IOException

References osmscout::TypeConfig::GetAreaTypeIdBytes(), rings, osmscout::typeIgnore, osmscout::FileWriter::Write(), osmscout::FileWriter::WriteCoord(), osmscout::FileWriter::WriteNumber(), and osmscout::FileWriter::WriteTypeId().

Member Data Documentation

◆ masterRingId

const uint8_t osmscout::Area::masterRingId =0
static

◆ outerRingId

const uint8_t osmscout::Area::outerRingId =1
static

Referenced by ReadImport(), VisitRings(), and WriteImport().

◆ rings


The documentation for this class was generated from the following files: