GEOS 3.9.1
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
37namespace geos {
38namespace geom {
39class Coordinate;
40class Geometry;
41}
42namespace operation {
43namespace overlay {
44class ElevationMatrixFilter;
45class ElevationMatrix;
46}
47}
48}
49
50namespace geos {
51namespace operation { // geos::operation
52namespace 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 */
61class GEOS_DLL ElevationMatrixFilter: public geom::CoordinateFilter {
62public:
63 ElevationMatrixFilter(ElevationMatrix& em);
64 ~ElevationMatrixFilter() override = default;
65 void filter_rw(geom::Coordinate* c) const override;
66 void filter_ro(const geom::Coordinate* c) override;
67private:
68 ElevationMatrix& em;
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 */
79class GEOS_DLL ElevationMatrix {
80 friend class ElevationMatrixFilter;
81public:
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;
92private:
93 ElevationMatrixFilter filter;
94 void add(const geom::Coordinate& c);
95 geom::Envelope env;
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
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:26