[Dive4elements-commits] [PATCH 3 of 5] Generate facets for bed diameter measurements and draw them into the generated chart

Wald Commits scm-commit at wald.intevation.org
Mon Jun 10 16:31:26 CEST 2013


# HG changeset patch
# User Raimund Renkert <rrenkert at intevation.de>
# Date 1370874537 -7200
# Node ID 38d6ce2c7164e0a2876efbcd934369bfb6a9e152
# Parent  68071f205c0e00adc7be2f7cc6e72c67689a7bfa
Generate facets for bed diameter measurements and draw them into the generated chart.

diff -r 68071f205c0e -r 38d6ce2c7164 artifacts/doc/conf/artifacts/minfo.xml
--- a/artifacts/doc/conf/artifacts/minfo.xml	Mon Jun 10 16:23:39 2013 +0200
+++ b/artifacts/doc/conf/artifacts/minfo.xml	Mon Jun 10 16:28:57 2013 +0200
@@ -395,14 +395,16 @@
             <outputmodes>
                 <outputmode name="bed_longitudinal_section" description="output.bed_longitudinal_section" mime-type="image/png" type="chart">
                     <facets>
-                    	<facet name="bed_longitudinal_section.porosity_toplayer"/>
-                    	<facet name="bed_longitudinal_section.porosity_sublayer"/>
-                    	<facet name="bed_longitudinal_section.sediment_density_toplayer"/>
-                    	<facet name="bed_longitudinal_section.sediment_density_sublayer"/>
-                    	<facet name="bed_longitudinal_section.bed_diameter_toplayer"/>
+                        <facet name="bed_longitudinal_section.porosity_toplayer"/>
+                        <facet name="bed_longitudinal_section.porosity_sublayer"/>
+                        <facet name="bed_longitudinal_section.sediment_density_toplayer"/>
+                        <facet name="bed_longitudinal_section.sediment_density_sublayer"/>
+                        <facet name="bed_longitudinal_section.bed_diameter_toplayer"/>
                         <facet name="bed_longitudinal_section.bed_diameter_sublayer"/>
+                        <facet name="bed_longitudinal_section.bed_diameter_data_top"/>
+                        <facet name="bed_longitudinal_section.bed_diameter_data_sub"/>
                         <facet name="bed_longitudinal_section.manualpoints" />
-                    	<facet name="bed_longitudinal_section.bedload_diameter"/>
+                        <facet name="bed_longitudinal_section.bedload_diameter"/>
                         <facet name="longitudinal_section.annotations" description="facet.longitudinal_section.annotations"/>
                     </facets>
                 </outputmode>
diff -r 68071f205c0e -r 38d6ce2c7164 artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/BedQualityState.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/BedQualityState.java	Mon Jun 10 16:23:39 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/BedQualityState.java	Mon Jun 10 16:28:57 2013 +0200
@@ -24,6 +24,7 @@
 import org.dive4elements.river.artifacts.model.DateRange;
 import org.dive4elements.river.artifacts.model.FacetTypes;
 import org.dive4elements.river.artifacts.model.minfo.BedDensityFacet;
+import org.dive4elements.river.artifacts.model.minfo.BedDiameterDataFacet;
 import org.dive4elements.river.artifacts.model.minfo.BedDiameterFacet;
 import org.dive4elements.river.artifacts.model.minfo.BedDiameterResult;
 import org.dive4elements.river.artifacts.model.minfo.BedParametersResult;
@@ -53,6 +54,9 @@
     public static final String I18N_FACET_BED_DENSITY_SUBLAYER = "facet.bedquality.bed.density.sublayer";
     public static final String I18N_FACET_BED_DIAMETER_TOPLAYER = "facet.bedquality.bed.diameter.toplayer";
     public static final String I18N_FACET_BED_DIAMETER_SUBLAYER = "facet.bedquality.bed.diameter.sublayer";
+    public static final String I18N_FACET_BED_DIAMETER_DATA_TOPLAYER = "facet.bedquality.bed.diameter.data.toplayer";
+    public static final String I18N_FACET_BED_DIAMETER_DATA_SUBLAYER = "facet.bedquality.bed.diameter.data.sublayer";
+    public static final String I18N_FACET_BEDLOAD_DIAMETER_DATA = "facet.bedquality.bedload.diameter.data";
     public static final String I18N_FACET_BEDLOAD_DIAMETER = "facet.bedquality.bedload.diameter";
 
     @Override
@@ -80,12 +84,120 @@
 
         generateFacets(context, newFacets, results, getID(), hash);
         logger.debug("Created " + newFacets.size() + " new Facets.");
-
+        generateDataFacets(context, newFacets, access, getID(), hash);
         facets.addAll(newFacets);
 
         return res;
     }
 
+    private void generateDataFacets(
+        CallContext context,
+        List<Facet> newFacets,
+        BedQualityAccess access,
+        String stateId,
+        String hash) {
+        List<String> diameters = access.getBedDiameter();
+        List<DateRange> ranges = access.getDateRanges();
+        for (int i = 0; i < ranges.size(); i++) {
+            DateRange range = ranges.get(i);
+            for (String diameter: diameters) {
+                int ndxTop = generateIndex(diameter, true);
+                int ndxSub = generateIndex(diameter, false);
+                String toplayer =
+                    Resources.getMsg(
+                        context.getMeta(), I18N_TOPLAYER, I18N_TOPLAYER);
+                String sublayer =
+                    Resources.getMsg(
+                        context.getMeta(), I18N_SUBLAYER, I18N_SUBLAYER);
+                //toplayer
+                newFacets.add(new BedDiameterDataFacet(
+                    ndxTop,
+                    BED_DIAMETER_DATA_TOP,
+                    Resources.getMsg(
+                        context.getMeta(),
+                        I18N_FACET_BED_DIAMETER_DATA_TOPLAYER,
+                        I18N_FACET_BED_DIAMETER_DATA_TOPLAYER,
+                        new Object[] { diameter.toUpperCase(),
+                            range.getFrom(), range.getTo(), toplayer}),
+                    ComputeType.ADVANCE,
+                    stateId,
+                    hash));
+                //sublayer
+                newFacets.add(new BedDiameterDataFacet(
+                    ndxSub,
+                    BED_DIAMETER_DATA_SUB,
+                    Resources.getMsg(
+                        context.getMeta(),
+                        I18N_FACET_BED_DIAMETER_DATA_TOPLAYER,
+                        I18N_FACET_BED_DIAMETER_DATA_TOPLAYER,
+                        new Object[] { diameter.toUpperCase(),
+                            range.getFrom(), range.getTo(), sublayer}),
+                    ComputeType.ADVANCE,
+                    stateId,
+                    hash));
+            }
+        }
+    }
+
+    private int generateIndex(String diameter, boolean b) {
+        int d = 0;
+        if(diameter.equals("d10")) {
+            d = 1;
+        }
+        else if (diameter.equals("d16")) {
+            d = 2;
+        }
+        else if (diameter.equals("d20")) {
+            d = 3;
+        }
+        else if (diameter.equals("d25")) {
+            d = 4;
+        }
+        else if (diameter.equals("d30")) {
+            d = 5;
+        }
+        else if (diameter.equals("d40")) {
+            d = 6;
+        }
+        else if (diameter.equals("d50")) {
+            d = 7;
+        }
+        else if (diameter.equals("d60")) {
+            d = 8;
+        }
+        else if (diameter.equals("d70")) {
+            d = 9;
+        }
+        else if (diameter.equals("d75")) {
+            d = 10;
+        }
+        else if (diameter.equals("d80")) {
+            d = 11;
+        }
+        else if (diameter.equals("d84")) {
+            d = 12;
+        }
+        else if (diameter.equals("d90")) {
+            d = 13;
+        }
+        else if (diameter.equals("dmin")) {
+            d = 14;
+        }
+        else if (diameter.equals("dmax")) {
+            d = 15;
+        }
+        else if (diameter.equals("dm")) {
+            d = 16;
+        }
+        int ndx = d;
+        ndx = ndx << 1;
+        if (b) {
+            ndx += 1;
+        }
+        ndx = ndx << 3;
+        return ndx;
+    }
+
     protected void generateFacets(CallContext context, List<Facet> newFacets,
         BedQualityResult[] results, String stateId, String hash) {
         logger.debug("BedQualityState.generateFacets");
diff -r 68071f205c0e -r 38d6ce2c7164 artifacts/src/main/java/org/dive4elements/river/exports/minfo/BedQualityGenerator.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/minfo/BedQualityGenerator.java	Mon Jun 10 16:23:39 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/minfo/BedQualityGenerator.java	Mon Jun 10 16:28:57 2013 +0200
@@ -15,6 +15,7 @@
 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
 import org.dive4elements.artifactdatabase.state.Facet;
 import org.dive4elements.river.artifacts.model.FacetTypes;
+import org.dive4elements.river.artifacts.model.minfo.BedDiameterData;
 import org.dive4elements.river.artifacts.model.minfo.BedDiameterResult;
 import org.dive4elements.river.artifacts.model.minfo.BedParametersResult;
 import org.dive4elements.river.artifacts.model.minfo.BedloadDiameterResult;
@@ -193,6 +194,12 @@
                 (BedParametersResult) artifactAndFacet.getData(context),
                 artifactAndFacet, attr, visible);
         }
+        else if (name.equals(BED_DIAMETER_DATA_TOP) ||
+                 name.equals(BED_DIAMETER_DATA_SUB)) {
+            doBedDiameterDataOut(
+                (BedDiameterData) artifactAndFacet.getData(context),
+                artifactAndFacet, attr, visible);
+        }
         else if (name.equals(LONGITUDINAL_ANNOTATION)) {
             doAnnotations(
                 (RiverAnnotation) artifactAndFacet.getData(context),
@@ -210,6 +217,18 @@
         }
     }
 
+    private void doBedDiameterDataOut(
+        BedDiameterData data,
+        ArtifactAndFacet aandf,
+        Document theme,
+        boolean visible
+    ) {
+        XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), theme);
+        StyledSeriesBuilder.addPoints(series, data.getDiameterData(), true);
+
+        addAxisSeries(series, YAXIS.W.idx, visible);
+    }
+
     protected void doBedDiameterTopLayerOut(BedDiameterResult data,
         ArtifactAndFacet aandf, Document theme, boolean visible) {
         logger.debug("BedQuality.doBedDiameterTopLayerOut");


More information about the Dive4elements-commits mailing list