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