libprop: source.h Source File

- Main Page
- Namespaces
- Classes
- Files

# source.h

Go to the documentation of this file.

    00001 /*
    00002         libprop -- library to simulate and measure radio signal propagation
    00003
    00004         Copyright (C) 2007 Jeffrey Sharkey, jsharkey.org
    00005
    00006         This program is free software: you can redistribute it and/or modify
    00007         it under the terms of the GNU General Public License as published by
    00008         the Free Software Foundation, either version 3 of the License, or
    00009         (at your option) any later version.
    00010
    00011         This program is distributed in the hope that it will be useful,
    00012         but WITHOUT ANY WARRANTY; without even the implied warranty of
    00013         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00014         GNU General Public License for more details.
    00015
    00016         You should have received a copy of the GNU General Public License
    00017         along with this program.  If not, see <http://www.gnu.org/licenses/>.
    00018 */
    00019
    00020 #pragma once
    00021
    00022 #include <iostream>
    00023 #include <fstream>
    00024 #include <string>
    00025
    00026 #include <math.h>
    00027
    00028 using namespace std;
    00029
    00030 #include "geom.h"
    00031 #include "utils.h"
    00032
    00033 #define TYPE_ELEV 2
    00034 #define TYPE_VEGTYPE 3
    00035 #define TYPE_VEGHEIGHT 4
    00036 #define TYPE_LAND 5
    00037
    00038 #define LAND_NONE 0
    00039 #define LAND_FOREST 1
    00040 #define LAND_RESIDENTIAL 2
    00041 #define LAND_COMMERCIAL 3
    00042
    00043 #define EC 0.082271854
    00044 #define EC2 0.006768658
    00045
    00046
    00048 class Convert {
    00049 public:
    00054         virtual void convert(Point* p, double* x, double* y);
    00055 };
    00056
    00057
    00059 class ConvertAlbers : public Convert {
    00060 private:
    00061         double middleLon, bigC, coneConst, r0;
    00062
    00063         double calcQ(double lat);
    00064         double calcMsq(double lat);
    00065
    00066 public:
    00067         ConvertAlbers();
    00068
    00073         void convert(Point* p, double* x, double* y);
    00074
    00075 };
    00076
    00077
    00079 class Source {
    00080 protected:
    00082         Convert* convert;
    00084         int type;
    00085         int ncols, nrows;
    00086         double top, left, bottom, right;
    00088         double cellsize;
    00090         string rawfilename;
    00092         ifstream raw;
    00093
    00094         Source();
    00095
    00099         Source(Convert* _convert, int _type);
    00100
    00101 public:
    00104         virtual void resolve(Point* p) = 0;
    00105
    00108         void resolveList(vector<Point*> list);
    00109
    00113         virtual bool contains(Point* p);
    00114
    00115 };
    00116
    00117
    00118
    00120 class SourceInteger : public Source {
    00121 protected:
    00123         int* cache;
    00124
    00128         int value(int offset);
    00129
    00130 public:
    00131
    00137         SourceInteger(Convert* convert, int type, string filename, bool cache);
    00138
    00139         ~SourceInteger();
    00140
    00143         void resolve(Point* p);
    00144 };
    00145
    00146
    00147
    00149 class SourceGridFloat : public Source {
    00150 protected:
    00152         double* cache;
    00153
    00157         double value(int offset);
    00158
    00159 public:
    00160
    00166         SourceGridFloat(Convert* convert, int type, string filename, bool cache);
    00167
    00177         SourceGridFloat(Convert* convert, int type, string filename, int _ncols, int _nrows, double _left, double _bottom, double _cellsize);
    00178
    00179         ~SourceGridFloat();
    00180
    00183         void resolve(Point* p);
    00184
    00185 };
    00186
    00187
    00188
    00190 class SourceGroup : public Source {
    00191 private:
    00193         vector<Source*> list;
    00194 public:
    00195         ~SourceGroup();
    00196
    00199         void add(Source* s);
    00200
    00203         void resolve(Point* p);
    00204
    00208         bool contains(Point* p);
    00209
    00210 };
    00211
    00212
    00213
    00214
    00215
    00216