Statistics
| Revision:

svn-gvsig-desktop / trunk / extensions / extGeoreferencing / src-test / org / gvsig / georeferencing / TestGeoTransformProcess.java @ 19139

History | View | Annotate | Download (6.44 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
         *
3
         * Copyright (C) 2006 Instituto de Desarrollo Regional and Generalitat Valenciana.
4
         *
5
         * This program is free software; you can redistribute it and/or
6
         * modify it under the terms of the GNU General Public License
7
         * as published by the Free Software Foundation; either version 2
8
         * of the License, or (at your option) any later version.
9
         *
10
         * This program is distributed in the hope that it will be useful,
11
         * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
         * GNU General Public License for more details.
14
         *
15
         * You should have received a copy of the GNU General Public License
16
         * along with this program; if not, write to the Free Software
17
         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
         *
19
         * For more information, contact:
20
         *
21
         *  Generalitat Valenciana
22
         *   Conselleria d'Infraestructures i Transport
23
         *   Av. Blasco Iba?ez, 50
24
         *   46010 VALENCIA
25
         *   SPAIN
26
         *
27
         *      +34 963862235
28
         *   gvsig@gva.es
29
         *      www.gvsig.gva.es
30
         *
31
         *    or
32
         *
33
         *   Instituto de Desarrollo Regional (Universidad de Castilla La-Mancha)
34
         *   Campus Universitario s/n
35
         *   02071 Alabacete
36
         *   Spain
37
         *
38
         *   +34 967 599 200
39
         */
40

    
41
package org.gvsig.georeferencing;
42

    
43
import java.awt.geom.Point2D;
44

    
45
import org.gvsig.georeferencing.process.geotransform.GeoTransformDataResult;
46
import org.gvsig.georeferencing.process.geotransform.GeoTransformProcess;
47
import org.gvsig.raster.datastruct.GeoPoint;
48

    
49
import Jama.Matrix;
50

    
51
import junit.framework.TestCase;
52

    
53
/**
54
 *  Test para el proceso de transformacion.
55
 *  
56
 *  El test prueba transformaciones de orden uno, dos  y tres, calculadas a partir de una lista 
57
 *  de diez puntos.Los resultados de la transformacion para el caso de orden uno se comparan con 
58
 *  resultados precalculados en ENVI.Para el caso de las transformaciones de orden dos y tres se 
59
 *  comparan con los resultados efectuados de forma manual.
60
 *   
61
 *  @author Alejandro Mu?oz Sanchez
62
 * 
63
 * */
64

    
65
public class TestGeoTransformProcess  extends TestCase{
66

    
67
        private GeoPoint gpcs[] = new GeoPoint[10];
68
        private GeoTransformDataResult transformData;
69
        
70
        private double geoPoints[][] ={        { 1369.000000          ,        2985.750000        },
71
                                                                        { 1673.500000          ,   2803.250000        },
72
                                                                        { 2092.500000         ,   2933.250000        },
73
                                                                        { 2354.000000          ,   3211.000000        },
74
                                                                        { 2731.500000    ,  3193.500000        },
75
                                                                        { 3054.500000    ,  3079.500000        },
76
                                                                        { 3009.250000    ,         3380.500000        },
77
                                                                        { 3057.250000    ,  3552.750000        },
78
                                                                        { 2944.750000    ,  3584.750000        },
79
                                                                        { 2892.500000    ,  3444.000000        },}; 
80

    
81
                                                                   
82
        private double imagePoints[][]={{ 577.500000     ,        2427.500000 },
83
                                                                        { 803.000000     ,  2235.500000 },
84
                                                                        { 1165.500000    ,  2285.250000        },
85
                                                                        { 1419.250000    ,  2478.750000 },
86
                                                                        { 1727.000000    ,  2412.250000 },
87
                                                                        { 1977.500000    ,  2274.250000        },
88
                                                                        { 1981.500000    ,  2528.250000        },
89
                                                                        { 2044.000000    ,  2663.750000 },
90
                                                                        { 1955.750000    ,  2705.500000 }, 
91
                                                                        { 1893.500000    ,         2596.250000},};
92
        
93
        public void start() {
94
                this.setUp();
95
                this.testStack();
96
        }
97
        
98
        
99
        public void setUp(){
100
        }
101
        
102
        public void testStack(){
103
                for(int i=0;i<geoPoints.length;i++)
104
                        {
105
                                Point2D  pW = new Point2D.Double(geoPoints[i][0],geoPoints[i][1]);
106
                                Point2D  pP = new Point2D.Double(imagePoints[i][0],imagePoints[i][1]);
107
                                gpcs[i]= new GeoPoint(pP,pW);
108
                        }
109
        
110
                GeoTransformProcess order2Transform = new GeoTransformProcess();
111
                order2Transform.addParam("gpcs",gpcs );
112
                order2Transform.addParam("orden",new Integer(2));
113
                order2Transform.run();        
114
                transformData= (GeoTransformDataResult)order2Transform.getResult();
115

    
116
                
117
//                 Resolucion del sistema  calculado manualmente
118
                double data[][]={
119
                                {10,                        15544.5,                        24607.25,                 26758589.88,                        38703411.06        ,                        60795805.19                  },                
120
                                {15544.5,                26758589.88,                38703411.06,         48625448159.44,                67148886519.52,                        96748134874.2         },
121
                                {24607.25,                38703411.06,                6.07958051875E7, 67148886519.52,                96748134874.2,                        150805605253.3        },
122
                                {26758589.88,        48625448159.44,                67148886519.52,         90973349316414.1,                1.22623111101991E014,        1.69145826718794E014},
123
                                {38703411.06,        67148886519.52,                96748134874.2,         1.22623111101991E014,        1.69145826718794E014,        2.42781993510560E014},
124
                                {60795805.19,        96748134874.2,                 150805605253.3,         1.69145826718794E014,        2.42781993510560E014,        3.7555377732236494E14}        
125
                };
126
                double[][] result={{25178.75},{42119706.94}, {62445537.63}, {75433589688.61}, {105416642600.75}, {155494570974.03} };
127
                double[][] result2={{32168.25},{5.10484513125E07}, {7.9534535625E07}, {8.899835767423438E10}, {1.276577668393125E11}, {1.9743243258296875E11} };
128
                
129
                
130
//                 Resolucion del sistema  calculado manualmente
131
                double data2[][]={
132
                                {10,                                25178.75,                                32168.25,                                  6.68261699375E7,                        8.2157005375E7        ,                        1.041305340625E8 },                
133
                                {25178.75,                        6.68261699375E7,                8.2157005375E7,                          1.8389906361945312E11,                2.2036071049725E11,                        2.69580937964375E11 },
134
                                {32168.25,                        8.2157005375E7,                        1.041305340625E8,                  2.2036071049725E11,                2.69580937964375E11,                3.391527268821094E11},
135
                                {6.68261699375E7,        1.8389906361945312E11,        2.2036071049725E11,                  5.185110007030175E14,                6.109291412182252E14,                7.302233191555645E14},
136
                                {8.2157005375E7,        2.2036071049725E11,                2.69580937964375E11,         6.109291412182252E14,                7.302233191555645E14,                8.893696706241302E14},
137
                                {1.041305340625E8,        2.69580937964375E11,         3.391527268821094E11,         7.302233191555645E14,                8.893696706241302E14,                1.1112299175456508E15}        
138
                };
139
                
140
                double[][] result3={{24607.25},{6.2445537625E7}, {7.9534535625E7}, {1.6674342953621875E11}, {2.0468178349823438E11}, {2.5867104246403125E11} };
141
                double[][] result4={{15544.5},{4.21197069375E7}, {5.10484513125E7}, {1.1748417342507812E11}, {1.3954105605085938E11}, {1.6852035242098438E11} };
142
                
143
                
144
                Matrix matrix= new Matrix(data);
145
                Matrix matrix2= new Matrix(data2);
146
                
147
                Matrix coef=matrix.solve(new Matrix(result)); 
148
                Matrix coef2= matrix.solve(new Matrix(result2));
149
                Matrix coef3= matrix2.solve(new Matrix(result3));
150
                Matrix coef4= matrix2.solve(new Matrix(result4));
151
                
152
        
153
                for(int i=0; i<transformData.getPixelToMapCoefX().length; i++){
154
                        assertEquals(coef.get(i,0),transformData.getPixelToMapCoefX()[i],0.2);
155
                        assertEquals(coef2.get(i,0),transformData.getPixelToMapCoefY()[i],0.2);
156
                        assertEquals(coef3.get(i,0),transformData.getMapToPixelCoefY()[i],0.2);
157
                        assertEquals(coef4.get(i,0),transformData.getMapToPixelCoefX()[i],0.2);
158
                }
159
                
160
                
161
        }        
162
}