Skip to content

Commit

Permalink
Add geometryUpdateCounter for import stats
Browse files Browse the repository at this point in the history
  • Loading branch information
praszuk committed Sep 7, 2024
1 parent 32ac5cc commit f95114f
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@ public class BuildingsImportStats {
private int importWithReplaceCounter;

private int importWithTagsUpdateCounter;
private int importWithGeometryUpdateCounter;

private int totalImportActionCounter;

// FIELD_* strings are used to name fields to (de)serialization to JOSM Settings
private static final String FIELD_IMPORT_NEW_BUILDING_COUNTER = "importNewBuilding";
private static final String FIELD_IMPORT_WITH_REPLACE_COUNTER = "importWithReplace";
private static final String FIELD_IMPORT_WITH_TAGS_UPDATE_COUNTER = "importWithTagsUpdate";
private static final String FIELD_IMPORT_WITH_GEOMETRY_UPDATE_COUNTER = "importWithGeometryUpdate";
private static final String FIELD_TOTAL_IMPORT_ACTION = "totalImportAction";

private BuildingsImportStats() {
Expand All @@ -55,6 +57,10 @@ public int getImportWithTagsUpdateCounter() {
return importWithTagsUpdateCounter;
}

public int getImportWithGeometryUpdateCounter() {
return importWithGeometryUpdateCounter;
}

public int getTotalImportActionCounter() {
return totalImportActionCounter;
}
Expand All @@ -73,6 +79,13 @@ public void addImportWithReplaceCounter(int value) {
importWithReplaceCounter += value;
}

public void addImportWithGeometryUpdateCounter(int value) {
if (value < 1) {
throw new IllegalArgumentException("Number must be greater than 0");
}
importWithGeometryUpdateCounter += value;
}

public void addImportWithTagsUpdateCounter(int value) {
if (value < 1) {
throw new IllegalArgumentException("Number must be greater than 0");
Expand All @@ -92,6 +105,7 @@ public HashMap<String, Object> getStats() {
stats.put(FIELD_IMPORT_NEW_BUILDING_COUNTER, importNewBuildingCounter);
stats.put(FIELD_IMPORT_WITH_REPLACE_COUNTER, importWithReplaceCounter);
stats.put(FIELD_IMPORT_WITH_TAGS_UPDATE_COUNTER, importWithTagsUpdateCounter);
stats.put(FIELD_IMPORT_WITH_GEOMETRY_UPDATE_COUNTER, importWithGeometryUpdateCounter);
stats.put(FIELD_TOTAL_IMPORT_ACTION, totalImportActionCounter);

return stats;
Expand All @@ -112,6 +126,7 @@ public void save() {
.add(FIELD_IMPORT_NEW_BUILDING_COUNTER, importNewBuildingCounter)
.add(FIELD_IMPORT_WITH_REPLACE_COUNTER, importWithReplaceCounter)
.add(FIELD_IMPORT_WITH_TAGS_UPDATE_COUNTER, importWithTagsUpdateCounter)
.add(FIELD_IMPORT_WITH_GEOMETRY_UPDATE_COUNTER, importWithGeometryUpdateCounter)
.add(FIELD_TOTAL_IMPORT_ACTION, totalImportActionCounter)
.build();

Expand All @@ -135,6 +150,7 @@ private void load() {
importNewBuildingCounter = jsonStats.getInt(FIELD_IMPORT_NEW_BUILDING_COUNTER, 0);
importWithReplaceCounter = jsonStats.getInt(FIELD_IMPORT_WITH_REPLACE_COUNTER, 0);
importWithTagsUpdateCounter = jsonStats.getInt(FIELD_IMPORT_WITH_TAGS_UPDATE_COUNTER, 0);
importWithGeometryUpdateCounter = jsonStats.getInt(FIELD_IMPORT_WITH_GEOMETRY_UPDATE_COUNTER, 0);
totalImportActionCounter = jsonStats.getInt(FIELD_TOTAL_IMPORT_ACTION, 0);
Logging.debug("Loaded import stats: {0}", toString());
}
Expand Down

0 comments on commit f95114f

Please sign in to comment.