CoverageEdge.h
/**********************************************************************
*
* GEOS - Geometry Engine Open Source
* http://geos.osgeo.org
*
* Copyright (C) 2022 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/geom/CoordinateSequence.h>
#include <geos/geom/LineSegment.h>
#include <geos/util.h>
// Forward declarations
namespace geos {
namespace geom {
class Coordinate;
class LinearRing;
class LineString;
class MultiLineString;
class GeometryFactory;
}
}
namespace geos { // geos.
namespace coverage { // geos.coverage
class GEOS_DLL CoverageEdge {
using Coordinate = geos::geom::Coordinate;
using CoordinateSequence = geos::geom::CoordinateSequence;
using GeometryFactory = geos::geom::GeometryFactory;
using LinearRing = geos::geom::LinearRing;
using LineString = geos::geom::LineString;
using LineSegment = geos::geom::LineSegment;
using MultiLineString = geos::geom::MultiLineString;
private:
// Members
std::unique_ptr<CoordinateSequence> m_pts;
std::size_t m_ringCount ;
bool m_isFreeRing = true;
// Methods
static std::unique_ptr<CoordinateSequence>
extractEdgePoints(const CoordinateSequence& ring,
std::size_t start, std::size_t end);
static const Coordinate&
findDistinctPoint(
const CoordinateSequence& pts,
std::size_t index,
bool isForward,
const Coordinate& pt);
public:
CoverageEdge(std::unique_ptr<CoordinateSequence> && pts, bool isFreeRing)
: m_pts(pts ? std::move(pts) : detail::make_unique<CoordinateSequence>())
, m_ringCount(0)
, m_isFreeRing(isFreeRing)
{}
static LineSegment key(
const CoordinateSequence& ring);
static LineSegment key(
const CoordinateSequence& ring,
std::size_t start,
std::size_t end);
static std::unique_ptr<CoverageEdge> createEdge(
const CoordinateSequence& ring);
static std::unique_ptr<CoverageEdge> createEdge(
const CoordinateSequence& ring,
std::size_t start,
std::size_t end);
static std::unique_ptr<MultiLineString> createLines(
const std::vector<CoverageEdge*>& edges,
const GeometryFactory* geomFactory);
std::unique_ptr<LineString> toLineString(
const GeometryFactory* geomFactory);
/* public */
void incRingCount()
{
m_ringCount++;
}
/* public */
std::size_t getRingCount() const
{
return m_ringCount;
}
bool isFreeRing() const
{
return m_isFreeRing;
}
void setCoordinates(const CoordinateSequence* pts)
{
m_pts = pts->clone();
}
const CoordinateSequence* getCoordinates() const
{
return m_pts.get();
}
const Coordinate& getEndCoordinate() const
{
return m_pts->getAt(m_pts->size() - 1);
}
const Coordinate& getStartCoordinate() const
{
return m_pts->getAt(0);
}
};
} // namespace geos.coverage
} // namespace geos
geos::coverage::CoverageEdge::key
static LineSegment key(const CoordinateSequence &ring)
geos::coverage::CoverageEdge::isFreeRing
bool isFreeRing() const
Definition CoverageEdge.h:142
geos::coverage::CoverageEdge::key
static LineSegment key(const CoordinateSequence &ring, std::size_t start, std::size_t end)
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::GeometryFactory
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition GeometryFactory.h:70
geos::geom::LineSegment
Definition LineSegment.h:61
geos::geom::LineString
Definition LineString.h:66
geos::geom::LinearRing
Models an OGC SFS LinearRing. A LinearRing is a LineString which is both closed and simple.
Definition LinearRing.h:54
geos::geom::MultiLineString
Models a collection of LineStrings.
Definition MultiLineString.h:49
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