Coverage Report

Created: 2026-10-31 06:44

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/geos/src/operation/buffer/BufferParameters.cpp
Line
Count
Source
1
/**********************************************************************
2
 *
3
 * GEOS - Geometry Engine Open Source
4
 * http://geos.osgeo.org
5
 *
6
 * Copyright (C) 2009  Sandro Santilli <strk@kbt.io>
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
 * Last port: operation/buffer/BufferParameters.java r278 (JTS-1.12)
16
 *
17
 **********************************************************************/
18
19
#include <cstdlib> // for std::abs()
20
#include <cmath> // for cos
21
22
#include <geos/algorithm/Angle.h>
23
#include <geos/constants.h>
24
#include <geos/operation/buffer/BufferParameters.h>
25
26
27
namespace geos {
28
namespace operation { // geos.operation
29
namespace buffer { // geos.operation.buffer
30
31
// public static const
32
const double BufferParameters::DEFAULT_MITRE_LIMIT = 5.0;
33
34
// public
35
BufferParameters::BufferParameters()
36
    :
37
0
    quadrantSegments(DEFAULT_QUADRANT_SEGMENTS),
38
0
    endCapStyle(CAP_ROUND),
39
0
    joinStyle(JOIN_ROUND),
40
0
    mitreLimit(DEFAULT_MITRE_LIMIT),
41
0
    _isSingleSided(false)
42
0
{}
43
44
// public
45
BufferParameters::BufferParameters(int p_quadrantSegments)
46
    :
47
0
    quadrantSegments(DEFAULT_QUADRANT_SEGMENTS),
48
0
    endCapStyle(CAP_ROUND),
49
0
    joinStyle(JOIN_ROUND),
50
0
    mitreLimit(DEFAULT_MITRE_LIMIT),
51
0
    _isSingleSided(false)
52
0
{
53
0
    setQuadrantSegments(p_quadrantSegments);
54
0
}
55
56
// public
57
BufferParameters::BufferParameters(int p_quadrantSegments,
58
                                   EndCapStyle p_endCapStyle)
59
    :
60
0
    quadrantSegments(DEFAULT_QUADRANT_SEGMENTS),
61
0
    endCapStyle(CAP_ROUND),
62
0
    joinStyle(JOIN_ROUND),
63
0
    mitreLimit(DEFAULT_MITRE_LIMIT),
64
0
    _isSingleSided(false)
65
0
{
66
0
    setQuadrantSegments(p_quadrantSegments);
67
0
    setEndCapStyle(p_endCapStyle);
68
0
}
69
70
// public
71
BufferParameters::BufferParameters(int p_quadrantSegments,
72
                                   EndCapStyle p_endCapStyle,
73
                                   JoinStyle p_joinStyle,
74
                                   double p_mitreLimit)
75
    :
76
0
    quadrantSegments(DEFAULT_QUADRANT_SEGMENTS),
77
0
    endCapStyle(CAP_ROUND),
78
0
    joinStyle(JOIN_ROUND),
79
0
    mitreLimit(DEFAULT_MITRE_LIMIT),
80
0
    _isSingleSided(false)
81
0
{
82
0
    setQuadrantSegments(p_quadrantSegments);
83
0
    setEndCapStyle(p_endCapStyle);
84
0
    setJoinStyle(p_joinStyle);
85
0
    setMitreLimit(p_mitreLimit);
86
0
}
87
88
// public
89
void
90
BufferParameters::setQuadrantSegments(int quadSegs)
91
0
{
92
0
    quadrantSegments = quadSegs;
93
0
}
94
95
// public static
96
double
97
BufferParameters::bufferDistanceError(int quadSegs)
98
0
{
99
0
    double alpha = algorithm::Angle::PI_OVER_2 / quadSegs;
100
0
    return 1 - cos(alpha / 2.0);
101
0
}
102
103
} // namespace geos.operation.buffer
104
} // namespace geos.operation
105
} // namespace geos