GEOS
3.6.2
|
00001 /********************************************************************** 00002 * 00003 * GEOS - Geometry Engine Open Source 00004 * http://geos.osgeo.org 00005 * 00006 * Copyright (C) 2006 Refractions Research Inc. 00007 * 00008 * This is free software; you can redistribute and/or modify it under 00009 * the terms of the GNU Lesser General Public Licence as published 00010 * by the Free Software Foundation. 00011 * See the COPYING file for more information. 00012 * 00013 *********************************************************************** 00014 * 00015 * Last port: original (by strk) 00016 * 00017 **********************************************************************/ 00018 00019 #ifndef GEOS_OP_OVERLAY_ELEVATIONMATRIX_H 00020 #define GEOS_OP_OVERLAY_ELEVATIONMATRIX_H 00021 00022 #include <geos/export.h> 00023 00024 #include <geos/geom/CoordinateFilter.h> // for inheritance 00025 #include <geos/geom/Envelope.h> // for composition 00026 #include <geos/operation/overlay/ElevationMatrixCell.h> // for composition 00027 00028 #include <vector> 00029 #include <string> 00030 00031 #ifdef _MSC_VER 00032 #pragma warning(push) 00033 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class 00034 #endif 00035 00036 // Forward declarations 00037 namespace geos { 00038 namespace geom { 00039 class Coordinate; 00040 class Geometry; 00041 } 00042 namespace operation { 00043 namespace overlay { 00044 class ElevationMatrixFilter; 00045 class ElevationMatrix; 00046 } 00047 } 00048 } 00049 00050 namespace geos { 00051 namespace operation { // geos::operation 00052 namespace overlay { // geos::operation::overlay 00053 00054 00055 /* 00056 * This is the CoordinateFilter used by ElevationMatrix. 00057 * filter_ro is used to add Geometry Coordinate's Z 00058 * values to the matrix. 00059 * filter_rw is used to actually elevate Geometries. 00060 */ 00061 class GEOS_DLL ElevationMatrixFilter: public geom::CoordinateFilter 00062 { 00063 public: 00064 ElevationMatrixFilter(ElevationMatrix &em); 00065 ~ElevationMatrixFilter(); 00066 void filter_rw(geom::Coordinate *c) const; 00067 void filter_ro(const geom::Coordinate *c); 00068 private: 00069 ElevationMatrix &em; 00070 double avgElevation; 00071 00072 // Declare type as noncopyable 00073 ElevationMatrixFilter(const ElevationMatrixFilter& other); 00074 ElevationMatrixFilter& operator=(const ElevationMatrixFilter& rhs); 00075 }; 00076 00077 00078 /* 00079 */ 00080 class GEOS_DLL ElevationMatrix { 00081 friend class ElevationMatrixFilter; 00082 public: 00083 ElevationMatrix(const geom::Envelope &extent, unsigned int rows, 00084 unsigned int cols); 00085 ~ElevationMatrix(); 00086 void add(const geom::Geometry *geom); 00087 void elevate(geom::Geometry *geom) const; 00088 // set Z value for each cell w/out one 00089 double getAvgElevation() const; 00090 ElevationMatrixCell &getCell(const geom::Coordinate &c); 00091 const ElevationMatrixCell &getCell(const geom::Coordinate &c) const; 00092 std::string print() const; 00093 private: 00094 ElevationMatrixFilter filter; 00095 void add(const geom::Coordinate &c); 00096 geom::Envelope env; 00097 unsigned int cols; 00098 unsigned int rows; 00099 double cellwidth; 00100 double cellheight; 00101 mutable bool avgElevationComputed; 00102 mutable double avgElevation; 00103 std::vector<ElevationMatrixCell>cells; 00104 }; 00105 00106 } // namespace geos::operation::overlay 00107 } // namespace geos::operation 00108 } // namespace geos 00109 00110 #ifdef _MSC_VER 00111 #pragma warning(pop) 00112 #endif 00113 00114 #endif // ndef GEOS_OP_OVERLAY_ELEVATIONMATRIX_H