33 ringPtr->closeRings();
35 polygon->addRingDirectly(ringPtr.release());
51 static OGRRingAdapter fromCanonicalRing(
const OGRLinearRing & ring) {
53 polygon->addRingDirectly(ring.clone());
64 static OGRRingAdapter fromCanonicalHole(
const OGRLinearRing & hole) {
66 ring->reversePoints();
68 polygon->addRingDirectly(ring.release());
94 int openPointCount()
const {
106 auto * ring =
geomPtr->getExteriorRing();
130 return std::ranges::views::iota(0, openPointCount())
131 | std::ranges::views::transform([
this](
int i) {
149 std::vector<fishnet::geometry::Segment<double>>
getSegments() const && {
155 return std::ranges::views::iota(0, openPointCount())
156 | std::ranges::views::transform([
this](
int i) {
158 return Vec2DReal(ring->getX(i), ring->getY(i));
163 std::vector<fishnet::geometry::Vec2DReal>
getPoints() const && {
198 return sum /
static_cast<double>(count);
207 | std::views::transform([&linearFeature](
const auto & segment){
return segment.intersection(linearFeature);})
208 | std::views::filter([](
const auto & optIntersection){
return optIntersection.has_value();})
209 | std::views::transform([](
const auto & optIntersection){
return optIntersection.value();});
210 return std::unordered_set<Vec2D<double>> {std::ranges::begin(intersectionRange), std::ranges::end(intersectionRange)};
214 if(not this->
aaBB().overlap(other.aaBB()))
216 return std::ranges::any_of(this->
getSegments(),[&other](
const auto & s){
return other.intersects(s);})
217 || std::ranges::any_of(other.getSegments(),[
this](
const auto & s){return this->intersects(s);});
221 if(not this->
aaBB().overlap(other.aaBB()))
225 if(this->
contains(other) || other.contains(*
this))
return false;
226 for(
const auto & p : other.getPoints()){
233 if(this->
contains(other) or other.contains(*
this) or this->crosses(other))
242static_assert(IRing<OGRRingAdapter>);
OGRUniquePtr< OGRPolygon > geomPtr
Definition OGRAdapterBase.hpp:85
Adapter for an OGRGeometry of statically unknown type, as handed out by a data source.
Definition OGRGeometryAdapter.hpp:83
IPolygon implementation backed by an OGRPolygon.
Definition OGRPolygonAdapter.hpp:22
Common base of the OGR backed adapters which enclose an area.
Definition OGRPolygonalAdapter.hpp:24
const OGRLinearRing * exteriorRing() const noexcept
Definition OGRPolygonalAdapter.hpp:116
bool contains(const IPoint auto &point) const
Definition OGRPolygonalAdapter.hpp:178
static OGRUniquePtr< OGRPolygon > toOGRPolygon(const IRing auto &ring)
Copy an arbitrary IRing into an OGRPolygon, ready to be used with GEOS.
Definition OGRPolygonalAdapter.hpp:44
bool isOnBoundary(const IPoint auto &point) const
Definition OGRPolygonalAdapter.hpp:165
Rectangle< double > aaBB() const
Definition OGRPolygonalAdapter.hpp:151
static OGRUniquePtr< OGRPolygon > emptyPolygon()
Definition OGRPolygonalAdapter.hpp:28
IRing implementation backed by an OGRPolygon holding nothing but an exterior ring.
Definition OGRRingAdapter.hpp:30
static constexpr GeometryType type
Definition OGRRingAdapter.hpp:115
OGRRingAdapter(OGRUniquePtr< OGRLinearRing > &&ringPtr)
Definition OGRRingAdapter.hpp:117
double distance(const OGRRingAdapter &other) const
Definition OGRRingAdapter.hpp:238
bool contains(const IPoint auto &point) const
Definition OGRPolygonalAdapter.hpp:178
Vec2DReal centroid() const
Centroid of the ring, i.e. the mean of its points.
Definition OGRRingAdapter.hpp:191
std::vector< fishnet::geometry::Segment< double > > getSegments() const &&
The segments of the ring, eagerly copied out into an owning vector.
Definition OGRRingAdapter.hpp:149
std::vector< fishnet::geometry::Vec2DReal > getPoints() const &&
&&
Definition OGRRingAdapter.hpp:163
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.
Definition OGRRingAdapter.hpp:154
double distance(const IRing auto &other) const
Definition OGRRingAdapter.hpp:232
bool crosses(const IRing auto &other) const
Definition OGRRingAdapter.hpp:213
std::vector< OGRRingAdapter > getHoles() const
Definition OGRRingAdapter.hpp:182
bool touches(const IRing auto &other) const
Definition OGRRingAdapter.hpp:220
std::unordered_set< Vec2DReal > intersections(const LinearGeometry auto &linearFeature) const
Definition OGRRingAdapter.hpp:205
OGRRingAdapter(IRing auto const &ring)
Definition OGRRingAdapter.hpp:121
bool intersects(const LinearGeometry auto &linearFeature) const
Definition OGRRingAdapter.hpp:201
OGRRingAdapter(OGRUniquePtr< OGRPolygon > &&polygonPtr)
Definition OGRRingAdapter.hpp:119
Ring< double > toNative() const
Copy the ring out into a fishnet Ring, which precomputes its segments.
Definition OGRRingAdapter.hpp:178
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.
Definition OGRRingAdapter.hpp:129
double numeric_type
Definition OGRRingAdapter.hpp:114
const OGRRingAdapter & getBoundary() const
Definition OGRRingAdapter.hpp:167
Implementation of a ring.
Definition Ring.hpp:31
Implementation of a segment.
Definition Segment.hpp:14
Implementation of a two-dimensional vector.
Definition Vec2D.hpp:16
constexpr T getX() const noexcept
Definition Vec2D.hpp:85
Interface for a ring A ring is a closed loop of segments, forming a boundary of a shape.
Definition IRing.hpp:143
Definition IGeometry.hpp:13
Definition BoundingBoxWrapper.hpp:5
std::unique_ptr< T, __impl::OGRGeometryDeleter > OGRUniquePtr
Definition OGRAdapterBase.hpp:48
GeometryType
Definition GeometryBase.hpp:6
Vec2D< fishnet::math::DEFAULT_FLOATING_POINT > Vec2DReal
Definition Vec2D.hpp:220
static fishnet::math::DEFAULT_FLOATING_POINT shapeDistance(Shape auto const &lhs, Shape auto const &rhs, util::BiFunction< Vec2DReal, Vec2DReal, fishnet::math::DEFAULT_FLOATING_POINT > auto const &distanceFunction) noexcept
Compute the distance between two shapes, with custom distance function.
Definition PolygonDistance.hpp:465
static constexpr bool ringIntersects(const R &ring, const L &linearFeature) noexcept
test whether a linear feature intersects a ring Check every intersection of the linear feature with t...
Definition RingIntersection.hpp:28
constexpr auto toVector(R &&range)
Definition CollectionConcepts.hpp:64
Definition BFSClustering.hpp:5
Tag for a polygon which is known to be in canonical form already.
Definition OGRPolygonalAdapter.hpp:125