Statistics
| Revision:

svn-gvsig-desktop / trunk / extensions / extGeoreferencing / src-test / TestGeoOperation.java @ 4899

History | View | Annotate | Download (2.14 KB)

1
import com.iver.cit.gvsig.GeoOperations;
2
import com.iver.cit.gvsig.utils.AffineT;
3
import com.iver.cit.gvsig.utils.PointT;
4

    
5
public class TestGeoOperation {
6
        
7
        private static final int MAXPOINTS = 3;
8
        
9
        public TestGeoOperation(GeoOperations go, double x, double y, int o){
10
                PointT[] srcPoints = new PointT[TestGeoOperation.MAXPOINTS];
11
                PointT[] dstPoints = new PointT[TestGeoOperation.MAXPOINTS];
12
                PointT corner = new PointT();
13
                int numsrcpoints = 3;
14
                int order = 0;
15
                AffineT affine = new AffineT();
16

    
17
                if(numsrcpoints >= 3*10)
18
                        order = 3;
19
                else if(numsrcpoints >= 3*6)
20
                        order = 2;
21
                else
22
                        order = 1;
23

    
24
                srcPoints[0] = new PointT();
25
                srcPoints[0].setX(3108); 
26
                srcPoints[0].setY(3523);
27
                srcPoints[0].setI(numsrcpoints);  
28

    
29
                srcPoints[1] = new PointT();
30
                srcPoints[1].setX(1651); 
31
                srcPoints[1].setY(1463);
32
                srcPoints[1].setI(numsrcpoints);  
33

    
34
                srcPoints[2] = new PointT();
35
                srcPoints[2].setX(5578); 
36
                srcPoints[2].setY(300);
37
                srcPoints[2].setI(numsrcpoints);  
38

    
39
                dstPoints[0] = new PointT();
40
                dstPoints[0].setX(433700.9072); 
41
                dstPoints[0].setY(4582611.7542);
42
                dstPoints[0].setI(numsrcpoints);  
43

    
44
                dstPoints[1] = new PointT();
45
                dstPoints[1].setX(432975.8313); 
46
                dstPoints[1].setY(4581581.5722);
47
                dstPoints[1].setI(numsrcpoints);  
48

    
49
                dstPoints[2] = new PointT();
50
                dstPoints[2].setX(434939.2793); 
51
                dstPoints[2].setY(4581000.0758);
52
                dstPoints[2].setI(numsrcpoints); 
53

    
54
                //Calcular la transformaci?n afin por m?nimos cuadrados
55
                affine = go.computeLeastSquaresAffine(affine, srcPoints, dstPoints, order);
56
                
57
                corner.setX(x);
58
                corner.setY(y);
59
                order = o;
60

    
61
                //Transformaci?no de un punto
62
                double[] point = go.transformPoint((int)corner.getX(), (int)corner.getY(), affine);
63

    
64
                System.out.println("Order: "+order);
65
                System.out.println("Pixel Point: ("+corner.getX()+", "+corner.getY()+")");
66
                System.out.println("Map Point: ("+point[0]+", "+point[1]+")");
67
        }
68
        /**
69
         * @param args
70
         */
71
        public static void main(String[] args) {
72
                GeoOperations go = new GeoOperations();
73
                double x = Double.parseDouble(args[0]);
74
                double y = Double.parseDouble(args[1]);
75
                int order = Integer.parseInt(args[2]);
76
                TestGeoOperation f = new TestGeoOperation(go, x, y, order);
77
        }
78

    
79
}