GEOS 3.14.0dev
HotPixelIndex.h
1/**********************************************************************
2 *
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
5 *
6 * Copyright (C) 2020 Paul Ramsey <pramsey@cleverelephant.ca>
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/geom/Envelope.h> // for unique_ptr
19#include <geos/geom/Coordinate.h> // for composition
20#include <geos/algorithm/LineIntersector.h>
21#include <geos/noding/snapround/HotPixel.h>
22#include <geos/geom/PrecisionModel.h>
23#include <geos/util/IllegalArgumentException.h>
24#include <geos/io/WKTWriter.h>
25#include <geos/index/kdtree/KdTree.h>
26#include <geos/index/kdtree/KdNodeVisitor.h>
27#include <geos/util.h>
28
29#include <array>
30#include <map>
31#include <memory>
32
33
34#ifdef _MSC_VER
35#pragma warning(push)
36#pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
37#endif
38
39// Forward declarations
40namespace geos {
41namespace algorithm {
42class LineIntersector;
43}
44namespace index {
45class ItemVisitor;
46}
47namespace noding {
48namespace snapround {
49class HotPixel;
50}
51}
52}
53
54
55namespace geos {
56namespace noding { // geos::noding
57namespace snapround { // geos::noding::snapround
58
59
60class GEOS_DLL HotPixelIndex {
61
62private:
63
64 /* members */
65 const geom::PrecisionModel* pm;
66 double scaleFactor;
67 std::unique_ptr<geos::index::kdtree::KdTree> index;
68 std::deque<HotPixel> hotPixelQue;
69
70 /* methods */
71 template<typename CoordType>
72 geom::CoordinateXYZM round(const CoordType& pt) {
73 geom::CoordinateXYZM p2(pt);
74 pm->makePrecise(p2);
75 return p2;
76 }
77
78 HotPixel* find(const geom::Coordinate& pixelPt);
79
80public:
81
82 HotPixelIndex(const geom::PrecisionModel* p_pm);
83 HotPixel* addRounded(const geom::CoordinateXYZM& pt);
84
85 template<typename CoordType>
86 HotPixel* add(const CoordType& p) {
87 static_assert(std::is_base_of<geom::CoordinateXY, CoordType>(), "Only valid for Coordinate types");
88
89 auto pRound = round(p);
90 return addRounded(pRound);
91 }
92
93 void add(const geom::CoordinateSequence* pts);
94 void add(const std::vector<geom::Coordinate>& pts);
95 void addNodes(const geom::CoordinateSequence* pts);
96 void addNodes(const std::vector<geom::Coordinate>& pts);
97
103 void query(const geom::CoordinateXY& p0, const geom::CoordinateXY& p1,
104 index::kdtree::KdNodeVisitor& visitor);
105
106};
107
108} // namespace geos::noding::snapround
109} // namespace geos::noding
110} // namespace geos
111
112#ifdef _MSC_VER
113#pragma warning(pop)
114#endif
115
116
double round(double val)
Definition math.h:36
Basic namespace for all GEOS functionalities.
Definition geos.h:39