MinimumAreaRectangle.h
/**********************************************************************
*
* GEOS - Geometry Engine Open Source
* http://geos.osgeo.org
*
* Copyright (C) 2023 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 <vector>
#include <memory>
// Forward declarations
namespace geos {
namespace geom {
class CoordinateSequence;
class CoordinateXY;
class Geometry;
class GeometryFactory;
class LineSegment;
class LineString;
class Polygon;
}
}
namespace geos {
namespace algorithm { // geos::algorithm
class GEOS_DLL MinimumAreaRectangle {
using CoordinateSequence = geos::geom::CoordinateSequence;
using CoordinateXY = geos::geom::CoordinateXY;
using Geometry = geos::geom::Geometry;
using GeometryFactory = geos::geom::GeometryFactory;
using LineSegment = geos::geom::LineSegment;
using LineString = geos::geom::LineString;
using Polygon = geos::geom::Polygon;
private:
// Members
const Geometry* m_inputGeom;
bool m_isConvex;
// Methods
std::unique_ptr<Geometry> getMinimumRectangle();
std::unique_ptr<Geometry> computeConvex(const Geometry* convexGeom);
std::unique_ptr<Polygon> computeConvexRing(const CoordinateSequence* ring);
std::size_t findFurthestVertex(
const CoordinateSequence* pts,
const LineSegment& baseSeg,
std::size_t startIndex,
int orient);
bool isFurtherOrEqual(double d1, double d2, int orient);
static double orientedDistance(
const LineSegment& seg,
const CoordinateXY& p,
int orient);
static std::size_t getNextIndex(
const CoordinateSequence* ring,
std::size_t index);
static std::unique_ptr<LineString> computeMaximumLine(
const CoordinateSequence* pts,
const GeometryFactory* factory);
public:
MinimumAreaRectangle(const Geometry* inputGeom)
: m_inputGeom(inputGeom)
, m_isConvex(false)
{};
MinimumAreaRectangle(const Geometry* inputGeom, bool isConvex)
: m_inputGeom(inputGeom)
, m_isConvex(isConvex)
{};
static std::unique_ptr<Geometry> getMinimumRectangle(const Geometry* geom);
};
} // namespace geos::algorithm
} // namespace geos
geos::algorithm::MinimumAreaRectangle::MinimumAreaRectangle
MinimumAreaRectangle(const Geometry *inputGeom, bool isConvex)
Definition MinimumAreaRectangle.h:137
geos::algorithm::MinimumAreaRectangle::MinimumAreaRectangle
MinimumAreaRectangle(const Geometry *inputGeom)
Definition MinimumAreaRectangle.h:123
geos::algorithm::MinimumAreaRectangle::getMinimumRectangle
static std::unique_ptr< Geometry > getMinimumRectangle(const Geometry *geom)
geos::geom::CoordinateSequence
The internal representation of a list of coordinates inside a Geometry.
Definition CoordinateSequence.h:56
geos::geom::GeometryFactory
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition GeometryFactory.h:70
geos::geom::Geometry
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition Geometry.h:196
geos::geom::LineSegment
Definition LineSegment.h:61
geos::geom::LineString
Definition LineString.h:66
geos::geom::Polygon
Represents a linear polygon, which may include holes.
Definition Polygon.h:61
geos::algorithm
Contains classes and interfaces implementing fundamental computational geometry algorithms.
Definition Angle.h:32
geos::geom
Definition Angle.h:26
geos::index
Provides classes for various kinds of spatial indexes.
Definition CleanCoverage.h:39
geos
Basic namespace for all GEOS functionalities.
Definition geos.h:38