GeometryPrecisionReducer.h
/**********************************************************************
*
* GEOS - Geometry Engine Open Source
* http://geos.osgeo.org
*
* Copyright (C) 2012 Sandro Santilli <strk@kbt.io>
*
* 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.
*
***********************************************************************
*
* Last port: precision/GeometryPrecisionReducer.cpp rev. 1.10 (JTS-1.7)
*
**********************************************************************/
#pragma once
#include <geos/export.h>
#include <geos/geom/GeometryFactory.h> // for GeometryFactory::Ptr
#include <memory> // for unique_ptr
// Forward declarations
namespace geos {
namespace geom {
class PrecisionModel;
class GeometryFactory;
class Geometry;
}
}
namespace geos {
namespace precision { // geos.precision
class GEOS_DLL GeometryPrecisionReducer {
private:
// Externally owned
const geom::GeometryFactory* newFactory;
const geom::PrecisionModel& targetPM;
bool removeCollapsed;
bool changePrecisionModel;
bool useAreaReducer;
bool isPointwise;
std::unique_ptr<geom::Geometry> fixPolygonalTopology(const geom::Geometry& geom);
geom::GeometryFactory::Ptr createFactory(
const geom::GeometryFactory& oldGF,
const geom::PrecisionModel& newPM);
std::unique_ptr<geom::Geometry> changePM(
const geom::Geometry* geom,
const geom::PrecisionModel& newPM);
GeometryPrecisionReducer(GeometryPrecisionReducer const&); /*= delete*/
GeometryPrecisionReducer& operator=(GeometryPrecisionReducer const&); /*= delete*/
public:
static std::unique_ptr<geom::Geometry>
reduce(const geom::Geometry& g, const geom::PrecisionModel& precModel);
static std::unique_ptr<geom::Geometry>
reducePointwise(const geom::Geometry& g, const geom::PrecisionModel& precModel);
static std::unique_ptr<geom::Geometry>
reduceKeepCollapsed(const geom::Geometry& g, const geom::PrecisionModel& precModel);
GeometryPrecisionReducer(const geom::PrecisionModel& pm)
: newFactory(nullptr)
, targetPM(pm)
, removeCollapsed(true)
, changePrecisionModel(false)
, useAreaReducer(false)
, isPointwise(false)
{}
GeometryPrecisionReducer(const geom::GeometryFactory& changeFactory)
: newFactory(&changeFactory)
, targetPM(*(changeFactory.getPrecisionModel()))
, removeCollapsed(true)
, changePrecisionModel(false)
, useAreaReducer(false)
, isPointwise(false)
{}
void
setRemoveCollapsedComponents(bool remove)
{
removeCollapsed = remove;
}
void
setChangePrecisionModel(bool change)
{
changePrecisionModel = change;
}
void
setUseAreaReducer(bool useAR)
{
useAreaReducer = useAR;
}
void
setPointwise(bool pointwise)
{
isPointwise = pointwise;
}
std::unique_ptr<geom::Geometry> reduce(const geom::Geometry& geom);
};
} // namespace geos.precision
} // namespace geos
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::PrecisionModel
Specifies the precision model of the Coordinate in a Geometry.
Definition PrecisionModel.h:87
geos::precision::GeometryPrecisionReducer::GeometryPrecisionReducer
GeometryPrecisionReducer(const geom::GeometryFactory &changeFactory)
Create a reducer that will change the precision model of the new reduced Geometry.
Definition GeometryPrecisionReducer.h:133
geos::precision::GeometryPrecisionReducer::setPointwise
void setPointwise(bool pointwise)
Sets whether the precision reduction will be done in pointwise fashion only.
Definition GeometryPrecisionReducer.h:189
geos::precision::GeometryPrecisionReducer::setChangePrecisionModel
void setChangePrecisionModel(bool change)
Sets whether the geom::PrecisionModel of the new reduced Geometry will be changed to be the geom::Pre...
Definition GeometryPrecisionReducer.h:166
geos::precision::GeometryPrecisionReducer::reduce
static std::unique_ptr< geom::Geometry > reduce(const geom::Geometry &g, const geom::PrecisionModel &precModel)
geos::precision::GeometryPrecisionReducer::setRemoveCollapsedComponents
void setRemoveCollapsedComponents(bool remove)
Definition GeometryPrecisionReducer.h:150
geos::geom
Definition Angle.h:26
geos::precision
Provides classes for manipulating the precision model of Geometries.
Definition namespaces.h:300
geos
Basic namespace for all GEOS functionalities.
Definition geos.h:38