root / trunk / extensions / extGeoreferencing / src-test / org / gvsig / georeferencing / process / TGeoTransformProcessPixelToMapXTest.java @ 21858
History | View | Annotate | Download (4.25 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 |
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 X), 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 TGeoTransformProcessPixelToMapXTest 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("TGeoTransformProcessPixelToMapXTest 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, 2546, 6948.25}, |
101 |
{2546, 2336705.5, 5860446.625}, |
102 |
{6948.25, 5860446.625, 16112584.0625} |
103 |
}; |
104 |
Matrix m_M = new Matrix(M);
|
105 |
double det= m_M.det();
|
106 |
|
107 |
|
108 |
double A0[][]={ |
109 |
{5135, 2546, 6948.25}, |
110 |
{4573226.75, 2336705.5, 5860446.625}, |
111 |
{11846242.375, 5860446.625, 16112584.0625} |
112 |
}; |
113 |
Matrix m_A0= new Matrix (A0);
|
114 |
double coef0= m_A0.det()/det;
|
115 |
|
116 |
|
117 |
|
118 |
double A1[][]={ |
119 |
{3, 5135, 6948.25}, |
120 |
{2546, 4573226.75, 5860446.625}, |
121 |
{6948.25, 11846242.375, 16112584.0625} |
122 |
}; |
123 |
Matrix m_A1= new Matrix (A1);
|
124 |
double coef1= m_A1.det()/det;
|
125 |
|
126 |
double A2[][]={ |
127 |
{3, 2546, 5135}, |
128 |
{2546, 2336705.5, 4573226.75}, |
129 |
{6948.25, 5860446.625, 11846242.375} |
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.getPixelToMapCoefX()[0],0.1); |
138 |
assertEquals(coef1, resultado.getPixelToMapCoefX()[1],0.1); |
139 |
assertEquals(coef2, resultado.getPixelToMapCoefX()[2],0.1); |
140 |
|
141 |
} |
142 |
} |