Statistics
| Revision:

svn-gvsig-desktop / trunk / extensions / extGeoreferencing / src-test / org / gvsig / georeferencing / process / TGeotransformProcessRMS.java @ 21827

History | View | Annotate | Download (5.31 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.process;
42

    
43
import java.awt.geom.Point2D;
44

    
45
import junit.framework.TestCase;
46

    
47
import org.gvsig.georeferencing.process.geotransform.GeoTransformDataResult;
48
import org.gvsig.georeferencing.process.geotransform.GeoTransformProcess;
49
import org.gvsig.raster.datastruct.GeoPoint;
50

    
51
/**
52
 * Test que prueba la el proceso de geotransfornmcion dados una serie de puntos de
53
 * control.  Compara las coordenadas aproximadas tras el calculo de los polinomios de transformaci?n.
54
 * El punto en coordenadas mapa que se evalua es (1500,2500). Se comprueban los errores obtenidos tras el proceso 
55
 * con los calculados manualmente.
56
 * 
57
 * @author aMu?oz (alejandro.munoz@uclm.es)
58
 * */
59

    
60
public class TGeotransformProcessRMS extends TestCase {
61

    
62
        private GeoPoint gpcs[] = new GeoPoint[3];
63
        private double geoPoints[][] ={{ 1369.000000          ,        2985.750000        },
64
                                                                   { 1673.500000          ,   2803.250000        },
65
                                                                   { 2092.500000         ,   2933.250000        },
66
                                                               }; 
67
                                                                   
68
        private double imagePoints[][]={{ 577.500000     ,        2427.500000 },
69
                                                                        { 803.000000     ,  2235.500000 },
70
                                                                        { 1165.500000    ,  2285.250000        },
71
                                                                        };
72
        public void start() {
73
                this.testStack();
74
        }
75
        
76
        
77
        public void testStack() {
78
                System.err.println("TGeotransformProcessRMS running...");
79
                
80
                for(int i=0;i<geoPoints.length;i++)
81
                {
82
                        Point2D  pW = new Point2D.Double(geoPoints[i][0],geoPoints[i][1]);
83
                        Point2D  pP = new Point2D.Double(imagePoints[i][0],imagePoints[i][1]);
84
                        gpcs[i]= new GeoPoint(pP,pW);
85
                }
86
                
87
                GeoTransformProcess proceso = new GeoTransformProcess();
88
                proceso.addParam("gpcs",gpcs);
89
                proceso.addParam("orden", new Integer(1));
90
                proceso.run();
91
                
92
                GeoTransformDataResult resultado= (GeoTransformDataResult) proceso.getResult();
93
                double coordPixel[]= resultado.getCoordPixel(1500,2500);
94
                
95
                // Aproximacion manual conocidos los coeficientes
96
                double x_value= -957.700+0.822655*1500+0.1369789*2500;
97
                double y_value= 155.357-0.13683*1500+0.82373*2500;
98
                assertEquals(coordPixel[0],x_value, 0.1);
99
                assertEquals(coordPixel[1],y_value, 0.1);
100
                
101
                
102
                // Se evaluan los RMS de los tres puntos de partida y se comparan con los obtenidos 
103
                // tras la transformaci?m.
104
                double x_1= -957.700+0.822655*1369+0.1369789*2985.75;
105
                double x_2= -957.700+0.822655*1673.5+0.1369789*2803.25;
106
                double x_3= -957.700+0.822655*2092.5+0.1369789*2933.25;
107
                
108
                double y_1= 155.357-0.13683*1369+0.82373*2985.75;
109
                double y_2= 155.357-0.13683*1673.5+0.82373*2803.25;
110
                double y_3= 155.357-0.13683*2092.5+0.82373*2933.25;
111
                
112
                assertEquals(x_1,resultado.getCoordPixel(1369.000000 ,2985.750000)[0],0.1);
113
                assertEquals(y_1,resultado.getCoordPixel(1369.000000 ,2985.750000)[1],0.1);
114
                
115
                assertEquals(x_2,resultado.getCoordPixel(1673.500000, 2803.250000)[0],0.1);
116
                assertEquals(y_2,resultado.getCoordPixel(1673.500000, 2803.250000)[1],0.1);
117
                
118
                assertEquals(x_3,resultado.getCoordPixel(2092.500000 , 2933.250000)[0],0.1);
119
                assertEquals(y_3,resultado.getCoordPixel(2092.500000 , 2933.250000)[1],0.1);
120
                
121
        
122
         // Comparativa del error en x
123
                assertEquals(Math.pow(x_1 - gpcs[0].pixelPoint.getX(), 2),resultado.getGpcs()[0].getErrorX(),0.001);
124
                assertEquals(Math.pow(x_2 - gpcs[1].pixelPoint.getX(), 2),resultado.getGpcs()[1].getErrorX(),0.001);        
125
                assertEquals(Math.pow(x_3 - gpcs[2].pixelPoint.getX(), 2),resultado.getGpcs()[2].getErrorX(),0.001);
126
                
127
//                 Comparativa del error en y
128
                assertEquals(Math.pow(y_1 - gpcs[0].pixelPoint.getY(), 2),resultado.getGpcs()[0].getErrorY(),0.001);
129
                assertEquals(Math.pow(y_2 - gpcs[1].pixelPoint.getY(), 2),resultado.getGpcs()[1].getErrorY(),0.001);        
130
                assertEquals(Math.pow(y_3 - gpcs[2].pixelPoint.getY(), 2),resultado.getGpcs()[2].getErrorY(),0.001);        
131
                                
132
                double rms1=Math.sqrt( Math.pow(x_1 - gpcs[0].pixelPoint.getX(), 2)+ Math.pow(y_1 - gpcs[0].pixelPoint.getY(), 2));
133
                double rms2=Math.sqrt( Math.pow(x_2 - gpcs[1].pixelPoint.getX(), 2)+ Math.pow(y_2 - gpcs[1].pixelPoint.getY(), 2));
134
                double rms3=Math.sqrt( Math.pow(x_3 - gpcs[2].pixelPoint.getX(), 2)+ Math.pow(y_3 - gpcs[2].pixelPoint.getY(), 2));
135
                
136
                assertEquals((rms1+rms2+rms3)/3, resultado.getRmsTotal(),0.01);
137
                
138
                
139
        }
140
}