Revision 21798

View differences:

trunk/extensions/extGeoreferencing/src-test/org/gvsig/georeferencing/process/TGeoTransformProcessPixelToMapYTest.java
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
import Jama.Matrix;
52

  
53
/**Test que prueba la el proceso de geotransfornmcion dados una serie de puntos de
54
 * control.  Compara los coeficientes obtenidos para el polinomio de transformacion  
55
 * (de coordenadas pixel a coordenadas mapa para las Y), con los obtenidos 
56
 * manualmente, resolviendo por el m?todo de Cramer.
57
 * 
58
 * 
59
 * @author aMu?oz (alejandro.munoz@uclm.es)
60
 * */
61

  
62
public class TGeoTransformProcessPixelToMapYTest extends TestCase {
63

  
64
	private GeoPoint gpcs[] = new GeoPoint[3];
65
	private double geoPoints[][] ={{ 1369.000000  	,	2985.750000	},
66
								   { 1673.500000  	,   2803.250000	},
67
								   { 2092.500000 	,   2933.250000	},
68
							       }; 
69
								   
70
	private double imagePoints[][]={{ 577.500000     ,	2427.500000 },
71
									{ 803.000000     ,  2235.500000 },
72
									{ 1165.500000    ,  2285.250000	},
73
									};
74
	public void start() {
75
		this.testStack();
76
	}
77
	
78
	
79
	public void testStack() {
80
		System.err.println("TGeoTransformProcessTest running...");
81
		
82
		for(int i=0;i<geoPoints.length;i++)
83
		{
84
			Point2D  pW = new Point2D.Double(geoPoints[i][0],geoPoints[i][1]);
85
			Point2D  pP = new Point2D.Double(imagePoints[i][0],imagePoints[i][1]);
86
			gpcs[i]= new GeoPoint(pP,pW);
87
		}
88
		
89
		GeoTransformProcess proceso = new GeoTransformProcess();
90
		proceso.addParam("gpcs",gpcs);
91
		proceso.addParam("orden", new Integer(1));
92
		proceso.run();
93
		
94
		GeoTransformDataResult resultado= (GeoTransformDataResult) proceso.getResult();
95
		resultado.getPixelToMapCoefX();
96
		
97
		// Estimacion de los coeficientes de forma manual, siquiento la teoria del manual de Jose Gonzalez
98
		 
99
		// Matriz para el ejmplo correspondiente a la figura 2.20
100
		double M[][]={
101
					{3,			2546,			6948.25},
102
					{2546,		2336705.5,		5860446.625},
103
					{6948.25,	5860446.625,	16112584.0625}
104
					};
105
		Matrix m_M = new Matrix(M);
106
		double det= m_M.det();
107
		
108
		
109
		double A0[][]={
110
				{8722.25,			2546,			6948.25},
111
				{7393983.25,		2336705.5,		5860446.625},
112
				{20217783.062,		5860446.625,	16112584.0625}
113
		};
114
		Matrix m_A0= new Matrix (A0);
115
		double coef0= m_A0.det()/det;
116
		
117
		
118
		
119
		double A1[][]={
120
				{3,			8722.25,		  6948.25},
121
				{2546,		7393983.25,	  	  5860446.625},
122
				{6948.25,	20217783.062,	  16112584.0625}
123
		};
124
		Matrix m_A1= new Matrix (A1);
125
		double coef1= m_A1.det()/det;
126
		
127
		double A2[][]={
128
				{3,			2546,			8722.25,		  },
129
				{2546,		2336705.5,		7393983.25,	  	  },
130
				{6948.25,	5860446.625,	20217783.062,	  }
131
				};
132
			
133
		Matrix m_A2= new Matrix (A2);
134
		double coef2= m_A2.det()/det;
135
		
136
		// Comprobacion de los coeficientes obtenidos tras el proceso con los determinados de forma manual
137
		
138
		assertEquals(coef0, resultado.getPixelToMapCoefY()[0],0.1);
139
		assertEquals(coef1, resultado.getPixelToMapCoefY()[1],0.1);
140
		assertEquals(coef2, resultado.getPixelToMapCoefY()[2],0.1);
141
		
142
	}
143
}

Also available in: Unified diff