use of org.geotoolkit.data.shapefile.lock.AccessManager in project geotoolkit by Geomatys.
the class IndexedFidWriter method generate.
/**
* Generates the FID index file for the shpFiles
*/
public static void generate(final ShpFiles shpFiles) throws IOException {
LOGGER.log(Level.FINE, "Generating fids for {0}", shpFiles.get(SHP));
final AccessManager locker = shpFiles.createLocker();
ShxReader indexFile = null;
StorageFile file = locker.getStorageFile(FIX);
try {
indexFile = locker.getSHXReader(false);
// writer closes channel for you.
final IndexedFidWriter writer = locker.getFIXWriter(file);
for (int i = 0, j = indexFile.getRecordCount(); i < j; i++) {
writer.next();
}
} finally {
try {
locker.disposeReaderAndWriters();
locker.replaceStorageFiles();
} finally {
if (indexFile != null) {
indexFile.close();
}
}
}
}
Aggregations