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

IPolygon implementation backed by an OGRPolygon. More...

#include <OGRPolygonAdapter.hpp>

Inheritance diagram for fishnet::geometry::OGRPolygonAdapter:
Collaboration diagram for fishnet::geometry::OGRPolygonAdapter:

Public Types

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

Public Member Functions

 OGRPolygonAdapter (OGRUniquePtr< OGRPolygon > &&polygonPtr)
 
 OGRPolygonAdapter (IPolygon auto const &polygon)
 
OGRRingAdapter getBoundary () const
 
std::vector< OGRRingAdapter > getHoles () const
 
bool isSimple () const
 
Polygon< double > toNative () const
 Copy the polygon out into a fishnet Polygon, which precomputes its segments.
 
Vec2DReal centroid () const
 Area weighted centroid of the polygon, obtained by decomposition into its rings.
 
bool containsInHole (const IPoint auto &point) const
 
bool containsInHole (const IPolygon auto &other) const
 
bool intersects (const LinearGeometry auto &linearFeature) const
 
std::unordered_set< Vec2DReal > intersections (const LinearGeometry auto &linearFeature) const
 
bool crosses (const IPolygon auto &other) const
 
bool touches (const IPolygon auto &other) const
 
double distance (const IPolygon auto &other) const
 Distance between the two polygons.
 
double distance (const OGRPolygonAdapter &other) const
 Distance between two OGR backed polygons.
 
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::POLYGON
 

Friends

class OGRMultiPolygonAdapter
 
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

IPolygon implementation backed by an OGRPolygon.

The exterior ring forms the boundary, the interior rings are the holes. Where OGR/OGC and fishnet disagree, fishnet's convention wins, so that an OGR backed polygon is substitutable for a fishnet::geometry::Polygon:

  • contains() includes the boundary, whereas OGR's Contains() is interior only
  • centroid() is the area weighted centroid over the mean-of-points centroids of its rings
  • distance() returns 0 for polygons which overlap in any way

Member Typedef Documentation

◆ numeric_type

Constructor & Destructor Documentation

◆ OGRPolygonAdapter() [1/2]

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

◆ OGRPolygonAdapter() [2/2]

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

Member Function Documentation

◆ centroid()

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

Area weighted centroid of the polygon, obtained by decomposition into its rings.

Note
fishnet defines the centroid of a ring as the mean of its points, which is what the decomposition below is built on; it is not the geometric centroid OGR/GEOS would compute. The rings are weighted by their share of the area, as Vec2D rounds coordinates below epsilon to zero, which would round away centroid * area for slivers (see Polygon::centroid).

◆ 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

◆ containsInHole() [1/2]

bool fishnet::geometry::OGRPolygonAdapter::containsInHole ( const IPoint auto &  point) const
inline

◆ containsInHole() [2/2]

bool fishnet::geometry::OGRPolygonAdapter::containsInHole ( const IPolygon auto &  other) const
inline

◆ crosses()

bool fishnet::geometry::OGRPolygonAdapter::crosses ( const IPolygon auto &  other) const
inline

◆ distance() [1/2]

double fishnet::geometry::OGRPolygonAdapter::distance ( const IPolygon auto &  other) const
inline

Distance between the two polygons.

Returns
0 if the polygons overlap in any way, i.e. if one contains or touches the other, otherwise the distance between their boundaries, measured through a hole where applicable

◆ distance() [2/2]

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

Distance between two OGR backed polygons.

Note
geomPtr already has its holes subtracted, so GEOS' own Distance() returns 0 exactly when the two regions overlap or touch and the true gap to the nearest boundary (a hole's rim included) otherwise - the same result the generic overload above computes by hand, without having to inspect bounding boxes or holes here

◆ getBoundary()

OGRRingAdapter fishnet::geometry::OGRPolygonAdapter::getBoundary ( ) const
inline
Note
the wrapped polygon is canonical, hence so is its exterior ring

◆ getHoles()

std::vector< OGRRingAdapter > fishnet::geometry::OGRPolygonAdapter::getHoles ( ) const
inline
Note
the wrapped polygon is canonical, so its holes only have to be turned the right way round,
See also
OGRRingAdapter::fromCanonicalHole

◆ intersections()

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

◆ intersects()

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

◆ isSimple()

bool fishnet::geometry::OGRPolygonAdapter::isSimple ( ) const
inline

◆ toNative()

Polygon< double > fishnet::geometry::OGRPolygonAdapter::toNative ( ) const
inline

Copy the polygon out into a fishnet Polygon, which precomputes its segments.

See also
OGRRingAdapter::toNative()

◆ touches()

bool fishnet::geometry::OGRPolygonAdapter::touches ( const IPolygon auto &  other) const
inline

Friends And Related Symbol Documentation

◆ OGRGeometryAdapter

friend class OGRGeometryAdapter
friend

◆ OGRMultiPolygonAdapter

friend class OGRMultiPolygonAdapter
friend

Member Data Documentation

◆ type

constexpr GeometryType fishnet::geometry::OGRPolygonAdapter::type = GeometryType::POLYGON
staticconstexpr

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