Skip to content

Commit

Permalink
Prevent bypassing the fallback to the standard style
Browse files Browse the repository at this point in the history
  • Loading branch information
tordanik committed Feb 25, 2025
1 parent 0102ba5 commit a079431
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public Integer call() throws Exception {
OSMDataReaderView osmReaderView = buildInput();

// TODO: enable sharing (most) scene calculations across different LOD
var sceneKey = new SceneInputs(osmReaderView, configOptions.config, extraProperties);
var sceneKey = new SceneInputs(osmReaderView, configOptions.getConfigFiles(), extraProperties);

Scene scene = cachedScenes.containsKey(sceneKey)
? cachedScenes.get(sceneKey)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public Integer call() {
File input = null; // TODO support input
LevelOfDetail lod = null; // TODO support lod

var viewerFrame = new ViewerFrame(configOptions.getO2WConfig(Map.of()), lod, configOptions.config, input);
var viewerFrame = new ViewerFrame(configOptions.getO2WConfig(Map.of()), lod, configOptions.getConfigFiles(), input);
viewerFrame.setVisible(true);

return -1; // tells the main method not to call System.exit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,25 @@
public class ConfigOptions {

@CommandLine.Option(names = {"--config"}, description = "properties file(s) with configuration parameters")
public List<File> config = List.of();
private List<File> config = List.of();

public static final File STANDARD_PROPERTIES_FILE = new File("standard.properties");

public O2WConfig getO2WConfig(Map<String, ?> extraProperties) {

File[] configFiles = config.toArray(new File[0]);
public List<File> getConfigFiles() {

if (config.isEmpty() && STANDARD_PROPERTIES_FILE.isFile()) {
System.out.println("No --config parameter, using default style (" + STANDARD_PROPERTIES_FILE + ").\n");
configFiles = new File[] { STANDARD_PROPERTIES_FILE };
return List.of(STANDARD_PROPERTIES_FILE);
} else {
return config;
}

}

public O2WConfig getO2WConfig(Map<String, ?> extraProperties) {

File[] configFiles = getConfigFiles().toArray(new File[0]);

try {
return new O2WConfig(extraProperties, configFiles);
} catch (Exception e) {
Expand Down

0 comments on commit a079431

Please sign in to comment.