PrecisionUtil.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/CoordinateFilter.h>
#include <geos/geom/Coordinate.h>
#include <vector>
#include <map>
// Forward declarations
namespace geos {
namespace geom {
class Geometry;
class Envelope;
class PrecisionModel;
}
namespace operation {
}
}
namespace geos { // geos.
namespace operation { // geos.operation
namespace overlayng { // geos.operation.overlayng
class GEOS_DLL PrecisionUtil {
using Geometry = geos::geom::Geometry;
using Envelope = geos::geom::Envelope;
using PrecisionModel = geos::geom::PrecisionModel;
using CoordinateFilter = geos::geom::CoordinateFilter;
private:
static double robustScale(double inherentScale, double safeScale);
static double maxBoundMagnitude(const Envelope* env);
static double precisionScale(double value, int precisionDigits);
public:
static constexpr int MAX_ROBUST_DP_DIGITS = 14;
PrecisionUtil() {};
static PrecisionModel robustPM(const Geometry* a, const Geometry* b);
static PrecisionModel robustPM(const Geometry* a);
static double robustScale(const Geometry* a, const Geometry* b);
static double robustScale(const Geometry* a);
static double safeScale(double value);
static double safeScale(const Geometry* geom);
static double safeScale(const Geometry* a, const Geometry* b);
static double inherentScale(double value);
static double inherentScale(const Geometry* geom);
static double inherentScale(const Geometry* a, const Geometry* b);
static int numberOfDecimals(double value);
class GEOS_DLL InherentScaleFilter: public CoordinateFilter {
private:
double scale;
void updateScaleMax(double value) {
double scaleVal = PrecisionUtil::inherentScale(value);
if (scaleVal > scale) {
scale = scaleVal;
}
}
public:
InherentScaleFilter()
: scale(0.0)
{}
void filter_ro(const geom::Coordinate* coord) override
{
updateScaleMax(coord->x);
updateScaleMax(coord->y);
}
double getScale() const {
return scale;
}
};
};
} // namespace geos.operation.overlayng
} // namespace geos.operation
} // namespace geos
geos::geom::CoordinateFilter
Geometry classes support the concept of applying a coordinate filter to every coordinate in the Geome...
Definition CoordinateFilter.h:43
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::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::operation::overlayng::PrecisionUtil::inherentScale
static double inherentScale(const Geometry *geom)
geos::operation::overlayng::PrecisionUtil::robustScale
static double robustScale(const Geometry *a, const Geometry *b)
geos::operation::overlayng::PrecisionUtil::robustPM
static PrecisionModel robustPM(const Geometry *a, const Geometry *b)
geos::operation::overlayng::PrecisionUtil::safeScale
static double safeScale(const Geometry *a, const Geometry *b)
geos::operation::overlayng::PrecisionUtil::inherentScale
static double inherentScale(double value)
geos::operation::overlayng::PrecisionUtil::robustScale
static double robustScale(const Geometry *a)
geos::operation::overlayng::PrecisionUtil::numberOfDecimals
static int numberOfDecimals(double value)
geos::operation::overlayng::PrecisionUtil::robustPM
static PrecisionModel robustPM(const Geometry *a)
geos::operation::overlayng::PrecisionUtil::safeScale
static double safeScale(double value)
geos::operation::overlayng::PrecisionUtil::inherentScale
static double inherentScale(const Geometry *a, const Geometry *b)
geos::operation::overlayng::PrecisionUtil::safeScale
static double safeScale(const Geometry *geom)
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