00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
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>
00025 #include <geos/geom/Envelope.h>
00026 #include <geos/operation/overlay/ElevationMatrixCell.h>
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
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 {
00052 namespace overlay {
00053
00054
00055
00056
00057
00058
00059
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
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
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 }
00107 }
00108 }
00109
00110 #ifdef _MSC_VER
00111 #pragma warning(pop)
00112 #endif
00113
00114 #endif // ndef GEOS_OP_OVERLAY_ELEVATIONMATRIX_H