GEOS 3.3.8

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

- File List

ElevationMatrix.h
1 /**********************************************************************
2 * $Id: ElevationMatrix.h 3255 2011-03-01 17:56:10Z mloskot $
3 *
4 * GEOS - Geometry Engine Open Source
5 * http://geos.refractions.net
6 *
7 * Copyright (C) 2006 Refractions Research Inc.
8 *
9 * This is free software; you can redistribute and/or modify it under
10 * the terms of the GNU Lesser General Public Licence as published
11 * by the Free Software Foundation.
12 * See the COPYING file for more information.
13 *
14 ***********************************************************************
15 *
16 * Last port: original (by strk)
17 *
18 **********************************************************************/
19
20 #ifndef GEOS_OP_OVERLAY_ELEVATIONMATRIX_H
21 #define GEOS_OP_OVERLAY_ELEVATIONMATRIX_H
22
23 #include <geos/export.h>
24
25 #include <geos/geom/CoordinateFilter.h> // for inheritance
26 #include <geos/geom/Envelope.h> // for composition
27 #include <geos/operation/overlay/ElevationMatrixCell.h> // for composition
28
29 #include <vector>
30 #include <string>
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 Coordinate;
41 class Geometry;
42 }
43 namespace operation {
44 namespace overlay {
45 class ElevationMatrixFilter;
46 class ElevationMatrix;
47 }
48 }
49 }
50
51 namespace geos {
52 namespace operation { // geos::operation
53 namespace overlay { // geos::operation::overlay
54
55
56 /*
57 * This is the CoordinateFilter used by ElevationMatrix.
58 * filter_ro is used to add Geometry Coordinate's Z
59 * values to the matrix.
60 * filter_rw is used to actually elevate Geometries.
61 */
62 class GEOS_DLL ElevationMatrixFilter: public geom::CoordinateFilter
63 {
64 public:
65 ElevationMatrixFilter(ElevationMatrix &em);
66 ~ElevationMatrixFilter();
67 void filter_rw(geom::Coordinate *c) const;
68 void filter_ro(const geom::Coordinate *c);
69 private:
70 ElevationMatrix &em;
71 double avgElevation;
72
73 // Declare type as noncopyable
74 ElevationMatrixFilter(const ElevationMatrixFilter& other);
75 ElevationMatrixFilter& operator=(const ElevationMatrixFilter& rhs);
76 };
77
78
79 /*
80 */
81 class GEOS_DLL ElevationMatrix {
82 friend class ElevationMatrixFilter;
83 public:
84 ElevationMatrix(const geom::Envelope &extent, unsigned int rows,
85 unsigned int cols);
86 ~ElevationMatrix();
87 void add(const geom::Geometry *geom);
88 void elevate(geom::Geometry *geom) const;
89 // set Z value for each cell w/out one
90 double getAvgElevation() const;
91 ElevationMatrixCell &getCell(const geom::Coordinate &c);
92 const ElevationMatrixCell &getCell(const geom::Coordinate &c) const;
93 std::string print() const;
94 private:
95 ElevationMatrixFilter filter;
96 void add(const geom::Coordinate &c);
97 geom::Envelope env;
98 unsigned int cols;
99 unsigned int rows;
100 double cellwidth;
101 double cellheight;
102 mutable bool avgElevationComputed;
103 mutable double avgElevation;
104 std::vector<ElevationMatrixCell>cells;
105 };
106
107 } // namespace geos::operation::overlay
108 } // namespace geos::operation
109 } // namespace geos
110
111 #ifdef _MSC_VER
112 #pragma warning(pop)
113 #endif
114
115 #endif // ndef GEOS_OP_OVERLAY_ELEVATIONMATRIX_H
116
117 /**********************************************************************
118 * $Log$
119 * Revision 1.1 2006/03/17 13:24:59 strk
120 * opOverlay.h header splitted. Reduced header inclusions in operation/overlay implementation files. ElevationMatrixFilter code moved from own file to ElevationMatrix.cpp (ideally a class-private).
121 *
122 **********************************************************************/
123