00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #include "gdal_alg.h"
00034 #include "cpl_conv.h"
00035
00036 typedef enum
00037 {
00038 VIZ_GEOREF_SPLINE_ZERO_POINTS,
00039 VIZ_GEOREF_SPLINE_ONE_POINT,
00040 VIZ_GEOREF_SPLINE_TWO_POINTS,
00041 VIZ_GEOREF_SPLINE_ONE_DIMENSIONAL,
00042 VIZ_GEOREF_SPLINE_FULL,
00043
00044 VIZ_GEOREF_SPLINE_POINT_WAS_ADDED,
00045 VIZ_GEOREF_SPLINE_POINT_WAS_DELETED
00046
00047 } vizGeorefInterType;
00048
00049
00050 #define VIZGEOREF_MAX_VARS 2
00051
00052 class VizGeorefSpline2D
00053 {
00054 public:
00055
00056 VizGeorefSpline2D(int nof_vars = 1){
00057 x = y = u = NULL;
00058 unused = index = NULL;
00059 for( int i = 0; i < nof_vars; i++ )
00060 {
00061 rhs[i] = NULL;
00062 coef[i] = NULL;
00063 }
00064
00065 _tx = _ty = 0.0;
00066 _ta = 10.0;
00067 _nof_points = 0;
00068 _nof_vars = nof_vars;
00069 _max_nof_points = 0;
00070 grow_points();
00071 type = VIZ_GEOREF_SPLINE_ZERO_POINTS;
00072 }
00073
00074 ~VizGeorefSpline2D(){
00075 CPLFree( x );
00076 CPLFree( y );
00077 CPLFree( u );
00078 CPLFree( unused );
00079 CPLFree( index );
00080 for( int i = 0; i < _nof_vars; i++ )
00081 {
00082 CPLFree( rhs[i] );
00083 CPLFree( coef[i] );
00084 }
00085 }
00086
00087 #if 0
00088 int get_nof_points(){
00089 return _nof_points;
00090 }
00091
00092 void set_toler( double tx, double ty ){
00093 _tx = tx;
00094 _ty = ty;
00095 }
00096
00097 void get_toler( double& tx, double& ty) {
00098 tx = _tx;
00099 ty = _ty;
00100 }
00101
00102 vizGeorefInterType get_interpolation_type ( ){
00103 return type;
00104 }
00105
00106 void dump_data_points()
00107 {
00108 for ( int i = 0; i < _nof_points; i++ )
00109 {
00110 fprintf(stderr, "X = %f Y = %f Vars = ", x[i], y[i]);
00111 for ( int v = 0; v < _nof_vars; v++ )
00112 fprintf(stderr, "%f ", rhs[v][i+3]);
00113 fprintf(stderr, "\n");
00114 }
00115 }
00116
00117 int delete_list()
00118 {
00119 _nof_points = 0;
00120 type = VIZ_GEOREF_SPLINE_ZERO_POINTS;
00121 if ( _AA )
00122 {
00123 CPLFree(_AA);
00124 _AA = NULL;
00125 }
00126 if ( _Ainv )
00127 {
00128 CPLFree(_Ainv);
00129 _Ainv = NULL;
00130 }
00131 return _nof_points;
00132 }
00133 #endif
00134
00135 void grow_points();
00136 int add_point( const double Px, const double Py, const double *Pvars );
00137 int get_point( const double Px, const double Py, double *Pvars );
00138 #if 0
00139 int delete_point(const double Px, const double Py );
00140 bool get_xy(int index, double& x, double& y);
00141 bool change_point(int index, double x, double y, double* Pvars);
00142 void reset(void) { _nof_points = 0; }
00143 #endif
00144 int solve(void);
00145
00146 private:
00147
00148 vizGeorefInterType type;
00149
00150 int _nof_vars;
00151 int _nof_points;
00152 int _max_nof_points;
00153 int _nof_eqs;
00154
00155 double _tx, _ty;
00156 double _ta;
00157 double _dx, _dy;
00158
00159 double *x;
00160 double *y;
00161
00162
00163
00164 double *rhs[VIZGEOREF_MAX_VARS];
00165 double *coef[VIZGEOREF_MAX_VARS];
00166
00167 double *u;
00168 int *unused;
00169 int *index;
00170 };