FeatureTypeConfig ftConfig;
//JD: GEOS-399, wrap rest of method in try catch block in order to
// report back nicely to app
try {
FeatureType featureType = dataStore.getSchema(featureTypeName);
ftConfig = new FeatureTypeConfig(dataStoreID,
featureType, false);
// DJB: this comment looks old - SRS support is much better now.
// TODO: delete this comment (but wait a bit)
// What is the Spatial Reference System for this FeatureType?
//
// getDefaultGeometry().getCoordinateSystem() should help but is null
// getDefaultGeometry().getGeometryFactory() could help, with getSRID(), but it is null
//
// So we will use 0 which means Cartisian Coordinates aka don't know
//
// Only other thing we could do is ask for a geometry and see what it's
// SRID number is?
//
ftConfig.setSRS(0);
// attempt to get a better SRS
try {
CoordinateReferenceSystem crs = featureType.getDefaultGeometry().getCoordinateSystem();
Set idents = crs.getIdentifiers();
Iterator it = idents.iterator();
while (it.hasNext())
{
Identifier id = (Identifier) it.next();
if (id.toString().indexOf("EPSG:") != -1) // this should probably use the Citation, but this is easier!
{
//we have an EPSG #, so lets use it!
String str_num = id.toString().substring(id.toString().indexOf(':')+1);
int num = Integer.parseInt(str_num);
ftConfig.setSRS(num);
break; // take the first EPSG
}
}
}catch(Exception e)
{
e.printStackTrace(); // not a big deal - we'll default to 0.
}
FeatureSource fs = dataStore.getFeatureSource(featureType.getTypeName());
// TODO translate to lat long, pending
//This should not be done by default, as it is an expensive operation.
//especially for very large tables. User may know it, if not he
//can hit the generate button (which is why it's there).