root / trunk / libraries / libGDBMS / src / main / java / com / hardcode / gdbms / engine / data / db / DBSpatialDataSourceAdapter.java @ 10627
History | View | Annotate | Download (1.76 KB)
1 |
package com.hardcode.gdbms.engine.data.db; |
---|---|
2 |
|
3 |
import java.awt.geom.Rectangle2D; |
4 |
import java.sql.SQLException; |
5 |
|
6 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
7 |
import com.hardcode.gdbms.engine.data.SpatialDataSource; |
8 |
import com.hardcode.gdbms.engine.data.driver.DriverException; |
9 |
import com.hardcode.gdbms.engine.data.driver.SpatialDBDriver; |
10 |
import com.hardcode.gdbms.engine.spatial.Geometry; |
11 |
|
12 |
/**
|
13 |
*
|
14 |
*/
|
15 |
public class DBSpatialDataSourceAdapter extends DBDataSourceAdapter implements |
16 |
DBDataSource, SpatialDataSource { |
17 |
|
18 |
public void start() throws ReadDriverException { |
19 |
try {
|
20 |
if (sem == 0) { |
21 |
con = getConnection(); |
22 |
SpatialDBTableSourceInfo info = (SpatialDBTableSourceInfo) getSourceInfo(); |
23 |
((SpatialDBDriver) driver).open(con, sql, info.tableName, info.geometryField); |
24 |
} |
25 |
|
26 |
sem++; |
27 |
} catch (SQLException e) { |
28 |
throw new ReadDriverException(getName(),e); |
29 |
} |
30 |
} |
31 |
|
32 |
/**
|
33 |
* @throws DriverException
|
34 |
* @see com.hardcode.gdbms.engine.data.SpatialDataSource#getFullExtent()
|
35 |
*/
|
36 |
public Rectangle2D getFullExtent() throws ReadDriverException { |
37 |
return ((SpatialDBDriver) getDriver()).getFullExtent();
|
38 |
} |
39 |
|
40 |
/**
|
41 |
* @see com.hardcode.gdbms.engine.data.SpatialDataSource#getGeometry(long)
|
42 |
*/
|
43 |
public Geometry getGeometry(long rowIndex) throws ReadDriverException { |
44 |
return ((SpatialDBDriver) getDriver()).getGeometry(rowIndex);
|
45 |
} |
46 |
|
47 |
/**
|
48 |
* @see com.hardcode.gdbms.engine.data.driver.SpatialDriver#getJTSGeometry(long)
|
49 |
*/
|
50 |
public com.vividsolutions.jts.geom.Geometry getJTSGeometry(long rowIndex) throws ReadDriverException { |
51 |
return ((SpatialDBDriver) getDriver()).getJTSGeometry(rowIndex);
|
52 |
} |
53 |
|
54 |
} |