GEOS 3.15.0beta1
geos::util Namespace Reference

Utility classes for GEOS. More...

Classes

class  AssertionFailedException
 Indicates a bug in GEOS code. More...
class  GeometricShapeFactory
 Computes various kinds of common geometric shapes. More...
class  GEOSException
 Base class for all GEOS exceptions. More...
class  IllegalArgumentException
 Indicates one or more illegal arguments. More...
class  IllegalStateException
 Indicates an illegal state. More...
class  Interrupt
 Used to manage interruption requests and callbacks. More...
class  TopologyException
 Indicates an invalid or inconsistent topological situation encountered during processing. More...
class  UnsupportedOperationException
 Indicates that the requested operation is unsupported. More...

Typedefs

typedef std::function< void(double, const char *)> ProgressFunction

Functions

std::ostream & operator<< (std::ostream &os, const Profile &)
 Return a string representing the Profile.
std::ostream & operator<< (std::ostream &os, const Profiler &)
 Return a string representing the Profiler.
template<typename T>
void ensureNoCurvedComponents (const T &geom)
template<typename T>
void ensureNoCurvedComponents (const T *geom)
double sym_round (double val)
 Symmetric Rounding Algorithm.
double java_math_round (double val)
 Asymmetric Rounding Algorithm.
double rint_vc (double val)
 Equivalent to Java Math.rint().
double round (double val)
double clamp (double x, double min, double max)
 Equivalent to std::clamp() in C++17.
void ProgressFunctionIteration (ProgressFunction &progressFunction, size_t i, size_t iterCount, size_t &iNotify, size_t notificationInterval)
ProgressFunction CreateScaledProgressFunction (double ratioMin, double ratioMax, ProgressFunction &progressFunction)
bool endsWith (const std::string &s, const std::string &suffix)
bool endsWith (const std::string &s, char suffix)
bool startsWith (const std::string &s, const std::string &prefix)
bool startsWith (const std::string &s, char prefix)
void toUpper (std::string &s)

Detailed Description

Utility classes for GEOS.

Typedef Documentation

◆ ProgressFunction

typedef std::function<void(double, const char*)> geos::util::ProgressFunction

Signature of a progression function.

Such function takes a progression ratio (between 0 and 1), and an optional message.

Function Documentation

◆ CreateScaledProgressFunction()

ProgressFunction geos::util::CreateScaledProgressFunction ( double ratioMin,
double ratioMax,
ProgressFunction & progressFunction )

Create a scaled progress function.

Sometimes when an operation wants to report progress, it actually invokes several subprocesses which also take a ProgressFunction, and it is desirable to map the progress of each sub operation into a portion of 0.0 to 1.0 progress of the overall process. The scaled progress function can be used for this.

For each subsection a scaled progress function is created and instead of passing the overall progress func down to the sub functions, the scale progress function is passed instead.

Parameters
ratioMinthe value to which 0.0 in the sub operation is mapped.
ratioMaxthe value to which 1.0 is the sub operation is mapped.
progressFunctionthe overall progress function.
Returns
scaled progress function.

◆ ProgressFunctionIteration()

void geos::util::ProgressFunctionIteration ( ProgressFunction & progressFunction,
size_t i,
size_t iterCount,
size_t & iNotify,
size_t notificationInterval )

Do progress function related processing for an iteration loop of iterCount iterations.

This function will invoke (*progressFunction) every notificationInterval iteration.

This function will return, or throw a geos::util::InterruptedException.

A typical use is:

const size_t notificationInterval = std::max<size_t>(1, iterCount / 100);
for (size_t i = 0, iNotify = 0; i < iterCount; ++i) {
// do something useful
if (progressFunction) {
geos::util::ProgressFunctionIteration(*progressFunction, i, iterCount, iNotify, notificationInterval);
}
}
if (progressFunction) {
(*progressFunction)(1.0, nullptr);
}
void ProgressFunctionIteration(ProgressFunction &progressFunction, size_t i, size_t iterCount, size_t &iNotify, size_t notificationInterval)
Parameters
progressFunctionProgress function
iCurrent index of loop iteration.
iterCountTotal number of loop iteration.
iNotifyNotification counter, updated by this function. Must be set by the caller (before the loop) to 0.
notificationIntervalNotification interval (e.g. iterCount / 100).

◆ round()

double geos::util::round ( double val)
inline

Default rounding method for GEOS

Note
Always use this rounding method, to easy easy switching between different rounding method for the whole codebase.

References java_math_round().