root / trunk / extensions / extGeoreferencing / src-test / org / gvsig / georeferencing / process / TGeoTransformProcessMapToPixelYTest.java @ 31036
History | View | Annotate | Download (4.35 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 |
import org.gvsig.raster.datastruct.GeoPointList; |
51 |
|
52 |
import Jama.Matrix; |
53 |
|
54 |
/**Test que prueba la el proceso de geotransfornmcion dados una serie de puntos de
|
55 |
* control. Compara los coeficientes obtenidos para el polinomio de transformacion
|
56 |
* (de coordenadas mapa a coordenadas pixel para las Y), con los obtenidos
|
57 |
* manualmente, resolviendo por el m?todo de Cramer.
|
58 |
*
|
59 |
*
|
60 |
* @author aMu?oz (alejandro.munoz@uclm.es)
|
61 |
* */
|
62 |
|
63 |
public class TGeoTransformProcessMapToPixelYTest extends TestCase { |
64 |
|
65 |
private GeoPointList gpl = new GeoPointList(); |
66 |
private double geoPoints[][] ={{ 1369.000000 , 2985.750000 }, |
67 |
{ 1673.500000 , 2803.250000 }, |
68 |
{ 2092.500000 , 2933.250000 }, |
69 |
}; |
70 |
|
71 |
private double imagePoints[][]={{ 577.500000 , 2427.500000 }, |
72 |
{ 803.000000 , 2235.500000 }, |
73 |
{ 1165.500000 , 2285.250000 }, |
74 |
}; |
75 |
public void start() { |
76 |
this.testStack();
|
77 |
} |
78 |
|
79 |
|
80 |
public void testStack() { |
81 |
System.err.println("TGeoTransformProcessMapToPixelYTest running..."); |
82 |
|
83 |
for(int i=0;i<geoPoints.length;i++) |
84 |
{ |
85 |
Point2D pW = new Point2D.Double(geoPoints[i][0],geoPoints[i][1]); |
86 |
Point2D pP = new Point2D.Double(imagePoints[i][0],imagePoints[i][1]); |
87 |
gpl.add(new GeoPoint(pP,pW));
|
88 |
} |
89 |
|
90 |
GeoTransformProcess proceso = new GeoTransformProcess();
|
91 |
proceso.addParam("gpcs", gpl);
|
92 |
proceso.addParam("orden", new Integer(1)); |
93 |
proceso.init(); |
94 |
proceso.process(); |
95 |
|
96 |
GeoTransformDataResult resultado= (GeoTransformDataResult) proceso.getResult(); |
97 |
|
98 |
// Estimacion de los coeficientes de forma manual, siquiento la teoria del manual de Jose Gonzalez
|
99 |
|
100 |
// Matriz para el ejmplo correspondiente a la figura 2.20
|
101 |
double M[][]={ |
102 |
{3, 5135, 8722.25}, |
103 |
{5135, 9053319.5, 14916556.225}, |
104 |
{8722.25, 14916556.225, 25376869.1875} |
105 |
}; |
106 |
Matrix m_M = new Matrix(M);
|
107 |
double det= m_M.det();
|
108 |
|
109 |
|
110 |
double A0[][]={ |
111 |
{6948.25, 5135, 8722.25}, |
112 |
{11846242.375, 9053319.5, 14916556.225}, |
113 |
{20217783.0625, 14916556.225, 25376869.1875} |
114 |
}; |
115 |
Matrix m_A0= new Matrix (A0);
|
116 |
double coef0= m_A0.det()/det;
|
117 |
|
118 |
|
119 |
|
120 |
double A1[][]={ |
121 |
{3, 6948.25, 8722.25}, |
122 |
{5135, 11846242.375, 14916556.225}, |
123 |
{8722.25, 20217783.0625, 25376869.1875} |
124 |
}; |
125 |
Matrix m_A1= new Matrix (A1);
|
126 |
double coef1= m_A1.det()/det;
|
127 |
|
128 |
double A2[][]={ |
129 |
{3, 5135, 6948.25}, |
130 |
{5135, 9053319.5, 11846242.375}, |
131 |
{8722.25, 14916556.225, 20217783.0625} |
132 |
}; |
133 |
|
134 |
Matrix m_A2= new Matrix (A2);
|
135 |
double coef2= m_A2.det()/det;
|
136 |
|
137 |
// Comprobacion de los coeficientes obtenidos tras el proceso con los determinados de forma manual
|
138 |
|
139 |
assertEquals(coef0, resultado.getMapToPixelCoefY()[0],0.1); |
140 |
assertEquals(coef1, resultado.getMapToPixelCoefY()[1],0.1); |
141 |
assertEquals(coef2, resultado.getMapToPixelCoefY()[2],0.1); |
142 |
|
143 |
} |
144 |
} |