Common base of the OGR backed adapters which enclose an area.
More...
#include <OGRPolygonalAdapter.hpp>
|
| struct | Canonical |
| | Tag for a polygon which is known to be in canonical form already. More...
|
| |
|
| 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 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?
|
| |
Common base of the OGR backed adapters which enclose an area.
A ring is a polygon with nothing but an exterior ring, so both OGRRingAdapter and OGRPolygonAdapter are backed by an OGRPolygon and share everything that only depends on the enclosed area. Storing an OGRPolygon rather than an OGRLinearRing is not merely convenient: OGR treats a standalone OGRLinearRing as a second class geometry. It has no WKB representation of its own (WkbSize()/exportToWkb() are private for it) and it cannot be handed to the GEOS backed predicates, which silently answer false / -1 for it instead of reporting an error.
The wrapped polygon is kept in the canonical form of GEOS (
- See also
- canonicalize()), which makes the coordinate wise OGRAdapterBase::operator== agree with geometric equality for everything but a different vertex density, and thereby keeps it consistent with OGRAdapterBase::hash().
◆ Base
◆ OGRPolygonalAdapter() [1/2]
| fishnet::geometry::OGRPolygonalAdapter::OGRPolygonalAdapter |
( |
OGRUniquePtr< OGRPolygon > && |
polygonPtr, |
|
|
Canonical |
|
|
) |
| |
|
inlineprotected |
Adopt a polygon which is already canonical, skipping the GEOS call.
◆ OGRPolygonalAdapter() [2/2]
| fishnet::geometry::OGRPolygonalAdapter::OGRPolygonalAdapter |
( |
OGRUniquePtr< OGRPolygon > && |
polygonPtr | ) |
|
|
inlineprotected |
Adopt a polygon and bring it into canonical form.
- Note
- only OGRRingAdapter and OGRPolygonAdapter construct one of these; the base itself is not part of the interface offered to users
◆ aaBB()
| Rectangle< double > fishnet::geometry::OGRPolygonalAdapter::aaBB |
( |
| ) |
const |
|
inline |
◆ area()
| double fishnet::geometry::OGRPolygonalAdapter::area |
( |
| ) |
const |
|
inline |
Area enclosed by the boundary, reduced by the area of the holes.
◆ canonicalize()
| void fishnet::geometry::OGRPolygonalAdapter::canonicalize |
( |
| ) |
|
|
inlineprotectednoexcept |
Bring the wrapped polygon into the canonical form of GEOS.
Canonicalising on construction is what lets equality stay a cheap coordinate comparison while still ignoring the starting vertex and the winding order of a ring: two rings which differ only in those are byte identical once normalised. It also keeps equality consistent with the inherited WKB hash, which no amount of comparing geometrically ever could.
- Note
- the vertex order of the wrapped geometry is rewritten, its area is not touched
◆ 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 |
◆ covers()
| static bool fishnet::geometry::OGRPolygonalAdapter::covers |
( |
const OGRGeometry & |
covering, |
|
|
const OGRGeometry & |
covered |
|
) |
| |
|
inlinestaticprotected |
Boundary inclusive containment: is every point of covered also a point of covering?
OGR only offers the strict (interior only) Contains predicate, whereas fishnet counts the boundary as contained. Contains() || Touches() does not express that either, since Touches() also holds when covered merely touches covering from the outside (e.g. two squares sharing a single corner). "covered minus covering is empty" is exactly boundary inclusive containment.
◆ emptyPolygon()
| static OGRUniquePtr< OGRPolygon > fishnet::geometry::OGRPolygonalAdapter::emptyPolygon |
( |
| ) |
|
|
inlinestaticprotected |
◆ envelopeOverlaps()
| bool fishnet::geometry::OGRPolygonalAdapter::envelopeOverlaps |
( |
const IPoint auto & |
lhs, |
|
|
const IPoint auto & |
rhs |
|
) |
| const |
|
inlineprotectednoexcept |
Whether the bounding box spanned by two points overlaps the one of this polygon.
Anything outside the bounding box is outside the polygon, which answers the common case without handing the geometry to GEOS at all.
- Note
- deliberately plain comparisons rather than a Rectangle: the box of an axis aligned segment is degenerate, which Rectangle cannot represent (it builds a Ring and would throw), and Rectangle's two point constructor expects its corners in top-left/bottom-right order, which two endpoints of a segment are not.
◆ exteriorRing()
| const OGRLinearRing * fishnet::geometry::OGRPolygonalAdapter::exteriorRing |
( |
| ) |
const |
|
inlineprotectednoexcept |
◆ isInside()
| bool fishnet::geometry::OGRPolygonalAdapter::isInside |
( |
const IPoint auto & |
point | ) |
const |
|
inline |
◆ isOnBoundary()
| bool fishnet::geometry::OGRPolygonalAdapter::isOnBoundary |
( |
const IPoint auto & |
point | ) |
const |
|
inline |
- Note
- the boundary comprises the exterior ring as well as the rings of the holes
◆ isOutside()
| bool fishnet::geometry::OGRPolygonalAdapter::isOutside |
( |
const IPoint auto & |
point | ) |
const |
|
inline |
◆ toLinearRing()
| static OGRLinearRing fishnet::geometry::OGRPolygonalAdapter::toLinearRing |
( |
const IRing auto & |
ring | ) |
|
|
inlinestaticprotected |
◆ toOGRPolygon() [1/2]
| static OGRUniquePtr< OGRPolygon > fishnet::geometry::OGRPolygonalAdapter::toOGRPolygon |
( |
const IPolygon auto & |
polygon | ) |
|
|
inlinestaticprotected |
Copy an arbitrary IPolygon into an OGRPolygon, ready to be used with GEOS.
◆ toOGRPolygon() [2/2]
| static OGRUniquePtr< OGRPolygon > fishnet::geometry::OGRPolygonalAdapter::toOGRPolygon |
( |
const IRing auto & |
ring | ) |
|
|
inlinestaticprotected |
Copy an arbitrary IRing into an OGRPolygon, ready to be used with GEOS.
The documentation for this class was generated from the following file: