svn-gvsig-desktop / tags / v1_0_2_Build_906 / extensions / extGeoreferencing / src-test / TestGeoOperation.java @ 10972
History | View | Annotate | Download (2.16 KB)
1 | 5217 | nacho | import org.gvsig.georeferencing.GeoOperations; |
---|---|---|---|
2 | import org.gvsig.georeferencing.utils.AffineT; |
||
3 | import org.gvsig.georeferencing.utils.PointT; |
||
4 | 4830 | nacho | |
5 | 5217 | nacho | |
6 | 4830 | nacho | public class TestGeoOperation { |
7 | |||
8 | private static final int MAXPOINTS = 3; |
||
9 | |||
10 | public TestGeoOperation(GeoOperations go, double x, double y, int o){ |
||
11 | PointT[] srcPoints = new PointT[TestGeoOperation.MAXPOINTS]; |
||
12 | PointT[] dstPoints = new PointT[TestGeoOperation.MAXPOINTS]; |
||
13 | PointT corner = new PointT();
|
||
14 | int numsrcpoints = 3; |
||
15 | int order = 0; |
||
16 | AffineT affine = new AffineT();
|
||
17 | |||
18 | if(numsrcpoints >= 3*10) |
||
19 | order = 3;
|
||
20 | else if(numsrcpoints >= 3*6) |
||
21 | order = 2;
|
||
22 | else
|
||
23 | order = 1;
|
||
24 | |||
25 | srcPoints[0] = new PointT(); |
||
26 | srcPoints[0].setX(3108); |
||
27 | srcPoints[0].setY(3523); |
||
28 | srcPoints[0].setI(numsrcpoints);
|
||
29 | |||
30 | srcPoints[1] = new PointT(); |
||
31 | srcPoints[1].setX(1651); |
||
32 | srcPoints[1].setY(1463); |
||
33 | srcPoints[1].setI(numsrcpoints);
|
||
34 | |||
35 | srcPoints[2] = new PointT(); |
||
36 | srcPoints[2].setX(5578); |
||
37 | srcPoints[2].setY(300); |
||
38 | srcPoints[2].setI(numsrcpoints);
|
||
39 | |||
40 | dstPoints[0] = new PointT(); |
||
41 | dstPoints[0].setX(433700.9072); |
||
42 | dstPoints[0].setY(4582611.7542); |
||
43 | dstPoints[0].setI(numsrcpoints);
|
||
44 | |||
45 | dstPoints[1] = new PointT(); |
||
46 | dstPoints[1].setX(432975.8313); |
||
47 | dstPoints[1].setY(4581581.5722); |
||
48 | dstPoints[1].setI(numsrcpoints);
|
||
49 | |||
50 | dstPoints[2] = new PointT(); |
||
51 | dstPoints[2].setX(434939.2793); |
||
52 | dstPoints[2].setY(4581000.0758); |
||
53 | dstPoints[2].setI(numsrcpoints);
|
||
54 | |||
55 | //Calcular la transformaci?n afin por m?nimos cuadrados
|
||
56 | affine = go.computeLeastSquaresAffine(affine, srcPoints, dstPoints, order); |
||
57 | |||
58 | corner.setX(x); |
||
59 | corner.setY(y); |
||
60 | order = o; |
||
61 | |||
62 | //Transformaci?no de un punto
|
||
63 | double[] point = go.transformPoint((int)corner.getX(), (int)corner.getY(), affine); |
||
64 | |||
65 | System.out.println("Order: "+order); |
||
66 | System.out.println("Pixel Point: ("+corner.getX()+", "+corner.getY()+")"); |
||
67 | System.out.println("Map Point: ("+point[0]+", "+point[1]+")"); |
||
68 | } |
||
69 | /**
|
||
70 | * @param args
|
||
71 | */
|
||
72 | public static void main(String[] args) { |
||
73 | GeoOperations go = new GeoOperations();
|
||
74 | double x = Double.parseDouble(args[0]); |
||
75 | double y = Double.parseDouble(args[1]); |
||
76 | int order = Integer.parseInt(args[2]); |
||
77 | TestGeoOperation f = new TestGeoOperation(go, x, y, order);
|
||
78 | } |
||
79 | |||
80 | } |