Skip to content

Commit

Permalink
comma separated list for general_station_assigned_plots; docu;
Browse files Browse the repository at this point in the history
  • Loading branch information
swoellauer committed Dec 15, 2020
1 parent 1a24e66 commit 11a8b20
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 53 deletions.
20 changes: 14 additions & 6 deletions docs/_configuration/project.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,35 @@ file structure:
---
### `config/project1/general_stations.ini`

Ini-file lists plot groups ("general stations"). One plot is contained in exactly one plot group.
Ini-file lists plot groups ("general stations"). One plot is contained in exactly one plot group (primary group).

Optionally several groups may form a super group. If present all plots of one super group are the set of plots for interpolation and reference generation purposes.
Optionally a plot may be assigned to several plot groups (secondary groups).

Optionally several plot groups may form a processing group ("general_station_groups"). If present all plots of one processing group are the set of plots for interpolation and reference generation purposes. Processing groups are not visible at the web interface.

file structure:

`[general_stations]`

`GROUP_NAME = REGION_NAME`
`PLOT_GROUP_NAME = REGION_NAME`

...

`[general_station_long_names]`

`GROUP_NAME = GROUP_LONG_NAME`
`PLOT_GROUP_NAME = LONG_NAME`

...

`[general_station_assigned_plots]` *(optional list of additional plots that are assigned to this plot group, plots that are contained in a different primary plot group)*

`PLOT_GROUP_NAME = PLOT1, PLOT2, PLOT3`, ...

...

`[general_station_groups]` (optional)
`[general_station_groups]` *(optional processing groups)*

`GROUP_NAME = SUPER_GROUP_NAME`
`PLOT_GROUP_NAME = PROCESSING_GROUP_NAME`

...

Expand Down
2 changes: 1 addition & 1 deletion example/config/proj3all/general_stations.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ proj3allmain = [2010, 2010]

[general_station_assigned_plots]

proj3allmain = stationA stationB stationC stationD
proj3allmain = stationA, stationB, stationC, stationD
Binary file modified example/tubedb.jar
Binary file not shown.
37 changes: 3 additions & 34 deletions src/tsdb/ConfigLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.yaml.snakeyaml.constructor.SafeConstructor;
import org.yaml.snakeyaml.nodes.Tag;

import tsdb.GeneralStation.GeneralStationBuilder;
import tsdb.component.LoggerType;
import tsdb.component.Region;
import tsdb.component.Sensor;
Expand Down Expand Up @@ -64,39 +65,6 @@ public ConfigLoader(TsDB tsdb) {
this.tsdb = tsdb;
}

private class GeneralStationBuilder {

public String name;
public Region region;
public String longName;
public String group;
public Interval viewTimeRange; //nullable
public List<String> assigned_plots; //nullable

public GeneralStationBuilder(String name) {
this.name = name;
}

public GeneralStation build() {
if(longName==null) {
longName = name;
}
if(group==null) {
group = name;
}
return new GeneralStation(name, region, longName, group, viewTimeRange, assigned_plots);
}

public void addAssigned_plots(String[] plots) {
List<String> plotList = Arrays.asList(plots);
if(assigned_plots == null) {
this.assigned_plots = plotList;
} else {
this.assigned_plots.addAll(plotList);
}
}
}

/**
* reads names of used general stations
* @param configFile
Expand Down Expand Up @@ -167,7 +135,8 @@ public void readGeneralStation(String configFile) {
for(Entry<String, String> entry : section_general_station_plots.entrySet()) {
if(creationMap.containsKey(entry.getKey())) {
String plotsText = entry.getValue();
String[] plots = plotsText.split("\\s+");
//String[] plots = plotsText.split("\\s+");
String[] plots = plotsText.split(",");
if(plots.length > 0) {
GeneralStationBuilder builder = creationMap.get(entry.getKey());
builder.addAssigned_plots(plots);
Expand Down
57 changes: 46 additions & 11 deletions src/tsdb/GeneralStation.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,25 @@
*
*/
public class GeneralStation {

public String name;

public final Region region;

public final String longName;

public Map<String,String> sensorNameTranlationMap;

public List<Station> stationList;

public List<VirtualPlot> virtualPlots;

public final String group;//not null // if no group: name of general station

public final Interval viewTimeRange; //nullable

public List<String> assigned_plots; //nullable

public GeneralStation(String name, Region region, String longName, String group, Interval viewTimeRange, List<String> assigned_plots) {
this.name = name;
this.region = region;
Expand All @@ -45,7 +45,7 @@ public GeneralStation(String name, Region region, String longName, String group,
this.viewTimeRange = viewTimeRange;
this.assigned_plots = assigned_plots;
}

public Stream<String> getStationAndVirtualPlotNames() {
Stream<String> stationStream = stationList.stream().map(s->s.stationID);
Stream<String> virtualPlotStream = virtualPlots.stream().map(v->v.plotID);
Expand All @@ -57,4 +57,39 @@ public String toString() {
return "GeneralStation [name=" + name + ", region=" + region + ", longName=" + longName + ", assigned_plots " + assigned_plots + "]";
}


public static class GeneralStationBuilder {

public String name;
public Region region;
public String longName;
public String group;
public Interval viewTimeRange; //nullable
public List<String> assigned_plots; //nullable

public GeneralStationBuilder(String name) {
this.name = name;
}

public GeneralStation build() {
if(longName==null) {
longName = name;
}
if(group==null) {
group = name;
}
return new GeneralStation(name, region, longName, group, viewTimeRange, assigned_plots);
}

public void addAssigned_plots(String[] plots) {
List<String> list = assigned_plots == null ? new ArrayList<String>() : assigned_plots;
for(String plot : plots) {
plot = plot.trim();
if(!plot.isEmpty()) {
list.add(plot);
}
}
assigned_plots = list.isEmpty() ? null : list;
}
}
}
2 changes: 1 addition & 1 deletion src/tsdb/TsDB.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
public class TsDB implements AutoCloseable {
private static final Logger log = LogManager.getLogger();

public static final String tubedb_version = "1.19.5";
public static final String tubedb_version = "1.19.6";

/**
* map regionName -> Region
Expand Down

0 comments on commit 11a8b20

Please sign in to comment.