• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List

ElevationMatrix.h

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

Generated on Thu Jul 22 2010 for GEOS by  doxygen 1.7.1