GEOS: ElevationMatrix.h Source File

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List

# ElevationMatrix.h

    00001 /**********************************************************************
    00002  * $Id: ElevationMatrix.h 3255 2011-03-01 17:56:10Z 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 <geos/geom/CoordinateFilter.h> // for inheritance
    00026 #include <geos/geom/Envelope.h> // for composition
    00027 #include <geos/operation/overlay/ElevationMatrixCell.h> // for composition
    00028
    00029 #include <vector>
    00030 #include <string>
    00031
    00032 #ifdef _MSC_VER
    00033 #pragma warning(push)
    00034 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
    00035 #endif
    00036
    00037 // Forward declarations
    00038 namespace geos {
    00039         namespace geom {
    00040                 class Coordinate;
    00041                 class Geometry;
    00042         }
    00043         namespace operation {
    00044                 namespace overlay {
    00045                         class ElevationMatrixFilter;
    00046                         class ElevationMatrix;
    00047                 }
    00048         }
    00049 }
    00050
    00051 namespace geos {
    00052 namespace operation { // geos::operation
    00053 namespace overlay { // geos::operation::overlay
    00054
    00055
    00056 /*
    00057  * This is the CoordinateFilter used by ElevationMatrix.
    00058  * filter_ro is used to add Geometry Coordinate's Z
    00059  * values to the matrix.
    00060  * filter_rw is used to actually elevate Geometries.
    00061  */
    00062 class GEOS_DLL ElevationMatrixFilter: public geom::CoordinateFilter
    00063 {
    00064 public:
    00065         ElevationMatrixFilter(ElevationMatrix &em);
    00066         ~ElevationMatrixFilter();
    00067         void filter_rw(geom::Coordinate *c) const;
    00068         void filter_ro(const geom::Coordinate *c);
    00069 private:
    00070         ElevationMatrix &em;
    00071         double avgElevation;
    00072
    00073     // Declare type as noncopyable
    00074     ElevationMatrixFilter(const ElevationMatrixFilter& other);
    00075     ElevationMatrixFilter& operator=(const ElevationMatrixFilter& rhs);
    00076 };
    00077
    00078
    00079 /*
    00080  */
    00081 class GEOS_DLL ElevationMatrix {
    00082 friend class ElevationMatrixFilter;
    00083 public:
    00084         ElevationMatrix(const geom::Envelope &extent, unsigned int rows,
    00085                 unsigned int cols);
    00086         ~ElevationMatrix();
    00087         void add(const geom::Geometry *geom);
    00088         void elevate(geom::Geometry *geom) const;
    00089         // set Z value for each cell w/out one
    00090         double getAvgElevation() const;
    00091         ElevationMatrixCell &getCell(const geom::Coordinate &c);
    00092         const ElevationMatrixCell &getCell(const geom::Coordinate &c) const;
    00093         std::string print() const;
    00094 private:
    00095         ElevationMatrixFilter filter;
    00096         void add(const geom::Coordinate &c);
    00097         geom::Envelope env;
    00098         unsigned int cols;
    00099         unsigned int rows;
    00100         double cellwidth;
    00101         double cellheight;
    00102         mutable bool avgElevationComputed;
    00103         mutable double avgElevation;
    00104         std::vector<ElevationMatrixCell>cells;
    00105 };
    00106
    00107 } // namespace geos::operation::overlay
    00108 } // namespace geos::operation
    00109 } // namespace geos
    00110
    00111 #ifdef _MSC_VER
    00112 #pragma warning(pop)
    00113 #endif
    00114
    00115 #endif // ndef GEOS_OP_OVERLAY_ELEVATIONMATRIX_H
    00116
    00117 /**********************************************************************
    00118  * $Log$
    00119  * Revision 1.1  2006/03/17 13:24:59  strk
    00120  * 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).
    00121  *
    00122  **********************************************************************/
    00123