Mercurial > dive4elements > river
changeset 4542:8e8cabaeab6a
Merged
author | Christian Lins <christian.lins@intevation.de> |
---|---|
date | Thu, 15 Nov 2012 17:06:54 +0100 |
parents | ba795aa13843 (diff) 7b454c6e2bcb (current diff) |
children | e357716cf346 |
files | |
diffstat | 11 files changed, 201 insertions(+), 45 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/doc/conf/artifacts/minfo.xml Thu Nov 15 17:06:09 2012 +0100 +++ b/flys-artifacts/doc/conf/artifacts/minfo.xml Thu Nov 15 17:06:54 2012 +0100 @@ -168,6 +168,7 @@ <facet name="bedheight_middle.single" description="A facet for total channels"/> <facet name="bedheight_middle.epoch" description="A facet for total channels"/> <facet name="longitudinal_section.w" description="Datacage facet"/> + <facet name="bedheight" description="Datacage facet"/> </facets> </outputmode> <outputmode name="bedheight_middle_export" description="output.bedheight_middle_export" mime-type="text/plain" type="export">
--- a/flys-artifacts/doc/conf/meta-data.xml Thu Nov 15 17:06:09 2012 +0100 +++ b/flys-artifacts/doc/conf/meta-data.xml Thu Nov 15 17:06:54 2012 +0100 @@ -786,6 +786,28 @@ <dc:call-macro name="annotations"/> <dc:call-macro name="flow_velocity_measurements"/> </dc:if> + <dc:comment> + MINFO bedheight middle + </dc:comment> + <dc:if test="dc:contains($artifact-outs, 'bedheight_middle')"> + <soundings_width> + <dc:context> + <dc:statement> + SELECT id AS bedh_id, + year AS bedh_year, + description AS bedh_descr + FROM bed_height_single WHERE river_id = ${river_id} + </dc:statement> + <dc:elements> + <height> + <dc:attribute name="factory" value="bedheight"/> + <dc:attribute name="ids" value="bedheight-singlevalues-${bedh_id}-${bedh_year}"/> + <dc:attribute name="description" value="${bedh_descr}"/> + </height> + </dc:elements> + </dc:context> + </soundings_width> + </dc:if> <dc:comment comment="--- non-recommendations---"/> </dc:otherwise> </dc:choose> @@ -2022,6 +2044,10 @@ </fix_longitudinal_section_curve> </dc:if> + <dc:comment> + MINFO bedheight middle + </dc:comment> + <dc:if test="dc:contains($artifact-outs, 'bedheight_middle')"> <fix_vollmer_wq_curve> <dc:elements>
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/BedHeightsArtifact.java Thu Nov 15 17:06:09 2012 +0100 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/BedHeightsArtifact.java Thu Nov 15 17:06:54 2012 +0100 @@ -6,25 +6,29 @@ import org.apache.log4j.Logger; import org.w3c.dom.Document; +import de.intevation.artifactdatabase.state.DefaultOutput; import de.intevation.artifactdatabase.state.Facet; import de.intevation.artifactdatabase.state.FacetActivity; -import de.intevation.artifactdatabase.state.State; import de.intevation.artifacts.ArtifactFactory; +import de.intevation.artifacts.Artifact; import de.intevation.artifacts.CallMeta; import de.intevation.artifacts.common.utils.XMLUtils; import de.intevation.flys.artifacts.model.minfo.BedHeight; import de.intevation.flys.artifacts.model.minfo.BedHeightFacet; import de.intevation.flys.artifacts.model.minfo.BedHeightFactory; import de.intevation.flys.artifacts.states.StaticState; +import de.intevation.flys.model.BedHeightSingle; +import de.intevation.flys.model.BedHeightSingleValue; public class BedHeightsArtifact -extends StaticFLYSArtifact +extends AbstractStaticStateArtifact { /** The logger for this class. */ private static Logger logger = Logger.getLogger(BedHeightsArtifact.class); private static final String NAME = "bedheights"; + private static final String STATIC_FACET_NAME = "bedheight"; static { // TODO: Move to configuration. @@ -40,10 +44,6 @@ public static final String DATA_HEIGHT_TYPE = "height_marks"; - /** One and only state to be in. */ - protected transient State state = null; - - /** * Trivial Constructor. */ @@ -69,53 +69,44 @@ { logger.debug("BedHeightsArtifact.setup"); - state = new StaticState(STATIC_STATE_NAME); - if (logger.isDebugEnabled()) { logger.debug(XMLUtils.toString(data)); } - List<Facet> fs = new ArrayList<Facet>(); String code = getDatacageIDValue(data); if (code != null) { String [] parts = code.split("-"); if (parts.length >= 4) { - if (parts[0].equals("bedheight")) { - addStringData("type", parts[1]); + String name = parts[0]; + String type = parts[1]; + String btype = type; + int hId = Integer.parseInt(parts[2]); + if (name.equals("bedheight")) { + addStringData("type", type); addStringData("height_id", parts[2]); addStringData("time", parts[3]); } - int hId = Integer.parseInt(parts[2]); - String bedHName = BedHeightFactory.getHeightName(parts[1], hId); + if (type.equals("singlevalues")) { + btype = "single"; + } - Facet bedHFacet = new BedHeightFacet( - "bedheight", - bedHName); + String bedHName = BedHeightFactory.getHeightName(btype, hId); - fs.add(bedHFacet); - addFacets(state.getID(), fs); + Facet facet = new BedHeightFacet( + STATIC_FACET_NAME, bedHName, type); + + ArrayList<Facet> facets = new ArrayList<Facet>(1); + facets.add(facet); + + addFacets(STATIC_STATE_NAME, facets); } } - - //spawnState(); super.setup(identifier, factory, context, callMeta, data); } /** - * Get a list containing the one and only State. - * @param context ignored. - * @return list with one and only state. - */ - @Override - protected List<State> getStates(Object context) { - ArrayList<State> states = new ArrayList<State>(); - states.add(state); - return states; - } - - /** */ public BedHeight getHeight() { return BedHeightFactory.getHeight( @@ -123,5 +114,45 @@ Integer.parseInt(getDataAsString("height_id")), Integer.parseInt(getDataAsString("time"))); } + + public List<BedHeightSingleValue> getSingleValues() { + logger.debug("getSingleValues"); + BedHeightSingle single = BedHeightSingle.getBedHeightSingleById( + getDataAsInteger("height_id")); + return BedHeightSingleValue.getBedHeightSingleValues(single, + getDataAsDouble("ld_from"), + getDataAsDouble("ld_to")); + } + + @Override + protected void initStaticState() { + + logger.debug("initStaticState " + getName() + " " + identifier()); + + StaticState state = new StaticState(STATIC_STATE_NAME); + DefaultOutput output = new DefaultOutput( + "general", + "general", + "image/png", + "chart"); + + List<Facet> facets = getFacets(STATIC_STATE_NAME); + output.addFacets(facets); + state.addOutput(output); + + setStaticState(state); + } + + @Override + protected void initialize(Artifact artifact, Object context, CallMeta meta) { + // do not clone facets, etc. from master artifact + + logger.debug("initialize"); + importData((FLYSArtifact)artifact, "ld_from"); + importData((FLYSArtifact)artifact, "ld_to"); + + logger.debug("ld_from " + getDataAsString("ld_from")); + logger.debug("ld_to " + getDataAsString("ld_to")); + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedHeightFacet.java Thu Nov 15 17:06:09 2012 +0100 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedHeightFacet.java Thu Nov 15 17:06:54 2012 +0100 @@ -10,13 +10,12 @@ extends BlackboardDataFacet implements FacetTypes { - public BedHeightFacet(String description) { - this(STATIC_BEDHEIGHT, description); - } + private String type; - public BedHeightFacet(String name, String description) { + public BedHeightFacet(String name, String description, String type) { this.name = name; this.description = description; + this.type = type; this.index = 0; } @@ -32,6 +31,9 @@ public Object getData(Artifact artifact, CallContext context) { BedHeightsArtifact staticData = (BedHeightsArtifact) artifact; + if (type.equals("singlevalues")) { + return staticData.getSingleValues(); + } return staticData.getHeight(); } /** @@ -40,7 +42,7 @@ */ @Override public BedHeightFacet deepCopy() { - BedHeightFacet copy = new BedHeightFacet(description); + BedHeightFacet copy = new BedHeightFacet(name, description, type); copy.set(this); return copy; }
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedHeightSingle.java Thu Nov 15 17:06:09 2012 +0100 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedHeightSingle.java Thu Nov 15 17:06:54 2012 +0100 @@ -63,4 +63,8 @@ } return Double.NaN; } + + public double[] getMorphWidths() { + return this.morphWidth.toNativeArray(); + } }
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/MiddleBedHeightGenerator.java Thu Nov 15 17:06:09 2012 +0100 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/MiddleBedHeightGenerator.java Thu Nov 15 17:06:54 2012 +0100 @@ -5,6 +5,7 @@ import de.intevation.flys.artifacts.FLYSArtifact; import de.intevation.flys.artifacts.model.FacetTypes; import de.intevation.flys.artifacts.model.MiddleBedHeightData; +import de.intevation.flys.exports.process.BedheightProcessor; import de.intevation.flys.exports.process.Processor; import de.intevation.flys.exports.process.WOutProcessor; import de.intevation.flys.jfree.FLYSAnnotation; @@ -26,7 +27,7 @@ implements FacetTypes { public enum YAXIS { - H(0), W(1); + H(0), W(1), P(2); protected int idx; private YAXIS(int c) { idx = c; @@ -61,6 +62,9 @@ public static final String I18N_W_YAXIS_LABEL = "chart.longitudinal.section.yaxis.label"; public static final String I18N_W_YAXIS_LABEL_DEFAULT = "W [NN + m]"; + public static final String I18N_P_YAXIS_LABEL_DEFAULT = "Gepeilte Breite [m]"; + public static final String I18N_P_YAXIS_LABEL = + "chart.bedheight_middle.sounding.yaxis.label"; @Override protected YAxisWalker getYAxisWalker() { @@ -118,6 +122,9 @@ else if (index == YAXIS.W.idx) { label = msg(I18N_W_YAXIS_LABEL, I18N_W_YAXIS_LABEL_DEFAULT); } + else if (index == YAXIS.P.idx) { + label = msg(I18N_P_YAXIS_LABEL, I18N_P_YAXIS_LABEL_DEFAULT); + } return label; } @@ -157,6 +164,9 @@ return; } + Processor woutp = new WOutProcessor(); + Processor bedp = new BedheightProcessor(); + if (name.equals(MIDDLE_BED_HEIGHT_SINGLE) || name.equals(MIDDLE_BED_HEIGHT_EPOCH)) { doHeightOut( (MiddleBedHeightData) artifactAndFacet.getData(context), @@ -186,14 +196,14 @@ visible, YAXIS.H.idx); } + else if (bedp.canHandle(name)) { + bedp.doOut(this, artifactAndFacet, attr, visible, YAXIS.P.idx); + } + else if (woutp.canHandle(name)) { + woutp.doOut(this, artifactAndFacet, attr, visible, YAXIS.W.idx); + } else { - Processor processor = new WOutProcessor(); - if (processor.canHandle(name)) { - processor.doOut(this, artifactAndFacet, attr, visible, YAXIS.W.idx); - } - else { - logger.warn("Unknown facet name: " + name); - } + logger.warn("Unknown facet name: " + name); } }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/process/BedheightProcessor.java Thu Nov 15 17:06:54 2012 +0100 @@ -0,0 +1,77 @@ +package de.intevation.flys.exports.process; + +import java.util.List; + +import javax.swing.text.html.HTMLDocument.HTMLReader.IsindexAction; + +import org.apache.log4j.Logger; +import org.jfree.data.xy.XYSeries; +import org.w3c.dom.Document; + +import de.intevation.artifactdatabase.state.ArtifactAndFacet; +import de.intevation.artifacts.CallContext; +import de.intevation.flys.artifacts.model.minfo.BedHeightSingle; +import de.intevation.flys.exports.XYChartGenerator; +import de.intevation.flys.jfree.StyledXYSeries; +import de.intevation.flys.model.BedHeightSingleValue; + +public class BedheightProcessor implements Processor { + + private final static Logger logger = + Logger.getLogger(BedheightProcessor.class); + + private final static String BEDHEIGHT = "bedheight"; + + @Override + public void doOut(XYChartGenerator generator, ArtifactAndFacet aandf, + Document theme, boolean visible, int index) { + CallContext context = generator.getCallContext(); + Object data = aandf.getData(context); + if (data instanceof BedHeightSingle) { + doBedheightSingleOut(generator, aandf, theme, index, visible, + (BedHeightSingle)data); + } + else if (data instanceof List<?>) { + doBedheightSingeValuesOut(generator, aandf, theme, index, visible, + (List<BedHeightSingleValue>)data); + } + logger.error("Can't process " + data.getClass().getName() + " objects"); + } + + private void doBedheightSingeValuesOut(XYChartGenerator generator, + ArtifactAndFacet aandf, Document theme, int index, boolean visible, + List<BedHeightSingleValue> data) { + logger.debug("doBedheightSingleOut"); + + XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), + theme); + for(BedHeightSingleValue bvalue: data) { + series.add(bvalue.getStation(), bvalue.getSoundingWidth()); + } + generator.addAxisSeries(series, index, visible); + } + + @Override + public boolean canHandle(String facettype) { + return BEDHEIGHT.equals(facettype); + } + + public void doBedheightSingleOut(XYChartGenerator generator, + ArtifactAndFacet aandf, Document theme, int index, boolean visible, + BedHeightSingle data) { + double[] width = data.getMorphWidths(); + double[] stations = data.getStations().toNativeArray(); + + logger.debug("doBedheightSingleOut"); + + XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), + theme); + + for (int i = 0; i < width.length; i++) { + series.add(stations[i], width[i], false); + } + + generator.addAxisSeries(series, index, visible); + } + +}
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java Thu Nov 15 17:06:09 2012 +0100 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java Thu Nov 15 17:06:54 2012 +0100 @@ -566,6 +566,8 @@ String soundings(); + String soundings_width(); + String bed_difference_year(); String bed_difference_epoch();
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties Thu Nov 15 17:06:09 2012 +0100 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties Thu Nov 15 17:06:54 2012 +0100 @@ -236,6 +236,7 @@ load_diameter = Bedload Diameter bed_diameter = Bed Diameter soundings = Soundings +soundings_width = Soundings Width bed_difference_year = Single Bedheight Differences bed_difference_epoch = Epoch Bedheight Differences bed_difference_height_year = Bedheight Differences per year
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties Thu Nov 15 17:06:09 2012 +0100 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties Thu Nov 15 17:06:54 2012 +0100 @@ -237,6 +237,7 @@ load_diameter = Geschiebedurchmesser bed_diameter = Sohldurchmesser soundings = Peilungen +soundings_width = Gepeilte Breite bed_difference_year = Sohlh\u00f6hendifferenz (Jahr) bed_difference_epoch = Sohlh\u00f6hendifferenz (Epoche) bed_difference_height_year = Sohlh\u00f6hendifferenz pro Jahr
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties Thu Nov 15 17:06:09 2012 +0100 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties Thu Nov 15 17:06:54 2012 +0100 @@ -237,6 +237,7 @@ load_diameter = Bedload Diameter bed_diameter = Bed Diameter soundings = Soundings +soundings_width = Soundings Width bed_difference_year = Single Bedheight Differences bed_difference_epoch = Epoch Bedheight Differences bed_difference_height_year = Bedheight Difference per year