Coverage Report

Created: 2026-06-13 06:12

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/geos/include/geos/geom/HeuristicOverlay.h
Line
Count
Source
1
/**********************************************************************
2
 *
3
 * GEOS - Geometry Engine Open Source
4
 * http://geos.osgeo.org
5
 *
6
 * Copyright (C) 2013-2020 Sandro Santilli <strk@kbt.io>
7
 * Copyright (C) 2006 Refractions Research 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: ORIGINAL WORK
17
 *
18
 **********************************************************************/
19
20
#pragma once
21
22
#include <geos/export.h>
23
#include <geos/geom/Geometry.h>
24
#include <geos/geom/Dimension.h>
25
26
27
#include <memory> // for unique_ptr
28
#include <vector>
29
30
31
namespace geos {
32
namespace geom {
33
class Geometry;
34
class GeometryFactory;
35
}
36
}
37
38
39
namespace geos {
40
namespace geom { // geos::geom
41
42
std::unique_ptr<Geometry> GEOS_DLL
43
HeuristicOverlay(const Geometry* g0, const Geometry* g1, int opCode);
44
45
class StructuredCollection {
46
47
public:
48
49
    static std::unique_ptr<Geometry> overlay(const Geometry* g0, const Geometry* g1, int opCode);
50
51
private:
52
53
    const GeometryFactory* factory;
54
    std::vector<const Geometry*> pts;
55
    std::vector<const Geometry*> lines;
56
    std::vector<const Geometry*> polys;
57
    std::unique_ptr<Geometry> pt_union;
58
    std::unique_ptr<Geometry> line_union;
59
    std::unique_ptr<Geometry> poly_union;
60
    Dimension::DimensionType dimension;
61
62
    StructuredCollection(const Geometry* g)
63
15.5k
        : factory(g->getFactory())
64
15.5k
        , pt_union(nullptr)
65
15.5k
        , line_union(nullptr)
66
15.5k
        , poly_union(nullptr)
67
15.5k
        , dimension(Dimension::DONTCARE)
68
15.5k
    {
69
15.5k
        readCollection(g);
70
15.5k
        unionByDimension();
71
15.5k
    };
72
73
    StructuredCollection()
74
6.15k
        : factory(nullptr)
75
6.15k
        , pt_union(nullptr)
76
6.15k
        , line_union(nullptr)
77
6.15k
        , poly_union(nullptr)
78
6.15k
        , dimension(Dimension::DONTCARE)
79
6.15k
    {};
80
81
    Dimension::DimensionType getDimension() const
82
12.3k
    {
83
12.3k
        return dimension;
84
12.3k
    };
85
86
    void addDimension(Dimension::DimensionType dim);
87
    std::unique_ptr<Geometry> doUnaryUnion(int resultDim) const;
88
    std::unique_ptr<Geometry> computeResult(StructuredCollection& coll, int opCode,
89
                Dimension::DimensionType dimA, Dimension::DimensionType dimB) const;
90
91
    void readCollection(const Geometry* g);
92
15.6k
    const Geometry* getPolyUnion()  const { return poly_union.get(); }
93
10.6k
    const Geometry* getLineUnion()  const { return line_union.get(); }
94
10.5k
    const Geometry* getPointUnion() const { return pt_union.get(); }
95
96
    std::unique_ptr<Geometry> doUnion(const StructuredCollection& a) const;
97
    std::unique_ptr<Geometry> doIntersection(const StructuredCollection& a) const;
98
    std::unique_ptr<Geometry> doSymDifference(const StructuredCollection& a) const;
99
    std::unique_ptr<Geometry> doDifference(const StructuredCollection& a) const;
100
101
    static void toVector(const Geometry* g, std::vector<const Geometry*>& v);
102
    void unionByDimension(void);
103
};
104
105
106
107
108
109
} // namespace geos::geom
110
} // namespace geos
111