svn-gvsig-desktop / tags / v1_1_Build_1001 / libraries / libFMap / src / com / iver / cit / gvsig / fmap / spatialindex / SpatialIndexTest.java @ 11984
History | View | Annotate | Download (1.82 KB)
1 | 9109 | azabala | package com.iver.cit.gvsig.fmap.spatialindex; |
---|---|---|---|
2 | |||
3 | import java.awt.geom.Rectangle2D; |
||
4 | import java.io.File; |
||
5 | |||
6 | import com.hardcode.driverManager.DriverLoadException; |
||
7 | import com.hardcode.driverManager.DriverManager; |
||
8 | import com.iver.cit.gvsig.fmap.DriverException; |
||
9 | import com.iver.cit.gvsig.fmap.crs.CRSFactory; |
||
10 | import com.iver.cit.gvsig.fmap.drivers.VectorialFileDriver; |
||
11 | import com.iver.cit.gvsig.fmap.edition.writers.shp.Prueba; |
||
12 | import com.iver.cit.gvsig.fmap.layers.FBitSet; |
||
13 | import com.iver.cit.gvsig.fmap.layers.FLayer; |
||
14 | import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
||
15 | import com.iver.cit.gvsig.fmap.layers.LayerFactory; |
||
16 | |||
17 | import junit.framework.TestCase; |
||
18 | |||
19 | public class SpatialIndexTest extends TestCase { |
||
20 | |||
21 | FLyrVect lyr; |
||
22 | |||
23 | public SpatialIndexTest(String name) { |
||
24 | super(name);
|
||
25 | } |
||
26 | |||
27 | protected void setUp() throws Exception { |
||
28 | super.setUp();
|
||
29 | LayerFactory.setDriversPath("../_fwAndami/gvSIG/extensiones/com.iver.cit.gvsig/drivers");
|
||
30 | lyr = (FLyrVect) LayerFactory.createLayer("Vias",
|
||
31 | (VectorialFileDriver) LayerFactory.getDM().getDriver("gvSIG shp driver"),
|
||
32 | new File("C:/lics.shp"), |
||
33 | CRSFactory.getCRS("EPSG:23030"));
|
||
34 | lyr.createSpatialIndex(); |
||
35 | } |
||
36 | |||
37 | protected void tearDown() throws Exception { |
||
38 | super.tearDown();
|
||
39 | lyr = null;
|
||
40 | } |
||
41 | |||
42 | |||
43 | public void testSpatialIndexFullExtent(){ |
||
44 | try {
|
||
45 | Rectangle2D rect2D = lyr.getFullExtent();
|
||
46 | FBitSet bitset = lyr.queryByRect(rect2D); |
||
47 | assertTrue(bitset.cardinality() != 0);
|
||
48 | |||
49 | double x = rect2D.getCenterX();
|
||
50 | double y = rect2D.getCenterY();
|
||
51 | rect2D = new Rectangle2D.Double( x, y , 100d, 100d); |
||
52 | bitset = lyr.queryByRect(rect2D); |
||
53 | assertTrue(bitset.cardinality() != 0);
|
||
54 | // for(int i = bitset.nextSetBit(0); i >= 0; i = bitset.nextSetBit(i+1))
|
||
55 | // {
|
||
56 | // System.out.println(i);
|
||
57 | // }
|
||
58 | } catch (DriverException e) {
|
||
59 | // TODO Auto-generated catch block
|
||
60 | e.printStackTrace(); |
||
61 | } |
||
62 | |||
63 | } |
||
64 | |||
65 | } |