svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libFMap_controls / src-test / org / gvsig / fmap / mapcontrol / tools / AreaListenerTest.java @ 27042
History | View | Annotate | Download (2.17 KB)
1 |
package org.gvsig.fmap.mapcontrol.tools; |
---|---|
2 |
|
3 |
import java.awt.geom.Point2D; |
4 |
|
5 |
import junit.framework.TestCase; |
6 |
|
7 |
import org.cresques.cts.IProjection; |
8 |
import org.gvsig.fmap.crs.CRSFactory; |
9 |
import org.gvsig.fmap.geom.impl.DefaultGeometryLibrary; |
10 |
import org.gvsig.fmap.mapcontext.MapContext; |
11 |
import org.gvsig.fmap.mapcontext.ViewPort; |
12 |
import org.gvsig.fmap.mapcontrol.MapControl; |
13 |
|
14 |
|
15 |
public class AreaListenerTest extends TestCase{ |
16 |
private IProjection projectionUTM = CRSFactory.getCRS("EPSG:23030"); |
17 |
private IProjection projectionGeo = CRSFactory.getCRS("EPSG:4230"); |
18 |
|
19 |
/* (non-Javadoc)
|
20 |
* @see junit.framework.TestCase#setUp()
|
21 |
*/
|
22 |
@Override
|
23 |
protected void setUp() throws Exception { |
24 |
super.setUp();
|
25 |
register(); |
26 |
} |
27 |
|
28 |
/**
|
29 |
* Registers the libraries
|
30 |
*/
|
31 |
protected void register() { |
32 |
//Initializes the geometries library
|
33 |
DefaultGeometryLibrary lib = new DefaultGeometryLibrary();
|
34 |
lib.initialize(); |
35 |
lib.postInitialize(); |
36 |
} |
37 |
|
38 |
|
39 |
public void test1() { |
40 |
AreaListenerImpl areaListenerUTM=new AreaListenerImpl(newMapControlUTM());
|
41 |
AreaListenerImpl areaListenerGeo=new AreaListenerImpl(newMapControlGeo());
|
42 |
Double[] xsUTM=new Double[] {new Double(731292),new Double(731901),new Double(730138)}; |
43 |
Double[] ysUTM=new Double[] {new Double(4351223),new Double(4350768),new Double(4349232)}; |
44 |
double areaUTM=areaListenerUTM.returnCoordsArea(xsUTM,ysUTM,new Point2D.Double(730138,4349232)); |
45 |
Double[] xsGeo=new Double[] {new Double(-0.31888183),new Double(-0.31173131),new Double(-0.33268401)}; |
46 |
Double[] ysGeo=new Double[] {new Double(39.27871741),new Double(39.27464327),new Double(39.26117368)}; |
47 |
double areaGeo=areaListenerGeo.returnGeoCArea(xsGeo,ysGeo,new Point2D.Double(-0.33268401,39.26117368)); |
48 |
assertTrue("Area UTM igual a Geo",areaUTM<(areaGeo+1000)&& areaUTM>(areaGeo-1000)); |
49 |
} |
50 |
private MapControl newMapControlUTM() {
|
51 |
ViewPort vp = new ViewPort(projectionUTM);
|
52 |
MapControl mc=new MapControl();
|
53 |
mc.setMapContext(new MapContext(vp));
|
54 |
return mc;
|
55 |
} |
56 |
private MapControl newMapControlGeo() {
|
57 |
ViewPort vp = new ViewPort(projectionGeo);
|
58 |
MapControl mc=new MapControl();
|
59 |
mc.setMapContext(new MapContext(vp));
|
60 |
return mc;
|
61 |
} |
62 |
} |