Skip to content

Commit

Permalink
removes code meant for a different branch
Browse files Browse the repository at this point in the history
  • Loading branch information
misaugstad committed Jan 22, 2024
1 parent b3c059d commit e9fd7e7
Showing 1 changed file with 18 additions and 21 deletions.
39 changes: 18 additions & 21 deletions app/controllers/helper/ShapefilesCreatorHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,28 +66,25 @@ public static void createGeneralShapeFile(String outputFile, SimpleFeatureType T
*
* Each data store has different limitations so check the resulting SimpleFeatureType.
*/
// // Implementing Batch processing to send features in batchsize of 20k
final int batchSize = 20000;
if (featureSource instanceof SimpleFeatureStore) {
SimpleFeatureStore featureStore = (SimpleFeatureStore) featureSource;
try {

for (int i = 0; i < features.size(); i += batchSize) {
int endIdx = Math.min(i + batchSize, features.size());
List<SimpleFeature> batchFeatures = features.subList(i, endIdx);

SimpleFeatureCollection collection = new ListFeatureCollection(TYPE, batchFeatures);
featureStore.setTransaction(transaction);
featureStore.addFeatures(collection);
}
transaction.commit();
} catch (Exception problem) {
problem.printStackTrace();
transaction.rollback();
} finally {
transaction.close();
}
if (featureSource instanceof SimpleFeatureStore) {
SimpleFeatureStore featureStore = (SimpleFeatureStore) featureSource;
/*
* SimpleFeatureStore has a method to add features from a
* SimpleFeatureCollection object, so we use the ListFeatureCollection
* class to wrap our list of features.
*/
SimpleFeatureCollection collection = new ListFeatureCollection(TYPE, features);
featureStore.setTransaction(transaction);
try {
featureStore.addFeatures(collection);
transaction.commit();
} catch (Exception problem) {
problem.printStackTrace();
transaction.rollback();
} finally {
transaction.close();
}
}
}

public static void createAttributeShapeFile(String outputFile, List<GlobalAttributeForAPI> attributes) throws Exception {
Expand Down

0 comments on commit e9fd7e7

Please sign in to comment.