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

IRing implementation backed by an OGRPolygon holding nothing but an exterior ring. More...

#include <OGRRingAdapter.hpp>

Inheritance diagram for fishnet::geometry::OGRRingAdapter:
Collaboration diagram for fishnet::geometry::OGRRingAdapter:

Public Types

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

Public Member Functions

 OGRRingAdapter (OGRUniquePtr< OGRLinearRing > &&ringPtr)
 
 OGRRingAdapter (OGRUniquePtr< OGRPolygon > &&polygonPtr)
 
 OGRRingAdapter (IRing auto const &ring)
 
auto getSegments () const &-> fishnet::util::forward_range_of< fishnet::geometry::Segment< double > > auto
 The segments of the ring, lazily read through this adapter on every access.
 
std::vector< fishnet::geometry::Segment< double > > getSegments () const &&
 The segments of the ring, eagerly copied out into an owning vector.
 
auto getPoints () const &-> fishnet::util::forward_range_of< fishnet::geometry::Vec2DReal > auto
 The segments of the ring, lazily read through this adapter on every access.
 
std::vector< fishnet::geometry::Vec2DReal > getPoints () const &&
 &&
 
const OGRRingAdapter & getBoundary () const
 
Ring< double > toNative () const
 Copy the ring out into a fishnet Ring, which precomputes its segments.
 
std::vector< OGRRingAdapter > getHoles () const
 
Vec2DReal centroid () const
 Centroid of the ring, i.e. the mean of its points.
 
bool intersects (const LinearGeometry auto &linearFeature) const
 
std::unordered_set< Vec2DReal > intersections (const LinearGeometry auto &linearFeature) const
 
bool crosses (const IRing auto &other) const
 
bool touches (const IRing auto &other) const
 
double distance (const IRing auto &other) const
 
double distance (const OGRRingAdapter &other) const
 
bool contains (const IPoint auto &point) const
 
bool contains (const ISegment auto &segment) const
 
bool contains (const IRing auto &ring) const
 
bool contains (const IPolygon auto &polygon) const
 
bool contains (const OGRPolygonalAdapter &other) const
 
- Public Member Functions inherited from fishnet::geometry::OGRPolygonalAdapter
double area () const
 Area enclosed by the boundary, reduced by the area of the holes.
 
Rectangle< double > aaBB () const
 
bool isInside (const IPoint auto &point) const
 
bool isOnBoundary (const IPoint auto &point) const
 
bool isOutside (const IPoint auto &point) const
 
bool contains (const IPoint auto &point) const
 
bool contains (const ISegment auto &segment) const
 
bool contains (const IRing auto &ring) const
 
bool contains (const IPolygon auto &polygon) const
 
bool contains (const OGRPolygonalAdapter &other) const
 
- Public Member Functions inherited from fishnet::geometry::OGRAdapterBase< OGRPolygon >
 OGRAdapterBase (OGRUniquePtr< OGRPolygon > &&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
 
OGRPolygon * raw () const noexcept
 
size_t hash () const noexcept
 
std::string toString () const
 

Static Public Attributes

static constexpr GeometryType type = GeometryType::RING
 

Friends

class OGRPolygonAdapter
 
class OGRGeometryAdapter
 

Additional Inherited Members

- Protected Types inherited from fishnet::geometry::OGRPolygonalAdapter
using Base = OGRAdapterBase< OGRPolygon >
 
- Protected Member Functions inherited from fishnet::geometry::OGRPolygonalAdapter
void canonicalize () noexcept
 Bring the wrapped polygon into the canonical form of GEOS.
 
bool envelopeOverlaps (const IPoint auto &lhs, const IPoint auto &rhs) const noexcept
 Whether the bounding box spanned by two points overlaps the one of this polygon.
 
const OGRLinearRing * exteriorRing () const noexcept
 
 OGRPolygonalAdapter (OGRUniquePtr< OGRPolygon > &&polygonPtr, Canonical)
 Adopt a polygon which is already canonical, skipping the GEOS call.
 
 OGRPolygonalAdapter (OGRUniquePtr< OGRPolygon > &&polygonPtr)
 Adopt a polygon and bring it into canonical form.
 
- Static Protected Member Functions inherited from fishnet::geometry::OGRPolygonalAdapter
static OGRUniquePtr< OGRPolygon > emptyPolygon ()
 
static OGRLinearRing toLinearRing (const IRing auto &ring)
 
static OGRUniquePtr< OGRPolygon > toOGRPolygon (const IRing auto &ring)
 Copy an arbitrary IRing into an OGRPolygon, ready to be used with GEOS.
 
static OGRUniquePtr< OGRPolygon > toOGRPolygon (const IPolygon auto &polygon)
 Copy an arbitrary IPolygon into an OGRPolygon, ready to be used with GEOS.
 
static bool covers (const OGRGeometry &covering, const OGRGeometry &covered)
 Boundary inclusive containment: is every point of covered also a point of covering?
 
- Protected Attributes inherited from fishnet::geometry::OGRAdapterBase< OGRPolygon >
OGRUniquePtr< OGRPolygon > geomPtr
 

Detailed Description

IRing implementation backed by an OGRPolygon holding nothing but an exterior ring.

The wrapped ring is always kept closed (first point == last point), as OGR/OGC require it. The IRing facing API however exposes the open representation used throughout fishnet: a ring over the points u,v,x,y,z reports exactly those points and the five segments u-v, v-x, x-y, y-z and z-u.

Note
the points are reported in the canonical order of the wrapped polygon, which is not necessarily the order they were handed in with,
See also
OGRPolygonalAdapter::canonicalize()
Note
getSegments() and getPoints() are ref-qualified: the lvalue (&) overload returns a view that lazily reads through this on every access, cheap but only valid as long as this adapter is (e.g. a named local or a longer-lived object accessed by reference); the rvalue (&&) overload, selected when this is itself a temporary, e.g. polygon.getBoundary().getSegments() where getBoundary() hands back a fresh, unnamed OGRRingAdapter, instead copies the result out into an owning vector before that temporary is destroyed at the end of the full expression. Splitting on value category like this keeps both the common lazy path and this once-off temporary chain safe without callers having to know or care which one they hit.

Member Typedef Documentation

◆ numeric_type

Constructor & Destructor Documentation

◆ OGRRingAdapter() [1/3]

fishnet::geometry::OGRRingAdapter::OGRRingAdapter ( OGRUniquePtr< OGRLinearRing > &&  ringPtr)
inline

◆ OGRRingAdapter() [2/3]

fishnet::geometry::OGRRingAdapter::OGRRingAdapter ( OGRUniquePtr< OGRPolygon > &&  polygonPtr)
inline

◆ OGRRingAdapter() [3/3]

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

Member Function Documentation

◆ centroid()

Vec2DReal fishnet::geometry::OGRRingAdapter::centroid ( ) const
inline

Centroid of the ring, i.e. the mean of its points.

Note
this is the centroid definition used by fishnet::geometry::Ring, not the area weighted centroid OGR/GEOS would compute. The two only coincide for symmetric rings.

◆ contains() [1/5]

bool fishnet::geometry::OGRPolygonalAdapter::contains ( const IPoint auto &  point) const
inline
Note
contains is boundary inclusive, unlike OGR's own Contains predicate

◆ contains() [2/5]

bool fishnet::geometry::OGRPolygonalAdapter::contains ( const IPolygon auto &  polygon) const
inline

◆ contains() [3/5]

bool fishnet::geometry::OGRPolygonalAdapter::contains ( const IRing auto &  ring) const
inline

◆ contains() [4/5]

bool fishnet::geometry::OGRPolygonalAdapter::contains ( const ISegment auto &  segment) const
inline
Note
unlike the two dimensional overloads below, this one cannot use Contains: a segment which grazes the boundary and lies otherwise outside satisfies Touches but is not covered, and Contains alone misses a segment running along an edge. covers() answers both correctly, and measures cheaper than any of the DE-9IM predicates on top of that. Only the bounding box is tested first, to answer the common "nowhere near" case without calling GEOS at all.

◆ contains() [5/5]

bool fishnet::geometry::OGRPolygonalAdapter::contains ( const OGRPolygonalAdapter &  other) const
inline

◆ crosses()

bool fishnet::geometry::OGRRingAdapter::crosses ( const IRing auto &  other) const
inline

◆ distance() [1/2]

double fishnet::geometry::OGRRingAdapter::distance ( const IRing auto &  other) const
inline

◆ distance() [2/2]

double fishnet::geometry::OGRRingAdapter::distance ( const OGRRingAdapter &  other) const
inline

◆ getBoundary()

const OGRRingAdapter & fishnet::geometry::OGRRingAdapter::getBoundary ( ) const
inline

◆ getHoles()

std::vector< OGRRingAdapter > fishnet::geometry::OGRRingAdapter::getHoles ( ) const
inline

◆ getPoints() [1/2]

std::vector< fishnet::geometry::Vec2DReal > fishnet::geometry::OGRRingAdapter::getPoints ( ) const &&
inline

&&

&&

◆ getPoints() [2/2]

auto fishnet::geometry::OGRRingAdapter::getPoints ( ) const & -> fishnet::util::forward_range_of<fishnet::geometry::Vec2DReal> auto
inline

The segments of the ring, lazily read through this adapter on every access.

Note
lvalue overload: the returned view keeps reading through this on every iteration, which is cheap as long as the adapter it reads through outlives the view, e.g. a named local or a longer-lived object accessed by reference.
See also
the && overload below for the rvalue case.

◆ getSegments() [1/2]

std::vector< fishnet::geometry::Segment< double > > fishnet::geometry::OGRRingAdapter::getSegments ( ) const &&
inline

The segments of the ring, eagerly copied out into an owning vector.

Note
rvalue overload, selected when this is about to be destroyed, e.g. polygon.getBoundary().getSegments() where getBoundary() hands back a fresh, unnamed OGRRingAdapter: the lvalue overload's view would keep reading through that temporary after it is gone, at the end of the full expression. A const & overload alone would not catch this, since a const lvalue reference binds to an rvalue too and the view would dangle just the same; only an overload specifically for rvalues lets us swap in a self-contained copy instead. Callers do not need to know or care which overload fires: both hand back a forward_range of Segment.

◆ getSegments() [2/2]

auto fishnet::geometry::OGRRingAdapter::getSegments ( ) const & -> fishnet::util::forward_range_of<fishnet::geometry::Segment<double>> auto
inline

The segments of the ring, lazily read through this adapter on every access.

Note
lvalue overload: the returned view keeps reading through this on every iteration, which is cheap as long as the adapter it reads through outlives the view, e.g. a named local or a longer-lived object accessed by reference.
See also
the && overload below for the rvalue case.

◆ intersections()

std::unordered_set< Vec2DReal > fishnet::geometry::OGRRingAdapter::intersections ( const LinearGeometry auto &  linearFeature) const
inline

◆ intersects()

bool fishnet::geometry::OGRRingAdapter::intersects ( const LinearGeometry auto &  linearFeature) const
inline

◆ toNative()

Ring< double > fishnet::geometry::OGRRingAdapter::toNative ( ) const
inline

Copy the ring out into a fishnet Ring, which precomputes its segments.

Segment access on an adapter is lazy, so code walking the same ring over and over is better served by a native ring. The points come from OGR and are taken as valid, validating them again here would cost far more than the conversion itself.

◆ touches()

bool fishnet::geometry::OGRRingAdapter::touches ( const IRing auto &  other) const
inline

Friends And Related Symbol Documentation

◆ OGRGeometryAdapter

friend class OGRGeometryAdapter
friend

◆ OGRPolygonAdapter

friend class OGRPolygonAdapter
friend

Member Data Documentation

◆ type

constexpr GeometryType fishnet::geometry::OGRRingAdapter::type = GeometryType::RING
staticconstexpr

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