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
00034
00035
00036
00037
00038
00039 #include "gdal_alg.h"
00040
00041 typedef enum
00042 {
00043 VIZ_GEOREF_SPLINE_ZERO_POINTS,
00044 VIZ_GEOREF_SPLINE_ONE_POINT,
00045 VIZ_GEOREF_SPLINE_TWO_POINTS,
00046 VIZ_GEOREF_SPLINE_ONE_DIMENSIONAL,
00047 VIZ_GEOREF_SPLINE_FULL,
00048
00049 VIZ_GEOREF_SPLINE_POINT_WAS_ADDED,
00050 VIZ_GEOREF_SPLINE_POINT_WAS_DELETED
00051
00052 } vizGeorefInterType;
00053
00054 #define VIZ_GEOREF_SPLINE_MAX_POINTS 40
00055 #define VIZGEOREF_MAX_VARS 2
00056
00057 class VizGeorefSpline2D
00058 {
00059 public:
00060
00061 VizGeorefSpline2D(int nof_vars = 1){
00062 _tx = _ty = 0.0;
00063 _ta = 10.0;
00064 _nof_points = 0;
00065 _nof_vars = nof_vars;
00066 _AA = NULL;
00067 _Ainv = NULL;
00068 for ( int v = 0; v < _nof_vars; v++ )
00069 for ( int i = 0; i < 3; i++ )
00070 rhs[i][v] = 0.0;
00071 type = VIZ_GEOREF_SPLINE_ZERO_POINTS;
00072 }
00073
00074 ~VizGeorefSpline2D(){
00075 if ( _AA )
00076 delete _AA;
00077 if ( _Ainv )
00078 delete _Ainv;
00079 }
00080
00081 int get_nof_points(){
00082 return _nof_points;
00083 }
00084
00085 void set_toler( float tx, float ty ){
00086 _tx = tx;
00087 _ty = ty;
00088 }
00089
00090 void get_toler( float& tx, float& ty) {
00091 tx = _tx;
00092 ty = _ty;
00093 }
00094
00095 vizGeorefInterType get_interpolation_type ( ){
00096 return type;
00097 }
00098
00099 void dump_data_points()
00100 {
00101 for ( int i = 0; i < _nof_points; i++ )
00102 {
00103 fprintf(stderr, "X = %f Y = %f Vars = ", x[i], y[i]);
00104 for ( int v = 0; v < _nof_vars; v++ )
00105 fprintf(stderr, "%f ", rhs[i+3][v]);
00106 fprintf(stderr, "\n");
00107 }
00108 }
00109 int delete_list()
00110 {
00111 _nof_points = 0;
00112 type = VIZ_GEOREF_SPLINE_ZERO_POINTS;
00113 if ( _AA )
00114 {
00115 delete _AA;
00116 _AA = NULL;
00117 }
00118 if ( _Ainv )
00119 {
00120 delete _Ainv;
00121 _Ainv = NULL;
00122 }
00123 return _nof_points;
00124 }
00125
00126 int add_point( const float Px, const float Py, const float *Pvars );
00127 int delete_point(const float Px, const float Py );
00128 int get_point( const float Px, const float Py, float *Pvars );
00129 bool get_xy(int index, float& x, float& y);
00130 bool change_point(int index, float x, float y, float* Pvars);
00131 void reset(void) { _nof_points = 0; }
00132 int solve(void);
00133
00134 private:
00135 float base_func( const float x1, const float y1,
00136 const float x2, const float y2 );
00137
00138 vizGeorefInterType type;
00139
00140 int _nof_vars;
00141 int _nof_points;
00142 int _nof_eqs;
00143
00144 float _tx, _ty;
00145 float _ta;
00146 float _dx, _dy;
00147
00148 float x[VIZ_GEOREF_SPLINE_MAX_POINTS+3];
00149 float y[VIZ_GEOREF_SPLINE_MAX_POINTS+3];
00150
00151 float rhs[VIZ_GEOREF_SPLINE_MAX_POINTS+3][VIZGEOREF_MAX_VARS];
00152 float coef[VIZ_GEOREF_SPLINE_MAX_POINTS+3][VIZGEOREF_MAX_VARS];
00153
00154 float u[VIZ_GEOREF_SPLINE_MAX_POINTS];
00155 int unused[VIZ_GEOREF_SPLINE_MAX_POINTS];
00156 int index[VIZ_GEOREF_SPLINE_MAX_POINTS];
00157
00158 float *_AA, *_Ainv;
00159 };
00160
00161