Integer geometryType = SpatialDatabaseService.convertJtsClassToGeometryType(geometryClass);
// TODO ask charset to user?
DbaseFileReader dbfReader = new DbaseFileReader(shpFiles, shpMemoryMapped, charset);
try {
DbaseFileHeader dbaseFileHeader = dbfReader.getHeader();
String[] fieldsName = new String[dbaseFileHeader.getNumFields()+1];
fieldsName[0] = "ID";
for (int i = 1; i < fieldsName.length; i++) {
fieldsName[i] = dbaseFileHeader.getFieldName(i-1);
}
Transaction tx = database.beginTx();
try {
if (crs != null) {
layer.setCoordinateReferenceSystem(crs);
}
if (geometryType != null) {
layer.setGeometryType(geometryType);
}
layer.mergeExtraPropertyNames(fieldsName);
tx.success();
} finally {
tx.close();
}
monitor.begin(dbaseFileHeader.getNumRecords());
try {
Record record;
Geometry geometry;
Object[] values;
ArrayList<Object> fields = new ArrayList<Object>();