GEOS  3.9.0dev
HotPixel.h
1 /**********************************************************************
2  *
3  * GEOS - Geometry Engine Open Source
4  * http://geos.osgeo.org
5  *
6  * Copyright (C) 2006 Refractions Research Inc.
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: noding/snapround/HotPixel.java r320 (JTS-1.12)
16  *
17  **********************************************************************/
18 
19 #pragma once
20 
21 #include <geos/export.h>
22 
23 #include <geos/inline.h>
24 
25 #include <geos/geom/Coordinate.h> // for composition
26 #include <geos/geom/Envelope.h> // for unique_ptr
27 #include <geos/io/WKTWriter.h>
28 
29 
30 #include <array>
31 
32 #ifdef _MSC_VER
33 #pragma warning(push)
34 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
35 #endif
36 
37 // Forward declarations
38 namespace geos {
39 namespace geom {
40 class Envelope;
41 }
42 namespace algorithm {
43 class LineIntersector;
44 }
45 namespace noding {
46 class NodedSegmentString;
47 }
48 }
49 
50 namespace geos {
51 namespace noding { // geos::noding
52 namespace snapround { // geos::noding::snapround
53 
63 class GEOS_DLL HotPixel {
64 
65 private:
66 
67  static constexpr double TOLERANCE = 0.5;
68 
69  static constexpr int UPPER_RIGHT = 0;
70  static constexpr int UPPER_LEFT = 1;
71  static constexpr int LOWER_LEFT = 2;
72  static constexpr int LOWER_RIGHT = 3;
73 
74  geom::Coordinate ptHot;
75  geom::Coordinate originalPt;
76 
77  bool hpIsNode;
78  double scaleFactor;
79 
80  double minx;
81  double maxx;
82  double miny;
83  double maxy;
84 
85  double scaleRound(double val) const;
86  geom::Coordinate scaleRound(const geom::Coordinate& p) const;
87 
88  double scale(double val) const;
89 
90  bool intersectsPixelClosure(const geom::Coordinate& p0,
91  const geom::Coordinate& p1) const;
92 
93  bool intersectsScaled(double p0x, double p0y, double p1x, double p1y) const;
94 
95  // Declare type as noncopyable
96  HotPixel(const HotPixel& other) = delete;
97  HotPixel& operator=(const HotPixel& rhs) = delete;
98 
99 public:
100 
104  double getWidth() const { return 1.0 / scaleFactor; };
105 
106  double getScaleFactor() const { return scaleFactor; };
107 
114  HotPixel(const geom::Coordinate& pt, double scaleFactor);
115 
116  /*
117  * Gets the coordinate this hot pixel is based at.
118  *
119  * @return the coordinate of the pixel
120  */
121  const geom::Coordinate& getCoordinate() const;
122 
130  bool intersects(const geom::Coordinate& p0,
131  const geom::Coordinate& p1) const;
132 
139  bool intersects(const geom::Coordinate& p) const;
140 
141  bool isNode() const { return hpIsNode; };
142  void setToNode() { hpIsNode = true; };
143 
144  std::ostream& operator<< (std::ostream& os);
145 };
146 
147 } // namespace geos::noding::snapround
148 } // namespace geos::noding
149 } // namespace geos
150 
151 #ifdef _MSC_VER
152 #pragma warning(pop)
153 #endif
154 
155 #ifdef GEOS_INLINE
156 # include "geos/noding/snapround/HotPixel.inl"
157 #endif
158 
Implements a "hot pixel" as used in the Snap Rounding algorithm.
Definition: HotPixel.h:63
double getWidth() const
Definition: HotPixel.h:104
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:26