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