GEOS  3.9.1dev
ElevationMatrix.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: original (by strk)
16  *
17  **********************************************************************/
18 
19 #ifndef GEOS_OP_OVERLAY_ELEVATIONMATRIX_H
20 #define GEOS_OP_OVERLAY_ELEVATIONMATRIX_H
21 
22 #include <geos/export.h>
23 
24 #include <geos/geom/CoordinateFilter.h> // for inheritance
25 #include <geos/geom/Envelope.h> // for composition
26 #include <geos/operation/overlay/ElevationMatrixCell.h> // for composition
27 
28 #include <vector>
29 #include <string>
30 
31 #ifdef _MSC_VER
32 #pragma warning(push)
33 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
34 #endif
35 
36 // Forward declarations
37 namespace geos {
38 namespace geom {
39 class Coordinate;
40 class Geometry;
41 }
42 namespace operation {
43 namespace overlay {
44 class ElevationMatrixFilter;
45 class ElevationMatrix;
46 }
47 }
48 }
49 
50 namespace geos {
51 namespace operation { // geos::operation
52 namespace overlay { // geos::operation::overlay
53 
54 
55 /*
56  * This is the CoordinateFilter used by ElevationMatrix.
57  * filter_ro is used to add Geometry Coordinate's Z
58  * values to the matrix.
59  * filter_rw is used to actually elevate Geometries.
60  */
62 public:
64  ~ElevationMatrixFilter() override = default;
65  void filter_rw(geom::Coordinate* c) const override;
66  void filter_ro(const geom::Coordinate* c) override;
67 private:
69  double avgElevation;
70 
71  // Declare type as noncopyable
72  ElevationMatrixFilter(const ElevationMatrixFilter& other) = delete;
73  ElevationMatrixFilter& operator=(const ElevationMatrixFilter& rhs) = delete;
74 };
75 
76 
77 /*
78  */
80  friend class ElevationMatrixFilter;
81 public:
82  ElevationMatrix(const geom::Envelope& extent, unsigned int rows,
83  unsigned int cols);
84  ~ElevationMatrix() = default;
85  void add(const geom::Geometry* geom);
86  void elevate(geom::Geometry* geom) const;
87  // set Z value for each cell w/out one
88  double getAvgElevation() const;
89  ElevationMatrixCell& getCell(const geom::Coordinate& c);
90  const ElevationMatrixCell& getCell(const geom::Coordinate& c) const;
91  std::string print() const;
92 private:
94  void add(const geom::Coordinate& c);
96  unsigned int cols;
97  unsigned int rows;
98  double cellwidth;
99  double cellheight;
100  mutable bool avgElevationComputed;
101  mutable double avgElevation;
102  std::vector<ElevationMatrixCell>cells;
103 };
104 
105 } // namespace geos::operation::overlay
106 } // namespace geos::operation
107 } // namespace geos
108 
109 #ifdef _MSC_VER
110 #pragma warning(pop)
111 #endif
112 
113 #endif // ndef GEOS_OP_OVERLAY_ELEVATIONMATRIX_H
An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition: Envelope.h:58
#define GEOS_DLL
Definition: export.h:28
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:188
Geometry classes support the concept of applying a coordinate filter to every coordinate in the Geome...
Basic namespace for all GEOS functionalities.
std::vector< ElevationMatrixCell > cells