GEOS: ElevationMatrix.h Source File

GEOS 3.5.0

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List

ElevationMatrix.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: 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 */
61 class GEOS_DLL ElevationMatrixFilter: public geom::CoordinateFilter
62 {
63 public:
64 ElevationMatrixFilter(ElevationMatrix &em);
65 ~ElevationMatrixFilter();
66 void filter_rw(geom::Coordinate *c) const;
67 void filter_ro(const geom::Coordinate *c);
68 private:
69 ElevationMatrix &em;
70 double avgElevation;
71
72 // Declare type as noncopyable
73 ElevationMatrixFilter(const ElevationMatrixFilter& other);
74 ElevationMatrixFilter& operator=(const ElevationMatrixFilter& rhs);
75 };
76
77
78 /*
79 */
80 class GEOS_DLL ElevationMatrix {
81 friend class ElevationMatrixFilter;
82 public:
83 ElevationMatrix(const geom::Envelope &extent, unsigned int rows,
84 unsigned int cols);
85 ~ElevationMatrix();
86 void add(const geom::Geometry *geom);
87 void elevate(geom::Geometry *geom) const;
88 // set Z value for each cell w/out one
89 double getAvgElevation() const;
90 ElevationMatrixCell &getCell(const geom::Coordinate &c);
91 const ElevationMatrixCell &getCell(const geom::Coordinate &c) const;
92 std::string print() const;
93 private:
94 ElevationMatrixFilter filter;
95 void add(const geom::Coordinate &c);
96 geom::Envelope env;
97 unsigned int cols;
98 unsigned int rows;
99 double cellwidth;
100 double cellheight;
101 mutable bool avgElevationComputed;
102 mutable double avgElevation;
103 std::vector<ElevationMatrixCell>cells;
104 };
105
106 } // namespace geos::operation::overlay
107 } // namespace geos::operation
108 } // namespace geos
109
110 #ifdef _MSC_VER
111 #pragma warning(pop)
112 #endif
113
114 #endif // ndef GEOS_OP_OVERLAY_ELEVATIONMATRIX_H
geos
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25