DouglasPeuckerLineSimplifier.h
/**********************************************************************
*
* GEOS - Geometry Engine Open Source
* http://geos.osgeo.org
*
* Copyright (C) 2006 Refractions Research Inc.
*
* This is free software; you can redistribute and/or modify it under
* the terms of the GNU Lesser General Licence as published
* by the Free Software Foundation.
* See the COPYING file for more information.
*
**********************************************************************
*
* Last port: simplify/DouglasPeuckerLineSimplifier.java rev. 1.4
*
**********************************************************************/
#pragma once
#include <geos/export.h>
#include <geos/geom/CoordinateSequence.h>
#include <vector>
#include <memory> // for unique_ptr
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
#endif
// Forward declarations
namespace geos {
namespace geom {
class Coordinate;
}
}
namespace geos {
namespace simplify { // geos::simplify
class GEOS_DLL DouglasPeuckerLineSimplifier {
public:
static std::unique_ptr<geom::CoordinateSequence> simplify(
const geom::CoordinateSequence& nPts,
double distanceTolerance,
bool preserveClosedEndpoint);
DouglasPeuckerLineSimplifier(const geom::CoordinateSequence& nPts);
void setDistanceTolerance(double nDistanceTolerance);
void setPreserveClosedEndpoint(bool preserve);
std::unique_ptr<geom::CoordinateSequence> simplify();
private:
const geom::CoordinateSequence& pts;
std::vector<bool> usePt;
double distanceTolerance;
bool preserveEndpoint;
void simplifySection(std::size_t i, std::size_t j);
// Declare type as noncopyable
DouglasPeuckerLineSimplifier(const DouglasPeuckerLineSimplifier& other) = delete;
DouglasPeuckerLineSimplifier& operator=(const DouglasPeuckerLineSimplifier& rhs) = delete;
};
} // namespace geos::simplify
} // namespace geos
#ifdef _MSC_VER
#pragma warning(pop)
#endif
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::simplify::DouglasPeuckerLineSimplifier::setPreserveClosedEndpoint
void setPreserveClosedEndpoint(bool preserve)
Sets whether the endpoint of a closed LineString should be preserved.
geos::simplify::DouglasPeuckerLineSimplifier::setDistanceTolerance
void setDistanceTolerance(double nDistanceTolerance)
Sets the distance tolerance for the simplification.
geos::simplify::DouglasPeuckerLineSimplifier::simplify
static std::unique_ptr< geom::CoordinateSequence > simplify(const geom::CoordinateSequence &nPts, double distanceTolerance, bool preserveClosedEndpoint)
Returns a newly allocated Coordinate vector, wrapped into an unique_ptr.
geos::simplify::DouglasPeuckerLineSimplifier::simplify
std::unique_ptr< geom::CoordinateSequence > simplify()
Returns a newly allocated Coordinate vector, wrapped into an unique_ptr.
geos::geom
Definition Angle.h:26
geos::simplify
Classes which implement algorithms for simplifying or generalizing geometries.
Definition Corner.h:26
geos
Basic namespace for all GEOS functionalities.
Definition geos.h:38