Revision 21857

View differences:

trunk/extensions/extGeoreferencing/src-test/org/gvsig/georeferencing/process/TGeoTransformProcessMapToPixelXTest.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 mapa a coordenadas pixel 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 TGeoTransformProcessMapToPixelXTest 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("TGeoTransformProcessMapToPixelYTest 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
		
96
		// Estimacion de los coeficientes de forma manual, siquiento la teoria del manual de Jose Gonzalez
97
		 
98
		// Matriz para el ejmplo correspondiente a la figura 2.20
99
		double M[][]={
100
					{3,			5135,			8722.25},
101
					{5135,		9053319.5,		14916556.225},
102
					{8722.25,	14916556.225,	25376869.1875}
103
					};
104
		Matrix m_M = new Matrix(M);
105
		double det= m_M.det();
106
		
107
		
108
		double A0[][]={
109
					{2546.0,			5135,			8722.25},
110
					{4573226.75,	9053319.5,		14916556.225},
111
					{7393983.25,	14916556.225,	25376869.1875}
112
		};
113
		Matrix m_A0= new Matrix (A0);
114
		double coef0= m_A0.det()/det;
115
		
116
		
117
		
118
		double A1[][]={
119
				{3,			2546.0,		  8722.25},
120
				{5135,		4573226.75,	  14916556.225},
121
				{8722.25,	7393983.25,	  25376869.1875}
122
		};
123
		Matrix m_A1= new Matrix (A1);
124
		double coef1= m_A1.det()/det;
125
		
126
		double A2[][]={
127
					{3,			5135,			2546.0},
128
					{5135,		9053319.5,		4573226.75},
129
					{8722.25,	14916556.225,	7393983.25}
130
				};
131
			
132
		Matrix m_A2= new Matrix (A2);
133
		double coef2= m_A2.det()/det;
134
		
135
		// Comprobacion de los coeficientes obtenidos tras el proceso con los determinados de forma manual
136
		
137
		assertEquals(coef0, resultado.getMapToPixelCoefX()[0],0.1);
138
		assertEquals(coef1, resultado.getMapToPixelCoefX()[1],0.1);
139
		assertEquals(coef2, resultado.getMapToPixelCoefX()[2],0.1);
140
		
141
	}
142
}
trunk/extensions/extGeoreferencing/src-test/org/gvsig/georeferencing/process/AllGeoTransformTest.java
50 50
		TestSuite suite = new TestSuite("Test GeoTransformProcess");
51 51
		//$JUnit-BEGIN$
52 52
		suite.addTestSuite(TGeoTransformProcessPixelToMapXTest.class);
53
		suite.addTestSuite(TGeoTransformProcessPixelToMapYTest.class);
54
		suite.addTestSuite(TGeoTransformProcessMapToPixelXTest.class);
53 55
		suite.addTestSuite(TGeoTransformProcessMapToPixelYTest.class);
54
		suite.addTestSuite(TGeoTransformProcessPixelToMapYTest.class);
55 56
		suite.addTestSuite(TGeotransformProcessRMS.class);
56 57
		//$JUnit-END$
57 58
		return suite;

Also available in: Unified diff