RingClipper.h
/**********************************************************************
*
* GEOS - Geometry Engine Open Source
* http://geos.osgeo.org
*
* Copyright (C) 2020 Paul Ramsey <pramsey@cleverelephant.ca>
*
* This is free software; you can redistribute and/or modify it under
* the terms of the GNU Lesser General Public Licence as published
* by the Free Software Foundation.
* See the COPYING file for more information.
*
**********************************************************************/
#pragma once
#include <geos/export.h>
#include <geos/geom/Envelope.h>
#include <geos/geom/CoordinateSequence.h>
// Forward declarations
namespace geos {
namespace geom {
class Coordinate;
class CoordinateSequence;
}
}
namespace geos { // geos.
namespace operation { // geos.operation
namespace overlayng { // geos.operation.overlayng
class GEOS_DLL RingClipper {
using Coordinate = geos::geom::Coordinate;
using CoordinateSequence = geos::geom::CoordinateSequence;
using Envelope = geos::geom::Envelope;
private:
// Constants
static constexpr int BOX_LEFT = 3;
static constexpr int BOX_TOP = 2;
static constexpr int BOX_RIGHT = 1;
static constexpr int BOX_BOTTOM = 0;
// Members
const Envelope clipEnv;
// Methods
std::unique_ptr<CoordinateSequence> clipToBoxEdge(const CoordinateSequence* pts, int edgeIndex, bool closeRing) const;
void intersection(const Coordinate& a, const Coordinate& b, int edgeIndex, Coordinate& rsltPt) const;
double intersectionLineY(const Coordinate& a, const Coordinate& b, double y) const;
double intersectionLineX(const Coordinate& a, const Coordinate& b, double x) const;
bool isInsideEdge(const Coordinate& p, int edgeIndex) const;
public:
RingClipper(const Envelope* env)
: clipEnv(*env)
{};
std::unique_ptr<CoordinateSequence> clip(const CoordinateSequence* cs) const;
};
} // namespace geos.operation.overlayng
} // namespace geos.operation
} // namespace geos
geos::geom::CoordinateSequence
The internal representation of a list of coordinates inside a Geometry.
Definition CoordinateSequence.h:56
geos::geom::Coordinate
Coordinate is the lightweight class used to store coordinates.
Definition Coordinate.h:217
geos::geom::Envelope
An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition Envelope.h:59
geos::operation::overlayng::RingClipper::clip
std::unique_ptr< CoordinateSequence > clip(const CoordinateSequence *cs) const
geos::geom
Definition Angle.h:26
geos::operation
Provides classes for implementing operations on geometries.
Definition CleanCoverage.h:34
geos
Basic namespace for all GEOS functionalities.
Definition geos.h:38