Skip to content

Commit

Permalink
Updated to allow evac zone ID header column to be configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
dhixsingh committed May 19, 2021
1 parent 45cc7b4 commit 2c6725c
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions ees/src/main/java/io/github/agentsoz/ees/MessagingModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@ public class MessagingModel implements DataSource<SortedMap<Double, EmergencyMes

private static final String eJsonFile = "fileJson";
private static final String eZonesFile = "fileZonesGeoJson";
private static final String eZonesFileIdColumnName = "zoneIdColumnName";

private String optJsonFile = null;
private String optGeoJsonZonesFile = null;
private String optZonesFile = null;
private String optZonesFileIdColumnName = null;

private double startTimeInSeconds = -1;
private DataServer dataServer = null;
Expand Down Expand Up @@ -82,7 +84,10 @@ private void parse(Map<String, String> opts) {
optJsonFile = opts.get(opt);
break;
case eZonesFile:
optGeoJsonZonesFile = opts.get(opt);
optZonesFile = opts.get(opt);
break;
case eZonesFileIdColumnName:
optZonesFileIdColumnName = opts.get(opt);
break;
case Config.eGlobalStartHhMm:
String[] tokens = opts.get(opt).split(":");
Expand Down Expand Up @@ -163,6 +168,9 @@ private void loadGeoJsonZones(String file) throws IOException, ParseException, j
String zoneId = (properties.get("SA1_MAIN11") != null) ?
(String) properties.get("SA1_MAIN11") :
(String) properties.get("SA1_MAIN16");
if (optZonesFileIdColumnName != null) {
zoneId = (String) properties.get(optZonesFileIdColumnName);
}
if (zoneId == null) {
logger.warn("Feature has no property named SA1_MAIN11 or SA1_MAIN16; discarding");
continue;
Expand Down Expand Up @@ -215,9 +223,9 @@ public void start(int[] hhmm) {
}

public void start() {
if (optGeoJsonZonesFile !=null && !optGeoJsonZonesFile.isEmpty() && optJsonFile != null && !optJsonFile.isEmpty()) {
if (optZonesFile !=null && !optZonesFile.isEmpty() && optJsonFile != null && !optJsonFile.isEmpty()) {
try {
loadJsonMessagesForZones(optJsonFile, optGeoJsonZonesFile);
loadJsonMessagesForZones(optJsonFile, optZonesFile);
dataServer.registerTimedUpdate(Constants.EMERGENCY_MESSAGE, this, Time.convertTime(startTimeInSeconds, Time.TimestepUnit.SECONDS, timestepUnit));
} catch (Exception e) {
throw new RuntimeException("Could not load json from [" + optJsonFile + "]", e);
Expand Down

0 comments on commit 2c6725c

Please sign in to comment.