# ElevationMatrix.h

    00001 /**********************************************************************
    00002  * $Id: ElevationMatrix.h 1820 2006-09-06 16:54:23Z 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 #ifndef GEOS_OP_OVERLAY_ELEVATIONMATRIX_H
    00017 #define GEOS_OP_OVERLAY_ELEVATIONMATRIX_H
    00018
    00019 #include <vector>
    00020 #include <string>
    00021
    00022 #include <geos/geom/CoordinateFilter.h> // for inheritance
    00023 #include <geos/geom/Envelope.h> // for composition
    00024 #include <geos/operation/overlay/ElevationMatrixCell.h> // for composition
    00025
    00026 // Forward declarations
    00027 namespace geos {
    00028         namespace geom {
    00029                 class Coordinate;
    00030                 class Geometry;
    00031         }
    00032         namespace operation {
    00033                 namespace overlay {
    00034                         class ElevationMatrixFilter;
    00035                         class ElevationMatrix;
    00036                 }
    00037         }
    00038 }
    00039
    00040 namespace geos {
    00041 namespace operation { // geos::operation
    00042 namespace overlay { // geos::operation::overlay
    00043
    00044
    00045 /*
    00046  * This is the CoordinateFilter used by ElevationMatrix.
    00047  * filter_ro is used to add Geometry Coordinate's Z
    00048  * values to the matrix.
    00049  * filter_rw is used to actually elevate Geometries.
    00050  */
    00051 class ElevationMatrixFilter: public geom::CoordinateFilter
    00052 {
    00053 public:
    00054         ElevationMatrixFilter(ElevationMatrix &em);
    00055         ~ElevationMatrixFilter();
    00056         void filter_rw(geom::Coordinate *c) const;
    00057         void filter_ro(const geom::Coordinate *c);
    00058 private:
    00059         ElevationMatrix &em;
    00060         double avgElevation;
    00061 };
    00062
    00063
    00064 /*
    00065  */
    00066 class ElevationMatrix {
    00067 friend class ElevationMatrixFilter;
    00068 public:
    00069         ElevationMatrix(const geom::Envelope &extent, unsigned int rows,
    00070                 unsigned int cols);
    00071         ~ElevationMatrix();
    00072         void add(const geom::Geometry *geom);
    00073         void elevate(geom::Geometry *geom) const;
    00074         // set Z value for each cell w/out one
    00075         double getAvgElevation() const;
    00076         ElevationMatrixCell &getCell(const geom::Coordinate &c);
    00077         const ElevationMatrixCell &getCell(const geom::Coordinate &c) const;
    00078         std::string print() const;
    00079 private:
    00080         ElevationMatrixFilter filter;
    00081         void add(const geom::Coordinate &c);
    00082         geom::Envelope env;
    00083         unsigned int cols;
    00084         unsigned int rows;
    00085         double cellwidth;
    00086         double cellheight;
    00087         mutable bool avgElevationComputed;
    00088         mutable double avgElevation;
    00089         std::vector<ElevationMatrixCell>cells;
    00090 };
    00091
    00092
    00093 } // namespace geos::operation::overlay
    00094 } // namespace geos::operation
    00095 } // namespace geos
    00096
    00097 #endif // ndef GEOS_OP_OVERLAY_ELEVATIONMATRIX_H
    00098
    00099 /**********************************************************************
    00100  * $Log$
    00101  * Revision 1.1  2006/03/17 13:24:59  strk
    00102  * 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).
    00103  *
    00104  **********************************************************************/
    00105