Fishnet 2.0.1
Framework for Graph-Based Analysis of GIS Vector Data
Loading...
Searching...
No Matches
fishnet::geometry::OGRGeometryAdapter Class Reference

Adapter for an OGRGeometry of statically unknown type, as handed out by a data source. More...

#include <OGRGeometryAdapter.hpp>

Inheritance diagram for fishnet::geometry::OGRGeometryAdapter:
Collaboration diagram for fishnet::geometry::OGRGeometryAdapter:

Public Types

using numeric_type = double
 
- Public Types inherited from fishnet::geometry::OGRAdapterBase< OGRGeometry >
using numeric_type = double
 

Public Member Functions

 OGRGeometryAdapter (OGRUniquePtr< OGRGeometry > &&geometryPtr)
 
 OGRGeometryAdapter (const OGRRingAdapter &ring)
 
 OGRGeometryAdapter (const OGRPolygonAdapter &polygon)
 
 OGRGeometryAdapter (const OGRMultiPolygonAdapter &multiPolygon)
 
 OGRGeometryAdapter (OGRRingAdapter &&ring)
 Adopt a ring, polygon or multi-polygon which is no longer needed, without cloning it.
 
 OGRGeometryAdapter (OGRPolygonAdapter &&polygon)
 
 OGRGeometryAdapter (OGRMultiPolygonAdapter &&multiPolygon)
 
 OGRGeometryAdapter (const IRing auto &ring)
 Build from any ring, polygon or multi-polygon which is not already one of the OGR adapters above, by first converting it through the corresponding adapter.
 
 OGRGeometryAdapter (const IPolygon auto &polygon)
 
 OGRGeometryAdapter (const IMultiPolygon auto &multiPolygon)
 
GeometryType geometryType () const noexcept
 Geometry type of the wrapped geometry.
 
bool isEmpty () const noexcept
 
bool isRing () const noexcept
 Whether the wrapped geometry can be viewed as a ring.
 
bool isPolygon () const noexcept
 
bool isMultiPolygon () const noexcept
 
bool isPoint () const noexcept
 
Option< Vec2DReal > toPoint () const
 Read the wrapped point out into a Vec2DReal.
 
Option< OGRRingAdapter > toRing () const
 Convert to an OGRRingAdapter.
 
Option< OGRPolygonAdapter > toPolygon () const &
 Convert to an OGRPolygonAdapter.
 
Option< OGRPolygonAdapter > toPolygon () &&
 Hand the wrapped polygon over to an OGRPolygonAdapter, without copying it.
 
Option< OGRMultiPolygonAdapter > toMultiPolygon () const &
 Convert to an OGRMultiPolygonAdapter.
 
Option< OGRMultiPolygonAdapter > toMultiPolygon () &&
 Hand the wrapped multi-polygon over to an OGRMultiPolygonAdapter, without copying it.
 
template<typename G >
requires OGRLayerGeometry<G> || Shape<G>
Option< NarrowTarget< G > > narrowTo () const &
 Narrow to G, leaving this adapter intact.
 
template<typename G >
requires OGRLayerGeometry<G> || Shape<G>
Option< NarrowTarget< G > > narrowTo () &&
 Narrow to G, coercing between polygon and multi-polygon where the shape is the same.
 
- Public Member Functions inherited from fishnet::geometry::OGRAdapterBase< OGRGeometry >
 OGRAdapterBase (OGRUniquePtr< OGRGeometry > &&geomPtr)
 
 OGRAdapterBase (OGRAdapterBase &&other) noexcept
 
 OGRAdapterBase (const OGRAdapterBase &other)
 
OGRAdapterBase & operator= (const OGRAdapterBase &other)
 
OGRAdapterBase & operator= (OGRAdapterBase &&other) noexcept
 
bool operator== (const OGRAdapterBase &other) const noexcept
 
OGRGeometry * raw () const noexcept
 
size_t hash () const noexcept
 
std::string toString () const
 

Additional Inherited Members

- Protected Attributes inherited from fishnet::geometry::OGRAdapterBase< OGRGeometry >
OGRUniquePtr< OGRGeometry > geomPtr
 

Detailed Description

Adapter for an OGRGeometry of statically unknown type, as handed out by a data source.

Narrows the wrapped geometry to one of the concrete adapters. Every conversion verifies the WKB type first and yields an empty Option if the geometry is of another type (or empty), so that a geometry read from a data source can be dispatched without an unchecked downcast:

 OGRGeometryAdapter geometry {std::move(geometryPtr)};
 geometry.toPolygon().if_value([](const auto & polygon){ ... });

The conversions copy the wrapped geometry, leaving this adapter intact.

Member Typedef Documentation

◆ numeric_type

Constructor & Destructor Documentation

◆ OGRGeometryAdapter() [1/10]

fishnet::geometry::OGRGeometryAdapter::OGRGeometryAdapter ( OGRUniquePtr< OGRGeometry > &&  geometryPtr)
inline

◆ OGRGeometryAdapter() [2/10]

fishnet::geometry::OGRGeometryAdapter::OGRGeometryAdapter ( const OGRRingAdapter &  ring)
inline

◆ OGRGeometryAdapter() [3/10]

fishnet::geometry::OGRGeometryAdapter::OGRGeometryAdapter ( const OGRPolygonAdapter &  polygon)
inline

◆ OGRGeometryAdapter() [4/10]

fishnet::geometry::OGRGeometryAdapter::OGRGeometryAdapter ( const OGRMultiPolygonAdapter &  multiPolygon)
inline

◆ OGRGeometryAdapter() [5/10]

fishnet::geometry::OGRGeometryAdapter::OGRGeometryAdapter ( OGRRingAdapter &&  ring)
inline

Adopt a ring, polygon or multi-polygon which is no longer needed, without cloning it.

Note
the source adapter is left moved-from and must not be used again

◆ OGRGeometryAdapter() [6/10]

fishnet::geometry::OGRGeometryAdapter::OGRGeometryAdapter ( OGRPolygonAdapter &&  polygon)
inline

◆ OGRGeometryAdapter() [7/10]

fishnet::geometry::OGRGeometryAdapter::OGRGeometryAdapter ( OGRMultiPolygonAdapter &&  multiPolygon)
inline

◆ OGRGeometryAdapter() [8/10]

fishnet::geometry::OGRGeometryAdapter::OGRGeometryAdapter ( const IRing auto &  ring)
inline

Build from any ring, polygon or multi-polygon which is not already one of the OGR adapters above, by first converting it through the corresponding adapter.

The adapter does the actual conversion (walking the shape's points/rings); the temporary it produces is then adopted by the move constructor above rather than cloned.

◆ OGRGeometryAdapter() [9/10]

fishnet::geometry::OGRGeometryAdapter::OGRGeometryAdapter ( const IPolygon auto &  polygon)
inline

◆ OGRGeometryAdapter() [10/10]

fishnet::geometry::OGRGeometryAdapter::OGRGeometryAdapter ( const IMultiPolygon auto &  multiPolygon)
inline

Member Function Documentation

◆ geometryType()

GeometryType fishnet::geometry::OGRGeometryAdapter::geometryType ( ) const
inlinenoexcept

Geometry type of the wrapped geometry.

Note
OGR reports wkbLineString for an OGRLinearRing, as a linear ring has no WKB type of its own;
See also
isRing()

◆ isEmpty()

bool fishnet::geometry::OGRGeometryAdapter::isEmpty ( ) const
inlinenoexcept

◆ isMultiPolygon()

bool fishnet::geometry::OGRGeometryAdapter::isMultiPolygon ( ) const
inlinenoexcept

◆ isPoint()

bool fishnet::geometry::OGRGeometryAdapter::isPoint ( ) const
inlinenoexcept

◆ isPolygon()

bool fishnet::geometry::OGRGeometryAdapter::isPolygon ( ) const
inlinenoexcept

◆ isRing()

bool fishnet::geometry::OGRGeometryAdapter::isRing ( ) const
inlinenoexcept

Whether the wrapped geometry can be viewed as a ring.

Note
a linear ring is reported as wkbLineString by OGR, so a line string with enough points to enclose an area is accepted here; it is closed on conversion, just like every other ring handed to OGRRingAdapter

◆ narrowTo() [1/2]

template<typename G >
requires OGRLayerGeometry<G> || Shape<G>
Option< NarrowTarget< G > > fishnet::geometry::OGRGeometryAdapter::narrowTo ( ) &&
inline

Narrow to G, coercing between polygon and multi-polygon where the shape is the same.

G is not limited to the OGR adapters: any other IRing/IPolygon/IMultiPolygon (a plain fishnet::geometry::Ring/Polygon/MultiPolygon, for instance) narrows to whichever adapter models the same kind of shape,

See also
NarrowTarget.

A data source does not always hold the geometry type its layer declares: a polygon layer may carry a multi-polygon of a single part, and a multi-polygon layer a lone polygon. Both denote the same shape, so they are converted rather than dropped. Anything else yields an empty Option, and the geometry is left where it was.

Note
on success this adapter is left moved-from and must not be used again

◆ narrowTo() [2/2]

template<typename G >
requires OGRLayerGeometry<G> || Shape<G>
Option< NarrowTarget< G > > fishnet::geometry::OGRGeometryAdapter::narrowTo ( ) const &
inline

Narrow to G, leaving this adapter intact.

Note
where the result has to own a geometry of its own this copies the wrapped one,
See also
narrowTo() && for the version which hands it over instead

◆ toMultiPolygon() [1/2]

Option< OGRMultiPolygonAdapter > fishnet::geometry::OGRGeometryAdapter::toMultiPolygon ( ) &&
inline

Hand the wrapped multi-polygon over to an OGRMultiPolygonAdapter, without copying it.

See also
toPolygon() && for the ownership semantics

◆ toMultiPolygon() [2/2]

Option< OGRMultiPolygonAdapter > fishnet::geometry::OGRGeometryAdapter::toMultiPolygon ( ) const &
inline

Convert to an OGRMultiPolygonAdapter.

Returns
empty Option if the wrapped geometry is not a multi-polygon

◆ toPoint()

Option< Vec2DReal > fishnet::geometry::OGRGeometryAdapter::toPoint ( ) const
inline

Read the wrapped point out into a Vec2DReal.

Returns
empty Option if the wrapped geometry is not a point
Note
unlike the shapes there is nothing to adapt here: a point is two doubles, so it is read out by value rather than kept behind a pointer

◆ toPolygon() [1/2]

Option< OGRPolygonAdapter > fishnet::geometry::OGRGeometryAdapter::toPolygon ( ) &&
inline

Hand the wrapped polygon over to an OGRPolygonAdapter, without copying it.

For a geometry this adapter owns and the caller does not need afterwards, e.g. one just taken from a data source. On success this adapter is left moved-from and must not be used again.

Returns
empty Option if the wrapped geometry is not a polygon, in which case nothing is handed over and this adapter stays intact

◆ toPolygon() [2/2]

Option< OGRPolygonAdapter > fishnet::geometry::OGRGeometryAdapter::toPolygon ( ) const &
inline

Convert to an OGRPolygonAdapter.

Returns
empty Option if the wrapped geometry is not a polygon

◆ toRing()

Option< OGRRingAdapter > fishnet::geometry::OGRGeometryAdapter::toRing ( ) const
inline

Convert to an OGRRingAdapter.

Returns
empty Option if the wrapped geometry is not a ring

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