GEOS 3.15.0beta1
LineToCurveParams.h
1/**********************************************************************
2*
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
5 *
6 * Copyright (C) 2026 ISciences, LLC
7 *
8 * This is free software; you can redistribute and/or modify it under
9 * the terms of the GNU Lesser General Public Licence as published
10 * by the Free Software Foundation.
11 * See the COPYING file for more information.
12 *
13 **********************************************************************/
14
15#pragma once
16
17#include <geos/export.h>
18#include <geos/constants.h>
19#include <geos/util/IllegalArgumentException.h>
20
21namespace geos::algorithm {
22
23class GEOS_DLL LineToCurveParams {
24
25public:
26
27 // Get the radius tolerance. For p[x] to be considered a continuation of the same arc,
28 // its radius must be within tol * the arc radius as computed from p[0], p[1], p[2].
29 double getRadiusTolerance() const {
30 return radiusTolerance;
31 }
32
33 // Get the maximum angle in degrees between successive vertices, measured from the circle center.
34 double getMaxAngleDegrees() const {
35 return maxAngleRadians * 180 / MATH_PI;
36 }
37
38 // Get the maximum angle in radians between two successive vertices, measured from the circle center.
39 double getMaxAngleRadians() const {
40 return maxAngleRadians;
41 }
42
43 // Get the maximum difference in sequentially calculated angles along the same arc.
44 double getMaxAngleDifferenceRadians() const {
45 return maxAngleDifferenceRadians;
46 }
47
48 void setRadiusTolerance(double tol) {
49 if (!(tol > 0)) {
50 throw geos::util::IllegalArgumentException("Radius tolerance must be positive");
51 }
52 radiusTolerance = tol;
53 }
54
55 void setMaxAngleDifferenceRadians(double tol) {
56 if (!(tol > 0)) {
57 throw geos::util::IllegalArgumentException("Angle tolerance must be positive");
58 }
59 maxAngleDifferenceRadians = tol;
60 }
61
62 void setMaxAngleDifferenceDegrees(double tol) {
63 setMaxAngleDifferenceRadians(tol * MATH_PI / 180.0);
64 }
65
66 void setMaxStepDegrees(double tol) {
67 if (!(tol > 0)) {
68 throw util::IllegalArgumentException("Angle step tolerance must be positive");
69 }
70 maxAngleRadians = tol * MATH_PI / 180.0;
71 }
72
73private:
74 double radiusTolerance{1e-6};
75 double maxAngleRadians{45.01 * MATH_PI / 180.0};
76 double maxAngleDifferenceRadians{0.01};
77};
78
79}
Contains classes and interfaces implementing fundamental computational geometry algorithms.
Definition Angle.h:32