Revision 32205 trunk/extensions/extPublish/src/org/gvsig/publish/infoproject/gvsig19/PostGISTableInfo.java
PostGISTableInfo.java | ||
---|---|---|
53 | 53 |
import org.gvsig.publish.infoproject.datasources.IDataBaseInfo; |
54 | 54 |
|
55 | 55 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
56 |
import com.iver.cit.gvsig.fmap.core.FShape; |
|
56 | 57 |
import com.iver.cit.gvsig.fmap.crs.CRSFactory; |
57 | 58 |
import com.iver.cit.gvsig.fmap.drivers.ConnectionJDBC; |
58 | 59 |
import com.iver.cit.gvsig.fmap.drivers.DBLayerDefinition; |
... | ... | |
174 | 175 |
* TODO: MAybe already exists this implementation, but I couldn't find it |
175 | 176 |
*/ |
176 | 177 |
public String getEPSG() { |
177 |
try { |
|
178 |
String sql = "SELECT srid FROM geometry_columns WHERE f_table_name = '" + getTableName() + "' AND f_geometry_column = '" + getGeometryColumn() + "'"; |
|
179 |
Statement st = connection.getConnection().createStatement(); |
|
180 |
ResultSet rs = st.executeQuery(sql); |
|
181 |
if (rs.first()){ |
|
182 |
int aux = rs.getInt("srid"); |
|
183 |
return "EPSG:" + aux; |
|
184 |
} |
|
185 |
} catch (SQLException e) { |
|
186 |
PublishLogger.getLog().error("ERROR PostGISTableInfo : SQL exception getting the EPSG",e); |
|
178 |
return this.adapter.getProjection().getAbrev(); |
|
187 | 179 |
} |
188 |
return null; |
|
189 |
//TODO: I can't get the datasource CRS !! |
|
190 |
//return this.driver.getDestProjection(); |
|
191 |
//return "EPSG:23030"; |
|
192 |
} |
|
193 | 180 |
/* |
194 | 181 |
* (non-Javadoc) |
195 | 182 |
* @see org.gvsig.publish.infoProject.IDataSourceInfo#getDataType() |
196 |
* TODO: MAybe already exists this implementation, but I couldn't find it
|
|
183 |
* TODO: Deal with the exception
|
|
197 | 184 |
*/ |
198 | 185 |
public String getGeomType() { |
199 |
String geomtype = null;
|
|
186 |
int type;
|
|
200 | 187 |
try { |
201 |
String sql = "SELECT type FROM geometry_columns WHERE f_table_name = '" + getTableName() + "' AND f_geometry_column = '" + getGeometryColumn() + "'"; |
|
202 |
Statement st = connection.getConnection().createStatement(); |
|
203 |
ResultSet rs = st.executeQuery(sql); |
|
204 |
if (rs.first()){ |
|
205 |
geomtype = rs.getString("type"); |
|
206 |
} |
|
207 |
} catch (SQLException e) { |
|
208 |
PublishLogger.getLog().error("ERROR PostGISTableInfo : SQL exception getting the geometry type",e); |
|
188 |
type = this.adapter.getShapeType(); |
|
189 |
} catch (ReadDriverException e) { |
|
190 |
// TODO Auto-generated catch block |
|
191 |
e.printStackTrace(); |
|
192 |
return null; |
|
209 | 193 |
} |
210 |
|
|
211 |
if (geomtype.equals("POINT") || geomtype.equals("MULTIPOINT")){
|
|
194 |
|
|
195 |
if (type == FShape.POINT || type == FShape.MULTIPOINT){
|
|
212 | 196 |
return IDataSourceInfo.POINT; |
213 | 197 |
} |
214 |
if (geomtype.equals("LINESTRING") || geomtype.equals("MULTILINESTRING")){
|
|
198 |
if (type == FShape.LINE){
|
|
215 | 199 |
return IDataSourceInfo.LINE; |
216 | 200 |
} |
217 |
if (geomtype.equals("POLYGON") || geomtype.equals("MULTIPOLYGON")){
|
|
201 |
if (type == FShape.POLYGON){
|
|
218 | 202 |
return IDataSourceInfo.POLYGON; |
219 | 203 |
} |
220 | 204 |
return null; |
Also available in: Unified diff