GEOS  3.9.1dev
HotPixel.h
Go to the documentation of this file.
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 
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 
75  double scaleFactor;
76 
77  /* Indicates if this hot pixel must be a node in the output. */
78  bool hpIsNode;
79 
80  /* The scaled ordinates of the hot pixel point */
81  double hpx;
82  double hpy;
83 
84  double scaleRound(double val) const;
85 
86  double scale(double val) const;
87 
88  bool intersectsPixelClosure(const geom::Coordinate& p0,
89  const geom::Coordinate& p1) const;
90 
91  bool intersectsScaled(double p0x, double p0y, double p1x, double p1y) const;
92 
93  // Declare type as noncopyable
94  HotPixel(const HotPixel& other) = delete;
95  HotPixel& operator=(const HotPixel& rhs) = delete;
96 
97 public:
98 
102  double getWidth() const { return 1.0 / scaleFactor; };
103 
104  double getScaleFactor() const { return scaleFactor; };
105 
112  HotPixel(const geom::Coordinate& pt, double scaleFactor);
113 
114  /*
115  * Gets the coordinate this hot pixel is based at.
116  *
117  * @return the coordinate of the pixel
118  */
119  const geom::Coordinate& getCoordinate() const;
120 
128  bool intersects(const geom::Coordinate& p0,
129  const geom::Coordinate& p1) const;
130 
137  bool intersects(const geom::Coordinate& p) const;
138 
139  bool isNode() const { return hpIsNode; };
140  void setToNode() { hpIsNode = true; };
141 
142  std::ostream& operator<< (std::ostream& os);
143 };
144 
145 } // namespace geos::noding::snapround
146 } // namespace geos::noding
147 } // namespace geos
148 
149 #ifdef _MSC_VER
150 #pragma warning(pop)
151 #endif
152 
153 #ifdef GEOS_INLINE
154 # include "geos/noding/snapround/HotPixel.inl"
155 #endif
156 
Implements a "hot pixel" as used in the Snap Rounding algorithm.
Definition: HotPixel.h:63
double getScaleFactor() const
Definition: HotPixel.h:104
#define GEOS_DLL
Definition: export.h:28
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
geom::Coordinate originalPt
Definition: HotPixel.h:74
std::ostream & operator<<(std::ostream &os, const Coordinate &c)
Output function.
Basic namespace for all GEOS functionalities.