// rename the schema to have the proper output file name
SimpleFeatureTypeBuilder tb = new SimpleFeatureTypeBuilder();
tb.init(c.getSchema());
tb.setName(fileName);
SimpleFeatureType renamed = tb.buildFeatureType();
c = new RetypingFeatureCollection(c, renamed);
}
SimpleFeatureStore fstore = null;
ShapefileDataStore dstore = null;
try {
// create attribute name mappings, to be compatible
// with shapefile constraints:
// - geometry field is always named the_geom
// - field names have a max length of 10
Map<String,String> attributeMappings=createAttributeMappings(c.getSchema());
// wraps the original collection in a remapping wrapper
SimpleFeatureCollection remapped = new RemappingFeatureCollection(c,attributeMappings);
SimpleFeatureType remappedSchema=(SimpleFeatureType)remapped.getSchema();
dstore = buildStore(tempDir, charset, remappedSchema);
fstore = (SimpleFeatureStore) dstore.getFeatureSource();
// we need retyping too, because the shapefile datastore
// could have sorted fields in a different order
SimpleFeatureCollection retyped = new RetypingFeatureCollection(remapped, fstore.getSchema());
fstore.addFeatures(retyped);
changeWKTFormatIfFileFormatIsESRI(tempDir, request, fileName,
remappedSchema);