Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | Related Pages

ElevationMatrix.h

00001 /**********************************************************************
00002  * $Id: ElevationMatrix.h 2564 2009-06-08 16:09:51Z strk $
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 
00069 
00070 /*
00071  */
00072 class GEOS_DLL ElevationMatrix {
00073 friend class ElevationMatrixFilter;
00074 public:
00075         ElevationMatrix(const geom::Envelope &extent, unsigned int rows,
00076                 unsigned int cols);
00077         ~ElevationMatrix();
00078         void add(const geom::Geometry *geom);
00079         void elevate(geom::Geometry *geom) const;
00080         // set Z value for each cell w/out one
00081         double getAvgElevation() const;
00082         ElevationMatrixCell &getCell(const geom::Coordinate &c);
00083         const ElevationMatrixCell &getCell(const geom::Coordinate &c) const;
00084         std::string print() const;
00085 private:
00086         ElevationMatrixFilter filter;
00087         void add(const geom::Coordinate &c);
00088         geom::Envelope env;
00089         unsigned int cols;
00090         unsigned int rows;
00091         double cellwidth;
00092         double cellheight;
00093         mutable bool avgElevationComputed;
00094         mutable double avgElevation;
00095         std::vector<ElevationMatrixCell>cells;
00096 };
00097 
00098 
00099 } // namespace geos::operation::overlay
00100 } // namespace geos::operation
00101 } // namespace geos
00102 
00103 #endif // ndef GEOS_OP_OVERLAY_ELEVATIONMATRIX_H
00104 
00105 /**********************************************************************
00106  * $Log$
00107  * Revision 1.1  2006/03/17 13:24:59  strk
00108  * 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).
00109  *
00110  **********************************************************************/
00111 

Generated on Thu Jun 11 06:17:01 2009 for GEOS by  doxygen 1.4.4