Statistics
| Revision:

svn-gvsig-desktop / tags / v1_1_Build_1008 / libraries / libGDBMS / src / main / java / com / hardcode / gdbms / engine / data / db / DBSpatialDataSourceAdapter.java @ 12520

History | View | Annotate | Download (1.7 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.engine.data.SpatialDataSource;
7
import com.hardcode.gdbms.engine.data.driver.DriverException;
8
import com.hardcode.gdbms.engine.data.driver.SpatialDBDriver;
9
import com.hardcode.gdbms.engine.spatial.Geometry;
10

    
11
/**
12
 * 
13
 */
14
public class DBSpatialDataSourceAdapter extends DBDataSourceAdapter implements
15
        DBDataSource, SpatialDataSource {
16

    
17
    public void start() throws DriverException {
18
        try {
19
            if (sem == 0) {
20
                con = getConnection();
21
                SpatialDBTableSourceInfo info = (SpatialDBTableSourceInfo) getSourceInfo();
22
                ((SpatialDBDriver) driver).open(con, sql, info.tableName, info.geometryField);
23
            }
24
    
25
            sem++;
26
        } catch (SQLException e) {
27
            throw new DriverException(e);
28
        }
29
    }
30

    
31
    /**
32
     * @throws DriverException
33
     * @see com.hardcode.gdbms.engine.data.SpatialDataSource#getFullExtent()
34
     */
35
    public Rectangle2D getFullExtent() throws DriverException {
36
        return ((SpatialDBDriver) getDriver()).getFullExtent();
37
    }
38

    
39
    /**
40
     * @throws DriverException
41
     * @see com.hardcode.gdbms.engine.data.SpatialDataSource#getGeometry(long)
42
     */
43
    public Geometry getGeometry(long rowIndex) throws DriverException {
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 DriverException {
51
        return ((SpatialDBDriver) getDriver()).getJTSGeometry(rowIndex);
52
    }
53

    
54
}