/* * SpatialReferenceSystemTable.java * * Created on January 24, 2001, 10:31 AM */ package uk.ac.leeds.ccg.sfsql; import java.sql.*; /** * * @author jamesm * @version */ public class SpatialReferenceSystemTable extends java.lang.Object { //SpatialReferenceSystem srs[]; Connection con; /** Creates new SpatialReferenceSystemTable */ public SpatialReferenceSystemTable(Connection c) { con = c; } public SpatialReferenceSystem[] getSystems() throws SQLException { Statement stmt = con.createStatement(); String query = "select srid,auth_name,auth_srid,srtext from SPATIAL_REFERENCE_SYSTEMS"; ResultSet res = stmt.executeQuery(query); int size = res.getFetchSize(); SpatialReferenceSystem[] systems = new SpatialReferenceSystem[size]; int index=0; while(res.next()){ SpatialReferenceSystem srs = new SpatialReferenceSystem(res.getInt("SRID"),res.getString("AUTH_NAME"),res.getInt("AUTH_SRID"),res.getString("SRTEXT")); systems[index]=srs; index++; } return systems; } public SpatialReferenceSystem getSystem(int srid) throws SQLException { Statement stmt = con.createStatement(); String query = "select srid,auth_name,auth_srid,srtext from SPATIAL_REFERENCE_SYSTEMS where srid = "+srid; ResultSet res = stmt.executeQuery(query); if(res.next()){ SpatialReferenceSystem srs = new SpatialReferenceSystem(res.getInt("SRID"),res.getString("AUTH_NAME"),res.getInt("AUTH_SRID"),res.getString("SRTEXT")); return srs; } return null; } }