Coverage Report

Created: 2025-12-14 06:52

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/geos/src/precision/PointwisePrecisionReducerTransformer.cpp
Line
Count
Source
1
/**********************************************************************
2
 *
3
 * GEOS - Geometry Engine Open Source
4
 * http://geos.osgeo.org
5
 *
6
 * Copyright (C) 2005-2006 Refractions Research Inc.
7
 * Copyright (C) 2001-2002 Vivid Solutions Inc.
8
 *
9
 * This is free software; you can redistribute and/or modify it under
10
 * the terms of the GNU Lesser General Public Licence as published
11
 * by the Free Software Foundation.
12
 * See the COPYING file for more information.
13
 *
14
 ***********************************************************************
15
 *
16
 * Last port: precision/SimpleGeometryPrecisionReducer.cpp rev. 1.10 (JTS-1.7)
17
 *
18
 **********************************************************************/
19
20
#include <geos/geom/Coordinate.h>
21
#include <geos/geom/CoordinateSequence.h>
22
#include <geos/geom/GeometryFactory.h>
23
#include <geos/geom/LineString.h>
24
#include <geos/geom/LinearRing.h>
25
#include <geos/geom/PrecisionModel.h>
26
#include <geos/precision/PointwisePrecisionReducerTransformer.h>
27
#include <geos/util.h>
28
29
30
using namespace geos::geom;
31
using namespace geos::geom::util;
32
33
namespace geos {
34
namespace precision { // geos.precision
35
36
37
/* public static */
38
std::unique_ptr<Geometry>
39
PointwisePrecisionReducerTransformer::reduce(const Geometry& geom, const PrecisionModel& targetPM)
40
0
{
41
0
    PointwisePrecisionReducerTransformer trans(targetPM);
42
0
    return trans.transform(&geom);
43
0
}
44
45
/* protected */
46
std::unique_ptr<CoordinateSequence>
47
PointwisePrecisionReducerTransformer::transformCoordinates(const CoordinateSequence* coords, const Geometry* parent)
48
0
{
49
0
    (void)(parent); // ignore unused variable
50
51
0
    if (coords->isEmpty()) {
52
0
        return detail::make_unique<CoordinateSequence>(0u, coords->getDimension());
53
0
    }
54
55
0
    return reducePointwise(coords);
56
0
}
57
58
59
/* private */
60
std::unique_ptr<CoordinateSequence>
61
PointwisePrecisionReducerTransformer::reducePointwise(const CoordinateSequence* coordinates)
62
0
{
63
0
    auto coordReduce = detail::make_unique<CoordinateSequence>();
64
0
    coordReduce->reserve(coordinates->size());
65
66
    // copy coordinates and reduce
67
0
    coordinates->forEach<Coordinate>([&coordReduce, this](Coordinate coord) {
68
0
        targetPM.makePrecise(coord);
69
0
        coordReduce->add(coord);
70
0
    });
71
0
    return coordReduce;
72
0
}
73
74
75
76
} // namespace geos.precision
77
} // namespace geos
78