root / trunk / extensions / extArcims / src / es / prodevelop / cit / gvsig / arcims / fmap / drivers / ArcImsVectorialAdapter.java @ 8110
History | View | Annotate | Download (5.61 KB)
1 |
package es.prodevelop.cit.gvsig.arcims.fmap.drivers; |
---|---|
2 |
|
3 |
import java.awt.geom.Rectangle2D; |
4 |
import java.io.IOException; |
5 |
|
6 |
import org.gvsig.remoteClient.arcims.exceptions.ArcImsException; |
7 |
|
8 |
import com.hardcode.driverManager.DriverLoadException; |
9 |
import com.hardcode.gdbms.engine.data.DataSource; |
10 |
import com.iver.cit.gvsig.fmap.core.IFeature; |
11 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
12 |
import com.iver.cit.gvsig.fmap.core.ShapeFactory; |
13 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
14 |
import com.iver.cit.gvsig.fmap.layers.FBitSet; |
15 |
import com.iver.cit.gvsig.fmap.layers.SelectableDataSource; |
16 |
import com.iver.cit.gvsig.fmap.layers.VectorialAdapter; |
17 |
|
18 |
public class ArcImsVectorialAdapter extends VectorialAdapter { |
19 |
|
20 |
private IFeature[] testArray; |
21 |
|
22 |
public ArcImsVectorialAdapter(FMapFeatureArcImsDriver drv) {
|
23 |
setDriver(drv); |
24 |
} |
25 |
|
26 |
public IGeometry getShape(int index) throws DriverIOException { |
27 |
try {
|
28 |
return getDriver().getShape(index);
|
29 |
} catch (IOException e) { |
30 |
DriverIOException dioe = new DriverIOException(e.getMessage());
|
31 |
throw dioe;
|
32 |
} |
33 |
} |
34 |
|
35 |
public int getShapeCount() throws DriverIOException { |
36 |
try {
|
37 |
return getDriver().getShapeCount();
|
38 |
} catch (IOException e) { |
39 |
DriverIOException dioe = new DriverIOException(e.getMessage());
|
40 |
throw dioe;
|
41 |
} |
42 |
} |
43 |
|
44 |
public Rectangle2D getFullExtent() throws DriverIOException { |
45 |
try {
|
46 |
return getDriver().getFullExtent();
|
47 |
} catch (IOException e) { |
48 |
DriverIOException dioe = new DriverIOException(e.getMessage());
|
49 |
throw dioe;
|
50 |
} |
51 |
} |
52 |
|
53 |
public int getShapeType() throws DriverIOException { |
54 |
return getDriver().getShapeType();
|
55 |
} |
56 |
|
57 |
/**
|
58 |
* This method is used when the data source is a proper database that needs
|
59 |
* initialization.
|
60 |
*/
|
61 |
public void start() throws DriverIOException { |
62 |
try {
|
63 |
((FMapFeatureArcImsDriver) getDriver()).getRecordSet().start(); |
64 |
} catch (com.hardcode.gdbms.engine.data.driver.DriverException e) {
|
65 |
DriverIOException dioe = new DriverIOException(e.getMessage());
|
66 |
throw dioe;
|
67 |
} |
68 |
} |
69 |
|
70 |
/**
|
71 |
* This method is used when the data source is a proper database that needs
|
72 |
* to be closed after use.
|
73 |
*/
|
74 |
public void stop() throws DriverIOException { |
75 |
try {
|
76 |
((FMapFeatureArcImsDriver) driver).getRecordSet().stop(); |
77 |
} catch (com.hardcode.gdbms.engine.data.driver.DriverException e) {
|
78 |
DriverIOException dioe = new DriverIOException(e.getMessage());
|
79 |
throw dioe;
|
80 |
} |
81 |
} |
82 |
|
83 |
public SelectableDataSource getRecordset() throws DriverLoadException { |
84 |
return ((FMapFeatureArcImsDriver) driver).getRecordSet();
|
85 |
} |
86 |
|
87 |
public void requestFeatureAttributes(FBitSet fbs) throws ArcImsException { |
88 |
((FMapFeatureArcImsDriver) driver).requestFeatureAttributes(fbs); |
89 |
} |
90 |
|
91 |
|
92 |
} |
93 |
|
94 |
// public class ArcImsVectorialAdapter implements ReadableVectorial {
|
95 |
//
|
96 |
// private FMapFeatureArcImsDriver driver;
|
97 |
// private IGeometry[] testArray;
|
98 |
// private Random rnd = new Random(System.currentTimeMillis());
|
99 |
// private DataSource dataSource;
|
100 |
//
|
101 |
// public ArcImsVectorialAdapter() {
|
102 |
//
|
103 |
// testArray = new IGeometry[10];
|
104 |
// for (int i=0; i<testArray.length; i++) {
|
105 |
// Rectangle2D.Double r = getRandomRect();
|
106 |
// GeneralPathX gp = new GeneralPathX(r);
|
107 |
// testArray[i] = ShapeFactory.createPolygon2D(gp);
|
108 |
// }
|
109 |
//
|
110 |
// }
|
111 |
//
|
112 |
// private Double getRandomRect() {
|
113 |
// double x = -180.0 * rnd.nextDouble();
|
114 |
// double y = -90.0 * rnd.nextDouble();
|
115 |
// double w = 180.0 * rnd.nextDouble();
|
116 |
// double h = 90.0 * rnd.nextDouble();
|
117 |
// return new Rectangle2D.Double(x, y, w, h);
|
118 |
// }
|
119 |
//
|
120 |
// /**
|
121 |
// * This method is used when the data source is a proper database
|
122 |
// * that needs initialization.
|
123 |
// */
|
124 |
// public void start() throws DriverIOException {
|
125 |
// System.out.println("===> public void start()");
|
126 |
// // TODO Auto-generated method stub
|
127 |
// }
|
128 |
//
|
129 |
// /**
|
130 |
// * This method is used when the data source is a proper database
|
131 |
// * that needs to be closed after use.
|
132 |
// */
|
133 |
// public void stop() throws DriverIOException {
|
134 |
// System.out.println("===> public void stop()");
|
135 |
// // TODO Auto-generated method stub
|
136 |
// }
|
137 |
//
|
138 |
// public IGeometry getShape(int index) throws DriverIOException {
|
139 |
// // TODO Auto-generated method stub
|
140 |
// return testArray[index];
|
141 |
// }
|
142 |
//
|
143 |
// public int getShapeCount() throws DriverIOException {
|
144 |
// // TODO Auto-generated method stub
|
145 |
// return testArray.length;
|
146 |
// }
|
147 |
//
|
148 |
// public Rectangle2D getFullExtent() throws DriverIOException {
|
149 |
// // TODO Auto-generated method stub
|
150 |
// System.out.println("===> public Rectangle2D getFullExtent()");
|
151 |
// return null;
|
152 |
// }
|
153 |
//
|
154 |
// public int getShapeType() throws DriverIOException {
|
155 |
// // TODO Auto-generated method stub
|
156 |
// System.out.println("===> public int getShapeType()");
|
157 |
// return 0;
|
158 |
// }
|
159 |
//
|
160 |
// public FMapFeatureArcImsDriver getDriver() {
|
161 |
// return driver;
|
162 |
// }
|
163 |
//
|
164 |
// public void setDriver(FMapFeatureArcImsDriver driver) {
|
165 |
// this.driver = driver;
|
166 |
// }
|
167 |
//
|
168 |
// public Rectangle2D getTestExtent() {
|
169 |
// return new Rectangle(-180, -90, 360, 180);
|
170 |
// }
|
171 |
//
|
172 |
// public DataSource getRecordset() throws DriverLoadException {
|
173 |
//
|
174 |
// if (dataSource != null) return dataSource;
|
175 |
//
|
176 |
// if (getDriver() instanceof ObjectDriver)
|
177 |
// {
|
178 |
// String name =
|
179 |
// LayerFactory.getDataSourceFactory().addDataSource((ObjectDriver)
|
180 |
// getDriver());
|
181 |
// try {
|
182 |
// dataSource = LayerFactory.getDataSourceFactory().createRandomDataSource(name,
|
183 |
// DataSourceFactory.AUTOMATIC_OPENING);
|
184 |
// return dataSource;
|
185 |
// } catch (NoSuchTableException e) {
|
186 |
// throw new RuntimeException(e);
|
187 |
// } catch (com.hardcode.gdbms.engine.data.driver.DriverException e) {
|
188 |
// throw new RuntimeException(e);
|
189 |
// }
|
190 |
// }
|
191 |
// System.err.println("Unable to get Data source in method public DataSource
|
192 |
// getRecordset().");
|
193 |
// System.err.println("class: ArcImsVectorialAdapter.");
|
194 |
// return null;
|
195 |
// }
|
196 |
//
|
197 |
// public void setRecordSet(DataSource ds) {
|
198 |
// dataSource = ds;
|
199 |
// }
|
200 |
//
|
201 |
// }
|
202 |
|