Mercurial > dive4elements > river
changeset 7340:2ce7bacc940f double-precision
Merged changes from default into double precision branch.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Tue, 15 Oct 2013 18:41:55 +0200 |
parents | f7d3fc619976 (current diff) 40e5ad76103c (diff) |
children | 588b02a4078a |
files | artifacts/src/main/java/org/dive4elements/river/exports/FlowVelocityGenerator.java artifacts/src/main/java/org/dive4elements/river/exports/FlowVelocityInfoGenerator.java artifacts/src/main/java/org/dive4elements/river/exports/sq/SQRelationGenerator.java artifacts/src/main/java/org/dive4elements/river/exports/sq/SQRelationGeneratorA.java artifacts/src/main/java/org/dive4elements/river/exports/sq/SQRelationGeneratorB.java artifacts/src/main/java/org/dive4elements/river/exports/sq/SQRelationGeneratorC.java artifacts/src/main/java/org/dive4elements/river/exports/sq/SQRelationGeneratorD.java artifacts/src/main/java/org/dive4elements/river/exports/sq/SQRelationGeneratorE.java artifacts/src/main/java/org/dive4elements/river/exports/sq/SQRelationGeneratorF.java artifacts/src/main/java/org/dive4elements/river/exports/sq/SQRelationInfoGenerator.java backend/src/main/java/org/dive4elements/river/importer/ImportRiver.java backend/src/main/java/org/dive4elements/river/importer/ImportWstColumn.java backend/src/main/java/org/dive4elements/river/importer/parsers/BedHeightParser.java backend/src/main/java/org/dive4elements/river/importer/parsers/FlowVelocityModelParser.java backend/src/main/java/org/dive4elements/river/importer/parsers/WstParser.java |
diffstat | 126 files changed, 2870 insertions(+), 1445 deletions(-) [+] |
line wrap: on
line diff
--- a/artifacts/contrib/list-unused-macros.xsl Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/contrib/list-unused-macros.xsl Tue Oct 15 18:41:55 2013 +0200 @@ -7,6 +7,16 @@ <xsl:output method="text" encoding="UTF-8"/> <xsl:template match="/"> + <xsl:text>Duplicate macros:
</xsl:text> + <xsl:for-each select="//dc:macro/@name"> + <xsl:variable name="mname" select="."/> + <xsl:if test="count(//dc:macro[@name=$mname]) > 1"> + <xsl:text> </xsl:text> + <xsl:value-of select="$mname"/> + <xsl:text>
</xsl:text> + </xsl:if> + </xsl:for-each> + <xsl:text>Marcos defined but not called:
</xsl:text> <xsl:for-each select="//dc:macro/@name"> <xsl:variable name="mname" select="."/>
--- a/artifacts/doc/conf/artifacts/chart.xml Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/doc/conf/artifacts/chart.xml Tue Oct 15 18:41:55 2013 +0200 @@ -77,7 +77,7 @@ <state id="state.chart.longitudinal_section" description="state.chart.logitudinal_section" state="org.dive4elements.river.artifacts.states.DischargeLongitudinalSection"> <outputmodes> - <outputmode name="longitudinal_section" description="output.discharge_longitudinal_section" mime-type="image/png" type="chart"> + <outputmode name="longitudinal_section" description="output.longitudinal_section" mime-type="image/png" type="chart"> <facets> <facet name="empty.facet" decription= "Empty"/> <facet name="w_differences" decription= "W Differences"/>
--- a/artifacts/doc/conf/artifacts/fixanalysis.xml Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/doc/conf/artifacts/fixanalysis.xml Tue Oct 15 18:41:55 2013 +0200 @@ -326,6 +326,11 @@ <facet name="pdf" description="facet.waterlevel_export.pdf" /> </facets> </outputmode> + <outputmode name="fix_report" description="output.fix_report.report" mime-type="text/plain" type="report"> + <facets> + <facet name="report" description="facet.fix.report" /> + </facets> + </outputmode> </outputmodes> </state> </states>
--- a/artifacts/doc/conf/conf.xml Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/doc/conf/conf.xml Tue Oct 15 18:41:55 2013 +0200 @@ -9,6 +9,7 @@ <!ENTITY rivermap SYSTEM "rivermap.xml"> <!ENTITY generators SYSTEM "generators.xml"> <!ENTITY longitudinal-defaults SYSTEM "longitudinal-diagram-defaults.xml"> + <!ENTITY sqrelation-defaults SYSTEM "sqrelation-diagram-defaults.xml"> ]> <artifact-database> <export-secret>YOUR_SECRET</export-secret> @@ -137,9 +138,18 @@ <artifact-factory name="gaugedischargecurve" description="Factory to create an artifact to show a discharge curve for a gauge." ttl="3600000" artifact="org.dive4elements.river.artifacts.GaugeDischargeCurveArtifact">org.dive4elements.artifactdatabase.DefaultArtifactFactory</artifact-factory> + <artifact-factory name="flowvelocitymodel" description="Factory to create an artifact to show measured flow velocities." + ttl="3600000" + artifact="org.dive4elements.river.artifacts.FlowVelocityModelArtifact">org.dive4elements.artifactdatabase.DefaultArtifactFactory</artifact-factory> <artifact-factory name="flowvelocity" description="Factory to create an artifact to show measured flow velocities." ttl="3600000" artifact="org.dive4elements.river.artifacts.FlowVelocityMeasurementArtifact">org.dive4elements.artifactdatabase.DefaultArtifactFactory</artifact-factory> + <artifact-factory name="sedimentdensity" description="Factory to create an artifact to show Sediment Density values." + ttl="3600000" + artifact="org.dive4elements.river.artifacts.SedimentDensityArtifact">org.dive4elements.artifactdatabase.DefaultArtifactFactory</artifact-factory> + <artifact-factory name="sedimentyield" description="Factory to create an artifact to show Sediment Yield values." + ttl="3600000" + artifact="org.dive4elements.river.artifacts.SedimentYieldArtifact">org.dive4elements.artifactdatabase.DefaultArtifactFactory</artifact-factory> </artifact-factories> <user-factory name="default" description="Factory to create new users">org.dive4elements.artifactdatabase.DefaultUserFactory</user-factory>
--- a/artifacts/doc/conf/generators.xml Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/doc/conf/generators.xml Tue Oct 15 18:41:55 2013 +0200 @@ -84,6 +84,42 @@ <processor class="org.dive4elements.river.exports.process.ManualPointsProcessor" axis="Velocity"/> </output-generator> + <output-generator names="sq_relation_a,sq_relation_a_chartinfo" + class="org.dive4elements.river.exports.DiagramGenerator" + converter="org.dive4elements.river.exports.DiagramAttributes"> + <title key="chart.sq_relation_a.title" default=""/> + &sqrelation-defaults; + </output-generator> + <output-generator names="sq_relation_b,sq_relation_b_chartinfo" + class="org.dive4elements.river.exports.DiagramGenerator" + converter="org.dive4elements.river.exports.DiagramAttributes"> + <title key="chart.sq_relation_b.title" default=""/> + &sqrelation-defaults; + </output-generator> + <output-generator names="sq_relation_c,sq_relation_c_chartinfo" + class="org.dive4elements.river.exports.DiagramGenerator" + converter="org.dive4elements.river.exports.DiagramAttributes"> + <title key="chart.sq_relation_e.title" default=""/> + &sqrelation-defaults; + </output-generator> + <output-generator names="sq_relation_d,sq_relation_d_chartinfo" + class="org.dive4elements.river.exports.DiagramGenerator" + converter="org.dive4elements.river.exports.DiagramAttributes"> + <title key="chart.sq_relation_d.title" default=""/> + &sqrelation-defaults; + </output-generator> + <output-generator names="sq_relation_e,sq_relation_e_chartinfo" + class="org.dive4elements.river.exports.DiagramGenerator" + converter="org.dive4elements.river.exports.DiagramAttributes"> + <title key="chart.sq_relation_e.title" default=""/> + &sqrelation-defaults; + </output-generator> + <output-generator names="sq_relation_f,sq_relation_f_chartinfo" + class="org.dive4elements.river.exports.DiagramGenerator" + converter="org.dive4elements.river.exports.DiagramAttributes"> + <title key="chart.sq_relation_f.title" default=""/> + &sqrelation-defaults; + </output-generator> <output-generator names="duration_curve" class="org.dive4elements.river.exports.DurationCurveGenerator"/> <output-generator names="duration_curve_chartinfo" class="org.dive4elements.river.exports.DurationCurveInfoGenerator"/> <output-generator names="waterlevel_export" class="org.dive4elements.river.exports.WaterlevelExporter"/> @@ -114,18 +150,6 @@ <output-generator names="bed_difference_epoch" class="org.dive4elements.river.exports.minfo.BedDifferenceEpochGenerator"/> <output-generator names="bed_difference_epoch_chartinfo" class="org.dive4elements.river.exports.minfo.BedDiffEpochInfoGenerator"/> <output-generator names="bedheight_difference_export" class="org.dive4elements.river.exports.minfo.BedDifferenceExporter"/> - <output-generator names="sq_relation_a" class="org.dive4elements.river.exports.sq.SQRelationGeneratorA"/> - <output-generator names="sq_relation_b" class="org.dive4elements.river.exports.sq.SQRelationGeneratorB"/> - <output-generator names="sq_relation_c" class="org.dive4elements.river.exports.sq.SQRelationGeneratorC"/> - <output-generator names="sq_relation_d" class="org.dive4elements.river.exports.sq.SQRelationGeneratorD"/> - <output-generator names="sq_relation_e" class="org.dive4elements.river.exports.sq.SQRelationGeneratorE"/> - <output-generator names="sq_relation_f" class="org.dive4elements.river.exports.sq.SQRelationGeneratorF"/> - <output-generator names="sq_relation_a_chartinfo" class="org.dive4elements.river.exports.sq.SQRelationInfoGenerator"/> - <output-generator names="sq_relation_b_chartinfo" class="org.dive4elements.river.exports.sq.SQRelationInfoGenerator"/> - <output-generator names="sq_relation_c_chartinfo" class="org.dive4elements.river.exports.sq.SQRelationInfoGenerator"/> - <output-generator names="sq_relation_d_chartinfo" class="org.dive4elements.river.exports.sq.SQRelationInfoGenerator"/> - <output-generator names="sq_relation_e_chartinfo" class="org.dive4elements.river.exports.sq.SQRelationInfoGenerator"/> - <output-generator names="sq_relation_f_chartinfo" class="org.dive4elements.river.exports.sq.SQRelationInfoGenerator"/> <output-generator names="sq_relation_export" class="org.dive4elements.river.exports.sq.SQRelationExporter"/> <output-generator names="sq_overview" class="org.dive4elements.river.exports.sq.SQOverviewGenerator"/> <output-generator names="fix_parameters_export" class="org.dive4elements.river.exports.fixings.ParametersExporter"/>
--- a/artifacts/doc/conf/longitudinal-diagram-defaults.xml Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/doc/conf/longitudinal-diagram-defaults.xml Tue Oct 15 18:41:55 2013 +0200 @@ -37,4 +37,5 @@ <processor class="org.dive4elements.river.exports.process.SedimentLoadProcessor" axis="SedimentLoad"/> <processor class="org.dive4elements.river.exports.process.FlowVelocityProcessor" axis="Velocity"/> <processor class="org.dive4elements.river.exports.process.ShearStressProcessor" axis="Tau"/> + <processor class="org.dive4elements.river.exports.process.SedimentDensityProcessor" axis="Density"/> </longitudinal-defaults>
--- a/artifacts/doc/conf/meta-data.xml Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/doc/conf/meta-data.xml Tue Oct 15 18:41:55 2013 +0200 @@ -73,7 +73,6 @@ <dc:call-macro name="mainvalues"/> </dc:when> <dc:when test="$out = 'reference_curve'"> - <dc:call-macro name="annotations"/> <dc:call-macro name="mainvalues"/> </dc:when> <dc:when test="$out = 'fix_wq_curve'"> @@ -124,7 +123,7 @@ </dc:when> <dc:otherwise> <dc:comment> - Non - Recommendations. + Non - Recommendations (offered to user to choose additional data from). </dc:comment> <dc:iterate var="out" container="artifact-outs"> <dc:message>Non Rec out iteration for: {$out}</dc:message> @@ -141,19 +140,15 @@ </dc:when> <dc:when test="$out = 'longitudinal_section'"> <dc:call-macro name="longitudinal-section-prototype"/> - <dc:call-macro name="bedheight_differences"/> </dc:when> <dc:when test="$out = 'w_differences'"> <dc:call-macro name="longitudinal-section-prototype"/> - <dc:call-macro name="bedheight_differences"/> </dc:when> <dc:when test="$out = 'discharge_longitudinal_section'"> <dc:call-macro name="longitudinal-section-prototype"/> </dc:when> <dc:when test="$out = 'historical_discharge_wq'"> - <dc:call-macro name="historical_discharge_curve"/> - <dc:call-macro name="discharge_table_gauge"/> - <dc:call-macro name="basedata_2_fixations_wqkms"/> + <dc:call-macro name="discharge-curve-prototype"/> <dc:call-macro name="basedata_5_flood-protections"/> <dc:call-macro name="basedata_0"/> <dc:call-macro name="basedata_1_additionals"/> @@ -163,13 +158,9 @@ </computed_discharge_curve> </dc:when> <dc:when test="$out = 'discharge_curve'"> - <dc:call-macro name="historical_discharge_curve"/> - <dc:call-macro name="discharge_table_gauge"/> - <dc:call-macro name="basedata_2_fixations_wqkms"/> + <dc:call-macro name="discharge-curve-prototype"/> + <dc:call-macro name="basedata_1_additionals_wq"/> <dc:call-macro name="basedata_5_flood-protections"/> - <dc:call-macro name="basedata_0_wq"/> - <dc:call-macro name="basedata_1_additionals"/> - <dc:call-macro name="basedata_4_heightmarks-points"/> <computed_discharge_curve> <dc:call-macro name="mainvalues"/> </computed_discharge_curve> @@ -189,13 +180,10 @@ <dc:call-macro name="basedata_5_flood-protections_relative_points"/> </dc:when> <dc:when test="$out = 'fix_wq_curve'"> - <dc:call-macro name="historical_discharge_curve"/> - <dc:call-macro name="discharge_table_gauge"/> - <dc:call-macro name="basedata_0_wq"/> + <dc:call-macro name="discharge-curve-prototype"/> <dc:call-macro name="basedata_1_additionals_marks"/> <dc:call-macro name="basedata_2_fixations_wqkms"/> <dc:call-macro name="basedata_3_officials"/> - <dc:call-macro name="basedata_4_heightmarks-points"/> <dc:call-macro name="basedata_5_flood-protections_relative_points"/> </dc:when> <dc:when test="$out = 'fix_longitudinal_section_curve'"> @@ -205,49 +193,25 @@ <dc:call-macro name="flood-map-complete"/> </dc:when> <dc:when test="$out = 'flow_velocity'"> - <dc:call-macro name="annotations_per_type"/> - <dc:call-macro name="flow_velocity_measurements"/> + <dc:call-macro name="longitudinal-section-prototype"/> </dc:when> <dc:when test="$out = 'bed_longitudinal_section'"> - <dc:call-macro name="annotations_per_type"/> + <dc:call-macro name="longitudinal-section-prototype"/> </dc:when> <dc:when test="$out = 'sedimentload_ls'"> - <dc:call-macro name="annotations_per_type"/> - <dc:call-macro name="morph_width"/> + <dc:call-macro name="longitudinal-section-prototype"/> </dc:when> <dc:when test="$out = 'bedheight_middle'"> - <dc:call-macro name="sounding-width"/> - <dc:call-macro name="basedata_0"/> - <dc:call-macro name="basedata_1_additionals"/> - <dc:call-macro name="basedata_2_fixations"/> - <dc:call-macro name="basedata_3_officials"/> - <dc:call-macro name="annotations_per_type"/> + <dc:call-macro name="longitudinal-section-prototype"/> </dc:when> <dc:when test="$out = 'bed_difference_height_year'"> - <dc:call-macro name="basedata_0"/> - <dc:call-macro name="basedata_1_additionals"/> - <dc:call-macro name="basedata_2_fixations"/> - <dc:call-macro name="basedata_3_officials"/> - <dc:call-macro name="basedata_6_delta_w"/> - <dc:call-macro name="annotations_per_type"/> - <dc:call-macro name="morph_width"/> + <dc:call-macro name="longitudinal-section-prototype"/> </dc:when> <dc:when test="$out = 'bed_difference_year'"> - <dc:call-macro name="basedata_0"/> - <dc:call-macro name="basedata_1_additionals"/> - <dc:call-macro name="basedata_2_fixations"/> - <dc:call-macro name="basedata_3_officials"/> - <dc:call-macro name="basedata_6_delta_w"/> - <dc:call-macro name="annotations_per_type"/> - <dc:call-macro name="morph_width"/> + <dc:call-macro name="longitudinal-section-prototype"/> </dc:when> <dc:when test="$out = 'bed_difference_epoch'"> - <dc:call-macro name="basedata_0"/> - <dc:call-macro name="basedata_1_additionals"/> - <dc:call-macro name="basedata_2_fixations"/> - <dc:call-macro name="basedata_3_officials"/> - <dc:call-macro name="annotations_per_type"/> - <dc:call-macro name="morph_width"/> + <dc:call-macro name="longitudinal-section-prototype"/> </dc:when> <dc:when test="$out = 'floodmap'"> <dc:choose> @@ -282,13 +246,10 @@ </dc:choose> </dc:when> <dc:when test="$out = 'computed_discharge_curve'"> - <dc:call-macro name="historical_discharge_curve"/> - <dc:call-macro name="discharge_table_gauge"/> - <dc:call-macro name="basedata_2_fixations_wqkms"/> - <dc:call-macro name="basedata_5_flood-protections"/> + <dc:call-macro name="discharge-curve-prototype"/> <dc:call-macro name="basedata_0_wq"/> <dc:call-macro name="basedata_1_additionals_wq"/> - <dc:call-macro name="basedata_4_heightmarks-points"/> + <dc:call-macro name="basedata_5_flood-protections"/> <computed_discharge_curve> <dc:call-macro name="mainvalues"/> </computed_discharge_curve> @@ -320,6 +281,9 @@ <dc:call-macro name="basedata_5_flood-protections"/> </dc:if> </dc:when> + <dc:when test="starts-with($out, 'sq_relation')"> + <dc:call-macro name="sqrelations"/> + </dc:when> </dc:choose> </dc:iterate> </dc:otherwise> @@ -347,24 +311,12 @@ </dc:when> <dc:otherwise> <dc:comment> - Non Recommendations (user) + Non Recommendations (user) - offer to load other projects </dc:comment> <dc:iterate var="out" container="artifact-outs"> <dc:choose> <dc:when test="$out = 'longitudinal_section'"> - <dc:call-macro name="longitudinal"/> - <dc:call-macro name="differences"/> - <dc:call-macro name="bedheight_differences"/> - <dc:call-macro name="bedquality-bed"/> - <dc:call-macro name="bedquality-load"/> - <dc:call-macro name="flow-velocity"/> - <dc:call-macro name="sediment-load"/> - <dc:call-macro name="bedquality-density"/> - <dc:call-macro name="bedquality-porosity"/> - <dc:call-macro name="waterlevels-discharge"/> - <dc:call-macro name="differenceable-fix"/> - <dc:call-macro name="delta-wt-ls"/> - <dc:call-macro name="longitudinal-section"/> + <dc:call-macro name="longitudinal-section-user-prototype"/> </dc:when> <dc:when test="$out = 'discharge_longitudinal_section'"> <dc:call-macro name="longitudinal"/> @@ -375,6 +327,12 @@ <dc:call-macro name="differences"/> <dc:call-macro name="bedheight_differences"/> </dc:when> + <dc:when test="$out = 'computed_discharge_curve'"> + <dc:call-macro name="computed-discharge-curve"/> + <dc:call-macro name="fix-wq-curve"/> + <dc:call-macro name="discharge-curve"/> + <dc:call-macro name="extreme-wq-curve"/> + </dc:when> <dc:when test="$out = 'fix_deltawt_curve'"> <dc:call-macro name="delta-wt"/> </dc:when> @@ -580,8 +538,8 @@ <dc:macro name="longitudinal"> <dc:filter expr="$out_name = 'longitudinal_section'"> <dc:if test="dc:has-result()"> - <waterlevels> - <dc:group expr="concat($river, ' ', dc:date-format('dd.MM.yyyy - H:mm:ss', $a_creation))"> + <waterlevels_ls> + <dc:group expr="concat($river, ' ', dc:date-format('dd.MM.yyyy - H:mm:ss', $a_creation), ' ', $collection_name)"> <dc:comment>Aheinecke: Why is this grouping different from the rest?</dc:comment> <longitudinal_section_columns description="{dc:group-key()}"> <dc:for-each> @@ -596,19 +554,19 @@ </dc:for-each> </longitudinal_section_columns> </dc:group> - </waterlevels> + </waterlevels_ls> </dc:if> </dc:filter> </dc:macro> - <dc:macro name="longitudinal-section"> + <dc:macro name="longitudinal-section-fix"> <dc:filter expr="$out_name = 'fix_longitudinal_section_curve' and (starts-with($facet_name, 'fix_deviation_ls') or starts-with($facet_name, 'fix_sector_average_ls') or starts-with($facet_name, 'fix_analysis_events_ls') or starts-with($facet_name, 'fix_reference_events_ls'))"> <dc:if test="dc:has-result()"> - <waterlevels> + <waterlevels_fix> <dc:group expr="concat($river, ' ', dc:date-format('dd.MM.yyyy - H:mm:ss', $a_creation), ' ', $collection_name)"> <waterlevels description="{dc:group-key()}"> <dc:for-each> @@ -623,7 +581,7 @@ </dc:for-each> </waterlevels> </dc:group> - </waterlevels> + </waterlevels_fix> </dc:if> </dc:filter> </dc:macro> @@ -731,6 +689,64 @@ </dc:filter> </dc:macro> + + <dc:macro name="discharge-curve"> + <dc:filter expr="$facet_name = 'discharge_curve.curve'"> + <dc:if test="dc:has-result()"> + <discharge_curves> + <dc:for-each> + <dc:element name="${facet_name}"> + <dc:attribute name="description" value="${facet_description}"/> + <dc:attribute name="factory" value="winfo"/> + <dc:attribute name="target_out" value="${out}"/> + <dc:attribute name="artifact-id" value="${a_gid}"/> + <dc:attribute name="ids" value="${a_gid}"/> + <dc:attribute name="out" value="discharge_curve"/> + </dc:element> + </dc:for-each> + </discharge_curves> + </dc:if> + </dc:filter> + </dc:macro> + + <dc:macro name="extreme-wq-curve"> + <dc:filter expr="$facet_name = 'extreme_wq_curve'"> + <dc:if test="dc:has-result()"> + <computed_discharge_curves> + <dc:for-each> + <dc:element name="${facet_name}"> + <dc:attribute name="description" value="${facet_description}"/> + <dc:attribute name="factory" value="fixanalysis"/> + <dc:attribute name="target_out" value="${out}"/> + <dc:attribute name="artifact-id" value="${a_gid}"/> + <dc:attribute name="ids" value="${a_gid}"/> + <dc:attribute name="out" value="computed_discharge_curve"/> + </dc:element> + </dc:for-each> + </computed_discharge_curves> + </dc:if> + </dc:filter> + </dc:macro> + + <dc:macro name="computed-discharge-curve"> + <dc:filter expr="$facet_name = 'computed_discharge_curve.q'"> + <dc:if test="dc:has-result()"> + <computed_discharge_curves> + <dc:for-each> + <dc:element name="${facet_name}"> + <dc:attribute name="description" value="${facet_description}"/> + <dc:attribute name="factory" value="winfo"/> + <dc:attribute name="target_out" value="${out}"/> + <dc:attribute name="artifact-id" value="${a_gid}"/> + <dc:attribute name="ids" value="${a_gid}"/> + <dc:attribute name="out" value="computed_discharge_curve"/> + </dc:element> + </dc:for-each> + </computed_discharge_curves> + </dc:if> + </dc:filter> + </dc:macro> + <dc:macro name="duration-curve"> <dc:filter expr="$facet_name = 'duration_curve.q' or $facet_name = 'duration_curve.w'"> <dc:if test="dc:has-result()"> @@ -1049,8 +1065,8 @@ <dc:macro name="waterlevels-discharge"> <dc:filter expr="$out_name = 'discharge_longitudinal_section' and $facet_name = 'discharge_longitudinal_section.w'"> <dc:if test="dc:has-result()"> - <waterlevels-discharge> - <dc:group expr="concat($oid, ' ', $river, ' ', $a_gid, ' ', dc:date-format('dd.MM.yyyy - H:mm:ss', $a_creation), ' ', $collection_name)"> + <waterlevels_discharge> + <dc:group expr="concat($river, ' ', dc:date-format('dd.MM.yyyy - H:mm:ss', $a_creation), ' ', $collection_name)"> <discharge description="{dc:group-key()}"> <dc:for-each> <dc:element name="${facet_name}"> @@ -1064,7 +1080,7 @@ </dc:for-each> </discharge> </dc:group> - </waterlevels-discharge> + </waterlevels_discharge> </dc:if> </dc:filter> </dc:macro> @@ -1212,6 +1228,14 @@ </dc:filter> </dc:macro> + <dc:macro name="discharge-curve-prototype"> + <dc:call-macro name="discharge_table_gauge"/> + <dc:call-macro name="historical_discharge_curve"/> + <dc:call-macro name="basedata_0_wq"/> + <dc:call-macro name="basedata_2_fixations_wqkms"/> + <dc:call-macro name="basedata_4_heightmarks-points"/> + </dc:macro> + <dc:macro name="longitudinal-section-prototype"> <dc:call-macro name="basedata_0"/> <dc:call-macro name="basedata_1_additionals"/> @@ -1221,69 +1245,184 @@ <dc:call-macro name="basedata_5_flood-protections"/> <dc:call-macro name="annotations_per_type"/> <minfo> - <dc:call-macro name="basedata_6_delta_w"/> - <dc:call-macro name="basedata_7_waterlevels"/> + <fixanalysis> + <dc:call-macro name="basedata_6_delta_w"/> + <dc:call-macro name="basedata_7_waterlevels"/> + </fixanalysis> + <dc:call-macro name="yields"/> + <dc:call-macro name="densities"/> <dc:call-macro name="minfo-heights"/> <dc:call-macro name="sounding-width"/> - <dc:call-macro name="yields"/> + <dc:call-macro name="morph_width"/> + <dc:call-macro name="flow_velocity_measurements"/> + <dc:call-macro name="flow_velocity_models"/> </minfo> </dc:macro> + <dc:macro name="longitudinal-section-user-prototype"> + <dc:call-macro name="longitudinal"/> + <dc:call-macro name="differences"/> + <dc:call-macro name="bedheight_differences"/> + <dc:call-macro name="bedquality-bed"/> + <dc:call-macro name="bedquality-load"/> + <dc:call-macro name="flow-velocity"/> + <dc:call-macro name="sediment-load"/> + <dc:call-macro name="bedquality-density"/> + <dc:call-macro name="bedquality-porosity"/> + <dc:call-macro name="waterlevels-discharge"/> + <dc:call-macro name="differenceable-fix"/><!-- TODO double entries? --> + <dc:call-macro name="delta-wt-ls"/> + <dc:call-macro name="longitudinal-section-fix"/> + <dc:call-macro name="discharge-curve"/> + </dc:macro> + + + <dc:macro name="densities"> + <densities> + <dc:context> + <dc:statement> + SELECT DISTINCT + sd.id AS sdid, + sd.description AS description, + d.lower AS depth_lower, + d.upper AS depth_upper + FROM sediment_density sd + JOIN rivers r ON sd.river_id = r.id + JOIN depths d ON sd.depth_id = d.id + WHERE r.id = ${river_id} + </dc:statement> + <dc:if test="dc:has-result()"> + <dc:for-each> + <density description="{$description}" + factory="sedimentdensity" + target_out="{$out}" + info="infome" + ids="{$sdid}" /> + </dc:for-each> + </dc:if> + </dc:context> + </densities> + </dc:macro> + + <dc:macro name="one-load"> + <dc:for-each> + <dc:variable name="syear" type="string" expr="dc:date-format('yyyy', $year)"/> + <year description="{$syear}" + factory="sedimentyield" + target_out="{$out}" + info="{$description}" + ids="{$syid}" /> + </dc:for-each> + </dc:macro> + + <dc:macro name="epoch-load"> + <dc:for-each> + <dc:variable name="syear" type="string" expr="dc:date-format('yyyy', $startyear)"/> + <dc:variable name="eyear" type="string" expr="dc:date-format('yyyy', $endyear)"/> + <year description="{$syear}-{$eyear}" + factory="sedimentyield" + target_out="{$out}" + info="{$description}" + ids="{$syid}" /> + </dc:for-each> + </dc:macro> + + <dc:macro name="loads"> + <dc:if test="dc:has-result()"> + <dc:filter expr="$fraction='sand'"> + <dc:if test="dc:has-result()"> + <sand> + <dc:macro-body/> + </sand> + </dc:if> + </dc:filter> + <dc:filter expr="$fraction='fine_middle'"> + <dc:if test="dc:has-result()"> + <fine_middle> + <dc:macro-body/> + </fine_middle> + </dc:if> + </dc:filter> + <dc:filter expr="$fraction='coarse'"> + <dc:if test="dc:has-result()"> + <coarse> + <dc:macro-body/> + </coarse> + </dc:if> + </dc:filter> + <dc:filter expr="$fraction='suspended_sediment'"> + <dc:if test="dc:has-result()"> + <susp_sediment> + <dc:macro-body/> + </susp_sediment> + </dc:if> + </dc:filter> + <dc:filter expr="$fraction='susp_sand'"> + <dc:if test="dc:has-result()"> + <susp_sand> + <dc:macro-body/> + </susp_sand> + </dc:if> + </dc:filter> + <dc:filter expr="$fraction='susp_sand_bed'"> + <dc:if test="dc:has-result()"> + <susp_sand_bed> + <dc:macro-body/> + </susp_sand_bed> + </dc:if> + </dc:filter> + </dc:if> + </dc:macro> + <dc:macro name="yields"> <yields> <years> <dc:context> <dc:statement> SELECT DISTINCT - sy.id AS syid, + sy.id AS syid, sy.description AS description, - ti.start_time AS year + ti.start_time AS year, + gf.name AS fraction FROM sediment_yield sy JOIN rivers r ON sy.river_id = r.id JOIN sediment_yield_values syv ON sy.id = syv.sediment_yield_id JOIN time_intervals ti ON sy.time_interval_id = ti.id - WHERE r.name = 'Elbe' + JOIN grain_fraction gf ON gf.id = sy.grain_fraction_id + WHERE r.id = ${river_id} AND ti.stop_time IS NULL AND syv.station BETWEEN ${fromkm} AND ${tokm} + ORDER BY fraction </dc:statement> - <dc:if test="dc:has-result()"> - <dc:for-each> - <year description="{$description}" - factory="sedimentyield" - target_out="{$out}" - info="infome" - ids="{$syid}" /> - </dc:for-each> - </dc:if> + <dc:call-macro name="loads"> + <dc:call-macro name="one-load"/> + </dc:call-macro> </dc:context> </years> <epochs> <dc:context> <dc:statement> SELECT DISTINCT - sy.id AS syid, + sy.id AS syid, sy.description AS description, - ti.start_time AS year + ti.start_time AS startyear, + ti.stop_time AS endyear, + gf.name AS fraction FROM sediment_yield sy JOIN rivers r ON sy.river_id = r.id JOIN sediment_yield_values syv ON sy.id = syv.sediment_yield_id JOIN time_intervals ti ON sy.time_interval_id = ti.id - WHERE r.name = 'Elbe' + JOIN grain_fraction gf ON gf.id = sy.grain_fraction_id + WHERE r.id = ${river_id} AND ti.stop_time IS NOT NULL AND syv.station BETWEEN ${fromkm} AND ${tokm} + ORDER BY fraction </dc:statement> - <dc:if test="dc:has-result()"> - <dc:for-each> - <epoch description="{$description}" - factory="sedimentyield" - target_out="{$out}" - info="infome" - ids="{$syid}" /> - </dc:for-each> - </dc:if> + <dc:call-macro name="loads"> + <dc:call-macro name="epoch-load"/> + </dc:call-macro> </dc:context> </epochs> - </yields> </dc:macro> @@ -1488,18 +1627,28 @@ <single> <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} - AND lower(description) NOT LIKE '%epoch%' + SELECT bhs.id AS bedh_id, + bhs.year AS bedh_year, + bhs.description AS bedh_descr, + bht.name AS type_name + FROM bed_height_single bhs + JOIN bed_height_type bht ON bht.id = bhs.type_id + WHERE bhs.river_id = ${river_id} + AND lower(bhs.description) NOT LIKE '%epoch%' </dc:statement> - <dc:for-each> - <height factory="bedheight" target_out="{$out}" - ids="bedheight-single-{$bedh_id}-{$bedh_year}" - description="{$bedh_descr}"/> - </dc:for-each> + <dc:if test="dc:has-result()"> + <dc:group expr="$bedh_year"> + <cross-sections name="{dc:group-key()}"> + <dc:for-each> + <height factory="bedheight" + target_out="{$out}" + ids="bedheight-single-{$bedh_id}-{$bedh_year}" + info="{$type_name}" + description="{$bedh_descr}"/> + </dc:for-each> + </cross-sections> + </dc:group> + </dc:if> </dc:context> </single> </dc:macro> @@ -1524,6 +1673,28 @@ </epoch> </dc:macro> + <dc:macro name="flow_velocity_models"> + <dc:context> + <dc:statement> + SELECT fvm.id AS fvmid, + fvm.description AS fvmd + FROM flow_velocity_model fvm + JOIN discharge_zone dz ON dz.id = fvm.discharge_zone_id + WHERE dz.river_id = ${river_id} + </dc:statement> + <dc:if test="dc:has-result()"> + <flowvelocitymodel> + <dc:for-each> + <measurement_value name="{$fvmd}" + ids="{$fvmid}" + factory="flowvelocitymodel" target_out="{$out}" /> + </dc:for-each> + </flowvelocitymodel> + </dc:if> + </dc:context> + </dc:macro> + + <dc:macro name="flow_velocity_measurements"> <dc:context> <dc:statement> @@ -1607,6 +1778,40 @@ </dc:context> </dc:macro> + <dc:macro name="sqrelations"> + <dc:context> + <dc:statement> + SELECT sq.description AS description, + ti.start_time AS start_time, + ti.stop_time AS stop_time, + ms.name AS station_name, + lower(sqv.parameter) AS parameter, + sqv.id AS sqvid + FROM sq_relation sq + JOIN time_intervals ti ON ti.id = sq.time_interval_id + JOIN rivers r ON r.id = sq.river_id + JOIN sq_relation_value sqv ON sqv.sq_relation_id = sq.id + JOIN measurement_station ms ON sqv.measurement_station_id = ms.id + WHERE r.id = ${river_id} + </dc:statement> + <dc:if test="dc:has-result()"> + <sq_relations> + <dc:filter expr="$out = concat('sq_relation_', $parameter)"> + <dc:group expr="$station_name"> + <station description="{dc:group-key()}"> + <dc:for-each> + <dc:variable name="combined_desc" expr="concat(dc:date-format('yyyy', $start_time), ' bis ', dc:date-format('yyyy', $stop_time))"/> + <sqvalue factory="staticsqrelation" target_out="{$out}" + ids="{$sqvid};{$station_name}: {$combined_desc}" description="{$combined_desc}"/> + </dc:for-each> + </station> + </dc:group> + </dc:filter> + </sq_relations> + </dc:if> + </dc:context> + </dc:macro> + <dc:macro name="basedata_0_macro"> <dc:filter expr="$kind = 0"> <dc:if test="dc:has-result()"> @@ -1675,6 +1880,15 @@ </dc:call-macro> </dc:macro> + <dc:macro name="basedata_1_additionals_wq"> + <dc:call-macro name="basedata_1_additionals_macro"> + <column name="{$wst_column_name}" + ids="base_data-wstv-{$wst_column_position}-{$wst_id}" + factory="wqinterpol" target_out="{$out}" + info="{$info} [km {$deffrom} - {$defto}]"/> + </dc:call-macro> + </dc:macro> + <!-- Floodmap part --> <dc:macro name="flood-map-complete"> <dc:call-macro name="flood-map-buildings"/> @@ -1709,18 +1923,6 @@ <dc:call-macro name="flood-map-hydr-boundaries-state"/> </dc:macro> - <dc:macro name="flood-map-recommended"> - <dc:comment> - FIXME: Following two macros look identical to me. - </dc:comment> - <kilometrage> - <riveraxis factory="riveraxis" ids="{$river_id}" target_out="{$out}" /> - </kilometrage> - <rastermap> - <background factory="wmsbackground" ids="{$river_id}" target_out="{$out}" /> - </rastermap> - </dc:macro> - <dc:macro name="flood-map-dem"> <dems> <dc:context>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/artifacts/doc/conf/sqrelation-diagram-defaults.xml Tue Oct 15 18:41:55 2013 +0200 @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<longitudinal-defaults> + <axis name="Transport" logarithmic="true"/> + <domain-axis key="chart.sq_relation.xaxis.label" default="" logarithmic="true"/> + <processor class="org.dive4elements.river.exports.process.SQRelationProcessor" axis="Transport"/> + <processor class="org.dive4elements.river.exports.process.ManualPointsProcessor" + axis="Transport"/> + <subtitle key="chart.computed.discharge.curve.subtitle" default="-"> + <arg expr="artifact.river"/> + <arg expr="artifact.ld_locations" type="double"/> + </subtitle> +</longitudinal-defaults> +
--- a/artifacts/doc/conf/themes/default.xml Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/doc/conf/themes/default.xml Tue Oct 15 18:41:55 2013 +0200 @@ -2163,4 +2163,13 @@ <field name="linecolor" type="Color" default="0, 0, 0" /> </fields> </theme> + + <theme name="MySQCurve"> + <inherits> + <inherit from="SQCurve" /> + </inherits> + <fields> + <field name="linecolor" type="Color" default="255, 0, 0" /> + </fields> + </theme> </themegroup>
--- a/artifacts/doc/conf/themes/second.xml Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/doc/conf/themes/second.xml Tue Oct 15 18:41:55 2013 +0200 @@ -84,6 +84,8 @@ display="Punktbeschriftung anzeigen" default="false" hints="hidden" /> <field name="linecolor" type="Color" display="Linienfarbe" default="204, 204, 204" /> + <field name="textorientation" type="boolean" display="Textausrichtung" + default="true" /> </fields> </theme> @@ -116,6 +118,19 @@ </fields> </theme> + <theme name="WQKmsHorizontal"> + <inherits> + <inherit from="WQKms" /> + </inherits> + <fields> + <field name="linecolor" type="Color" display="Linienfarbe" + default="204, 204, 204" /> + <field name="textorientation" type="boolean" display="Textausrichtung" + default="true" /> + </fields> + </theme> + + <theme name="WQPoints"> <inherits> <inherit from="Points" /> @@ -2148,4 +2163,13 @@ <field name="linecolor" type="Color" default="0, 0, 0" /> </fields> </theme> + + <theme name="MySQCurve"> + <inherits> + <inherit from="SQCurve" /> + </inherits> + <fields> + <field name="linecolor" type="Color" default="255, 0, 0" /> + </fields> + </theme> </themegroup>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/artifacts/doc/datacage_ref_de.rst Tue Oct 15 18:41:55 2013 +0200 @@ -0,0 +1,530 @@ +========= +Datenkorb +========= + + +.. contents:: Inhalt + +Übersicht +--------- + +Daten +----- +Im Datenkorb stehen zwei Arten von Daten zur Auswertung zur Verfügung. + +``Datensätze`` +~~~~~~~~~~~~~~ +Datensätze sind Tabellen mit benannten Spalten. Sie werden von Datenquellen +erzeugt und in einem Stapel verwaltet. Die konkreten Werte stehen erst durch +Auffaltung als Variablen zur Verfügung. + + +``Variablen`` +~~~~~~~~~~~~~ +Variablen sind die Werte, die aktuell zur Auswertung zur Verfügung stehen. Sie haben +einen Namen und einen Typ (String, Zahl, durch Datenquelle bestimmt). + +Textersatz +---------- +Um die Wertebelegungen in das Ausgabedokument schreiben zu kann an entsprechenden +Stellen eine String-Interpolation durchgeführt werden. +Hier finden zwei Arten von Textersatz ihren Einsatz. + +``${}-Ersetzungen`` +~~~~~~~~~~~~~~~~~~~ +Die ältere Variante. Innerhalb von Strings werden hier nur Variablen aufgelöst. +Beispiel: "**Hallo, ${planet}!**" wird bei planet = 'Welt' zu "**Hallo, Welt!**". + +``{$}-Ersetzungen`` +~~~~~~~~~~~~~~~~~~~ +Die neuere Variante, allerdings noch nicht komplett an allen Stellen einsatzfähig. +Innerhalb der geschweiften Klammern können beliebige XPath-Ausdrück stehen, die +zu Strings evaluiert werden. Dies orientiert sich an den String-Auswertungen in XSLT. +"**{ concat($greet, ', ', $planet, '!') }**" wird bei gesetzten Variablen greet = Hallo +und planet = "Welt" zu **Hallo, Welt!** ausgewertet. + +Datenkorb-Elemente +------------------ + +Datensätze erzeugen +~~~~~~~~~~~~~~~~~~~ + +``dc:context`` Aufspannen eines Gültigkeitsbereiches eines Datenbankdatensatz +............................................................................. + +.. code:: xml + + <dc:context connection="Verbindung"> + ... + </dc:element> + +Spannt einen Gültigkeitsbereich für einen Datensatz auf, der aus der Datenbank +kommt. Die adressierte Datenbank wird über das optionale Attribut 'connection' +bestimmt. Zur Zeit sind drei Datenbanken angebunden: + +- **user**: Die Index-Datenbank des Artefakt-Servers. Hierüber stehen Meta-Informationen + zu alten Berechnungen zur Verfügung. + +- **system**: Die FLYS-Datenbank mit den hydrologischen, morphologische und geodätischen + Daten. + +- **seddb**: Die Sediment-Datenbank. + +In einem `<dc:context>`-Element wird zwingend ein `<dc:statement>`-Element erwartet, +um einen Datensatz aus der Datenbank zu holen. Dieser Datensatz steht dann innerhalb des +`<dc:context>`-Elementes ein oder mehrfach zur Verfügung. Innerhalb eines +`<dc:context>`-Elementes können weitere `<dc:context>`-Elemente eingeschachtelt werden. +Ist kein 'connection'-Attribut vorhanden, wird die Datenbank-Verbindung des umgebenen +Kontextes weiterbenutzt. Initial wird je nach Aufrufart der Datenkorbs entweder +der **user** oder **system**-Kontext angenommen. Dies richtet sich danach, ob in +der Aufrufumgebung eine Artefakt gesetzt wird oder nicht. Im ersten Fall wird +angenommen, dass es sich um einen Ladevorgang für zusätzliche Daten handelt, die +auch alte Berechnungen mit einschliesst. + + +``dc:statement`` Holen eines Datensatzes aus einer Datenbank +............................................................ + +.. code:: xml + + <dc:statement> + SQL-Select-Statement. + </dc:element> + +Mittels eines SQL-Select-Statements werden in einem `<dc:context>`-Elementes aus +der dort definierten Datenbank geholt. Die Spaltennamen der Projektion des SQL-Statements +werden übernommen und später beim Auffalten des Datensatzes benutzt. + +``dc:container-context`` **TODO** + +``dc:properties`` **TODO** + +``dc:virtual-column`` Virtuelle Spalten definieren +.................................................. + +.. code:: xml + + <dc:virtual-column name="Name" type="Type" expr="XPath-Ausdruck"> + ... + </dc:virtual-column> + +Definiert eine neue, virtuelle Spalte namens Name für den aktuellen Datensatz. +Der Typ wird optional durch Typ festgelegt; ohne Angabe wird der Typ String angenommen. +Die Wertebelegung ergibt sich aus der zeilenweisen Auswertung des XPath-Ausdrucks. + +Dies sei an folgendem Beispiel illustriert: + + +----+ + +Zahl+ + +====+ + + 1+ + +----+ + + 2+ + +----+ + + 3+ + +----+ + +.. code:: xml + + <dc:virtual-column name="Quadrat" type="number" expr="$Zahl * $Zahl"> + ... + </dc:virtual-column> + +Erzeugt einen neuen Datensatz folgender Struktur: + + +----+-------+ + +Zahl+Quadrat+ + +====+=======+ + + 1+ 1+ + +----+-------+ + + 2+ 4+ + +----+-------+ + + 3+ 9+ + +----+-------+ + +Innerhalb eines `virtual-column`-Elementes kann der Datensatz mittel `dc:for-each` wie +gewohnt realisiert werden. Wird das `dc:virtual-column`-Element verlassen, gilt wieder +der vormalige Datensatz ohne die zusätzlich Spalte. + +Datensätze einschränken +~~~~~~~~~~~~~~~~~~~~~~~ + +``dc:filter`` Selektieren einzelner Zeilen aus dem aktuellen Datensatz +...................................................................... + +.. code:: xml + + <dc:filter expr="XPath-Ausdruck"> + ... + </dc:filter> + +Evaluiert pro Zeile des aktuellen Datensatzes den XPath-Ausdruck 'expr' und erzeugt +einen neuen Datensatz, der nur die Zeilen des Originaldatensatzes enthält für den +die Auswertung logisch wahr ergab. Im XPath-Ausdruck stehen die aufgefalteten Werte +der jeweiligen Zeile zur Verfügung. + +Folgends Beispiel soll dies verdeutlichen: + + +----+ + +Zahl+ + +====+ + + 1+ + +----+ + + 2+ + +----+ + + 3+ + +----+ + + 4+ + +----+ + +Zahlen erhalten, die einen Wert kleiner drei haben. + +.. code:: xml + + <dc:filter expr="$Zahl < 3"> + ... + <dc:filter> + +Dies erzeugt folgenden neuen Datensatz: + + +----+ + +Zahl+ + +====+ + + 1+ + +----+ + + 2+ + +----+ + +Innerhalb des `dc:filter`-Elementes kann der neue Datensatz wie gewohnt mit `dc:for-each` +realisiert werden. Nach Verlassen des `dc:filter`-Elementes ist wieder der vormalige +Datensatz aktuell. + +``dc:group`` Datensätzen in Gruppen ordnen +.......................................... + +.. code:: xml + + <dc:group expr="XPath-Ausdruck"> + ... + </dc:group> + +Pro Zeile der Originaldatensatzes wird der XPath-Ausdruck 'expr' ausgewertet. +Wie bei `dc:filter` stehen hier die aufgefalteten Werte der einzelnen Spalten zur +Verfügung. Das Resultat der XPath-Auswertung wird als Schlüssel für zu erzeugende +Gruppen benutzt, denen dann die Zeilen zugeordnet werden. +Nachdem alle Zeilen ihren entsprechenden Gruppen zugeordnet wurden, wir der +Inhalt des `dc:group`-Elements für jede Gruppe durchlaufen. Innerhalb des +`dc:group`-Elementes steht der jeweilige Schlüssel der aktuellen Gruppe über +die Funktion `dc:group-key()` zur Auswertung zu Verfügung. Innerhalb der +jeweiligen Gruppen kann mittel `dc:for-each` der jeweilige Unterdatensatz +realisiert werden. + +Zur Verdeutlichung folgendes Beispiel: + + +-------+-----------+ + +Marke +Bezeichnung+ + +=======+===========+ + +Ferrari+Testarossa + + +-------+-----------+ + +Volvo +V40 + + +-------+-----------+ + +Volvo +780 + + +-------+-----------+ + +Ferrari+F40 + + +-------+-----------+ + +VW +Käfer + + +-------+-----------+ + +.. code:: xml + + <marken> + <dc:group expr="$Marke"> + <marke name="{dc:group-key()}"> + <dc:for-each> + <bezeichnung name="$Bezeichnung"/> + </dc:for-each> + </marke> + </dc:group> + </marken> + +Dies führt zu folgender Ausgabe: + +.. code:: xml + + <marken> + <marke name="Ferrari"> + <bezeichnung name="F40"/> + <bezeichnung name="Testarossa"/> + </marke> + <marke name="Volvo"> + <bezeichnung name="V40"/> + <bezeichnung name="780"/> + </marke> + <marke name="VW"> + <bezeichnung name="Käfer"/> + </marke> + </marken> + +Datensätze auffalten +~~~~~~~~~~~~~~~~~~~~ + +``dc:for-each`` Realisieren eines Datensatzes +............................................. + +.. code:: xml + + <dc:for-each> + ... + <dc:for-each> + +Erzeugt nacheinander alle zeilenweisen Realisationen des aktuellen Datensatzes. Die +einzelnen Spaltenwerte sind dann über Variablen erreichbar, die nach den Spaltenbezeichnern +des Datenstzes benannt sind. + +Folgendes Beispiel soll den Sachverhalt illustieren: + + +----+ + +Zahl+ + +====+ + + 1+ + +----+ + + 2+ + +----+ + + 3+ + +----+ + +.. code:: xml + + <zahlen> + <dc:for-each> + <zahl wert="$Zahl"/> + <dc:for-each> + </zahlen> + +Dies erzeugt folgende Ausgabe: + +.. code:: xml + + <zahlen> + <zahl wert="1"/> + <zahl wert="2"/> + <zahl wert="3"/> + </zahlen> + +``dc:iterate`` **TODO** + +Bedingte Ausführung +~~~~~~~~~~~~~~~~~~~ + +``<dc:if>`` Einfaches Wenn-Dann ohne Sonst-Fall +............................................... + +.. code:: xml + + <dc:if test="XPath-Ausdruck"> + ... + </dc:if> + +Der innere Teil wird nur dann betreten, wenn der XPath-Ausdruck zu +logisch wahr evaluiert wird. Dieses Konstrukt kennt keinen alternativen +Pfad, der betreten wird, falls der Ausdruck zu logisch falsch ausgewertet +wird. Wird dies benötigt, muss man ``<dc:choose>`` benutzen. +``<dc:if>`` ist in Symmetrie zu ``<xsl:if>`` von XSLT entworfen worden. + +``<dc:choose>`` Ketten von Wenn-Dann-Ausdrücken +............................................... + +.. code:: xml + + <dc:choose> + <dc:when test="XPath-Ausdruck 1"> ... </dc:when> + <dc:when test="XPath-Ausdruck 2"> ... </dc:when> + ... + <dc:otherwise> ... </dc:otherwise> + </dc:choose> + +Es werden der Reihe nach von oben nach unter die ``test``-XPath-Ausdrücke der ``dc:when``-Elemente ausgewertet. Evaluiert ein Ausdruck zu logisch wahr, wird der innere Teil des entsprechenden ``<dc:when>``-Elements betreten. Die verbliebenen +``<dc:when>``- und ``<dc:otherwise>``-Elemente werden dann ignoriert. Evaluiert +keiner der ``test``-Ausdrücke zu wahr, wird der innere Teil des +``<dc:otherwise>``-Elements betreten. +``<dc:choose>`` ist in Symmetrie zu ``<xsl:choose>`` von XSLT entworfen worden. + + + +Makros +~~~~~~ +Um innerhalb des Definitionsdokumentes Wiederholungen zu vermeiden, können sogenannte +Makros definiert werden, die dann von anderer Stellen aus eingefügt werden können. + +``dc:macro`` Wiederverwendbare Teile definieren +............................................... + +.. code:: xml + + <dc:macro name="Name"> + ... + </dc:macro> + +Definiert ein Makro namens Name. Nach der Definition ist dieses dann unter diesem +Namen global innerhalb des Definitionsdokumentes bekannt. Makros können geschachtelt +werden. Auch eingeschachtelte Makros sind global sichtbar. Die Makrodefinition und +ihre eingeschalteten Elemente werden nicht in das Ausgabedokument übernommen. + +``dc:call-macro`` Makros aufrufen + +.. code:: xml + + <dc:call-macro name="Name"> + +Ruft ein Makro names Name auf. Dieses muss mit `dc:macro` definiert sein. Die Reihenfolge +von Definition und Aufruf ist egal. + +``dc:macro-body`` Elemente an ein Makro übergeben +................................................. + +.. code:: xml + + <dc:macro name="Name"> + ... + <dc:macro-body/> + ... + </dc:macro> + +Um an Makros weitere Bausteine als Argument übergeben zu können, ist es optional +möglich innerhalb einer Makrodefinition ein Element `dc:macro-body` einzufügen. +Dieses Element expandiert sich zum Inhalt des `dc:call-macro`-Aufrufs. + +.. code:: xml + + <dc:call-macro name="Name">Inhalt von dc:macro-body</dc:call-macro> + +Zur Verdeutlichung ein konkretes Beispiel + +.. code:: xml + + <dc:macro name="Greetings"> + <Hallo> + <dc:macro-body/> + </Hallo> + </dc:macro> + + <dc:call-macro name="Greetings">Welt</dc:call-macro> + <dc:call-macro name="Greetings">Mond</dc:call-macro> + +Dies produziert folgende Ausgabe + +.. code:: xml + + <Hallo>Welt</Hallo> + <Hallo>Mond</Hallo> + +Das Haupteinsatzgebiet dieses Konstruktes ist die transparente Bereitstellung +von Kontexten, die dann verschiedentlich ausgewertet werden sollen. + +Sonstige Elemente +~~~~~~~~~~~~~~~~~ + +``dc:element`` Hinzufügen neuer Elemente in der Ausgabe +....................................................... + +.. code:: xml + + <dc:element name="Name"> + ... + </dc:element> + +Erzeugt ein Element namens Name. Für den Namen gelten die `${}-Ersetzungen`_. + + +``dc:attribute`` Hinzufügen neuer Attribute zum umgebenden Ausgabeelement +......................................................................... + +.. code:: xml + + <dc:attribute name="Name" value="Wert"/> + +Fügt dem umgebenden Ausgabeelement ein weiteres Attribut namens Name mit dem +Wert von Wert hinzu. Für Namen und Wert gelten die `${}-Ersetzungen`_. +Der Einsatz dieses Konstrukts findet häufig im Zusammenhang mit dc:element +seinen Einsatz, wenn es ein Ausgabeelement vollständig aus Variablenbelegungen +erstellt werden soll. + +``dc:comment`` Kommentare im Beschreibungsdokument +.................................................. + +.. code:: xml + + <dc:comment> + ... + </dc:comment> + +Ein Kommentar auf Ebene des Beschreibungsdokumentes, das keinerlei Ausgabe +im Ausgabedokument erzeugt. Eingeschachtelte Elemente werden ebenfalls nicht ausgewertet. +Im Gegensatz dazu werden die XML-typischen **<!-- Kommetare -->** in das Ausgabedokument übernommen! + + +``dc:message`` Ausgabe auf die Diagnoseausgabe (Log) +.................................................... + +.. code:: xml + + <dc:message> + Text für die Diagnose. + </dc:message> + +Gibt den Text innerhalb des Elementes aus Ausgabe im Log aus. Dies dient in erster Linie +dem Nachvollziehen von Aufrufen innerhalb des Datenkorbdokumentes. Für den Text gelten +die `{$}-Ersetzungen`_. + +``dc:variable`` Erzeugung einer kontext-lokalen Variablen +......................................................... + +.. code:: xml + + <dc:variable name="Name" type="Typ" expr="XPath-Ausdruck"/> + +Legt im aktuellen Kontext eine lokale Variable namens Name an. Diese hat den +Typ Typ und entsteht durch Auswertung des XPath-Ausdruck expr. Der Typ +ist optional. Wird dieser nicht gesetzt, wird das Ergebnis als String interpretiert. +Alternativ können hier die Werte 'number' für Zahlen, 'bool' für Boolean-Werte +benutzt werden. Für den Namen und den Typ gelten die `${}-Ersetzungen`_. +Wird der aktuellen `dc:context` verlassen, ist diese Variable nicht mehr definiert. + + +``dc:convert`` kontext-lokale Konvertierung von Variablen +......................................................... + +.. code:: xml + + <dc:convert name="Name" type="Typ"/> + +Konvertiert die Variable namens Name für die Gültigkeit des aktuellen Kontextes in +einen anderen Typ. Für Name und Typ gelten die `${}-Ersetzungen`_. Für die +Typen gilt das gleiche wie für die Typen von `dc:variable`. + + +Datenkorb-Funktionen +-------------------- + +``dc:contains`` **TODO** + +``dc:fromValue`` **TODO** + +``dc:toValue`` **TODO** + +``dc:replace`` **TODO** + +``dc:replace-all`` **TODO** + +``dc:has-result`` **TODO** + +``dc:group-key`` **TODO** + +``dc:date-format`` **TODO** + +``dc:dump-variables`` **TODO** + +``dc:get`` **TODO** + + +
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/BedHeightsArtifact.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/BedHeightsArtifact.java Tue Oct 15 18:41:55 2013 +0200 @@ -21,19 +21,21 @@ import org.dive4elements.artifacts.Artifact; import org.dive4elements.artifacts.CallMeta; import org.dive4elements.artifacts.common.utils.XMLUtils; +import org.dive4elements.river.artifacts.model.FacetTypes; import org.dive4elements.river.artifacts.model.minfo.BedHeightFacet; import org.dive4elements.river.artifacts.model.minfo.BedHeightFactory; import org.dive4elements.river.artifacts.states.StaticState; public class BedHeightsArtifact extends AbstractStaticStateArtifact +implements FacetTypes { /** The logger for this class. */ private static Logger logger = Logger.getLogger(BedHeightsArtifact.class); + /** Artifact name. */ private static final String NAME = "bedheights"; - private static final String STATIC_FACET_NAME = "bedheight"; static { // TODO: Move to configuration. @@ -44,7 +46,7 @@ public static final String STATIC_STATE_NAME = "state.additional_bedheights.static"; - /** Data Item name to know whether we are Heighmarks and reveive + /** Data Item name to know whether we are Heighmarks and receive * some data slightly different. */ public static final String DATA_HEIGHT_TYPE = "height_marks"; @@ -100,7 +102,7 @@ String bedHName = BedHeightFactory.getHeightName(btype, hId); Facet facet = new BedHeightFacet( - STATIC_FACET_NAME, bedHName, type); + BEDHEIGHT, bedHName, type); ArrayList<Facet> facets = new ArrayList<Facet>(1); facets.add(facet); @@ -135,6 +137,7 @@ // do not clone facets, etc. from master artifact logger.debug("initialize"); + importData((D4EArtifact)artifact, "river"); importData((D4EArtifact)artifact, "ld_from"); importData((D4EArtifact)artifact, "ld_to");
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/D4EArtifact.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/D4EArtifact.java Tue Oct 15 18:41:55 2013 +0200 @@ -52,6 +52,7 @@ import org.dive4elements.artifacts.common.utils.XMLUtils.ElementCreator; import org.dive4elements.river.artifacts.cache.CacheFactory; import org.dive4elements.river.artifacts.context.RiverContext; +import org.dive4elements.river.artifacts.context.RiverContextFactory; import org.dive4elements.river.artifacts.model.CalculationMessage; import org.dive4elements.river.artifacts.states.DefaultState; import org.dive4elements.river.artifacts.states.DefaultState.ComputeType; @@ -119,6 +120,13 @@ private String boundToOut; + /** + * Interface to a global facet filter. + */ + public interface FacetFilter { + boolean accept(String outName, String facetName); + } // interface FacetFilter + /** * The default constructor that creates an empty D4EArtifact. @@ -1279,7 +1287,7 @@ log.debug("State '" + stateId + "' has facets " + fs); } - List<Output> gen = generateOutputs(list, fs); + List<Output> gen = generateOutputs(list, filterFacets(fs)); if (debug) { log.debug("State '" + stateId + "' has " + gen.size() + " outs"); @@ -1288,6 +1296,40 @@ return gen; } + /** If we use a facet filter that bases the list of compatible facets + * on the output this artifact is bound to then this returns true */ + public boolean usesOutputFacetFilter() { + if (boundToOut == null || boundToOut.isEmpty()) { + return false; + } + + FacetFilter facetFilter = + (FacetFilter)RiverContextFactory.getGlobalContext() + .get(RiverContext.FACETFILTER_KEY); + + return facetFilter != null; + } + + /** If a global facet filter and a bounded out are defined + * use them to eliminate unwished facets. + */ + protected List<Facet> filterFacets(List<Facet> facets) { + if (!usesOutputFacetFilter()) { + return facets; + } + + FacetFilter facetFilter = + (FacetFilter)RiverContextFactory.getGlobalContext() + .get(RiverContext.FACETFILTER_KEY); + + List<Facet> result = new ArrayList<Facet>(facets.size()); + for (Facet facet: facets) { + if (facetFilter.accept(boundToOut, facet.getName())) { + result.add(facet); + } + } + return result; + } /** * Generate a list of outputs with facets from fs if type is found in list @@ -1297,14 +1339,21 @@ * @param fs List of facets */ protected List<Output> generateOutputs(List<Output> list, List<Facet> fs) { - List<Output> generated = new ArrayList<Output>(); - log.debug("generateOutputs for Artifact " + getName() + " " - + identifier()); - boolean debug = log.isDebugEnabled(); + List<Output> generated = new ArrayList<Output>(); + + if (debug) { + log.debug("generateOutputs for Artifact " + getName() + " " + + identifier()); + } + + boolean useFacetFilter = usesOutputFacetFilter(); + for (Output out: list) { - log.debug("check facets for output: " + out.getName()); + if (debug) { + log.debug("check facets for output: " + out.getName()); + } String outName = out.getName(); Output o = new DefaultOutput( outName, @@ -1325,13 +1374,9 @@ String type = f.getName(); /* Match the facets to the output configuration. - * This is only done when we are not already bound to an out. - * If we are bound we come from the datacage so the user has - * explicitly requested our nice and shiny facets. And who - * are we to deny them to him. */ - if (outTypes.contains(type) || - (boundToOut != null && - boundToOut.equals(outName))) { + * This is only done when we are not using the Output + * we are bound to to determine the compatible facets. */ + if (useFacetFilter || outTypes.contains(type)) { if (debug) { log.debug("Add facet " + f); }
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/FlowVelocityMeasurementArtifact.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/FlowVelocityMeasurementArtifact.java Tue Oct 15 18:41:55 2013 +0200 @@ -130,10 +130,22 @@ name += " - " + dateFormatter.format( flowVelocityMeasurement.getDatetime()); - Facet facet = new FlowVelocityMeasurementFacet( + // TODO naming/ i18N + Facet vFacet = new FlowVelocityMeasurementFacet( FLOW_VELOCITY_MEASUREMENT, - name); - fs.add(facet); + "v " + name); + fs.add(vFacet); + + Facet qFacet = new FlowVelocityMeasurementFacet( + FLOW_VELOCITY_DISCHARGE, + "q " + name); + fs.add(qFacet); + + Facet wFacet = new FlowVelocityMeasurementFacet( + FLOW_VELOCITY_WATERLEVEL, + "w " + name); + fs.add(wFacet); + addFacets(state.getID(), fs); addStringData(DATA_NAME, code); }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/FlowVelocityModelArtifact.java Tue Oct 15 18:41:55 2013 +0200 @@ -0,0 +1,248 @@ +/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde + * Software engineering by Intevation GmbH + * + * This file is Free Software under the GNU AGPL (>=v3) + * and comes with ABSOLUTELY NO WARRANTY! Check out the + * documentation coming with Dive4Elements River for details. + */ + +package org.dive4elements.river.artifacts; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.log4j.Logger; +import org.w3c.dom.Document; + +import org.dive4elements.artifactdatabase.state.DefaultOutput; +import org.dive4elements.artifactdatabase.state.Facet; +import org.dive4elements.artifactdatabase.state.FacetActivity; +import org.dive4elements.artifactdatabase.state.State; +import org.dive4elements.artifacts.Artifact; +import org.dive4elements.artifacts.ArtifactFactory; +import org.dive4elements.artifacts.CallMeta; +import org.dive4elements.artifacts.common.utils.XMLUtils; +import org.dive4elements.river.artifacts.model.Calculation; +import org.dive4elements.river.artifacts.model.CalculationResult; +import org.dive4elements.river.artifacts.states.DefaultState.ComputeType; +import org.dive4elements.river.model.FlowVelocityModel; +import org.dive4elements.river.artifacts.model.FlowVelocityCalculation; +import org.dive4elements.river.artifacts.model.FlowVelocityData; +import org.dive4elements.river.artifacts.model.FlowVelocityFacet; +import org.dive4elements.river.artifacts.states.StaticState; + +import org.dive4elements.river.artifacts.model.FacetTypes; + + +/** Artifact to access flow velocity models. */ +public class FlowVelocityModelArtifact +extends StaticD4EArtifact +implements FacetTypes +{ + /** The logger for this class. */ + private static Logger logger = + Logger.getLogger(FlowVelocityModelArtifact.class); + + /** Artifact key name. */ + private static final String NAME = "flowvelocitymodel"; + + /** Spawn only inactive facets. */ + static { + // TODO: Move to configuration. + FacetActivity.Registry.getInstance() + .register(NAME, FacetActivity.INACTIVE); + } + + /** Need to give the state an id. */ + public static final String STATIC_STATE_NAME = + "state.flowvelocitymodel.static"; + + /** One and only state to be in. */ + protected transient State state = null; + + protected String DATA_ID = "ID"; + + /** + * Trivial Constructor. + */ + public FlowVelocityModelArtifact() { + logger.debug("FlowVelocityModelArtifact.FlowVelocityModelArtifact"); + } + + + /** Get artifact key name. */ + @Override + public String getName() { + return NAME; + } + + + private Object getFlowVelocity() { + logger.debug("FlowVelocityModelArtifact.getFlowVelocity"); + Integer id = getDataAsInteger(DATA_ID); + + FlowVelocityModel model = FlowVelocityModel.getModel(id); + FlowVelocityData data = new FlowVelocityData(); + + // TODO rangeaccess + FlowVelocityCalculation.prepareData(data, model, 0d, 1000d); + + return new CalculationResult( + new FlowVelocityData[] {data} , new Calculation()); + } + + + /** Create a static state. */ + private State newState() { + return new StaticState(STATIC_STATE_NAME) { + public Object staticCompute(List<Facet> facets) { + return getFlowVelocity(); + } + }; + } + + + /** Create a new state with bogus output. */ + protected State spawnState() { + state = newState(); + List<Facet> fs = getFacets(STATIC_STATE_NAME); + DefaultOutput output = new DefaultOutput( + "general", + "general", + "image/png", + fs, + "chart"); + + state.getOutputs().add(output); + + return state; + } + + + /** + * Gets called from factory, to set things up. + */ + @Override + public void setup( + String identifier, + ArtifactFactory factory, + Object context, + CallMeta callMeta, + Document data) + { + logger.debug("FlowVelocityModelArtifact.setup"); + + state = newState(); + if (logger.isDebugEnabled()) { + logger.debug(XMLUtils.toString(data)); + } + + List<Facet> fs = new ArrayList<Facet>(); + + String code = getDatacageIDValue(data); + + if (code != null) { + //String name = FlowVelocityModel.getFlowVelocityModelDescription(Integer.valueOf(code)); + String name = "facet"; + Facet facet = new FlowVelocityFacet( + 0, + FLOW_VELOCITY_MAINCHANNEL, + name + "main", + ComputeType.ADVANCE, state.getID(), "hash" + ); + fs.add(facet); + Facet tauFacet = new FlowVelocityFacet( + 0, + FLOW_VELOCITY_TAU, + name+"tau", + ComputeType.ADVANCE, state.getID(), "hash" + ); + fs.add(tauFacet); + Facet qFacet = new FlowVelocityFacet( + 0, + FLOW_VELOCITY_DISCHARGE, + name+"q", + ComputeType.ADVANCE, state.getID(), "hash" + ); + fs.add(qFacet); + Facet tFacet = new FlowVelocityFacet( + 0, + FLOW_VELOCITY_TOTALCHANNEL, + name+"t", + ComputeType.ADVANCE, state.getID(), "hash" + ); + fs.add(tFacet); + addFacets(state.getID(), fs); + addStringData(DATA_ID, code); + } + else { + logger.error("No id given."); + } + + 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(getState()); + return states; + } + + + /** + * Get the "current" state (there is but one). + * @param cc ignored. + * @return the "current" (only possible) state. + */ + @Override + public State getCurrentState(Object cc) { + return getState(); + } + + + /** + * Get the only possible state. + * @return the state. + */ + protected State getState() { + return getState(null, null); + } + + + /** + * Get the state. + * @param context ignored. + * @param stateID ignored. + * @return the state. + */ + @Override + protected State getState(Object context, String stateID) { + return (state != null) + ? state + : spawnState(); + } + + + /** + * Called via setup. Overridden to avoid cloning all data. + * + * @param artifact The master-artifact. + */ + @Override + protected void initialize( + Artifact artifact, + Object context, + CallMeta meta) + { + logger.debug("FlowVelocityModelArtifact.initialize"); + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/SQRelationArtifact.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/SQRelationArtifact.java Tue Oct 15 18:41:55 2013 +0200 @@ -17,6 +17,7 @@ import org.dive4elements.artifactdatabase.data.DefaultStateData; import org.dive4elements.artifactdatabase.state.DefaultOutput; import org.dive4elements.artifactdatabase.state.Facet; +import org.dive4elements.artifacts.Artifact; import org.dive4elements.artifacts.ArtifactFactory; import org.dive4elements.artifacts.ArtifactNamespaceContext; import org.dive4elements.artifacts.CallMeta; @@ -28,7 +29,7 @@ public class SQRelationArtifact -extends AbstractStaticStateArtifact +extends StaticD4EArtifact { private static final Logger logger = Logger.getLogger(SQRelationArtifact.class); @@ -57,6 +58,17 @@ ) { logger.debug("SQRelationArtifact.setup()"); + String code = getDatacageIDValue(data); + + logger.debug("SQRelationDCArtifact.setup Id: " + code); + + if (code != null && !code.isEmpty()) { + /* Case that we were instantiated from the datacage */ + addStringData("ids", code); + super.setup(identifier, factory, context, callmeta, data); + return; + } + String river = XMLUtils.xpathString( data, XPATH_RIVER, @@ -81,14 +93,26 @@ "String", station)); super.setup(identifier, factory, context, callmeta, data); + // When we are in this case we did not come from the datacage + // e.g. had an ID string set. So we also did not have a template + // set and initialize is not called. So we have to do this ourself. + initialize(this, context, callmeta); } @Override - protected void initStaticState() { + protected void initialize( + Artifact artifact, + Object context, + CallMeta callMeta + ) { StaticState state = new SQStaticState(STATIC_STATE_NAME); List<Facet> fs = new ArrayList<Facet>(); - state.staticCompute(fs, this); + state.computeInit(this, hash(), context, callMeta, fs); + logger.debug("Init static state computed facets"); + for (Facet face: fs) { + logger.debug("Got a facet with name: " + face.getName()); + } if (hasParameter(StaticSQRelation.Parameter.A, fs)) { DefaultOutput outputA = new DefaultOutput( @@ -145,8 +169,6 @@ state.addOutput(outputF); } addFacets(STATIC_STATE_NAME, fs); - state.setUIProvider(UIPROVIDER); - setStaticState(state); } @Override
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/SedimentDensityArtifact.java Tue Oct 15 18:41:55 2013 +0200 @@ -0,0 +1,219 @@ +/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde + * Software engineering by Intevation GmbH + * + * This file is Free Software under the GNU AGPL (>=v3) + * and comes with ABSOLUTELY NO WARRANTY! Check out the + * documentation coming with Dive4Elements River for details. + */ + +package org.dive4elements.river.artifacts; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.log4j.Logger; +import org.w3c.dom.Document; + +import org.dive4elements.artifactdatabase.state.DefaultOutput; +import org.dive4elements.artifactdatabase.state.Facet; +import org.dive4elements.artifactdatabase.state.FacetActivity; +import org.dive4elements.artifactdatabase.state.State; +import org.dive4elements.artifacts.Artifact; +import org.dive4elements.artifacts.ArtifactFactory; +import org.dive4elements.artifacts.CallMeta; +import org.dive4elements.artifacts.common.utils.XMLUtils; +import org.dive4elements.river.artifacts.states.DefaultState.ComputeType; +import org.dive4elements.river.artifacts.model.minfo.SedimentDensityFacet; +import org.dive4elements.river.artifacts.model.minfo.SedimentDensityFactory; +import org.dive4elements.river.artifacts.resources.Resources; +import org.dive4elements.river.artifacts.states.StaticState; + +import org.dive4elements.river.artifacts.model.FacetTypes; + + +/** Artifact to access sediment density measurements. */ +public class SedimentDensityArtifact +extends StaticD4EArtifact +implements FacetTypes +{ + /** The logger for this class. */ + private static Logger logger = + Logger.getLogger(SedimentDensityArtifact.class); + + /** Artifact key name. */ + private static final String NAME = "sedimentdensity"; + + /** Spawn only inactive facets. */ + static { + // TODO: Move to configuration. + FacetActivity.Registry.getInstance() + .register(NAME, FacetActivity.INACTIVE); + } + + /** Need to give the state an id. */ + public static final String STATIC_STATE_NAME = + "state.sedimentdensity.static"; + + /** One and only state to be in. */ + protected transient State state = null; + + protected String DATA_ID = "ID"; + + /** + * Trivial Constructor. + */ + public SedimentDensityArtifact() { + logger.debug("SedimentDensityArtifact.SedimentDensityArtifact"); + } + + + /** Get artifact key name. */ + @Override + public String getName() { + return NAME; + } + + + private Object getSedimentDensity() { + logger.debug("SedimentDensityArtifact.getSedimentDensity"); + Integer id = getDataAsInteger(DATA_ID); + + // TODO use cache if possible + return SedimentDensityFactory.getSedimentDensityUncached(id); + } + + + private State newDensityState() { + return new StaticState(STATIC_STATE_NAME) { + public Object staticCompute(List<Facet> facets) { + return getSedimentDensity(); + } + }; + } + + + /** Create a new state with bogus output. */ + protected State spawnState() { + state = newDensityState(); + List<Facet> fs = getFacets(STATIC_STATE_NAME); + DefaultOutput output = new DefaultOutput( + "general", + "general", + "image/png", + fs, + "chart"); + + state.getOutputs().add(output); + + return state; + } + + + /** + * Gets called from factory, to set things up. + */ + @Override + public void setup( + String identifier, + ArtifactFactory factory, + Object context, + CallMeta callMeta, + Document data) + { + logger.debug("SedimentDensityArtifact.setup"); + + state = newDensityState(); + if (logger.isDebugEnabled()) { + logger.debug(XMLUtils.toString(data)); + } + + List<Facet> fs = new ArrayList<Facet>(); + + String code = getDatacageIDValue(data); + + if (code != null) { + double[] depth = SedimentDensityFactory.getDepth(Integer.valueOf(code)); + + String name = Resources.getMsg(callMeta, "sedimentdensity", "sedimentdensity"); + name += " " + depth[0] + " - " + depth[1] + " cm"; + Facet facet = new SedimentDensityFacet( + 0, + SEDIMENT_DENSITY, + name, + ComputeType.ADVANCE, state.getID(), "hash" + ); + fs.add(facet); + addFacets(state.getID(), fs); + addStringData(DATA_ID, code); + } + else { + logger.error("No id given."); + } + + 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(getState()); + return states; + } + + + /** + * Get the "current" state (there is but one). + * @param cc ignored. + * @return the "current" (only possible) state. + */ + @Override + public State getCurrentState(Object cc) { + return getState(); + } + + + /** + * Get the only possible state. + * @return the state. + */ + protected State getState() { + return getState(null, null); + } + + + /** + * Get the state. + * @param context ignored. + * @param stateID ignored. + * @return the state. + */ + @Override + protected State getState(Object context, String stateID) { + return (state != null) + ? state + : spawnState(); + } + + + /** + * Called via setup. Overridden to avoid cloning all data. + * + * @param artifact The master-artifact. + */ + @Override + protected void initialize( + Artifact artifact, + Object context, + CallMeta meta) + { + logger.debug("SedimentDensityArtifact.initialize"); + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/SedimentYieldArtifact.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/SedimentYieldArtifact.java Tue Oct 15 18:41:55 2013 +0200 @@ -9,6 +9,8 @@ package org.dive4elements.river.artifacts; import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; import java.util.List; import org.apache.log4j.Logger; @@ -29,14 +31,14 @@ import org.dive4elements.river.artifacts.model.minfo.SedimentLoadFacet; import org.dive4elements.river.artifacts.model.minfo.SedimentLoadFactory; import org.dive4elements.river.artifacts.model.minfo.SedimentLoadResult; +import org.dive4elements.river.artifacts.resources.Resources; import org.dive4elements.river.artifacts.states.StaticState; import org.dive4elements.river.artifacts.model.FacetTypes; -import org.dive4elements.river.utils.Formatter; - -/** Artifact to access sediment yield measurements (inspired from flow velocity artifact). */ +/** Artifact to access sediment yield measurements. */ +// TODO Naming: would SedimentLoadArtifact be more precise? public class SedimentYieldArtifact extends StaticD4EArtifact implements FacetTypes @@ -84,6 +86,7 @@ String id = getDataAsString(DATA_NAME); String river = getDataAsString("river"); + // TODO use cache if possible SedimentLoad myLoad = SedimentLoadFactory.getSedimentLoadWithDataUncached(id, river); return new CalculationResult( new SedimentLoadResult[] { @@ -142,14 +145,44 @@ List<Facet> fs = new ArrayList<Facet>(); String code = getDatacageIDValue(data); - // TODO need river, too. - // if (code != null) { - String name = SedimentLoadFactory.getSedimentYieldDescription(Integer.valueOf(code)); + String fraction = SedimentLoadFactory.getSedimentYieldFractionName(Integer.valueOf(code)); + String fractionName = Resources.getMsg(callMeta, fraction, "-"); + Date[] dates = SedimentLoadFactory.getSedimentYieldTimes(Integer.valueOf(code)); + Calendar date = Calendar.getInstance(); + date.setTime(dates[0]); + String name = fractionName + " - " + date.get(Calendar.YEAR); + if (dates[1] != null) { + date.setTime(dates[1]); + name += " - " + date.get(Calendar.YEAR); + } + + String facetType = ""; + if (fraction.equals("coarse")) { + facetType = SEDIMENT_LOAD_COARSE; + } + else if (fraction.equals("sand")) { + facetType = SEDIMENT_LOAD_SAND; + } + else if (fraction.equals("fine_middle")) { + facetType = SEDIMENT_LOAD_FINEMIDDLE; + } + else if (fraction.equals("susp_sand")) { + facetType = SEDIMENT_LOAD_SUSP_SAND; + } + else if (fraction.equals("susp_sand_bed")) { + facetType = SEDIMENT_LOAD_SUSP_SAND_BED; + } + else if (fraction.equals("suspended_sediment")) { + facetType = SEDIMENT_LOAD_SUSP_SEDIMENT; + } + else { + logger.error("Do not know fraction type " + fraction); + } Facet facet = new SedimentLoadFacet( 0, - SEDIMENT_LOAD_COARSE, + facetType, name, //???? ComputeType.ADVANCE, state.getID(), "hash"
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/access/RangeAccess.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/access/RangeAccess.java Tue Oct 15 18:41:55 2013 +0200 @@ -122,28 +122,38 @@ } - /** Return ld_from data (in km). */ + /** Return ld_from data (in km). If not found, the min. */ public double getFrom() { if (from == null) { from = getDouble("ld_from"); } if (logger.isDebugEnabled()) { - logger.debug("from: '" + from + "'"); + logger.debug("from from data: '" + from + "'"); + } + + if (from == null) { + logger.warn("No 'from' found. assume max of river."); + return getRiver().determineMinMaxDistance()[0]; } return from.doubleValue(); } - /** Return ld_to data (in km). */ + /** Return ld_to data (in km), if not found, the max. */ public double getTo() { if (to == null) { to = getDouble("ld_to"); } if (logger.isDebugEnabled()) { - logger.debug("to: '" + to + "'"); + logger.debug("to from data: '" + to + "'"); + } + + if (to == null) { + logger.warn("No 'to' found. assume max of river."); + return getRiver().determineMinMaxDistance()[1]; } return to.doubleValue();
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/access/RiverAccess.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/access/RiverAccess.java Tue Oct 15 18:41:55 2013 +0200 @@ -10,6 +10,10 @@ import org.dive4elements.river.artifacts.D4EArtifact; +import org.dive4elements.river.artifacts.model.RiverFactory; + +import org.dive4elements.river.model.River; + import org.apache.log4j.Logger; /** Access to river data of an artifact. */ @@ -32,7 +36,7 @@ /** Get River name. */ - public String getRiver() { + public String getRiverName() { if (river == null) { river = getString("river"); } @@ -41,5 +45,13 @@ } return river; } + + public River getRiver() { + getRiverName(); + + return (river != null) + ? RiverFactory.getRiver(river) + : null; + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/access/SQRelationAccess.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/access/SQRelationAccess.java Tue Oct 15 18:41:55 2013 +0200 @@ -100,7 +100,7 @@ return measurementStation; } List<MeasurementStation> candidates = MeasurementStation.getStationsAtKM( - getRiver(), getLocation()); + getRiverName(), getLocation()); if (candidates != null) { // Just take the first one as we only use the name // and that "should" be unique at the location
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/context/RiverContext.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/context/RiverContext.java Tue Oct 15 18:41:55 2013 +0200 @@ -8,14 +8,13 @@ package org.dive4elements.river.artifacts.context; -import java.util.Map; - import org.apache.log4j.Logger; import org.w3c.dom.Document; import org.dive4elements.artifactdatabase.DefaultArtifactContext; import org.dive4elements.artifacts.CallContext; +import org.dive4elements.river.exports.GeneratorLookup; import org.dive4elements.river.exports.OutGenerator; import org.dive4elements.river.utils.Pair; @@ -47,6 +46,9 @@ public static final String OUTGENERATORS_KEY = "flys.export.outgenerators"; + public static final String FACETFILTER_KEY = + "flys.export.facetfilter"; + /** The key that is used to store the map of themes in the context. */ public static final String THEMES = "flys.themes.map"; @@ -100,15 +102,14 @@ ? (RiverContext) context : (RiverContext) context.globalContext(); - Map<String, Pair<Class<OutGenerator>, Object>> generators = - (Map<String, Pair<Class<OutGenerator>, Object>>)flysContext - .get(RiverContext.OUTGENERATORS_KEY); + GeneratorLookup generators = + (GeneratorLookup)flysContext.get(RiverContext.OUTGENERATORS_KEY); if (generators == null) { return null; } - Pair<Class<OutGenerator>, Object> pair = generators.get(name); + Pair<Class<OutGenerator>, Object> pair = generators.getGenerator(name); if (pair == null) { logger.warn("No generator class found for " + name);
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/context/RiverContextFactory.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/context/RiverContextFactory.java Tue Oct 15 18:41:55 2013 +0200 @@ -39,6 +39,7 @@ import org.dive4elements.river.artifacts.transitions.TransitionFactory; +import org.dive4elements.river.exports.GeneratorLookup; import org.dive4elements.river.exports.OutGenerator; import org.dive4elements.river.themes.Theme; @@ -46,8 +47,6 @@ import org.dive4elements.river.themes.ThemeGroup; import org.dive4elements.river.themes.ThemeMapping; -import org.dive4elements.river.utils.Pair; - import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; @@ -335,8 +334,7 @@ logger.info("Found " + num + " configured output generators."); - Map<String, Pair<Class<OutGenerator>, Object>> generators = - new HashMap<String, Pair<Class<OutGenerator>, Object>>(); + GeneratorLookup generators = new GeneratorLookup(); int idx = 0; @@ -381,12 +379,9 @@ } } - Pair<Class<OutGenerator>, Object> pair = - new Pair<Class<OutGenerator>, Object>(generatorClass, cfg); - for (String key: names.split("[\\s,]")) { if (!(key = key.trim()).isEmpty()) { - generators.put(key, pair); + generators.putGenerator(key, generatorClass, cfg); idx++; } } @@ -394,6 +389,7 @@ logger.info("Successfully loaded " + idx + " output generators."); context.put(RiverContext.OUTGENERATORS_KEY, generators); + context.put(RiverContext.FACETFILTER_KEY, generators); }
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/datacage/templating/Builder.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/datacage/templating/Builder.java Tue Oct 15 18:41:55 2013 +0200 @@ -991,9 +991,11 @@ protected Object evaluateXPath(String expr, QName returnType) { + /* if (log.isDebugEnabled()) { log.debug("evaluate: '" + expr + "'"); } + */ try { XPathExpression x = getXPathExpression(expr);
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/datacage/templating/FunctionResolver.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/datacage/templating/FunctionResolver.java Tue Oct 15 18:41:55 2013 +0200 @@ -165,7 +165,7 @@ Object stateId = args.get(1); return artifactName instanceof String - && stateId instanceof String + && stateId instanceof String ? allStateSuccessors((String)artifactName, (String)stateId) : Collections.<String>emptySet(); } @@ -253,7 +253,7 @@ Object locations = args.get(1); Object from = args.get(2); - if ((mode instanceof String && mode.equals("location")) || + if ((mode instanceof String && mode.equals("location")) || (locations instanceof String && !((String)locations).isEmpty())) { if (!(locations instanceof String)) { return -FAR_AWAY;
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/datacage/templating/StackFrames.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/datacage/templating/StackFrames.java Tue Oct 15 18:41:55 2013 +0200 @@ -151,9 +151,11 @@ @Override public Object resolveVariable(QName variableName) { + /* if (log.isDebugEnabled()) { log.debug("resolve var: " + variableName); } + */ return getNull(variableName.getLocalPart()); }
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/BlackboardDataFacet.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/BlackboardDataFacet.java Tue Oct 15 18:41:55 2013 +0200 @@ -19,7 +19,7 @@ /** - * Facet that writes artifact-uui and facet index on the blackboard, + * Facet that writes artifact-uuid facet name and facet index on the blackboard, * delivers data if asked so. */ public class BlackboardDataFacet extends DefaultFacet { @@ -56,10 +56,10 @@ /** * Can provide whatever getData returns. - * @param key will respond on uuid+index + * @param key will respond on uuid+facetname+index * @param param ignored * @param context ignored - * @return whatever getData delivers. + * @return whatever getData delivers when asked for the 'right' key. */ @Override public Object provideBlackboardData(Artifact artifact,
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/Calculation4.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/Calculation4.java Tue Oct 15 18:41:55 2013 +0200 @@ -47,7 +47,7 @@ public Calculation4(Calculation4Access access) { logger.debug("Calculation4Access.cnst"); - String river = access.getRiver(); + String river = access.getRiverName(); List<Segment> segments = access.getSegments(); double [] range = access.getFromToStep(); boolean isQ = access.isQ(); @@ -339,19 +339,21 @@ infoldings.add(infolding); } - for (int i = 0; i < infoldings.size(); i++) { - String name = infoldings.get(i).getName(); + for (int i = 0, I = infoldings.size(); i < I; i++) { + ConstantWQKms infolding = infoldings.get(i); + String name = infolding.getName(); // TODO: i18n if (i == 0) { - infoldings.get(i).setName("untere Umh\u00fcllende " + name); + infolding.setName("untere Umh\u00fcllende " + name); } - else if (i == infoldings.size() - 1) { - infoldings.get(i).setName("obere Umh\u00fcllende " + name); + else if (i == I-1) { + infolding.setName("obere Umh\u00fcllende " + name); } else { - infoldings.get(i).setName("geschnitten " + name); + infolding.setName("geschnitten " + name); } } + return infoldings.toArray(new ConstantWQKms[infoldings.size()]); }
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/Calculation6.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/Calculation6.java Tue Oct 15 18:41:55 2013 +0200 @@ -46,7 +46,7 @@ double [] vs = mode != null && mode == EvaluationMode.W ? access.getWs() : access.getQs(); - riverName = access.getRiver(); + riverName = access.getRiverName(); Long officialGaugeNumber = access.getOfficialGaugeNumber();
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/FacetTypes.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/FacetTypes.java Tue Oct 15 18:41:55 2013 +0200 @@ -266,6 +266,7 @@ String FLOW_VELOCITY_MAINCHANNEL = "flow_velocity.mainchannel"; String FLOW_VELOCITY_TOTALCHANNEL = "flow_velocity.totalchannel"; + /** Also called SHEAR_STRESS. */ String FLOW_VELOCITY_TAU = "flow_velocity.tau"; String FLOW_VELOCITY_MAINCHANNEL_FILTERED = "flow_velocity.mainchannel.filtered"; String FLOW_VELOCITY_TOTALCHANNEL_FILTERED = "flow_velocity.totalchannel.filtered"; @@ -273,6 +274,7 @@ String FLOW_VELOCITY_ANNOTATION = "flow_velocity.annotation"; String FLOW_VELOCITY_MEASUREMENT = "flow_velocity.measurement"; String FLOW_VELOCITY_DISCHARGE = "flow_velocity.discharge"; + String FLOW_VELOCITY_WATERLEVEL = "flow_velocity.waterlevel"; String MIDDLE_BED_HEIGHT_SINGLE = "bedheight_middle.single"; String MIDDLE_BED_HEIGHT_EPOCH = "bedheight_middle.epoch"; @@ -306,6 +308,8 @@ String BED_DIFFERENCE_EPOCH_HEIGHT2_FILTERED = "bedheight_difference.epoch.height2.filtered"; String MORPHOLOGIC_WIDTH = "morph-width"; + String SEDIMENT_DENSITY = "sediment.density"; + String SEDIMENT_LOAD_COARSE = "sedimentload.coarse"; String SEDIMENT_LOAD_SAND = "sedimentload.sand"; String SEDIMENT_LOAD_FINEMIDDLE = "sedimentload.finemiddle"; @@ -390,6 +394,10 @@ String STATIC_BEDHEIGHT = "static_bedheight"; + String BEDHEIGHT = "bedheight"; + String BEDHEIGHT_SOUNDING_WIDTH = "bedheight_sounding_width"; + String BEDHEIGHT_WIDTH = "bedheight_width"; + String EXTREME_WQ_CURVE = "extreme_wq_curve"; String EXTREME_WQ_CURVE_BASE = "extreme_wq_curve_base";
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/FlowVelocityCalculation.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/FlowVelocityCalculation.java Tue Oct 15 18:41:55 2013 +0200 @@ -98,7 +98,7 @@ FlowVelocityAccess access, List<DischargeZone> zones ) { - String riverName = access.getRiver(); + String riverName = access.getRiverName(); if (riverName == null) { logger.warn("No river name found"); return Collections.<FlowVelocityModel>emptyList(); @@ -115,7 +115,7 @@ } - protected void prepareData( + public static void prepareData( FlowVelocityData data, FlowVelocityModel model, double kmLo, @@ -148,8 +148,12 @@ } + /** + * From the given models and range restrictions from access, + * create and return a calculationresult with flowvelocityDate. + */ protected CalculationResult buildCalculationResult( - FlowVelocityAccess access, + FlowVelocityAccess access, List<FlowVelocityModel> models ) { double kmLo = access.getLowerKM();
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/FlowVelocityData.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/FlowVelocityData.java Tue Oct 15 18:41:55 2013 +0200 @@ -18,12 +18,13 @@ private TDoubleArrayList km; private TDoubleArrayList vMain; private TDoubleArrayList vTotal; + /** Also called 'shearstress'. */ private TDoubleArrayList tauMain; private TDoubleArrayList q; private String zone; private String type; - protected FlowVelocityData() { + public FlowVelocityData() { this.km = new TDoubleArrayList(); this.vMain = new TDoubleArrayList(); this.vTotal = new TDoubleArrayList();
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/FlowVelocityFilterFacet.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/FlowVelocityFilterFacet.java Tue Oct 15 18:41:55 2013 +0200 @@ -62,7 +62,7 @@ RiverContext fc = (RiverContext)context.globalContext(); ZoomScale scales = (ZoomScale)fc.get("zoomscale"); RiverAccess access = new RiverAccess((D4EArtifact)artifact); - String river = access.getRiver(); + String river = access.getRiverName(); double radius = scales.getRadius(river, start, end); FlowVelocityData oldData = data[index];
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/LinearInterpolated.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/LinearInterpolated.java Tue Oct 15 18:41:55 2013 +0200 @@ -161,7 +161,7 @@ } public LinearInterpolated sub( - LinearInterpolated other, + LinearInterpolated other, double from, double to ) { @@ -169,7 +169,7 @@ } public LinearInterpolated max( - LinearInterpolated other, + LinearInterpolated other, double from, double to ) {
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/OfficialLineFinder.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/OfficialLineFinder.java Tue Oct 15 18:41:55 2013 +0200 @@ -53,7 +53,7 @@ public ValueRange( double start, - double end, + double end, double value, int wstId, int columnPos,
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/Parameters.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/Parameters.java Tue Oct 15 18:41:55 2013 +0200 @@ -314,6 +314,67 @@ return values; } + public double [] interpolateWithLimit( + String keyName, + double key, + String [] columnNames, + double limit + ) { + int keyIndex = columnIndex(keyName); + return keyIndex < 0 + ? null + : interpolateWithLimit(keyIndex, key, columnNames, limit); + } + + /* Only interpolate if the difference between the two key's + * is less then limit */ + public double [] interpolateWithLimit( + int keyIndex, + double key, + String [] columnNames, + double limit + ) { + int row = binarySearch(keyIndex, key, EPSILON); + + if (row >= 0) { // direct match + double [] values = new double[columnNames.length]; + for (int i = 0; i < values.length; ++i) { + int ci = columnIndex(columnNames[i]); + values[i] = ci < 0 + ? Double.NaN + : columns[ci].getQuick(row); + } + return values; + } + + row = -row - 1; + if (row < 1 || row >= size()) { + log.debug("interpolate: row is out of bounds"); + return null; + } + + double v1 = columns[keyIndex].getQuick(row-1); + double v2 = columns[keyIndex].getQuick(row); + if (Math.abs(v1-v2) > limit) { + return null; + } + double factor = Linear.factor(key, v1, v2); + + double [] values = new double[columnNames.length]; + + for (int i = 0; i < values.length; ++i) { + int ci = columnIndex(columnNames[i]); + values[i] = ci < 0 + ? Double.NaN + : Linear.weight( + factor, + columns[ci].getQuick(row-1), + columns[ci].getQuick(row)); + } + + return values; + } + public boolean isSorted(String columnName) { return isSorted(columnIndex(columnName)); }
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/WQ.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/WQ.java Tue Oct 15 18:41:55 2013 +0200 @@ -126,8 +126,10 @@ // When we convert and have a datum we have a calculated // result at a gauge so we must subtract the datum. double subtractDatum = datum == null ? 0 : datum.doubleValue(); - for (int i=0; i < wq.size(); i++) { - ret.add((wq.get(i)[0] - subtractDatum)* 100, wq.get(i)[1]); + double [] data = new double[8]; + for (int i = 0, WQ = wq.size(); i < WQ; i++) { + wq.get(i, data); + ret.add((data[0] - subtractDatum)*100d, data[1]); } log.debug("Converted W values to centimeter and substracted: " + subtractDatum); return ret;
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/extreme/ExtremeCalculation.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/extreme/ExtremeCalculation.java Tue Oct 15 18:41:55 2013 +0200 @@ -63,7 +63,7 @@ } public ExtremeCalculation(ExtremeAccess access) { - String river = access.getRiver(); + String river = access.getRiverName(); String function = access.getFunction(); Double from = access.getFrom(); Double to = access.getTo();
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/Fitting.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/Fitting.java Tue Oct 15 18:41:55 2013 +0200 @@ -148,9 +148,6 @@ xs.add(qs[i]); ys.add(ws[i]); } - else { - log.warn("remove invalid value " + qs[i] + " " + ws[i]); - } } if (xs.size() < 2) { @@ -166,7 +163,7 @@ for (;;) { parameters = null; - for (double tolerance = 1e-10; tolerance < 1e-3; tolerance *= 10d) { + for (double tolerance = 1e-10; tolerance < 1e-1; tolerance *= 10d) { lmo = new LevenbergMarquardtOptimizer(); lmo.setCostRelativeTolerance(tolerance); @@ -190,6 +187,11 @@ } } if (parameters == null) { + /* + log.debug("Parameters is null"); + for (int i = 0, N = xs.size(); i < N; ++i) { + log.debug("DATA: " + xs.getQuick(i) + " " + ys.getQuick(i)); + }*/ return false; }
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixCalculation.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixCalculation.java Tue Oct 15 18:41:55 2013 +0200 @@ -178,7 +178,7 @@ } public FixCalculation(FixAccess access) { - String river = access.getRiver(); + String river = access.getRiverName(); Double from = access.getFrom(); Double to = access.getTo(); Double step = access.getStep(); @@ -363,6 +363,7 @@ fitting.reset(); if (!fitting.fit(qs, ws)) { + log.debug("Fitting for km: " + km + " failed"); ++numFailed; addProblem(km, "fix.fitting.failed"); continue;
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixWQCurveFacet.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixWQCurveFacet.java Tue Oct 15 18:41:55 2013 +0200 @@ -97,10 +97,11 @@ Parameters params = result.getParameters(); String[] paramNames = ff.getParameterNames(); - double [] coeffs = params.interpolate("km", currentKm, paramNames); + double [] coeffs = params.interpolateWithLimit( + "km", currentKm, paramNames, access.getStep() / 1000 + 1E-3); if (coeffs == null) { - logger.warn("getData: coeffs == null"); + logger.warn("getData: coeffs not in interpolation limits"); return null; }
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/map/HWSFactory.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/map/HWSFactory.java Tue Oct 15 18:41:55 2013 +0200 @@ -168,8 +168,7 @@ sqlQuery.setString("river", river); List<Object []> resultsPoints = sqlQuery.list(); - for (int i = 0; i < resultsPoints.size(); i++) { - Object[] row = resultsPoints.get(i); + for (Object [] row: resultsPoints) { container.addHws( new HWS( (String) row[0],
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiameterDataFacet.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiameterDataFacet.java Tue Oct 15 18:41:55 2013 +0200 @@ -59,7 +59,7 @@ QualityMeasurements measurements = QualityMeasurementFactory.getBedMeasurements( - access.getRiver(), + access.getRiverName(), access.getFrom(), access.getTo(), access.getDateRanges().get(ndx).getFrom(),
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiffCalculation.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiffCalculation.java Tue Oct 15 18:41:55 2013 +0200 @@ -38,7 +38,7 @@ public CalculationResult calculate(BedDifferencesAccess access, CallContext context) { logger.info("BedDiffCalculation.calculate"); - String river = access.getRiver(); + String river = access.getRiverName(); String yearEpoch = access.getYearEpoch(); int [][] heightIds = access.extractHeightIds(context);
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiffEpochFilterFacet.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiffEpochFilterFacet.java Tue Oct 15 18:41:55 2013 +0200 @@ -53,7 +53,7 @@ RiverContext fc = (RiverContext)context.globalContext(); ZoomScale scales = (ZoomScale)fc.get("zoomscale"); RiverAccess access = new RiverAccess((D4EArtifact)artifact); - String river = access.getRiver(); + String river = access.getRiverName(); double radius = scales.getRadius(river, start, end); BedDiffEpochResult oldData = data[index];
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiffYearFilterFacet.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiffYearFilterFacet.java Tue Oct 15 18:41:55 2013 +0200 @@ -53,7 +53,7 @@ // Adaptive smoothing, based on zoom factor/diagram extents. ZoomScale scales = (ZoomScale)fc.get("zoomscale"); RiverAccess access = new RiverAccess((D4EArtifact)artifact); - String river = access.getRiver(); + String river = access.getRiverName(); double radius = scales.getRadius(river, start, end); BedDiffYearResult oldData = data[index];
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedHeightFactory.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedHeightFactory.java Tue Oct 15 18:41:55 2013 +0200 @@ -152,8 +152,7 @@ sqlQuery.setInteger("height_id", height_id); List<Object []> results = sqlQuery.list(); - for (int i = 0; i < results.size(); i++) { - Object[] row = results.get(i); + for (Object [] row: results) { log.debug("got station: " + (Double)row[1]); Double row0 = row[0] != null ? (Double)row[0] : Double.NaN; Double row1 = row[1] != null ? (Double)row[1] : Double.NaN;
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedQualityCalculation.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedQualityCalculation.java Tue Oct 15 18:41:55 2013 +0200 @@ -41,7 +41,7 @@ public CalculationResult calculate(BedQualityAccess access) { logger.info("BedQualityCalculation.calculate"); - String river = access.getRiver(); + String river = access.getRiverName(); Double from = access.getFrom(); Double to = access.getTo(); List<String> bedDiameter = access.getBedDiameter();
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedloadDiameterDataFacet.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedloadDiameterDataFacet.java Tue Oct 15 18:41:55 2013 +0200 @@ -59,7 +59,7 @@ QualityMeasurements measurements = QualityMeasurementFactory.getBedloadMeasurements( - access.getRiver(), + access.getRiverName(), access.getFrom(), access.getTo(), access.getDateRanges().get(ndx).getFrom(),
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/MorphologicWidthFactory.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/MorphologicWidthFactory.java Tue Oct 15 18:41:55 2013 +0200 @@ -82,8 +82,7 @@ List<Object []> results = sqlQuery.list(); MorphologicWidth widths = new MorphologicWidth(); - for (int i = 0; i < results.size(); i++) { - Object[] row = results.get(i); + for (Object [] row: results) { log.debug("got station: " + (Double)row[0]); widths.add( (Double) row[0],
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentDensity.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentDensity.java Tue Oct 15 18:41:55 2013 +0200 @@ -14,10 +14,12 @@ import java.util.List; import java.util.Map; import java.util.Set; +import java.util.TreeMap; import org.apache.log4j.Logger; +/** Sediment Densities for multiple years. */ public class SedimentDensity { private static final Logger logger = Logger @@ -67,8 +69,8 @@ /** * Get the density at year. - * measured densities are valid until the next measurement. - * if no measurement was found 1.8 is returned. + * Measured densities are valid until the next measurement. + * If no measurement was found 1.8 is returned. */ public double getDensity(double km, int year) { Collections.sort(this.years); @@ -77,7 +79,7 @@ return getDensityAtKm(densities.get(years.get(0)), km); } else if (this.years.size() > 1) { - for (int i = 0; i < years.size() -1; i++) { + for (int i = 0, I = years.size()-1; i < I; i++) { int y1 = years.get(i); int y2 = years.get(i + 1); if (year >= y1 && year < y2) { @@ -91,6 +93,45 @@ return 1.8d; } + /** Get (sorted) map of km to density of all years. */ + public double[][] getAllDensities() + { + TreeMap<Double, Double> map = new TreeMap<Double,Double>(); + for (int year: years) { + for (SedimentDensityValue sdv: densities.get(year)) { + map.put(sdv.getKm(), sdv.getDensity()); + } + } + double[][] points = new double[2][map.keySet().size()]; + int i = 0; + for (Map.Entry<Double, Double> kmDens: map.entrySet()) { + points[0][i] = kmDens.getKey(); + points[1][i] = kmDens.getValue(); + i++; + } + + return points; + } + + /** Get points km,density (sorted by km), for a given year. */ + public double[][] getDensities(int year) + { + TreeMap<Double, Double> map = new TreeMap<Double,Double>(); + for (SedimentDensityValue sdv: densities.get(year)) { + map.put(sdv.getKm(), sdv.getDensity()); + } + double[][] points = new double[2][map.keySet().size()]; + int i = 0; + for (Map.Entry<Double, Double> kmDens: map.entrySet()) { + points[0][i] = kmDens.getKey(); + points[1][i] = kmDens.getValue(); + i++; + } + + return points; + } + + /** Get value at km, interpolated. */ private double getDensityAtKm( List<SedimentDensityValue> values, double km @@ -111,6 +152,7 @@ return spline(prev, next, km); } + /** Linearly interpolate between density values. */ private static double spline( SedimentDensityValue prev, SedimentDensityValue next,
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentDensityFacet.java Tue Oct 15 18:41:55 2013 +0200 @@ -0,0 +1,72 @@ +/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde + * Software engineering by Intevation GmbH + * + * This file is Free Software under the GNU AGPL (>=v3) + * and comes with ABSOLUTELY NO WARRANTY! Check out the + * documentation coming with Dive4Elements River for details. + */ + +package org.dive4elements.river.artifacts.model.minfo; + +import org.dive4elements.artifactdatabase.state.Facet; + +import org.dive4elements.artifacts.Artifact; +import org.dive4elements.artifacts.CallContext; + +import org.dive4elements.river.artifacts.D4EArtifact; + +import org.dive4elements.river.artifacts.model.DataFacet; + +import org.dive4elements.river.artifacts.states.DefaultState.ComputeType; + +import org.apache.log4j.Logger; + + +/** Facet to access sediment density values measured in one year. */ +public class SedimentDensityFacet +extends DataFacet +{ + /** Very own logger. */ + private static Logger logger = Logger.getLogger(SedimentDensityFacet.class); + + /** Used as tolerance value when fetching measurement stations. */ + private static double EPSILON = 1e-5; + + + public SedimentDensityFacet() { + } + + public SedimentDensityFacet(int idx, String name, String description, + ComputeType type, String stateId, String hash) { + super(idx, name, description, type, hash, stateId); + } + + @Override + public Object getData(Artifact artifact, CallContext context) { + logger.debug("Get data for sediment density at index: " + index); + + D4EArtifact flys = (D4EArtifact) artifact; + + SedimentDensity res = (SedimentDensity) flys.compute(context, hash, + stateId, type, false); + + if (res == null) { + logger.error("No SedimentDensity"); + } + + return res; + } + + + /** Copy deeply. */ + @Override + public Facet deepCopy() { + SedimentDensityFacet copy = new SedimentDensityFacet(); + copy.set(this); + copy.type = type; + copy.hash = hash; + copy.stateId = stateId; + return copy; + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentDensityFactory.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentDensityFactory.java Tue Oct 15 18:41:55 2013 +0200 @@ -29,7 +29,7 @@ private static final String DENSITY_CACHE_NAME = "sedimentdensity"; - /**Query to get sediment density values and kms. */ + /** Query to get sediment density values and kms. */ private static final String SQL_SELECT_DENSITY = "SELECT sdv.station AS km, " + " sdv.density AS density," + @@ -39,6 +39,29 @@ " JOIN sediment_density_values sdv ON sd.id = sdv.sediment_density_id" + " WHERE r.name = :name"; + /** Query to get sediment density values and kms by id. */ + private static final String SQL_SELECT_DENSITY_BY_ID = + "SELECT sdv.station AS km, " + + " sdv.density AS density," + + " sdv.year AS year " + + " FROM sediment_density sd" + + " JOIN sediment_density_values sdv ON sd.id = sdv.sediment_density_id" + + " WHERE sd.id = :id"; + + /** Query to get sediment density depth by sediment density id. */ + private static final String SQL_SELECT_DENSITY_DEPTH_BY_ID = + "SELECT d.lower AS lower, " + + " d.upper AS upper" + + " FROM sediment_density sd " + + " JOIN depths d ON d.id = sd.depth_id " + + " WHERE sd.id = :id"; + + /** Query to get sediment density description by id. */ + private static final String SQL_SELECT_DESCRIPTION_BY_ID = + "SELECT sd.description " + + " FROM sediment_density sd" + + " WHERE sd.id = :id"; + private SedimentDensityFactory() {} public static SedimentDensity getSedimentDensity( @@ -96,5 +119,53 @@ density.cleanUp(); return density; } + + /** Query and return depth of a sediment density entry. */ + public static double[] getDepth(int id) { + log.debug("getDepth"); + Session session = SessionHolder.HOLDER.get(); + SQLQuery sqlQuery = session.createSQLQuery(SQL_SELECT_DENSITY_DEPTH_BY_ID) + .addScalar("lower", StandardBasicTypes.DOUBLE) + .addScalar("upper", StandardBasicTypes.DOUBLE); + sqlQuery.setInteger("id", id); + List<Object[]> results = sqlQuery.list(); + Object[] row = results.get(0); + + return new double[] {(Double)row[0], (Double)row[1]}; + } + + /** Query and return description of a sediment density entry. */ + public static String getSedimentDensityDescription(int id) { + log.debug("getSedimentDensityDescription"); + Session session = SessionHolder.HOLDER.get(); + SQLQuery sqlQuery = session.createSQLQuery(SQL_SELECT_DESCRIPTION_BY_ID) + .addScalar("description", StandardBasicTypes.STRING); + sqlQuery.setInteger("id", id); + List<Object> results = sqlQuery.list(); + + return (String) results.get(0); + } + + public static SedimentDensity getSedimentDensityUncached( + int id + ) { + log.debug("getSedimentDensityUncached id/year"); + Session session = SessionHolder.HOLDER.get(); + SQLQuery sqlQuery = session.createSQLQuery(SQL_SELECT_DENSITY_BY_ID) + .addScalar("km", StandardBasicTypes.DOUBLE) + .addScalar("density", StandardBasicTypes.DOUBLE) + .addScalar("year", StandardBasicTypes.INTEGER); + sqlQuery.setInteger("id", id); + List<Object[]> results = sqlQuery.list(); + SedimentDensity density = new SedimentDensity(); + for (Object[] row : results) { + if (row[0] != null && row[1] != null && row[2] != null) { + density.addDensity((Double)row[0], (Double)row[1], (Integer)row[2]); + } + } + + density.cleanUp(); + return density; + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadCalculation.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadCalculation.java Tue Oct 15 18:41:55 2013 +0200 @@ -46,7 +46,7 @@ public CalculationResult calculate(SedimentLoadAccess access) { logger.info("SedimentLoadCalculation.calculate"); - String river = access.getRiver(); + String river = access.getRiverName(); String yearEpoch = access.getYearEpoch(); String unit = access.getUnit(); int[] period = null; @@ -237,7 +237,7 @@ } } - for (int j = 0; j < kms.size(); j++) { + for (int j = 0, J = kms.size(); j < J; j++) { calculateEpochKm(epochLoads, resLoad, kms.get(j)); } resLoad.setDescription("");
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFacet.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFacet.java Tue Oct 15 18:41:55 2013 +0200 @@ -153,7 +153,7 @@ int i = 0; for (Map.Entry<Double, Double> kmLoad: sortedKmLoad.entrySet()) { boolean matchFound = false; - for (int k = 0; k < stations.size(); k++) { + for (int k = 0, S = stations.size(); k < S; k++) { MeasurementStation station = stations.get(k); if (Math.abs(station.getStation() - kmLoad.getKey()) < EPSILON) { // Value has been taken at measurement station. @@ -162,7 +162,7 @@ double endValue = 0d; // Valid until next measurements stations begin of range, // or end of current range if last value. - if (k+2 <= stations.size()) { + if (k+2 <= S) { endValue = stations.get(k+1).getRange().getA().doubleValue(); } else {
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFactory.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFactory.java Tue Oct 15 18:41:55 2013 +0200 @@ -54,11 +54,28 @@ " AND ti.stop_time IS NULL " + " AND syv.station BETWEEN :startKm AND :endKm"; + /** Query to get fraction name of single sediment_yield. */ + public static final String SQL_SELECT_SINGLE_TIMES_BY_ID = + "SELECT DISTINCT " + + " ti.start_time AS starttime, " + + " ti.stop_time AS stoptime " + + " FROM sediment_yield sy " + + " JOIN time_intervals ti ON ti.id = sy.time_interval_id " + + " WHERE sy.id = :id "; + + /** Query to get fraction name of single sediment_yield. */ + public static final String SQL_SELECT_SINGLE_FRACTION_BY_ID = + "SELECT DISTINCT " + + " gf.name AS fraction " + + " FROM sediment_yield sy " + + " JOIN grain_fraction gf ON gf.id = grain_fraction_id " + + " WHERE sy.id = :id "; + /** Query to get description of single sediment_yield. */ public static final String SQL_SELECT_SINGLE_BY_ID = "SELECT DISTINCT " + " sy.description AS description " + - " FROM sediment_yield sy " + + " FROM sediment_yield sy " + " WHERE sy.id = :id "; /** Query to get description, name and time range for official @@ -278,6 +295,45 @@ } /** + * Get sediment yields time definition. + * @param id the sediment yield by id. + * @return sediment yields fraction name. + */ + public static Date[] getSedimentYieldTimes(int id) { + log.debug("SedimentLoadFactory.getSedimentYieldTimes"); + + Session session = SessionHolder.HOLDER.get(); + SQLQuery sqlQuery = session.createSQLQuery(SQL_SELECT_SINGLE_TIMES_BY_ID) + .addScalar("starttime", StandardBasicTypes.DATE) + .addScalar("stoptime", StandardBasicTypes.DATE); + sqlQuery.setDouble("id", id); + + List<Object[]> results = sqlQuery.list(); + Object[] row = results.get(0); + + return new Date[] {(Date)row[0], (Date) row[1]}; + } + + /** + * Get sediment load fraction name. + * @param id the sediment yield by id. + * @return sediment yields fraction name. + */ + public static String getSedimentYieldFractionName(int id) { + log.debug("SedimentLoadFactory.getSedimentYieldFractionName"); + + Session session = SessionHolder.HOLDER.get(); + SQLQuery sqlQuery = session.createSQLQuery(SQL_SELECT_SINGLE_FRACTION_BY_ID) + .addScalar("fraction", StandardBasicTypes.STRING); + sqlQuery.setDouble("id", id); + + List<Object> results = sqlQuery.list(); + + return (String) results.get(0); + } + + + /** * Get sediment load description. * @param id the sediment yield by id. * @return sediment yields description @@ -293,7 +349,6 @@ List<Object> results = sqlQuery.list(); return (String) results.get(0); - } @@ -323,7 +378,7 @@ sqlQuery.setDouble("endKm", endKm); List<Object []> results = sqlQuery.list(); SedimentLoad[] loads = new SedimentLoad[results.size()]; - for (int i = 0; i < results.size(); i++) { + for (int i = 0, R = results.size(); i < R; i++) { Object[] row = results.get(i); loads[i] = new SedimentLoad( (String) row[0], @@ -345,7 +400,7 @@ List<Object []> results = sqlQuery.list(); SedimentLoad[] loads = new SedimentLoad[results.size()]; - for (int i = 0; i < results.size(); i++) { + for (int i = 0, R = results.size(); i < R; i++) { Object[] row = results.get(i); loads[i] = new SedimentLoad( (String) row[0], @@ -366,7 +421,7 @@ List<Object []> results = sqlQuery.list(); SedimentLoad[] loads = new SedimentLoad[results.size()]; - for (int i = 0; i < results.size(); i++) { + for (int i = 0, R = results.size(); i < R; i++) { Object[] row = results.get(i); loads[i] = new SedimentLoad( ((Date) row[0]).toString() + (Date) row[1], @@ -450,12 +505,12 @@ String fraction = (String) row[3]; - TreeMap<Double,MeasurementStation> relevantStations = + TreeMap<Double,MeasurementStation> relevantStations = fraction.equals("suspended_sediment") /* || TODO clarify: fraction.equals("susp_sand") */ ? suspStations : floatStations; - for (int i = 0; i < results.size(); i++) { + for (int i = 0, R = results.size(); i < R; i++) { row = results.get(i); double km = (Double) row[2]; Range range = findMeasurementStationRange(relevantStations, km); @@ -608,7 +663,7 @@ true, (String)row[5]); TDoubleArrayList kms = new TDoubleArrayList(); - for (int i = 0; i < results.size(); i++) { + for (int i = 0, R = results.size(); i < R; i++) { row = results.get(i); kms.add((Double)row[3]); load.setLoadTotal((Double)row[3], (Double)row[2]); @@ -680,7 +735,7 @@ (String)row[5]); } - for (int i = 0; i < results.size(); i++) { + for (int i = 0, R = results.size(); i < R; i++) { Object[] row = results.get(i); double km = (Double)row[3]; Range range = findMeasurementStationRange(stations, km); @@ -799,7 +854,7 @@ false, (String)row[5]); - for (int i = 0; i < results.size(); i++) { + for (int i = 0, R = results.size(); i < R; i++) { row = results.get(i); SedimentLoadFraction fraction = new SedimentLoadFraction(); fraction.setUnknown((Double)row[3]);
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadUnknownFacet.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadUnknownFacet.java Tue Oct 15 18:41:55 2013 +0200 @@ -32,7 +32,7 @@ D4EArtifact flys = (D4EArtifact) artifact; SedimentLoadAccess access = new SedimentLoadAccess(flys); - String river = access.getRiver(); + String river = access.getRiverName(); String unit = access.getUnit(); SedimentLoad[] unknown = SedimentLoadFactory.getSedimentLoadUnknown(
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/sq/MeasurementFactory.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/sq/MeasurementFactory.java Tue Oct 15 18:41:55 2013 +0200 @@ -115,9 +115,9 @@ public static final BasicTransformerAdapter TOTALS_TRANSFORMER = new BasicTransformerAdapter() { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - @Override + @Override public Object transformTuple(Object [] tuple, String [] aliases) { Map<String, Object> map = new HashMap<String, Object>(); for (int i = 0; i < tuple.length; ++i) { @@ -136,7 +136,7 @@ public static final BasicTransformerAdapter FRACTIONS_TRANSFORMER = new BasicTransformerAdapter() { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; @Override public Object transformTuple(Object [] tuple, String [] aliases) {
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/sq/SQCurveFacet.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/sq/SQCurveFacet.java Tue Oct 15 18:41:55 2013 +0200 @@ -10,6 +10,8 @@ import org.apache.log4j.Logger; +import java.util.List; + import org.dive4elements.artifacts.Artifact; import org.dive4elements.artifacts.CallContext; @@ -107,5 +109,27 @@ return copy; } + + + @Override + public List getStaticDataProviderKeys(Artifact art) { + List list = super.getStaticDataProviderKeys(art); + list.add(name); + return list; + } + + @Override + public Object provideBlackboardData(Artifact artifact, + Object key, + Object param, + CallContext context + ) { + log.debug("I should provide date for key: " + key +" name " + name); + if (key.equals(name)) { + return getData(artifact, context); + } + return super.provideBlackboardData(artifact, key, + param, context); + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/sq/SQRelationCalculation.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/sq/SQRelationCalculation.java Tue Oct 15 18:41:55 2013 +0200 @@ -58,7 +58,7 @@ public SQRelationCalculation(SQRelationAccess access) { - String river = access.getRiver(); + String river = access.getRiverName(); Double location = access.getLocation(); DateRange period = access.getPeriod(); Double outliers = access.getOutliers(); @@ -416,7 +416,7 @@ if (bP == -1 || mP == -1 || aO == -1 || bO == -1) { log.error("index not found: " - + bP + " " + mP + " " + + bP + " " + mP + " " + aO + " " + bO); return coeffs; }
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/sq/StaticSQFactory.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/sq/StaticSQFactory.java Tue Oct 15 18:41:55 2013 +0200 @@ -44,11 +44,16 @@ "JOIN time_intervals ti ON ti.id = sq.time_interval_id " + "JOIN rivers r ON r.id = sq.river_id " + "JOIN sq_relation_value sqv ON sqv.sq_relation_id = sq.id " + - "JOIN measurement_station ms ON sqv.measurement_station_id = ms.id " + + "JOIN measurement_station ms ON sqv.measurement_station_id = ms.id "; + + public static final String STATION_CLAUSE = "WHERE " + "r.name = :river " + "AND ms.id = :ms_id "; + public static final String ID_CLAUSE = + "WHERE " + + "sqv.id = :dis_id "; private StaticSQFactory() { } @@ -83,13 +88,56 @@ return values; } + public static StaticSQContainer getDistinctRelation(int id) { + Session session = SessionHolder.HOLDER.get(); + + Query query = session.createSQLQuery(SQL_SQ + ID_CLAUSE) + .addScalar("description") + .addScalar("start_time") + .addScalar("stop_time") + .addScalar("station_name") + .addScalar("station_km") + .addScalar("measurement_type") + .addScalar("parameter") + .addScalar("a") + .addScalar("b") + .addScalar("qmax"); + + query.setParameter("dis_id", id); + + /* This could be done nicer with hibernate */ + List<Object []> list = query.list(); + if (list.isEmpty()) { + log.debug("Query returened nothing"); + return null; + } + Object [] row = list.get(0); + + StaticSQContainer sq = new StaticSQContainer(); + sq.setDescription((String)list.get(0)[0]); + sq.setStationName((String)list.get(0)[3]); + sq.setKm(((BigDecimal)list.get(0)[4]).doubleValue()); + + StaticSQRelation relation = new StaticSQRelation(); + relation.setStartTime((Date)row[1]); + relation.setStopTime((Date)row[2]); + relation.setType((String)row[5]); + relation.setParameter((String)row[6]); + relation.setA(((BigDecimal)row[7]).doubleValue()); + relation.setB(((BigDecimal)row[8]).doubleValue()); + relation.setQmax(((BigDecimal)row[9]).doubleValue()); + sq.addSQRelation(relation); + + return sq; + } + private static StaticSQContainer getUncached( String river, int measurementStation ) { Session session = SessionHolder.HOLDER.get(); - Query query = session.createSQLQuery(SQL_SQ) + Query query = session.createSQLQuery(SQL_SQ + STATION_CLAUSE) .addScalar("description") .addScalar("start_time") .addScalar("stop_time") @@ -107,6 +155,7 @@ List<Object []> list = query.list(); if (list.isEmpty()) { + log.debug("Query returened empty"); return new StaticSQContainer(); }
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/FloodMapState.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/FloodMapState.java Tue Oct 15 18:41:55 2013 +0200 @@ -752,7 +752,7 @@ protected void setAxis(D4EArtifact artifact, File dir, WSPLGENJob job) { DGMAccess access = new DGMAccess(artifact); - String river = access.getRiver(); + String river = access.getRiverName(); String srid = String.valueOf(access.getDGM().getSrid()); String srs = "EPSG:" + srid; @@ -799,7 +799,7 @@ protected void setPro(D4EArtifact artifact, File dir, WSPLGENJob job) { DGMAccess access = new DGMAccess(artifact); - String river = access.getRiver(); + String river = access.getRiverName(); String srid = String.valueOf(access.getDGM().getSrid()); String srs = "EPSG:" + srid; @@ -874,7 +874,7 @@ } DGMAccess access = new DGMAccess(artifact); - String river = access.getRiver(); + String river = access.getRiverName(); String srid = String.valueOf(access.getDGM().getSrid()); String srs = "EPSG:" + srid;
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/FlowVelocityState.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/FlowVelocityState.java Tue Oct 15 18:41:55 2013 +0200 @@ -221,7 +221,7 @@ protected String buildFacetName( - D4EArtifact flys, + D4EArtifact flys, CallContext cc, FlowVelocityData data, String resourceId
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/HWSBarriersState.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/HWSBarriersState.java Tue Oct 15 18:41:55 2013 +0200 @@ -88,7 +88,7 @@ } MapAccess access = new MapAccess(artifact); - String river = access.getRiver(); + String river = access.getRiverName(); HWSContainer hwsLines = HWSFactory.getHWSLines(river); HWSContainer hwsPoints = HWSFactory.getHWSPoints(river); List<String> selected = access.getHWS();
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/StaticWQKmsState.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/StaticWQKmsState.java Tue Oct 15 18:41:55 2013 +0200 @@ -85,7 +85,7 @@ // is != -1 boolean qEmpty = true; TDoubleArrayList qs = wqkms.allQs(); - for (int i = 0; i < qs.size(); i++) { + for (int i = 0, Q = qs.size(); i < Q; i++) { if (qs.getQuick(i) != -1d) { qEmpty = false; break;
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/extreme/ExtremeQInput.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/extreme/ExtremeQInput.java Tue Oct 15 18:41:55 2013 +0200 @@ -25,7 +25,6 @@ import org.dive4elements.artifacts.common.utils.XMLUtils; -import org.dive4elements.river.artifacts.model.RiverFactory; import org.dive4elements.river.artifacts.model.WstValueTable; /* import org.dive4elements.river.model.Gauge; @@ -87,7 +86,7 @@ D4EArtifact flysArtifact = (D4EArtifact) artifact; ExtremeAccess access = new ExtremeAccess(flysArtifact); - River river = RiverFactory.getRiver(access.getRiver()); + River river = access.getRiver(); WstValueTable wstValueTable = WstValueTableFactory.getTable(river); List<Range> ranges = wstValueTable.findSegments(access.getFrom(),
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/BedQualityState.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/BedQualityState.java Tue Oct 15 18:41:55 2013 +0200 @@ -128,11 +128,11 @@ List<String> diameters = access.getBedDiameter(); List<String> loadDiameters = access.getBedloadDiameter(); List<DateRange> ranges = access.getDateRanges(); - for (int i = 0; i < ranges.size(); i++) { + for (int i = 0, R = ranges.size(); i < R; i++) { DateRange range = ranges.get(i); for (String diameter: diameters) { int ndxTop = generateIndex(diameter); - int ndxSub = generateIndex(diameter); + int ndxSub = ndxTop; // TODO: Is this correct? ndxTop += 1; ndxTop = ndxTop << 3; ndxSub = ndxSub << 3;
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/SedimentLoadCalculate.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/SedimentLoadCalculate.java Tue Oct 15 18:41:55 2013 +0200 @@ -152,7 +152,7 @@ } logger.debug("Created " + newFacets.size() + " new Facets."); - String river = access.getRiver(); + String river = access.getRiverName(); SedimentLoad[] unknown = SedimentLoadFactory.getSedimentLoadUnknown(river, access.getUnit().replace("_per_","/"), type);
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/sq/SQStaticState.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/sq/SQStaticState.java Tue Oct 15 18:41:55 2013 +0200 @@ -10,11 +10,12 @@ import java.text.DateFormat; import java.util.List; - +import java.text.SimpleDateFormat; import org.apache.log4j.Logger; import org.dive4elements.artifactdatabase.state.Facet; +import org.dive4elements.artifacts.CallMeta; import org.dive4elements.river.artifacts.D4EArtifact; import org.dive4elements.river.artifacts.access.StaticSQRelationAccess; import org.dive4elements.river.artifacts.model.sq.StaticSQContainer; @@ -22,13 +23,18 @@ import org.dive4elements.river.artifacts.model.sq.StaticSQRelation; import org.dive4elements.river.artifacts.states.StaticState; +import org.dive4elements.river.artifacts.resources.Resources; public class SQStaticState extends StaticState { + private static final Logger log = Logger.getLogger(SQStaticState.class); + private static final String FACET_DESCRIPTION = + "facet.sq_relation.static_data"; + public SQStaticState() { super(); } @@ -38,26 +44,51 @@ } @Override - public Object staticCompute( - List<Facet> facets, - D4EArtifact artifact + public Object computeInit( + D4EArtifact artifact, + String hash, + Object context, + CallMeta meta, + List<Facet> facets ) { - StaticSQRelationAccess access = new StaticSQRelationAccess(artifact); + StaticSQContainer sqRelations; - String river = access.getRiver(); - String measurementStation = access.getMeasurementStation(); + String id_string = artifact.getDataAsString("ids"); - int ms = -1; - try { - ms = Integer.parseInt(measurementStation); - } - catch (NumberFormatException nfe) { - log.error("Unparseable measurement station: " + measurementStation); - return null; + int static_id = -1; + String static_desc = null; + + if (id_string != null && !id_string.isEmpty()) { + String[] id_parts = id_string.split(";"); + static_id = Integer.parseInt(id_parts[0]); + if (id_parts.length > 1) { + static_desc = id_parts[1]; + } } - StaticSQContainer sqRelations = - StaticSQFactory.getSQRelations(river, ms); + if (static_id != -1) { + // If the next line fails a traceback is the best debug output anyhow + sqRelations = StaticSQFactory.getDistinctRelation(static_id); + log.debug("Got a distinct relation" + sqRelations); + } else { + StaticSQRelationAccess access = new StaticSQRelationAccess(artifact); + String river = access.getRiverName(); + String measurementStation = access.getMeasurementStation(); + + int ms = -1; + try { + ms = Integer.parseInt(measurementStation); + } + catch (NumberFormatException nfe) { + log.error("Unparseable measurement station: " + measurementStation); + return null; + } + log.debug("Parsed measurement station: " + ms); + + sqRelations = StaticSQFactory.getSQRelations(river, ms); + } + + DateFormat df = new SimpleDateFormat("yyyy"); for (StaticSQRelation.Parameter p: StaticSQRelation.Parameter.values()) { @@ -69,11 +100,14 @@ for (StaticSQRelation relation : relations) { String name = "sq_" + p.toString().toLowerCase() + "_curve"; - DateFormat df = - DateFormat.getDateInstance(DateFormat.SHORT); - String desc = p.toString() + ": " + - df.format(relation.getStartTime()) + " - " + - df.format(relation.getStopTime()); + String desc = static_desc == null ? + Resources.getMsg(meta, + FACET_DESCRIPTION, + FACET_DESCRIPTION, + new Object[] { + df.format(relation.getStartTime()), + df.format(relation.getStopTime())}) : + static_desc; facets.add(new StaticSQRelationFacet( count, name,
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/sq/StaticSQRelationFacet.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/sq/StaticSQRelationFacet.java Tue Oct 15 18:41:55 2013 +0200 @@ -8,10 +8,15 @@ package org.dive4elements.river.artifacts.states.sq; +import java.util.List; + +import org.apache.log4j.Logger; + import org.dive4elements.artifactdatabase.state.DefaultFacet; import org.dive4elements.artifactdatabase.state.Facet; import org.dive4elements.artifacts.Artifact; import org.dive4elements.artifacts.CallContext; +import org.dive4elements.artifacts.DataProvider; import org.dive4elements.river.artifacts.math.fitting.Function; import org.dive4elements.river.artifacts.math.fitting.FunctionFactory; import org.dive4elements.river.artifacts.model.sq.SQFunction; @@ -26,6 +31,8 @@ private StaticSQRelation relation; + private static final Logger logger = + Logger.getLogger(StaticSQRelationFacet.class); public StaticSQRelationFacet( int ndx, @@ -43,7 +50,34 @@ Function func = FunctionFactory.getInstance().getFunction(FUNCTION); org.dive4elements.river.artifacts.math.Function function = func.instantiate(coeffs); - SQFunction sqf = new SQFunction(function, 0, qmax); + + /* Figure out a good starting point by checking for calculated + * SQ Curves and using their starting point */ + + // this is ok because we are a DefaultFacet and not a DataFacet + // and so we are not registred with Mr. Blackboard + List<DataProvider> providers = context.getDataProvider(name); + + double startingPoint = Double.MAX_VALUE; + + for (DataProvider dp: providers) { + SQFunction other = (SQFunction) dp.provideData( + name, + null, + context); + if (other == null) { + // name is not really unique here but it's our only key + // should not happen anyhow. + logger.error("Did not get data from: " + name); + continue; + } + startingPoint = Math.min(other.getMinQ(), startingPoint); + } + if (startingPoint == Double.MAX_VALUE) { + startingPoint = 0; + } + + SQFunction sqf = new SQFunction(function, startingPoint, qmax); return sqf; }
--- a/artifacts/src/main/java/org/dive4elements/river/exports/DiagramAttributes.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/DiagramAttributes.java Tue Oct 15 18:41:55 2013 +0200 @@ -26,7 +26,7 @@ import org.dive4elements.artifacts.common.utils.ElementConverter; public class DiagramAttributes -implements ElementConverter +implements ElementConverter, D4EArtifact.FacetFilter { private static Logger log = Logger.getLogger(DiagramAttributes.class); @@ -115,6 +115,7 @@ private boolean includeZero; // TODO: Use Evaluator private Evaluator isInverted; + private Evaluator isLog; public AxisAttributes() { } @@ -124,13 +125,15 @@ boolean isLeftAlign, boolean forceAlign, boolean includeZero, - Evaluator isInverted + Evaluator isInverted, + Evaluator isLog ) { this.name = name; this.isLeftAlign = isLeftAlign; this.forceAlign = forceAlign; this.includeZero = includeZero; this.isInverted = isInverted; + this.isLog = isLog; } public String getName() { @@ -152,6 +155,10 @@ public Evaluator isInverted() { return isInverted; } + + public Evaluator isLog() { + return isLog; + } } // class AxisAttributes public class DomainAxisAttributes extends AxisAttributes { @@ -167,9 +174,11 @@ boolean forceAlign, boolean includeZero, Evaluator isInverted, + Evaluator isLog, Title title ) { - super(name, isLeftAlign, forceAlign, includeZero, isInverted); + super(name, isLeftAlign, forceAlign, includeZero, isInverted, + isLog); this.title = title; } @@ -364,6 +373,7 @@ axisElement.getAttribute("include-zero").trim(); String isInverted = axisElement.getAttribute("inverted"); + String isLog = axisElement.getAttribute("logarithmic"); if (name.isEmpty()) { continue; @@ -379,10 +389,12 @@ Evaluator isInvertedE = parseEvaluator(isInverted, FALSE); + Evaluator isLogE = parseEvaluator(isLog, FALSE); + axesAttrs.add(new AxisAttributes( name, isleftAlign, forceAlign, includeZero.equals("true"), - isInvertedE)); + isInvertedE, isLogE)); } } @@ -466,8 +478,18 @@ private void parseDomainAxis(Element config) { Title title = extractTitle(config, "domain-axis"); - String includeZero = config.getAttribute("include-zero"); - String isInverted = config.getAttribute("inverted"); + String includeZero = ""; + String isInverted = ""; + String isLog = ""; + + NodeList dAlist = config.getElementsByTagName("domain-axis"); + if (dAlist.getLength() > 0) { + Element dAelement = (Element)dAlist.item(0); + + includeZero = dAelement.getAttribute("include-zero"); + isInverted = dAelement.getAttribute("inverted"); + isLog = dAelement.getAttribute("logarithmic"); + } domainAxis = new DomainAxisAttributes( "X", @@ -475,6 +497,7 @@ false, includeZero.equals("true"), parseEvaluator(isInverted, FALSE), + parseEvaluator(isLog, FALSE), title); } @@ -528,5 +551,16 @@ ? "" // null? : axesAttrs.get(index).getName(); } + + @Override + public boolean accept(String outName, String facetName) { + Instance instance = new Instance(); + for (Processor pr: instance.getProcessors()) { + if (pr.canHandle(facetName)) { + return true; + } + } + return false; + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/artifacts/src/main/java/org/dive4elements/river/exports/DiagramGenerator.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/DiagramGenerator.java Tue Oct 15 18:41:55 2013 +0200 @@ -73,7 +73,7 @@ * * This class is the glue between output processors and facets. * The generator creates one diagram and calls the appropiate - * processors for the state and + * processors for the state and * * With respect to datasets, ranges and axis, there are following requirements: * <ul> @@ -135,8 +135,6 @@ super.init(outName, request, out, context); RiverUtils.setKMFromRequestInContext(request, context); - - setInvertedFromConfig(); } private void setInvertedFromConfig() { @@ -192,6 +190,9 @@ //debugAxis(plot); localizeAxes(plot); + + setInvertedFromConfig(); + adjustAxes(plot); if (!(axis instanceof LogarithmicAxis)) { // XXX: @@ -356,7 +357,14 @@ protected NumberAxis createXAxis(String label) { - return new NumberAxis(label); + boolean logarithmic = (Boolean)diagramAttributes.getDomainAxis(). + isLog().evaluate((D4EArtifact)getMaster(), context); + + if (logarithmic) { + return new LogarithmicAxis(label); + } else { + return new NumberAxis(label); + } } @@ -1090,6 +1098,10 @@ return axisSections; } + protected String getYAxisLabel(int index) { + return getYAxisLabel(diagramAttributes.getAxisName(index)); + } + /** * Returns the Y-Axis label of a chart at position <i>pos</i>. * @@ -1157,7 +1169,15 @@ @Override protected NumberAxis createYAxis(int index) { - NumberAxis axis = super.createYAxis(index); + NumberAxis axis; + boolean logarithmic = (Boolean)diagramAttributes.getAxesAttributes(). + get(index).isLog().evaluate((D4EArtifact)getMaster(), context); + + if (logarithmic) { + axis = new LogarithmicAxis(getYAxisLabel(index)); + } else { + axis = super.createYAxis(index); + } if (diagramAttributes.getAxesAttributes().get(index).includeZero()) { axis.setAutoRangeIncludesZero(true);
--- a/artifacts/src/main/java/org/dive4elements/river/exports/FlowVelocityGenerator.java Tue Oct 15 15:32:36 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,554 +0,0 @@ -/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU AGPL (>=v3) - * and comes with ABSOLUTELY NO WARRANTY! Check out the - * documentation coming with Dive4Elements River for details. - */ - -package org.dive4elements.river.exports; - -import java.util.Arrays; - -import org.apache.log4j.Logger; - -import org.jfree.data.xy.XYSeries; - -import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; -import org.dive4elements.artifactdatabase.state.Facet; - -import org.dive4elements.river.artifacts.D4EArtifact; - -import org.dive4elements.river.artifacts.access.FlowVelocityAccess; -import org.dive4elements.river.artifacts.model.FacetTypes; -import org.dive4elements.river.artifacts.model.FlowVelocityData; -import org.dive4elements.river.artifacts.model.minfo.BedDiameterResult; -import org.dive4elements.river.artifacts.model.minfo.BedloadDiameterResult; -import org.dive4elements.river.model.FlowVelocityMeasurementValue; - -import org.dive4elements.river.jfree.Bounds; -import org.dive4elements.river.jfree.DoubleBounds; -import org.dive4elements.river.jfree.RiverAnnotation; -import org.dive4elements.river.jfree.StyledXYSeries; - -import org.dive4elements.river.themes.ThemeDocument; -import org.dive4elements.river.utils.RiverUtils; - - -/** - * An OutGenerator that generates flow velocity curves. - * - * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> - */ -public class FlowVelocityGenerator -extends XYChartGenerator -implements FacetTypes -{ - public enum YAXIS { - V(0), - T(1), - Q(2), - D(3); - /* TODO Q and Density will come as 4th and 3rd axis. */ - protected int idx; - private YAXIS(int c) { - idx = c; - } - } - - /** The logger that is used in this generator. */ - private static Logger logger = Logger.getLogger(FlowVelocityGenerator.class); - - /** Key to look up internationalized String for annotations label. */ - public static final String I18N_ANNOTATIONS_LABEL = - "chart.flow_velocity.annotations.label"; - - /** - * Key to look up internationalized String for LongitudinalSection diagrams - * titles. - */ - public static final String I18N_CHART_TITLE = - "chart.flow_velocity.section.title"; - - /** - * Key to look up internationalized String for LongitudinalSection diagrams - * subtitles. - */ - public static final String I18N_CHART_SUBTITLE = - "chart.flow_velocity.section.subtitle"; - - /** - * Key to look up internationalized String for LongitudinalSection diagrams - * short subtitles. - */ - public static final String I18N_CHART_SHORT_SUBTITLE = - "chart.flow_velocity.section.shortsubtitle"; - - public static final String I18N_XAXIS_LABEL = - "chart.flow_velocity.section.xaxis.label"; - - public static final String I18N_YAXIS_LABEL = - "chart.flow_velocity.section.yaxis.label"; - - public static final String I18N_2YAXIS_LABEL = - "chart.flow_velocity.section.yaxis.second.label"; - - public static final String I18N_3YAXIS_LABEL = - "chart.flow_velocity.section.yaxis.third.label"; - public static final String I18N_4YAXIS_LABEL = "chart.bedquality.yaxis.label.diameter"; - - public static final String I18N_CHART_TITLE_DEFAULT = "Geschwindigkeit- und Schubspannung"; - public static final String I18N_XAXIS_LABEL_DEFAULT = "km"; - public static final String I18N_YAXIS_LABEL_DEFAULT = "Geschwindigkeit v [m/s]"; - public static final String I18N_2YAXIS_LABEL_DEFAULT = "Schubspannung Tau [N]"; - public static final String I18N_3YAXIS_LABEL_DEFAULT = "Q [m³/s]"; - public static final String I18N_4YAXIS_LABEL_DEFAULT = "Durchmesser [mm]"; - - @Override - protected YAxisWalker getYAxisWalker() { - return new YAxisWalker() { - @Override - public int length() { - return YAXIS.values().length; - } - - @Override - public String getId(int idx) { - YAXIS[] yaxes = YAXIS.values(); - return yaxes[idx].toString(); - } - }; - } - - - /** - * Returns the default title for this chart. - * - * @return the default title for this chart. - */ - @Override - public String getDefaultChartTitle() { - Object[] args = new Object[] { - getRiverName() - }; - - return msg(I18N_CHART_TITLE, I18N_CHART_TITLE_DEFAULT, args); - } - - - /** - * Get internationalized label for the x axis. - */ - @Override - protected String getDefaultXAxisLabel() { - D4EArtifact flys = (D4EArtifact) master; - - return msg( - I18N_XAXIS_LABEL, - I18N_XAXIS_LABEL_DEFAULT, - new Object[] { RiverUtils.getRiver(flys).getName() }); - } - - - @Override - protected String getDefaultYAxisLabel(int index) { - String label = "default"; - - if (index == YAXIS.V.idx) { - label = getVAxisLabel(); - } - else if (index == YAXIS.T.idx) { - label = getTAxisLabel(); - } - else if (index == YAXIS.Q.idx) { - label = getQAxisLabel(); - } - else if (index == YAXIS.D.idx) { - label = getDAxisLabel(); - } - - return label; - } - - - /** - * Get internationalized label for the y axis. - */ - protected String getVAxisLabel() { - return msg(I18N_YAXIS_LABEL, I18N_YAXIS_LABEL_DEFAULT); - } - - - /** - * Get internationalized label for the y axis. - */ - protected String getQAxisLabel() { - return msg(I18N_3YAXIS_LABEL, I18N_3YAXIS_LABEL_DEFAULT); - } - - /** - * Get internationalized label for the y axis. - */ - protected String getTAxisLabel() { - return msg(I18N_2YAXIS_LABEL, I18N_2YAXIS_LABEL_DEFAULT); - } - - /** - * Get internationalized label for the y axis. - */ - protected String getDAxisLabel() { - return msg(I18N_4YAXIS_LABEL, I18N_4YAXIS_LABEL_DEFAULT); - } - - /** - * Produce output. - * @param artifactAndFacet current facet. - * @param attr theme for facet - * @param visible Whether this facets data is actually visible or not. - */ - public void doOut( - ArtifactAndFacet artifactAndFacet, - ThemeDocument attr, - boolean visible - ) { - String name = artifactAndFacet.getFacetName(); - - logger.debug("FlowVelocityGenerator.doOut: " + name); - - if (name == null) { - logger.error("No facet name for doOut(). No output generated!"); - return; - } - - Facet facet = artifactAndFacet.getFacet(); - - if (facet == null) { - return; - } - - if (getXBounds(0) != null && getDomainAxisRange() != null) { - logger.debug(Arrays.toString(getDomainAxisRangeFromRequest())); - Bounds bounds = - calculateZoom(getXBounds(0), getDomainAxisRange()); - context.putContextValue("startkm", bounds.getLower()); - context.putContextValue("endkm", bounds.getUpper()); - } - else if (getXBounds(0) != null && getDomainAxisRange() == null) { - context.putContextValue("startkm", getXBounds(0).getLower()); - context.putContextValue("endkm", getXBounds(0).getUpper()); - } - else if (getXBounds(0) == null && getDomainAxisRange() == null) { - D4EArtifact artifact = (D4EArtifact)artifactAndFacet.getArtifact(); - FlowVelocityAccess access = new FlowVelocityAccess(artifact); - context.putContextValue("startkm", access.getLowerKM()); - context.putContextValue("endkm", access.getUpperKM()); - } - else if (getXBounds(0) == null && getDomainAxisRange() != null){ - D4EArtifact artifact = (D4EArtifact)artifactAndFacet.getArtifact(); - FlowVelocityAccess access = new FlowVelocityAccess(artifact); - Bounds b = new DoubleBounds(access.getLowerKM(), access.getUpperKM()); - Bounds bounds = - calculateZoom(b, getDomainAxisRange()); - context.putContextValue("startkm", bounds.getLower()); - context.putContextValue("endkm", bounds.getUpper()); - } - if (name.equals(FLOW_VELOCITY_MAINCHANNEL)) { - doMainChannelOut( - (FlowVelocityData) artifactAndFacet.getData(context), - artifactAndFacet, - attr, - visible); - } - else if (name.equals(FLOW_VELOCITY_TOTALCHANNEL)) { - doTotalChannelOut( - (FlowVelocityData) artifactAndFacet.getData(context), - artifactAndFacet, - attr, - visible); - } - else if (name.equals(FLOW_VELOCITY_MAINCHANNEL_FILTERED)) { - doMainChannelOut( - (FlowVelocityData) artifactAndFacet.getData(context), - artifactAndFacet, - attr, - visible); - } - else if (name.equals(FLOW_VELOCITY_TOTALCHANNEL_FILTERED)) { - doTotalChannelOut( - (FlowVelocityData) artifactAndFacet.getData(context), - artifactAndFacet, - attr, - visible); - } - else if (name.equals(FLOW_VELOCITY_DISCHARGE)) { - doQOut( - (FlowVelocityData) artifactAndFacet.getData(context), - artifactAndFacet, - attr, - visible); - } - else if (name.equals(FLOW_VELOCITY_TAU)) { - doTauOut( - (FlowVelocityData) artifactAndFacet.getData(context), - artifactAndFacet, - attr, - visible); - } - else if (name.equals(FLOW_VELOCITY_TAU_FILTERED)) { - doTauOut( - (FlowVelocityData) artifactAndFacet.getData(context), - artifactAndFacet, - attr, - visible); - } - - else if (name.equals(FLOW_VELOCITY_ANNOTATION)) { - doAnnotations( - (RiverAnnotation) artifactAndFacet.getData(context), - artifactAndFacet, - attr, - visible); - } - else if (FacetTypes.IS.AREA(name)) { - doArea( - artifactAndFacet.getData(context), - artifactAndFacet, - attr, - visible); - } - else if (FacetTypes.IS.MANUALPOINTS(name)) { - doPoints( - artifactAndFacet.getData(context), - artifactAndFacet, - attr, - visible, - YAXIS.V.idx); - } - else if (name.equals(LONGITUDINAL_ANNOTATION)) { - doAnnotations( - (RiverAnnotation) artifactAndFacet.getData(context), - artifactAndFacet, - attr, - visible); - } - else if (name.equals(FLOW_VELOCITY_MEASUREMENT)) { - doVPointOut( - artifactAndFacet.getData(context), - artifactAndFacet, - attr, - visible); - } - else if (name.equals(BED_QUALITY_BED_DIAMETER_SUBLAYER)) { - doBedQualitySubLayerOut( - (BedDiameterResult)artifactAndFacet.getData(context), - artifactAndFacet, - attr, - visible); - } - else if (name.equals(BED_QUALITY_BED_DIAMETER_TOPLAYER)) { - doBedQualityTopLayerOut( - (BedDiameterResult)artifactAndFacet.getData(context), - artifactAndFacet, - attr, - visible); - } - else if (name.equals(BED_QUALITY_BEDLOAD_DIAMETER)) { - doBedQualityLoadDiameter( - (BedloadDiameterResult)artifactAndFacet.getData(context), - artifactAndFacet, - attr, - visible); - } - else { - logger.warn("Unknown facet name: " + name); - return; - } - } - - - private void doBedQualityLoadDiameter( - BedloadDiameterResult data, - ArtifactAndFacet aandf, - ThemeDocument attr, - boolean visible) { - XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), attr); - StyledSeriesBuilder.addPoints(series, data.getDiameterData(), true); - - addAxisSeries(series, YAXIS.D.idx, visible); - } - - - private void doBedQualityTopLayerOut( - BedDiameterResult data, - ArtifactAndFacet aandf, - ThemeDocument attr, - boolean visible) { - XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), attr); - StyledSeriesBuilder.addPoints(series, data.getDiameterSubData(), true); - addAxisSeries(series, YAXIS.D.idx, visible); - } - - - private void doBedQualitySubLayerOut( - BedDiameterResult data, - ArtifactAndFacet aandf, - ThemeDocument attr, - boolean visible - ) { - logger.debug("Do beddiametersubout"); - XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), attr); - StyledSeriesBuilder.addPoints(series, data.getDiameterSubData(), true); - addAxisSeries(series, YAXIS.D.idx, visible); - } - - - /** - * Process the output for W facets in a longitudinal section curve. - * - * @param data A FlowVelocityData object - * @param aandf The facet. This facet does NOT support any data objects. Use - * D4EArtifact.getNativeFacet() instead to retrieve a Facet which supports - * data. - * @param theme The theme that contains styling information. - * @param visible The visibility of the curve. - */ - protected void doMainChannelOut( - FlowVelocityData data, - ArtifactAndFacet aandf, - ThemeDocument theme, - boolean visible - ) { - logger.debug("FlowVelocityGenerator.doMainChannelOut"); - - XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), theme); - - StyledSeriesBuilder.addPoints(series, data.getMainChannelPoints(), true); - - addAxisSeries(series, YAXIS.V.idx, visible); - } - - - /** Handle VWQKms. */ - protected void doVPointOut ( - Object data, - ArtifactAndFacet aandf, - ThemeDocument theme, - boolean visible - ) { - logger.debug("FlowVelocityGenerator.doVPointOut"); - - XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), theme); - - FlowVelocityMeasurementValue.FastFlowVelocityMeasurementValue - value = (FlowVelocityMeasurementValue.FastFlowVelocityMeasurementValue) - data; - - StyledSeriesBuilder.addPoints(series, new double[][] {{value.getStation()},{value.getV()}}, true); - - addAxisSeries(series, YAXIS.V.idx, visible); - } - - - /** - * Add items to dataseries which describes the differences. - */ - protected void doTotalChannelOut( - FlowVelocityData data, - ArtifactAndFacet aandf, - ThemeDocument theme, - boolean visible - ) { - logger.debug("FlowVelocityGenerator.doTotalChannelOut"); - - if (data == null) { - logger.warn("No data to add to FlowVelocity chart."); - return; - } - - XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), theme); - - StyledSeriesBuilder.addPoints(series, data.getTotalChannelPoints(), true); - - addAxisSeries(series, YAXIS.V.idx, visible); - } - - - - /** - * @param data A FlowVelocityData object - * @param aandf The facet. This facet does NOT support any data objects. Use - * D4EArtifact.getNativeFacet() instead to retrieve a Facet which supports - * data. - * @param theme The theme that contains styling information. - * @param visible The visibility of the curve. - */ - protected void doQOut( - FlowVelocityData data, - ArtifactAndFacet aandf, - ThemeDocument theme, - boolean visible - ) { - logger.debug("FlowVelocityGenerator.doQOut"); - - XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), theme); - - StyledSeriesBuilder.addPoints(series, data.getQPoints(), true); - - addAxisSeries(series, YAXIS.Q.idx, visible); - } - - /** - * @param data A FlowVelocityData object - * @param aandf The facet. This facet does NOT support any data objects. Use - * D4EArtifact.getNativeFacet() instead to retrieve a Facet which supports - * data. - * @param theme The theme that contains styling information. - * @param visible The visibility of the curve. - */ - protected void doTauOut( - FlowVelocityData data, - ArtifactAndFacet aandf, - ThemeDocument theme, - boolean visible - ) { - logger.debug("FlowVelocityGenerator.doTauOut"); - - XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), theme); - - StyledSeriesBuilder.addPoints(series, data.getTauPoints(), true); - - addAxisSeries(series, YAXIS.T.idx, visible); - } - - - /** Look up the axis identifier for a given facet type. */ - public int axisIdxForFacet(String facetName) { - if (FacetTypes.IS.V(facetName)) { - return YAXIS.V.idx; - } - else if (FacetTypes.IS.T(facetName)) { - return YAXIS.T.idx; - } - else { - logger.warn("Could not find axis for facet " + facetName); - return YAXIS.V.idx; - } - } - - - /** - * Do Area out. - * @param theme styling information. - * @param visible whether or not visible. - */ - protected void doArea( - Object o, - ArtifactAndFacet aandf, - ThemeDocument theme, - boolean visible - ) { - logger.debug("FlowVelocityGenerator.doArea"); - logger.warn("TODO: Implement FlowVelocityGenerator.doArea"); - } -} -// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/artifacts/src/main/java/org/dive4elements/river/exports/FlowVelocityInfoGenerator.java Tue Oct 15 15:32:36 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,25 +0,0 @@ -/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU AGPL (>=v3) - * and comes with ABSOLUTELY NO WARRANTY! Check out the - * documentation coming with Dive4Elements River for details. - */ - -package org.dive4elements.river.exports; - - -/** - * A ChartInfoGenerator that generates meta information for specific - * flow velocity curves. - * - * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> - */ -public class FlowVelocityInfoGenerator -extends ChartInfoGenerator -{ - public FlowVelocityInfoGenerator() { - super(new FlowVelocityGenerator()); - } -} -// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/GeneratorLookup.java Tue Oct 15 18:41:55 2013 +0200 @@ -0,0 +1,54 @@ +/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde + * Software engineering by Intevation GmbH + * + * This file is Free Software under the GNU AGPL (>=v3) + * and comes with ABSOLUTELY NO WARRANTY! Check out the + * documentation coming with Dive4Elements River for details. + */ + +package org.dive4elements.river.exports; + +import java.util.HashMap; +import java.util.Map; + +import org.dive4elements.river.utils.Pair; +import org.dive4elements.river.artifacts.D4EArtifact.FacetFilter; + +public class GeneratorLookup +implements FacetFilter +{ + private Map<String, Pair<Class<OutGenerator>, Object>> generators; + + public GeneratorLookup() { + generators = new HashMap<String, Pair<Class<OutGenerator>, Object>>(); + } + + public void putGenerator( + String outName, + Class<OutGenerator> generatorClass, + Object ctx + ) { + Pair<Class<OutGenerator>, Object> pair = + new Pair<Class<OutGenerator>, Object>(generatorClass, ctx); + generators.put(outName, pair); + } + + public Pair<Class<OutGenerator>, Object> getGenerator(String outName) { + return generators.get(outName); + } + + @Override + public boolean accept(String outName, String facetName) { + + Pair<Class<OutGenerator>, Object> pair = generators.get(outName); + if (pair == null) { + return true; + } + + Object ff = pair.getB(); + return ff instanceof FacetFilter + ? ((FacetFilter)ff).accept(outName, facetName) + : true; + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/artifacts/src/main/java/org/dive4elements/river/exports/IsKmUpEvaluator.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/IsKmUpEvaluator.java Tue Oct 15 18:41:55 2013 +0200 @@ -11,7 +11,6 @@ import org.dive4elements.artifacts.CallContext; import org.dive4elements.river.artifacts.D4EArtifact; import org.dive4elements.river.artifacts.access.RiverAccess; -import org.dive4elements.river.artifacts.model.RiverFactory; import org.dive4elements.river.model.River; public class IsKmUpEvaluator @@ -23,7 +22,7 @@ @Override public Object evaluate(D4EArtifact artifact, CallContext context) { RiverAccess access = new RiverAccess(artifact); - River river = RiverFactory.getRiver(access.getRiver()); + River river = access.getRiver(); return river == null ? Boolean.FALSE : river.getKmUp();
--- a/artifacts/src/main/java/org/dive4elements/river/exports/LegendProcessor.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/LegendProcessor.java Tue Oct 15 18:41:55 2013 +0200 @@ -119,7 +119,7 @@ // Remove the shapes of all but the first items, // to prevent "overfill" of legenditemblock. - for (int i = 0; i < itemList.size(); i++) { + for (int i = 0, I = itemList.size(); i < I; i++) { if (i != 0) { LegendItem litem = itemList.get(i);
--- a/artifacts/src/main/java/org/dive4elements/river/exports/OutputHelper.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/OutputHelper.java Tue Oct 15 18:41:55 2013 +0200 @@ -83,7 +83,7 @@ doBlackboardPass(themeList, context, outName); try { - for (int i = 0; i < themeList.size(); i++) { + for (int i = 0, T = themeList.size(); i < T; i++) { ManagedFacet theme = themeList.get(i); if (theme == null) {
--- a/artifacts/src/main/java/org/dive4elements/river/exports/WaterlevelExporter.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/WaterlevelExporter.java Tue Oct 15 18:41:55 2013 +0200 @@ -390,7 +390,7 @@ } } } else { - for (int i = 0; i < wqkms.size(); i++) { + for (int i = 0, N = wqkms.size(); i < N; i++) { dp = wqkms.get(i, dp); if (dp[2] < last + 1E-5 && dp[2] > first - 1E-5) { filtered.add(dp[0], dp[1], dp[2]);
--- a/artifacts/src/main/java/org/dive4elements/river/exports/extreme/ExtremeWQCurveGenerator.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/extreme/ExtremeWQCurveGenerator.java Tue Oct 15 18:41:55 2013 +0200 @@ -197,7 +197,7 @@ context.getMeta(), I18N_CHART_SUBTITLE, "", - access.getRiver(), + access.getRiverName(), dateRange.getFrom(), dateRange.getTo(), refRange.getFrom(),
--- a/artifacts/src/main/java/org/dive4elements/river/exports/fixings/FixDeltaWtGenerator.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/fixings/FixDeltaWtGenerator.java Tue Oct 15 18:41:55 2013 +0200 @@ -130,7 +130,7 @@ context.getMeta(), I18N_CHART_SUBTITLE, "", - access.getRiver(), + access.getRiverName(), dateRange.getFrom(), dateRange.getTo(), refRange.getFrom(),
--- a/artifacts/src/main/java/org/dive4elements/river/exports/fixings/FixWQCurveGenerator.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/fixings/FixWQCurveGenerator.java Tue Oct 15 18:41:55 2013 +0200 @@ -282,15 +282,22 @@ DateFormat dateFormat = DateFormat.getDateInstance( DateFormat.SHORT); - series.add(qwd.getQ(), qwd.getW()); + double gaugeDatum = getCurrentGaugeDatum(); + double factor = (gaugeDatum == 0d) ? 1d : 100d; + series.add(qwd.getQ(), factor*(qwd.getW()-gaugeDatum)); XYTextAnnotation anno = new CollisionFreeXYTextAnnotation( dateFormat.format(qwd.getDate()), qwd.getQ(), - qwd.getW()); + factor*(qwd.getW()-gaugeDatum)); textAnnos.add(anno); - addAxisSeries(series, YAXIS.W.idx, visible); + if (gaugeDatum == 0d) { + addAxisSeries(series, YAXIS.W.idx, visible); + } + else { + addAxisSeries(series, YAXIS.WCm.idx, visible); + } if(visible && doc.parseShowPointLabel()) { RiverAnnotation flysAnno = new RiverAnnotation(null, null, null, doc); flysAnno.setTextAnnotations(textAnnos); @@ -319,20 +326,28 @@ DateFormat dateFormat = DateFormat.getDateInstance( DateFormat.SHORT); - series.add(qwd.getQ(), qwd.getW(), false); + double gaugeDatum = getCurrentGaugeDatum(); + double factor = (gaugeDatum == 0d) ? 1d : 100d; + series.add(qwd.getQ(), factor*(qwd.getW()-gaugeDatum), false); XYTextAnnotation anno = new CollisionFreeXYTextAnnotation( dateFormat.format(qwd.getDate()), qwd.getQ(), - qwd.getW()); + factor*(qwd.getW()-gaugeDatum)); textAnnos.add(anno); - addAxisSeries(series, YAXIS.W.idx, visible); if(visible && doc.parseShowPointLabel()) { RiverAnnotation flysAnno = new RiverAnnotation(null, null, null, doc); flysAnno.setTextAnnotations(textAnnos); addAnnotations(flysAnno); } + + if (gaugeDatum == 0d) { + addAxisSeries(series, YAXIS.W.idx, visible); + } + else { + addAxisSeries(series, YAXIS.WCm.idx, visible); + } } @@ -348,6 +363,8 @@ return; } double[] kms = wqkms.getKms(); + double gaugeDatum = getCurrentGaugeDatum(); + double factor = (gaugeDatum == 0d) ? 1d : 100d; for (int i = 0 ; i< kms.length; i++) { if (Math.abs(kms[i] - ckm) <= EPSILON) { series.add(wqkms.getQ(i), wqkms.getW(i), false); @@ -357,7 +374,7 @@ XYTextAnnotation anno = new CollisionFreeXYTextAnnotation( title, wqkms.getQ(i), - wqkms.getW(i)); + factor*(wqkms.getW(i)-gaugeDatum)); textAnnos.add(anno); RiverAnnotation flysAnno = new RiverAnnotation(null, null, null, theme); flysAnno.setTextAnnotations(textAnnos); @@ -401,8 +418,6 @@ double gaugeDatum = getCurrentGaugeDatum(); - double factor = (gaugeDatum == 0d) ? 1d : 100d; - if (gaugeDatum == 0d) { addAxisSeries(series, YAXIS.W.idx, visible); } @@ -417,7 +432,7 @@ addAxisSeries(series2, YAXIS.W.idx, false); // Use second axis at cm if at gauge. for (int i = 0; i < series.getItemCount(); i++) { - series.updateByIndex(i, new Double(factor*(series.getY(i).doubleValue()-gaugeDatum))); + series.updateByIndex(i, new Double(100d*(series.getY(i).doubleValue()-gaugeDatum))); } addAxisSeries(series, YAXIS.WCm.idx, visible); } @@ -570,8 +585,22 @@ } XYSeries series = new StyledXYSeries(description, theme); - StyledSeriesBuilder.addPointsQW(series, wqkms); - addAxisSeries(series, YAXIS.W.idx, visible); + + double gaugeDatum = getCurrentGaugeDatum(); + + if (true || gaugeDatum == 0d) { + StyledSeriesBuilder.addPointsQW(series, wqkms); + addAxisSeries(series, YAXIS.W.idx, visible); + } + else { + XYSeries series2 = new StyledXYSeries(description, theme); + StyledSeriesBuilder.addPointsQW(series2, wqkms); + addAxisSeries(series2, YAXIS.W.idx, false); + + // Use second axis... + StyledSeriesBuilder.addPointsQW(series, wqkms, -gaugeDatum, 100d); + addAxisSeries(series, YAXIS.WCm.idx, visible); + } } @@ -626,18 +655,25 @@ DateFormat dateFormat = DateFormat.getDateInstance( DateFormat.SHORT); + double gaugeDatum = getCurrentGaugeDatum(); + double factor = (gaugeDatum == 0d) ? 1d : 100d; for (QWI qw: qws) { - series.add(qw.getQ(), qw.getW(), false); + series.add(qw.getQ(), factor*(qw.getW()-gaugeDatum), false); XYTextAnnotation anno = new CollisionFreeXYTextAnnotation( dateFormat.format(qw.getDate()), qw.getQ(), - qw.getW()); + factor*(qw.getW()-gaugeDatum)); textAnnos.add(anno); } - addAxisSeries(series, YAXIS.W.idx, visible); - if (visible && theme.parseShowPointLabel()) { + if (gaugeDatum == 0d) { + addAxisSeries(series, YAXIS.W.idx, visible); + } + else { + addAxisSeries(series, YAXIS.WCm.idx, visible); + } + if (visible && theme != null && theme.parseShowPointLabel()) { RiverAnnotation flysAnno = new RiverAnnotation(null, null, null, theme); flysAnno.setTextAnnotations(textAnnos); @@ -670,7 +706,7 @@ context.getMeta(), I18N_CHART_SUBTITLE, "", - access.getRiver(), + access.getRiverName(), dateRange.getFrom(), dateRange.getTo(), refRange.getFrom(),
--- a/artifacts/src/main/java/org/dive4elements/river/exports/minfo/BedQualityExporter.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/minfo/BedQualityExporter.java Tue Oct 15 18:41:55 2013 +0200 @@ -15,7 +15,7 @@ import java.text.DateFormat; import java.text.NumberFormat; import java.util.Arrays; -import java.util.LinkedList; +import java.util.ArrayList; import java.util.List; import org.apache.log4j.Logger; @@ -71,18 +71,20 @@ BedDiameterResult[] beds = results[i].getBedResults(); for (int j = 0; j < beds.length; j++) { TDoubleArrayList bkms = beds[j].getKms(); - for (int k = 0; k < bkms.size(); k++) { - if (!kms.contains(bkms.get(k))) { - kms.add(bkms.get(k)); + for (int k = 0, K = bkms.size(); k < K; k++) { + double km = bkms.get(k); + if (!kms.contains(km)) { // XXX: O(N^2) + kms.add(km); } } } BedloadDiameterResult[] loads = results[i].getBedloadResults(); for (int j = 0; j < loads.length; j++) { TDoubleArrayList lkms = loads[i].getKms(); - for (int k = 0; k < lkms.size(); k++) { - if (!kms.contains(lkms.get(k))) { - kms.add(lkms.get(k)); + for (int k = 0, L = lkms.size(); k < L; k++) { + double km = lkms.get(k); + if (!kms.contains(km)) { // XXX: O(N^2) + kms.add(km); } } } @@ -94,8 +96,8 @@ } kms.sort(); - List<double[]> rows = new LinkedList<double[]>(); - for (int i = 0; i < kms.size(); i++) { + List<double[]> rows = new ArrayList<double[]>(kms.size()); + for (int i = 0, K = kms.size(); i < K; i++) { double[] row = new double[cols]; double km = kms.get(i); row[0] = km; @@ -134,7 +136,7 @@ } for (double[] d : rows) { logger.debug(Arrays.toString(d)); - List<String> cells = new LinkedList<String>(); + List<String> cells = new ArrayList<String>(d.length); for (int i = 0; i < d.length; i++) { if (!Double.isNaN(d[i])) { NumberFormat nf = Formatter.getFormatter(context, 1, 3); @@ -174,7 +176,7 @@ protected void writeCSVHeader(CSVWriter writer) { logger.debug("writeCSVHeader()"); - List<String> header = new LinkedList<String>(); + List<String> header = new ArrayList<String>(); if (results != null) { header.add(msg(CSV_HEADER_KM, "km")); for (int i = 0; i < results.length; i++) {
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/Processor.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/Processor.java Tue Oct 15 18:41:55 2013 +0200 @@ -44,9 +44,12 @@ /** * Processes data to generate e.g. a chart. + * Called for generators configured in the new-style way. + * In contrast to other doOut, no axis is given, as its name + * is in the given configuration. * - * @param generator XYChartGenerator to add output on. - * @param bundle The artifact and facet + * @param generator DiagramGenerator to add output on. + * @param bundle The artifact and facet * @param theme The theme that contains styling information. * @param visible The visibility of the curve. */ @@ -58,12 +61,13 @@ /** * Processes data to generate e.g. a chart. + * Called for 'unconconfigured' (old-style) generators. * - * @param generator DiagramGenerator to add output on. - * @param bundle The artifact and facet + * @param generator XYChartGenerator to add output on. + * @param bundle The artifact and facet. * @param theme The theme that contains styling information. * @param visible The visibility of the curve. - * @param index The index of the curve + * @param index The index of the axis. */ @Deprecated public void doOut(
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/QOutProcessor.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/QOutProcessor.java Tue Oct 15 18:41:55 2013 +0200 @@ -16,6 +16,7 @@ import org.dive4elements.river.artifacts.model.FacetTypes; import org.dive4elements.river.artifacts.model.WQKms; import org.dive4elements.river.artifacts.model.FlowVelocityData; +import org.dive4elements.river.model.FlowVelocityMeasurementValue.FastFlowVelocityMeasurementValue; import org.dive4elements.river.exports.StyledSeriesBuilder; import org.dive4elements.river.exports.XYChartGenerator; @@ -52,8 +53,17 @@ String facetName = bundle.getFacetName(); if (facetName.equals(FacetTypes.FLOW_VELOCITY_DISCHARGE)) { - FlowVelocityData fData = (FlowVelocityData) data; - StyledSeriesBuilder.addPoints(series, fData.getQPoints(), true); + if (data instanceof FlowVelocityData) { + FlowVelocityData fData = (FlowVelocityData) data; + StyledSeriesBuilder.addPoints(series, fData.getQPoints(), true); + } + else { + FastFlowVelocityMeasurementValue fData = + (FastFlowVelocityMeasurementValue) data; + double[][] points = new double[][] {{fData.getStation()},{fData.getQ()}}; + StyledSeriesBuilder.addPoints(series, points, true); + generator.addAxisSeries(series, axisName, visible); + } } else { WQKms wqkms = (WQKms) data; StyledSeriesBuilder.addStepPointsKmQ(series, wqkms);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/SQRelationProcessor.java Tue Oct 15 18:41:55 2013 +0200 @@ -0,0 +1,110 @@ +/* Copyright (C) 2013 by Bundesanstalt für Gewässerkunde + * Software engineering by Intevation GmbH + * + * This file is Free Software under the GNU AGPL (>=v3) + * and comes with ABSOLUTELY NO WARRANTY! Check out the + * documentation coming with Dive4Elements River for details. + */ + +package org.dive4elements.river.exports.process; + +import org.apache.log4j.Logger; +import org.jfree.data.xy.XYSeries; + +import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; +import org.dive4elements.artifacts.CallContext; +import org.dive4elements.river.exports.DiagramGenerator; +import org.dive4elements.river.jfree.StyledXYSeries; +import org.dive4elements.river.themes.ThemeDocument; +import org.dive4elements.river.artifacts.model.FacetTypes; + +import org.dive4elements.river.jfree.JFreeUtil; + +import org.dive4elements.river.artifacts.model.sq.SQ; +import org.dive4elements.river.artifacts.model.sq.SQFunction; + +public class SQRelationProcessor extends DefaultProcessor { + + public static final String I18N_AXIS_LABEL = + "chart.sq_relation.yaxis.label"; + public static final String I18N_AXIS_LABEL_DEFAULT = + ""; + + private final static Logger logger = + Logger.getLogger(SQRelationProcessor.class); + + @Override + public void doOut( + DiagramGenerator generator, + ArtifactAndFacet bundle, + ThemeDocument theme, + boolean visible) { + CallContext context = generator.getCallContext(); + String facetName = bundle.getFacetName(); + XYSeries series; + Object data = bundle.getData(context); + String desc = bundle.getFacetDescription(); + + if (data == null) { + // Check has been here before so we keep it but + // this should never happen. + logger.error("Data is null for facet: " + facetName); + return; + } + + if (FacetTypes.IS.SQ_CURVE(facetName)) { + SQFunction func = (SQFunction) data; + + series = JFreeUtil.sampleFunction2DPositive( + func.getFunction(), + theme, + desc, + 500, + Math.max(func.getMinQ(), 0.01), + Math.max(func.getMaxQ(), 0.02)); + + } else if (FacetTypes.IS.SQ_MEASUREMENT(facetName) || + FacetTypes.IS.SQ_OUTLIER(facetName)) { + + SQ[] sqs = (SQ[]) data; + series = new StyledXYSeries(desc, theme); + + for (SQ sq: sqs) { + double q = sq.getQ(); + double s = sq.getS(); + if (s > 0d && q > 0d) { + series.add(q, s, false); + } + } + } else { + logger.error("Could not handle: " + facetName); + return; + } + + if (logger.isDebugEnabled()) { + logger.debug("Series '" + desc + "' has " + + series.getItemCount() + " items."); + + logger.debug(" -> min x = " + series.getMinX()); + logger.debug(" -> max x = " + series.getMaxX()); + logger.debug(" -> min y = " + series.getMinY()); + logger.debug(" -> max y = " + series.getMaxY()); + } + + generator.addAxisSeries(series, axisName, visible); + } + + @Override + public boolean canHandle(String facettype) { + return FacetTypes.IS.SQ_CURVE(facettype) || + FacetTypes.IS.SQ_MEASUREMENT(facettype) || + FacetTypes.IS.SQ_OUTLIER(facettype); + } + + @Override + public String getAxisLabel(DiagramGenerator generator) { + return generator.msg( + I18N_AXIS_LABEL, + I18N_AXIS_LABEL_DEFAULT); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/SedimentDensityProcessor.java Tue Oct 15 18:41:55 2013 +0200 @@ -0,0 +1,73 @@ +/* Copyright (C) 2013 by Bundesanstalt für Gewässerkunde + * Software engineering by Intevation GmbH + * + * This file is Free Software under the GNU AGPL (>=v3) + * and comes with ABSOLUTELY NO WARRANTY! Check out the + * documentation coming with Dive4Elements River for details. + */ + +package org.dive4elements.river.exports.process; + +import org.apache.log4j.Logger; +import org.jfree.data.xy.XYSeries; + +import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; +import org.dive4elements.artifacts.CallContext; + +import org.dive4elements.river.artifacts.model.FacetTypes; +import org.dive4elements.river.artifacts.model.minfo.SedimentDensity; + +import org.dive4elements.river.exports.DiagramGenerator; +import org.dive4elements.river.exports.StyledSeriesBuilder; +import org.dive4elements.river.jfree.StyledXYSeries; +import org.dive4elements.river.themes.ThemeDocument; + + +/** Process Sediment Density data. */ +public class SedimentDensityProcessor extends DefaultProcessor { + + /** Private logger. */ + private final static Logger logger = + Logger.getLogger(SedimentDensityProcessor.class); + + public static final String I18N_AXIS_LABEL_DEFAULT = + "Sedimentdichte [t/m^3]"; + public static final String I18N_AXIS_LABEL = + "chart.yaxis.label.sedimentdensity"; + + @Override + public void doOut( + DiagramGenerator generator, + ArtifactAndFacet bundle, + ThemeDocument theme, + boolean visible) { + CallContext context = generator.getCallContext(); + XYSeries series = new StyledXYSeries(bundle.getFacetDescription(), + theme); + Object data = bundle.getData(context); + String facetName = bundle.getFacetName(); + double [][] points; + + if (facetName.equals(FacetTypes.SEDIMENT_DENSITY)) { + points =((SedimentDensity) data).getAllDensities(); + } else { + logger.error("Unknown facet name: " + facetName); + return; + } + StyledSeriesBuilder.addPoints(series, points, true); + + generator.addAxisSeries(series, axisName, visible); + } + + @Override + public boolean canHandle(String facettype) { + return facettype.equals(FacetTypes.SEDIMENT_DENSITY); + } + + @Override + public String getAxisLabel(DiagramGenerator generator) { + return generator.msg( + I18N_AXIS_LABEL, + I18N_AXIS_LABEL_DEFAULT); + } +}
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/WOutProcessor.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/WOutProcessor.java Tue Oct 15 18:41:55 2013 +0200 @@ -23,6 +23,7 @@ import org.dive4elements.river.jfree.StyledAreaSeriesCollection; import org.dive4elements.river.jfree.StyledXYSeries; import org.dive4elements.river.themes.ThemeDocument; +import org.dive4elements.river.model.FlowVelocityMeasurementValue.FastFlowVelocityMeasurementValue; import org.dive4elements.river.utils.RiverUtils; /** @@ -46,15 +47,27 @@ DiagramGenerator generator, ArtifactAndFacet bundle, ThemeDocument theme, - boolean visible) { + boolean visible + ) { + logger.debug("Processing facet: " + bundle.getFacetName()); CallContext context = generator.getCallContext(); Object data = bundle.getData(context); - WKms wkms = (WKms) data; - - logger.debug("Processing facet: " + bundle.getFacetName()); XYSeries series = new StyledXYSeries(bundle.getFacetDescription(), theme); + // Handle non WKms data. + if (bundle.getFacetName().equals(FacetTypes.FLOW_VELOCITY_WATERLEVEL)) { + FastFlowVelocityMeasurementValue fData = + (FastFlowVelocityMeasurementValue) data; + double[][] points = new double[][] {{fData.getStation()},{fData.getW()}}; + StyledSeriesBuilder.addPoints(series, points, true); + generator.addAxisSeries(series, axisName, visible); + return; + } + + // Handle WKms data. + WKms wkms = (WKms) data; + if (bundle.getFacetName().equals(FacetTypes.DISCHARGE_LONGITUDINAL_C)) { // Add corrected values WQCKms wqckms = (WQCKms) data; @@ -162,6 +175,7 @@ || facetType.equals(FacetTypes.HEIGHTMARKS_POINTS) || facetType.equals(FacetTypes.STATIC_WQKMS) || facetType.equals(FacetTypes.STATIC_WQKMS_W) + || facetType.equals(FacetTypes.FLOW_VELOCITY_WATERLEVEL) || facetType.equals(FacetTypes.DISCHARGE_LONGITUDINAL_W) || facetType.equals(FacetTypes.DISCHARGE_LONGITUDINAL_C)) { return true;
--- a/artifacts/src/main/java/org/dive4elements/river/exports/sq/SQOverviewGenerator.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/sq/SQOverviewGenerator.java Tue Oct 15 18:41:55 2013 +0200 @@ -35,7 +35,7 @@ import org.dive4elements.artifacts.common.utils.XMLUtils; import org.dive4elements.river.artifacts.context.RiverContext; import org.dive4elements.river.collections.D4EArtifactCollection; -import org.dive4elements.river.exports.ChartGenerator; +import org.dive4elements.river.exports.ChartGenerator2; import org.dive4elements.river.exports.OutGenerator; import org.dive4elements.river.exports.OutputHelper; import org.dive4elements.river.themes.ThemeDocument; @@ -87,11 +87,13 @@ String name = artifactAndFacet.getData(context).toString(); if(name != null) { logger.debug("name: " + name); - ChartGenerator g = - (ChartGenerator)RiverContext.getOutGenerator( + ChartGenerator2 g = + (ChartGenerator2)RiverContext.getOutGenerator( context, name, null); + /* Make sure master is also set in those */ + g.setMasterArtifact(master); if (g == null) { logger.debug("generator is null."); @@ -149,7 +151,7 @@ } BufferedImage result = new BufferedImage(size[0], size[1], BufferedImage.TYPE_INT_RGB); - for (int i = 0; i < charts.size(); i++) { + for (int i = 0, S = charts.size(); i < S; i++) { logger.debug("index: " + i); JFreeChart chart = charts.get(i); ChartRenderingInfo info = new ChartRenderingInfo();
--- a/artifacts/src/main/java/org/dive4elements/river/exports/sq/SQRelationGenerator.java Tue Oct 15 15:32:36 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,245 +0,0 @@ -/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU AGPL (>=v3) - * and comes with ABSOLUTELY NO WARRANTY! Check out the - * documentation coming with Dive4Elements River for details. - */ - -package org.dive4elements.river.exports.sq; - -import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; -import org.dive4elements.artifactdatabase.state.Facet; - -import org.dive4elements.river.artifacts.D4EArtifact; - -import org.dive4elements.river.artifacts.access.SQRelationAccess; - -import org.dive4elements.river.artifacts.model.FacetTypes; - -import org.dive4elements.river.artifacts.model.sq.SQ; -import org.dive4elements.river.artifacts.model.sq.SQFunction; - -import org.dive4elements.river.exports.XYChartGenerator; - -import org.dive4elements.river.jfree.JFreeUtil; -import org.dive4elements.river.jfree.StyledXYSeries; -import org.dive4elements.river.themes.ThemeDocument; - -import org.apache.log4j.Logger; - -import org.jfree.chart.axis.LogarithmicAxis; -import org.jfree.chart.axis.NumberAxis; - -import org.jfree.data.xy.XYSeries; - - -/** - * An OutGenerator that generates charts for MINFO sq relation. - * - * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> - */ -public class SQRelationGenerator -extends XYChartGenerator -implements FacetTypes -{ - public enum YAXIS { - S(0); - protected int idx; - private YAXIS(int c) { - idx = c; - } - } - - - public static final String I18N_XAXIS_LABEL = - "chart.sq_relation.xaxis.label"; - - public static final String I18N_YAXIS_LABEL = - "chart.sq_relation.yaxis.label"; - - public static final String I18N_SUBTITLE = - "chart.computed.discharge.curve.subtitle"; - - /** Needed to access data to create subtitle. */ - protected D4EArtifact artifact; - - /** The logger that is used in this generator. */ - private static Logger logger = Logger.getLogger(SQRelationGenerator.class); - - - @Override - protected YAxisWalker getYAxisWalker() { - return new YAxisWalker() { - @Override - public int length() { - return YAXIS.values().length; - } - - @Override - public String getId(int idx) { - YAXIS[] yaxes = YAXIS.values(); - return yaxes[idx].toString(); - } - }; - } - - /** - * Returns the default subtitle for this chart. - * - * @return the default subtitle for this chart. - */ - @Override - protected String getDefaultChartSubtitle() { - SQRelationAccess sqAccess = new SQRelationAccess(artifact); - Object[] args = null; - args = new Object[] { - sqAccess.getRiver(), - sqAccess.getLocation() - }; - return msg(I18N_SUBTITLE, "", args); - } - - - - @Override - public String getDefaultChartTitle() { - return "TODO: CHART TITLE"; - } - - - @Override - protected String getDefaultXAxisLabel() { - return msg(I18N_XAXIS_LABEL, I18N_XAXIS_LABEL); - } - - - @Override - protected String getDefaultYAxisLabel(int index) { - return msg(I18N_YAXIS_LABEL, I18N_YAXIS_LABEL); - } - - - @Override - protected NumberAxis createXAxis(String label) { - return new LogarithmicAxis(label); - } - - - @Override - protected NumberAxis createYAxis(int index) { - return new LogarithmicAxis(getDefaultYAxisLabel(index)); - } - - - @Override - public void doOut( - ArtifactAndFacet artifactAndFacet, - ThemeDocument attr, - boolean visible - ) { - logger.debug("doOut"); - - this.artifact = (D4EArtifact) artifactAndFacet.getArtifact(); - - Facet facet = artifactAndFacet.getFacet(); - String name = facet != null ? facet.getName() : null; - - if (name == null || name.length() == 0) { - logger.warn("Invalid facet with no name given!"); - return; - } - - if (IS.SQ_CURVE(name)) { - doSQCurveOut(artifactAndFacet, attr, visible); - } - else if (IS.SQ_MEASUREMENT(name)) { - doSQOut(artifactAndFacet, attr, visible); - } - else if (IS.SQ_OUTLIER(name)) { - doSQOut(artifactAndFacet, attr, visible); - } - else if (IS.MANUALPOINTS(name)) { - doPoints( - artifactAndFacet.getData(context), - artifactAndFacet, - attr, - visible, - YAXIS.S.idx); - } - } - - - protected void doSQCurveOut( - ArtifactAndFacet artifactAndFacet, - ThemeDocument attr, - boolean visible - ) { - String desc = artifactAndFacet.getFacetDescription(); - logger.debug("doSQCurveOut: " + desc); - - SQFunction func = (SQFunction) artifactAndFacet.getData(context); - - if (func == null) { - return; - } - - XYSeries series = JFreeUtil.sampleFunction2DPositive( - func.getFunction(), - attr, - desc, - 500, - Math.max(func.getMinQ(), 0.01), - Math.max(func.getMaxQ(), 0.02)); - - if (logger.isDebugEnabled()) { - logger.debug("Series '" + desc + "' has " - + series.getItemCount() + " items."); - - logger.debug(" -> min x = " + series.getMinX()); - logger.debug(" -> max x = " + series.getMaxX()); - logger.debug(" -> min y = " + series.getMinY()); - logger.debug(" -> max y = " + series.getMaxY()); - } - - addAxisSeries(series, YAXIS.S.idx, visible); - } - - - protected void doSQOut( - ArtifactAndFacet artifactAndFacet, - ThemeDocument attr, - boolean visible - ) { - String desc = artifactAndFacet.getFacetDescription(); - logger.debug("doSQOut: " + desc); - - SQ[] sqs = (SQ[]) artifactAndFacet.getData(context); - if (sqs == null) { - logger.debug("No SQs found for facet"); - return; - } - XYSeries series = new StyledXYSeries(desc, attr); - - for (SQ sq: sqs) { - double q = sq.getQ(); - double s = sq.getS(); - if (s > 0d && q > 0d) { - series.add(q, s, false); - } - } - - if (logger.isDebugEnabled()) { - logger.debug("Series '" + desc + "' has " - + series.getItemCount() + " items."); - - logger.debug(" -> min x = " + series.getMinX()); - logger.debug(" -> max x = " + series.getMaxX()); - logger.debug(" -> min y = " + series.getMinY()); - logger.debug(" -> max y = " + series.getMaxY()); - } - - addAxisSeries(series, YAXIS.S.idx, visible); - } -} -// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/artifacts/src/main/java/org/dive4elements/river/exports/sq/SQRelationGeneratorA.java Tue Oct 15 15:32:36 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,23 +0,0 @@ -/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU AGPL (>=v3) - * and comes with ABSOLUTELY NO WARRANTY! Check out the - * documentation coming with Dive4Elements River for details. - */ - -package org.dive4elements.river.exports.sq; - - -public class SQRelationGeneratorA extends SQRelationGenerator { - - public static final String I18N_CHART_TITLE = - "chart.sq_relation_a.title"; - - - @Override - public String getDefaultChartTitle() { - return msg(I18N_CHART_TITLE, I18N_CHART_TITLE); - } -} -// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/artifacts/src/main/java/org/dive4elements/river/exports/sq/SQRelationGeneratorB.java Tue Oct 15 15:32:36 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,23 +0,0 @@ -/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU AGPL (>=v3) - * and comes with ABSOLUTELY NO WARRANTY! Check out the - * documentation coming with Dive4Elements River for details. - */ - -package org.dive4elements.river.exports.sq; - - -public class SQRelationGeneratorB extends SQRelationGenerator { - - public static final String I18N_CHART_TITLE = - "chart.sq_relation_b.title"; - - - @Override - public String getDefaultChartTitle() { - return msg(I18N_CHART_TITLE, I18N_CHART_TITLE); - } -} -// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/artifacts/src/main/java/org/dive4elements/river/exports/sq/SQRelationGeneratorC.java Tue Oct 15 15:32:36 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,23 +0,0 @@ -/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU AGPL (>=v3) - * and comes with ABSOLUTELY NO WARRANTY! Check out the - * documentation coming with Dive4Elements River for details. - */ - -package org.dive4elements.river.exports.sq; - - -public class SQRelationGeneratorC extends SQRelationGenerator { - - public static final String I18N_CHART_TITLE = - "chart.sq_relation_c.title"; - - - @Override - public String getDefaultChartTitle() { - return msg(I18N_CHART_TITLE, I18N_CHART_TITLE); - } -} -// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/artifacts/src/main/java/org/dive4elements/river/exports/sq/SQRelationGeneratorD.java Tue Oct 15 15:32:36 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,23 +0,0 @@ -/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU AGPL (>=v3) - * and comes with ABSOLUTELY NO WARRANTY! Check out the - * documentation coming with Dive4Elements River for details. - */ - -package org.dive4elements.river.exports.sq; - - -public class SQRelationGeneratorD extends SQRelationGenerator { - - public static final String I18N_CHART_TITLE = - "chart.sq_relation_d.title"; - - - @Override - public String getDefaultChartTitle() { - return msg(I18N_CHART_TITLE, I18N_CHART_TITLE); - } -} -// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/artifacts/src/main/java/org/dive4elements/river/exports/sq/SQRelationGeneratorE.java Tue Oct 15 15:32:36 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,23 +0,0 @@ -/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU AGPL (>=v3) - * and comes with ABSOLUTELY NO WARRANTY! Check out the - * documentation coming with Dive4Elements River for details. - */ - -package org.dive4elements.river.exports.sq; - - -public class SQRelationGeneratorE extends SQRelationGenerator { - - public static final String I18N_CHART_TITLE = - "chart.sq_relation_e.title"; - - - @Override - public String getDefaultChartTitle() { - return msg(I18N_CHART_TITLE, I18N_CHART_TITLE); - } -} -// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/artifacts/src/main/java/org/dive4elements/river/exports/sq/SQRelationGeneratorF.java Tue Oct 15 15:32:36 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,23 +0,0 @@ -/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU AGPL (>=v3) - * and comes with ABSOLUTELY NO WARRANTY! Check out the - * documentation coming with Dive4Elements River for details. - */ - -package org.dive4elements.river.exports.sq; - - -public class SQRelationGeneratorF extends SQRelationGenerator { - - public static final String I18N_CHART_TITLE = - "chart.sq_relation_f.title"; - - - @Override - public String getDefaultChartTitle() { - return msg(I18N_CHART_TITLE, I18N_CHART_TITLE); - } -} -// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/artifacts/src/main/java/org/dive4elements/river/exports/sq/SQRelationInfoGenerator.java Tue Oct 15 15:32:36 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,27 +0,0 @@ -/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU AGPL (>=v3) - * and comes with ABSOLUTELY NO WARRANTY! Check out the - * documentation coming with Dive4Elements River for details. - */ - -package org.dive4elements.river.exports.sq; - -import org.dive4elements.river.exports.ChartInfoGenerator; - - -/** - * A ChartInfoGenerator that generates meta information for specific - * sq relation charts. - * - * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> - */ -public class SQRelationInfoGenerator -extends ChartInfoGenerator -{ - public SQRelationInfoGenerator() { - super(new SQRelationGenerator()); - } -} -// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/artifacts/src/main/java/org/dive4elements/river/utils/ArtifactMapfileGenerator.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/utils/ArtifactMapfileGenerator.java Tue Oct 15 18:41:55 2013 +0200 @@ -94,7 +94,7 @@ layerinfo.setDirectory(identifier); layerinfo.setData(WSPLGEN_RESULT_SHAPE); - String river = access.getRiver(); + String river = access.getRiverName(); double from = access.hasFrom() ? access.getFrom() : 0d; double to = access.hasTo() ? access.getTo() : 0d;
--- a/artifacts/src/main/java/org/dive4elements/river/utils/KMIndex.java Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/utils/KMIndex.java Tue Oct 15 18:41:55 2013 +0200 @@ -80,6 +80,7 @@ Collections.sort(entries); } + /** Return the first entry at km. */ public Entry<A> search(double km) { for (Entry<A> entry: entries) { if (entry.epsilonEquals(km)) {
--- a/artifacts/src/main/resources/messages.properties Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/resources/messages.properties Tue Oct 15 18:41:55 2013 +0200 @@ -234,11 +234,20 @@ chart.sq_relation_e.title = Grobkornanteil (> Mittelkies) chart.sq_relation_f.title = Geschiebetransport gesamt facet.sq_relation.curve = Potenziell (Geschiebedaten) +facet.sq_relation.static_data = {0} to {1} facet.sq_relation.measurements = Geschiebedaten facet.sq_relation.outliers = Ausrei\u00dfer Durchgang {0} facet.sq_relation.outlier.curve = Potenziell Durchgang {0} facet.sq_relation.outlier.measurement = Geschiebedaten Durchgang {0} +sedimentdensity = sediment density +coarse = Coarse gravel +sand = Sand +fine_middle = Fine/Mid. gravel +susp_sand = Susp. Sand +susp_sand_bed = Bed. part Susp.Sand +suspended_sediment = Sediment + chart.sedimentload.ls.title = Sediment load chart.sedimentload.ls.xaxis.label = km chart.sedimentload.ls.yaxis.label.diff = [t/a]
--- a/artifacts/src/main/resources/messages_de.properties Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/resources/messages_de.properties Tue Oct 15 18:41:55 2013 +0200 @@ -235,10 +235,19 @@ chart.sq_relation_f.title = Geschiebetransport gesamt facet.sq_relation.curve = Potenziell (Geschiebedaten) facet.sq_relation.measurements = Geschiebedaten +facet.sq_relation.static_data = {0} bis {1} facet.sq_relation.outliers = Ausrei\u00dfer Durchgang {0} facet.sq_relation.outlier.curve = Potenziell Durchgang {0} facet.sq_relation.outlier.measurement = Geschiebedaten Durchgang {0} +sedimentdensity = Sedimentdichte +coarse = Grober Kies +sand = Sand +fine_middle = Feine/Mittl. Kies +susp_sand = Susp. Sand +susp_sand_bed = Bettb. Anteil Susp. Sand +suspended_sediment = Schwebstoff + chart.sedimentload.ls.title = Sedimentfracht chart.sedimentload.ls.xaxis.label = km chart.sedimentload.ls.yaxis.label.diff = [t/a]
--- a/artifacts/src/main/resources/messages_de_DE.properties Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/resources/messages_de_DE.properties Tue Oct 15 18:41:55 2013 +0200 @@ -233,10 +233,19 @@ chart.sq_relation_f.title = Geschiebetransport gesamt facet.sq_relation.curve = Potenziell (Geschiebedaten) facet.sq_relation.measurements = Geschiebedaten +facet.sq_relation.static_data = {0} bis {1} facet.sq_relation.outliers = Ausrei\u00dfer Durchgang {0} facet.sq_relation.outlier.curve = Potenziell Durchgang {0} facet.sq_relation.outlier.measurement = Geschiebedaten Durchgang {0} +sedimentdensity = Sedimentdichte +sand = Sand +fine_middle = Feine/Mittl. Kies +susp_sand = Susp. Sand +susp_sand_bed = Bettb. Anteil Susp. Sand +suspended_sediment = Schwebstoff +coarse = Grober Kies + chart.sedimentload.ls.title = Sedimentfracht chart.sedimentload.ls.xaxis.label = km chart.sedimentload.ls.yaxis.label.diff = [t/a]
--- a/artifacts/src/main/resources/messages_en.properties Tue Oct 15 15:32:36 2013 +0200 +++ b/artifacts/src/main/resources/messages_en.properties Tue Oct 15 18:41:55 2013 +0200 @@ -238,10 +238,19 @@ chart.sq_relation_f.title = Geschiebetransport gesamt facet.sq_relation.curve = Potenziell (Geschiebedaten) facet.sq_relation.measurements = Geschiebedaten +facet.sq_relation.static_data = {0} to {1} facet.sq_relation.outliers = Ausrei\u00dfer Durchgang {0} facet.sq_relation.outlier.curve = Potenziell Durchgang {0} facet.sq_relation.outlier.measurement = Geschiebedaten Durchgang {0} +sedimentdensity = sediment density +coarse = Coarse gravel +sand = Sand +fine_middle = Fine/Mid. gravel +susp_sand = Susp. Sand +susp_sand_bed = Bed. part Susp.Sand +suspended_sediment = Sediment + chart.sedimentload.ls.title = Sediment load chart.sedimentload.ls.xaxis.label = km chart.sedimentload.ls.yaxis.label.diff = [t/a]
--- a/backend/src/main/java/org/dive4elements/river/importer/ImportBedHeightSingle.java Tue Oct 15 15:32:36 2013 +0200 +++ b/backend/src/main/java/org/dive4elements/river/importer/ImportBedHeightSingle.java Tue Oct 15 18:41:55 2013 +0200 @@ -145,19 +145,19 @@ if (theType == null) { log.warn("BHS: No bed height type given. Skip file '" + - description + "'"); + description + "'"); return null; } if (theCurModel == null) { log.warn("BHS: No elevation model given. Skip file '" + - description + "'"); + description + "'"); return null; } if (theRange == null) { log.warn("BHS: No km-range given: '" + - description + "'"); + description + "'"); } Session session = ImporterSession.getInstance().getDatabaseSession();
--- a/backend/src/main/java/org/dive4elements/river/importer/ImportRiver.java Tue Oct 15 15:32:36 2013 +0200 +++ b/backend/src/main/java/org/dive4elements/river/importer/ImportRiver.java Tue Oct 15 18:41:55 2013 +0200 @@ -356,12 +356,17 @@ continue; } log.info("found file '" + file.getName() + "'"); - WstParser wstParser = new WstParser(); - wstParser.parse(file); - ImportWst iw = wstParser.getWst(); - iw.setKind(5); - iw.setDescription(FLOOD_PROTECTION + "/" + iw.getDescription()); - floodProtection.add(iw); + try { + WstParser wstParser = new WstParser(); + wstParser.parse(file); + ImportWst iw = wstParser.getWst(); + iw.setKind(5); + iw.setDescription(FLOOD_PROTECTION + "/" + iw.getDescription()); + floodProtection.add(iw); + } + catch (WstParser.ParseException e) { + log.error(e); + } } } @@ -768,12 +773,17 @@ continue; } log.info("found file '" + file.getName() + "'"); - WstParser wstParser = new WstParser(); - wstParser.parse(file); - ImportWst iw = wstParser.getWst(); - iw.setKind(4); - iw.setDescription(FLOOD_WATER + "/" + iw.getDescription()); - floodWater.add(iw); + try { + WstParser wstParser = new WstParser(); + wstParser.parse(file); + ImportWst iw = wstParser.getWst(); + iw.setKind(4); + iw.setDescription(FLOOD_WATER + "/" + iw.getDescription()); + floodWater.add(iw); + } + catch (WstParser.ParseException e) { + log.error(e); + } } } @@ -805,7 +815,14 @@ ImportWst iw = new ImportWst(ImportOfficialWstColumn.COLUMN_FACTORY); WstParser wstParser = new WstParser(iw); - wstParser.parse(file); + try { + wstParser.parse(file); + } + catch (WstParser.ParseException e) { + log.error(e); + continue; + } + iw.setKind(3); iw.setDescription(folder + "/" + iw.getDescription()); @@ -878,12 +895,17 @@ } log.debug("Found WST file: " + file); - WstParser wstParser = new WstParser(); - wstParser.parse(file); - ImportWst iw = wstParser.getWst(); - iw.setKind(2); - iw.setDescription(FIXATIONS+ "/" + iw.getDescription()); - fixations.add(iw); + try { + WstParser wstParser = new WstParser(); + wstParser.parse(file); + ImportWst iw = wstParser.getWst(); + iw.setKind(2); + iw.setDescription(FIXATIONS+ "/" + iw.getDescription()); + fixations.add(iw); + } + catch (WstParser.ParseException e) { + log.error(e); + } } } @@ -922,12 +944,17 @@ } log.debug("Found WST file: " + file); - WstParser wstParser = new WstParser(); - wstParser.parse(file); - ImportWst iw = wstParser.getWst(); - iw.setKind(1); - iw.setDescription(EXTRA_LONGITUDINALS + "/" + iw.getDescription()); - extraWsts.add(iw); + try { + WstParser wstParser = new WstParser(); + wstParser.parse(file); + ImportWst iw = wstParser.getWst(); + iw.setKind(1); + iw.setDescription(EXTRA_LONGITUDINALS + "/" + iw.getDescription()); + extraWsts.add(iw); + } + catch (WstParser.ParseException e) { + log.error(e); + } } } @@ -939,9 +966,14 @@ } WstParser wstParser = new WstParser(); - wstParser.parse(wstFile); - wst = wstParser.getWst(); - wst.setKmUp(wst.guessWaterLevelIncreasing()); + try { + wstParser.parse(wstFile); + wst = wstParser.getWst(); + wst.setKmUp(wst.guessWaterLevelIncreasing()); + } + catch (WstParser.ParseException e) { + log.error(e); + } } public void parseGauges() throws IOException { @@ -1356,8 +1388,7 @@ log.debug("name: " + desc); - single.storeDependencies(river); - + single.storeDependencies(river); } } else { @@ -1377,8 +1408,7 @@ log.debug("name: " + desc); - epoch.storeDependencies(river); - + epoch.storeDependencies(river); } } else { @@ -1397,8 +1427,7 @@ log.debug("name: " + desc); - density.storeDependencies(river); - + density.storeDependencies(river); } } } @@ -1410,9 +1439,7 @@ River river = getPeer(); for (ImportMorphWidth width: morphologicalWidths) { - - width.storeDependencies(river); - + width.storeDependencies(river); } } } @@ -1424,15 +1451,11 @@ River river = getPeer(); for (ImportFlowVelocityModel flowVelocityModel: flowVelocityModels){ - - flowVelocityModel.storeDependencies(river); - + flowVelocityModel.storeDependencies(river); } for (ImportFlowVelocityMeasurement m: flowVelocityMeasurements) { - - m.storeDependencies(river); - + m.storeDependencies(river); } } } @@ -1445,9 +1468,7 @@ River river = getPeer(); for (ImportSedimentYield sedimentYield: sedimentYields) { - - sedimentYield.storeDependencies(river); - + sedimentYield.storeDependencies(river); } } } @@ -1462,12 +1483,10 @@ int count = 0; for (ImportMeasurementStation station: measurementStations) { - - boolean success = station.storeDependencies(river); - if (success) { - count++; - } - + boolean success = station.storeDependencies(river); + if (success) { + count++; + } } log.info("stored " + count + " measurement stations."); @@ -1484,10 +1503,8 @@ int count = 0; for (ImportSQRelation sqRelation: sqRelations) { - - sqRelation.storeDependencies(river); - count++; - + sqRelation.storeDependencies(river); + count++; } log.info("stored " + count + " sq relations.");
--- a/backend/src/main/java/org/dive4elements/river/importer/ImportWstColumn.java Tue Oct 15 15:32:36 2013 +0200 +++ b/backend/src/main/java/org/dive4elements/river/importer/ImportWstColumn.java Tue Oct 15 18:41:55 2013 +0200 @@ -187,7 +187,7 @@ Query query = session.createQuery( "from WstColumn where" + " wst=:wst and name=:name" + - " and source=:source" + + " and source=:source" + " and position=:position"); query.setParameter("wst", w); query.setParameter("name", name);
--- a/backend/src/main/java/org/dive4elements/river/importer/parsers/BedHeightParser.java Tue Oct 15 15:32:36 2013 +0200 +++ b/backend/src/main/java/org/dive4elements/river/importer/parsers/BedHeightParser.java Tue Oct 15 18:41:55 2013 +0200 @@ -102,7 +102,6 @@ protected TreeSet<Double> kmExists; - public BedHeightParser() { bedHeights = new ArrayList<ImportBedHeight>(); kmExists = new TreeSet<Double>(EpsilonComparator.CMP); @@ -262,11 +261,11 @@ return true; } catch (NumberFormatException e) { - log.warn("BHP: Could not parse sounding width in line '" + line + - "'. -> Set default value '0'"); + log.warn("BHP: Could not parse sounding width in line '" + line + + "'. -> Set default value '0'"); } obj.setSoundingWidth(0); - return true; + return true; } return false;
--- a/backend/src/main/java/org/dive4elements/river/importer/parsers/FlowVelocityModelParser.java Tue Oct 15 15:32:36 2013 +0200 +++ b/backend/src/main/java/org/dive4elements/river/importer/parsers/FlowVelocityModelParser.java Tue Oct 15 18:41:55 2013 +0200 @@ -94,8 +94,7 @@ @Override protected void finish() { models.add(current); - - // description = null; + // description = null; }
--- a/backend/src/main/java/org/dive4elements/river/importer/parsers/LineParser.java Tue Oct 15 15:32:36 2013 +0200 +++ b/backend/src/main/java/org/dive4elements/river/importer/parsers/LineParser.java Tue Oct 15 18:41:55 2013 +0200 @@ -140,7 +140,7 @@ /** Create Date on first moment (1st jan) of given year. */ public static Date getStartDateFromYear(int year) { Calendar cal = Calendar.getInstance(); - cal.clear(); + cal.clear(); cal.set(year, 0, 1, 0, 0, 0); return cal.getTime(); @@ -150,7 +150,7 @@ /** Create Date on last moment (31st dec) of given year. */ public static Date getEndDateFromYear(int year) { Calendar cal = Calendar.getInstance(); - cal.clear(); + cal.clear(); cal.set(year, 11, 31, 23, 59, 59); return cal.getTime();
--- a/backend/src/main/java/org/dive4elements/river/importer/parsers/SQRelationParser.java Tue Oct 15 15:32:36 2013 +0200 +++ b/backend/src/main/java/org/dive4elements/river/importer/parsers/SQRelationParser.java Tue Oct 15 18:41:55 2013 +0200 @@ -127,18 +127,21 @@ Integer nOutlier = parseInteger(cols[11], line); Double cFer = parseDouble(cols[12], line); Double cDuan = parseDouble(cols[13], line); - if (km == null || a == null || b == null || - qMax == null || cols[1].length() == 0) { - if (km == null) { - log.error("No km for measurement station: Can not reference measurement station: " - + line); - } - if ( a == null || b == null || - qMax == null || cols[1].length() == 0) { - log.error("Incomplete SQ-relation row (missing a, b, Qmax or parameter): " - + line); - } - return; + + if (km == null || a == null || b == null + || qMax == null || cols[1].length() == 0 + ) { + if (km == null) { + log.error("No km for measurement station: Can not reference measurement station: " + + line); + } + if (a == null || b == null + || qMax == null || cols[1].length() == 0 + ) { + log.error("Incomplete SQ-relation row (missing a, b, Qmax or parameter): " + + line); + } + return; } current.addValue(new ImportSQRelationValue( cols[1],
--- a/backend/src/main/java/org/dive4elements/river/importer/parsers/SedimentYieldParser.java Tue Oct 15 15:32:36 2013 +0200 +++ b/backend/src/main/java/org/dive4elements/river/importer/parsers/SedimentYieldParser.java Tue Oct 15 18:41:55 2013 +0200 @@ -379,7 +379,7 @@ public static String getGrainFractionTypeName(String filename) { if (Pattern.matches(FRACTION_COARSE_STR, filename)) { - return GrainFraction.COARSE; + return GrainFraction.COARSE; } else if (Pattern.matches(FRACTION_FINE_MIDDLE_STR, filename)) { return GrainFraction.FINE_MIDDLE; @@ -391,7 +391,7 @@ else if (Pattern.matches(FRACTION_SUSP_SAND, filename)) { return GrainFraction.SUSP_SAND; } - else if (Pattern.matches(FRACTION_SAND, filename)) { + else if (Pattern.matches(FRACTION_SAND, filename)) { return GrainFraction.SAND; } else if (Pattern.matches(FRACTION_SUSPENDED_SEDIMENT, filename)) {
--- a/backend/src/main/java/org/dive4elements/river/importer/parsers/WstParser.java Tue Oct 15 15:32:36 2013 +0200 +++ b/backend/src/main/java/org/dive4elements/river/importer/parsers/WstParser.java Tue Oct 15 18:41:55 2013 +0200 @@ -87,6 +87,15 @@ this.wst = wst; } + public static final class ParseException extends Exception { + public ParseException() { + } + + public ParseException(String msg) { + super(msg); + } + } // class ParseException + /** Returns a new ImportTimeInterval with a date guessed from string. */ public static ImportTimeInterval guessDate(String string) { try { @@ -107,7 +116,7 @@ return null; } - public void parse(File file) throws IOException { + public void parse(File file) throws IOException, ParseException { log.info("Parsing WST file '" + file + "'"); @@ -240,7 +249,7 @@ continue; } quellen = StringUtil.splitQuoted(spezial, '"'); - log.debug("sources: " + Arrays.toString(quellen)); + log.debug("sources: " + Arrays.toString(quellen)); } else if (spezial.startsWith(COLUMN_DATUM)) { spezial = spezial.substring(COLUMN_DATUM.length()).trim();
--- a/backend/src/main/java/org/dive4elements/river/model/BedHeightType.java Tue Oct 15 15:32:36 2013 +0200 +++ b/backend/src/main/java/org/dive4elements/river/model/BedHeightType.java Tue Oct 15 18:41:55 2013 +0200 @@ -72,14 +72,14 @@ } public static BedHeightType fetchBedHeightTypeForType(String type) { - return fetchBedHeightTypeForType(type, null); + return fetchBedHeightTypeForType(type, null); } public static BedHeightType fetchBedHeightTypeForType(String name, Session session) { - if (session == null) { - session = SessionHolder.HOLDER.get(); - } + if (session == null) { + session = SessionHolder.HOLDER.get(); + } Query query = session.createQuery( "from BedHeightType where name=:name");
--- a/backend/src/main/java/org/dive4elements/river/model/FlowVelocityModel.java Tue Oct 15 15:32:36 2013 +0200 +++ b/backend/src/main/java/org/dive4elements/river/model/FlowVelocityModel.java Tue Oct 15 18:41:55 2013 +0200 @@ -110,5 +110,17 @@ return query.list(); } + + public static FlowVelocityModel getModel(int id) { + + Session session = SessionHolder.HOLDER.get(); + + Query query = session.createQuery( + "from FlowVelocityModel where id=:id"); + + query.setParameter("id", id); + + return (FlowVelocityModel) query.list().get(0); + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/backend/src/main/java/org/dive4elements/river/model/SedimentDensityValue.java Tue Oct 15 15:32:36 2013 +0200 +++ b/backend/src/main/java/org/dive4elements/river/model/SedimentDensityValue.java Tue Oct 15 18:41:55 2013 +0200 @@ -45,14 +45,14 @@ public SedimentDensityValue( SedimentDensity sedimentDensity, BigDecimal station, - BigDecimal shoreOffset, + BigDecimal shoreOffset, BigDecimal density, BigDecimal year, String desc ) { this.sedimentDensity = sedimentDensity; this.station = station; - this.shoreOffset = shoreOffset; + this.shoreOffset = shoreOffset; this.density = density; this.year = year; this.description = desc;
--- a/backend/src/main/java/org/dive4elements/river/seddb/model/SlotlinksId.java Tue Oct 15 15:32:36 2013 +0200 +++ b/backend/src/main/java/org/dive4elements/river/seddb/model/SlotlinksId.java Tue Oct 15 18:41:55 2013 +0200 @@ -181,11 +181,11 @@ public boolean equals(Object other) { if ( (this == other ) ) return true; - if ( (other == null ) ) return false; - if ( !(other instanceof SlotlinksId) ) return false; - SlotlinksId castOther = ( SlotlinksId ) other; + if ( (other == null ) ) return false; + if ( !(other instanceof SlotlinksId) ) return false; + SlotlinksId castOther = ( SlotlinksId ) other; - return (this.getSlotrechteid()==castOther.getSlotrechteid()) + return (this.getSlotrechteid()==castOther.getSlotrechteid()) && (this.getMessungid()==castOther.getMessungid()) && ( (this.getUferabst()==castOther.getUferabst()) || ( this.getUferabst()!=null && castOther.getUferabst()!=null && this.getUferabst().equals(castOther.getUferabst()) ) ) && ( (this.getTsand()==castOther.getTsand()) || ( this.getTsand()!=null && castOther.getTsand()!=null && this.getTsand().equals(castOther.getTsand()) ) )
--- a/backend/src/main/java/org/dive4elements/river/seddb/model/SsiebungsiebId.java Tue Oct 15 15:32:36 2013 +0200 +++ b/backend/src/main/java/org/dive4elements/river/seddb/model/SsiebungsiebId.java Tue Oct 15 18:41:55 2013 +0200 @@ -588,11 +588,11 @@ public boolean equals(Object other) { if ( (this == other ) ) return true; - if ( (other == null ) ) return false; - if ( !(other instanceof SsiebungsiebId) ) return false; - SsiebungsiebId castOther = ( SsiebungsiebId ) other; + if ( (other == null ) ) return false; + if ( !(other instanceof SsiebungsiebId) ) return false; + SsiebungsiebId castOther = ( SsiebungsiebId ) other; - return (this.getSiebanalyseid()==castOther.getSiebanalyseid()) + return (this.getSiebanalyseid()==castOther.getSiebanalyseid()) && (this.getGsiebsatzid()==castOther.getGsiebsatzid()) && ( (this.getGmasse()==castOther.getGmasse()) || ( this.getGmasse()!=null && castOther.getGmasse()!=null && this.getGmasse().equals(castOther.getGmasse()) ) ) && ( (this.getMasche01()==castOther.getMasche01()) || ( this.getMasche01()!=null && castOther.getMasche01()!=null && this.getMasche01().equals(castOther.getMasche01()) ) )
--- a/etl/README.txt Tue Oct 15 15:32:36 2013 +0200 +++ b/etl/README.txt Tue Oct 15 18:41:55 2013 +0200 @@ -252,6 +252,14 @@ Der DIPS-Pegel Name hat eine Pegelnummer <NUMMER>, die sich nicht in einen 64bit-Integer erwandeln lässt. +DIPS: Skipping Gauge: '<NAME>' because it is at Station: <pos> and the +river is limited to: <fromkm> - <tokm> + + Der DIPS Pegel wurde nicht eingelesen da seine Stationierung + nicht mit den Fluss Kilometern in FLYS übereinstimmt. In einer + darauffolgenden Meldung wird geloggt das dieser Pegel nicht in + DIPS vorhanden ist (da er nicht eingelesen wurde). + AFT: ----
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/etl/doc/havel.xsl Tue Oct 15 18:41:55 2013 +0200 @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8"?> +<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> + + <xsl:output method="xml"/> + + <xsl:template match="/DIPSFLYS/STATIONEN/PEGELSTATION[@GEWAESSER='Untere Havel-Wasserstraße (UHW)']"> + <PEGELSTATION> + <xsl:attribute name="GEWAESSER">Havel</xsl:attribute> + <xsl:apply-templates select="@*[local-name() != 'GEWAESSER']"/> + <xsl:apply-templates select="node()"/> + </PEGELSTATION> + </xsl:template> + + <xsl:template match="@*|node()"> + <xsl:copy> + <xsl:apply-templates select="@*|node()"/> + </xsl:copy> + </xsl:template> + +</xsl:stylesheet>
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.java Tue Oct 15 15:32:36 2013 +0200 +++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.java Tue Oct 15 18:41:55 2013 +0200 @@ -588,6 +588,8 @@ String sq_relation_export(); + String sq_relations(); + String exportATTooltip(); String load_diameter(); @@ -822,6 +824,12 @@ String waterlevels(); + String waterlevels_discharge(); + + String waterlevels_fix(); + + String waterlevels_ls(); + String beddifferences(); String bedheight_differences(); @@ -852,6 +860,8 @@ String flowvelocitymeasurement(); + String flowvelocitymodel(); + String bed_quality_bed(); String bed_quality_load(); @@ -946,6 +956,20 @@ String epochs(); + String densities(); + + String sand(); + + String fine_middle(); + + String susp_sediment(); + + String coarse(); + + String susp_sand(); + + String susp_sand_bed(); + // Capabilities Information Panel String addwmsInputTitle();
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.properties Tue Oct 15 15:32:36 2013 +0200 +++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.properties Tue Oct 15 18:41:55 2013 +0200 @@ -424,6 +424,9 @@ # data cage waterlevels = Waterlevels +waterlevels_ls = Longitudinal Section +waterlevels_discharge = Discharge Longitudinal Section +waterlevels_fix = Waterlevels from fixation analyis beddifferences = Bedheight Differences bedheight_differences = Bedheight Differences vollmer_waterlevels = Vollmer Waterlevels @@ -439,6 +442,7 @@ annotations = Annotations all_annotations = All annotations flowvelocitymeasurement = Flowvelocity measurements +flowvelocitymodel = Flowvelocity model bed_quality_bed = Quality - Bed bed_quality_load = Quality - Load additionals = Additional Longitudinal Section Curves @@ -503,6 +507,13 @@ yields = sedimentyields years = years epochs = epochs +densities = Sediment Densities +sand = Sand +fine_middle = Fine Middle +susp_sediment = Suspended Sediment +coarse = Coarse +susp_sand = Suspended Sand +susp_sand_bed = Suspended Sand (bed) # No translation for the pegelonline wms service layer names. gauge_points = Pegelpunkte (WSV) gauge_level = Aktueller Wasserstand (WSV) @@ -638,6 +649,7 @@ fix_parameters = CSV sq_overview=Overview +sq_relations=SQ Relations gauge_zero = GZG gauge_q_unit = m\u00b3/s
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants_de.properties Tue Oct 15 15:32:36 2013 +0200 +++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants_de.properties Tue Oct 15 18:41:55 2013 +0200 @@ -428,6 +428,9 @@ # data cage waterlevels = Wasserst\u00e4nde +waterlevels_ls = Wasserst\u00e4 aus Wasserspiegellagen +waterlevels_discharge = Benutzerdefinierte Abflussl\u00e4ngsschnitte +waterlevels_fix = Wasserst\u00e4nde aus Fixierungsanalyse beddifferences = Sohlh\u00f6hendifferenzen bedheight_differences = Sohlh\u00f6hendifferenzen vollmer_waterlevels = Ausgelagerte WSPL. @@ -444,6 +447,7 @@ annotations = Streckenfavoriten all_annotations = Alle Streckenfavoriten flowvelocitymeasurement = gemessene Flie\u00dfgeschwindigkeiten +flowvelocitymodel = modellierte Flie\u00dfgeschwindigkeiten bed_quality_bed = Sohlbeschaffenheit - Sohle bed_quality_load = Sohlbeschaffenheit - Geschiebe additionals = Zus\u00e4tzliche L\u00e4ngsschnitte @@ -508,6 +512,13 @@ yields = Frachten years = Einzeljahre epochs = Epochen +densities = Sedimentdichte +sand = Geschiebe Sand +fine_middle = Geschiebe Fein Mittel Kies +coarse = Geschiebe Grobkorn +susp_sand = Susp. Sand +susp_sediment = Susp. Sediment +susp_sand_bed = Bettb. Anteil susp. Sand gauge_points = Pegelmessstelle (WMS) gauge_level = Wasserstand (WMS) gauge_names = Pegelname (WMS) @@ -637,6 +648,7 @@ fix_parameters_export = Angepasste Koeffizienten fix_parameters = CSV sq_overview=\u00dcbersicht +sq_relations=Feststofftransport-Abfluss-Beziehung gauge_zero = PNP gauge_q_unit = m\u00b3/s
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants_en.properties Tue Oct 15 15:32:36 2013 +0200 +++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants_en.properties Tue Oct 15 18:41:55 2013 +0200 @@ -426,6 +426,9 @@ # data cage waterlevels = Waterlevels +waterlevels_ls = Longitudinal Section +waterlevels_discharge = Discharge Longitudinal Section +waterlevels_fix = Waterlevels from fixation analyis beddifferences = Bedheight Differences bedheight_differences = Bedheight Differences vollmer_waterlevels = Vollmer Waterlevels @@ -441,6 +444,7 @@ annotations = Annotations all_annotations = All annotations flowvelocitymeasurement = Flowvelocity measurements +flowvelocitymodel = Flowvelocity model bed_quality_bed = Quality - Bed bed_quality_load = Quality - Load additionals = Additional Longitudinal Section Curves @@ -487,6 +491,13 @@ yields = sedimentyields years = years epochs = epochs +densities = Sediment Densities +sand = Sand +fine_middle = Fine Middle +susp_sediment = Suspended Sediment +coarse = Coarse +susp_sand = Suspended Sand +susp_sand_bed = Suspended Sand (bed) startcolor = Colorrange start color endcolor = Colorrange end color @@ -612,6 +623,7 @@ fix_parameters_export = Adjusted coefficient fix_parameters = CSV sq_overview=Overview +sq_relations=SQ Relations gauge_zero = GZG gauge_q_unit = m\u00b3/s
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/RiverInfoPanel.java Tue Oct 15 15:32:36 2013 +0200 +++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/RiverInfoPanel.java Tue Oct 15 18:41:55 2013 +0200 @@ -14,7 +14,6 @@ import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.Widget; import com.smartgwt.client.widgets.form.DynamicForm; -import com.smartgwt.client.widgets.form.fields.LinkItem; import java.util.Iterator;
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/fixation/FixationPanel.java Tue Oct 15 15:32:36 2013 +0200 +++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/fixation/FixationPanel.java Tue Oct 15 18:41:55 2013 +0200 @@ -40,6 +40,7 @@ import org.dive4elements.river.client.client.services.FixingsOverviewService; import org.dive4elements.river.client.client.services.FixingsOverviewServiceAsync; import org.dive4elements.river.client.client.ui.AbstractUIProvider; +import org.dive4elements.river.client.shared.MapUtils; import org.dive4elements.river.client.shared.model.Data; import org.dive4elements.river.client.shared.model.DataList; import org.dive4elements.river.client.shared.model.FixAnalysisArtifact; @@ -154,7 +155,7 @@ overviewService.generateOverview( locale, artifact.getUuid(), - getOverviewFilter(art.getFilter()), + MapUtils.toJavaEncodedString(getOverviewFilter(art.getFilter())), renderCheckboxes(), callBack, new AsyncCallback<FixingsOverviewInfo>() {
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/map/MapPrintPanel.java Tue Oct 15 15:32:36 2013 +0200 +++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/map/MapPrintPanel.java Tue Oct 15 18:41:55 2013 +0200 @@ -283,7 +283,7 @@ // O.o String river = findRiver(((MapOutputTab)mapToolbar.getOutputTab() ).getCollectionView().getArtifact()); - url.append("&" + MapUtils.toSaveHTMLJavaString(MSG.getString(MAPFISH_RIVER)) + "=" + + url.append("&" + MapUtils.toSaveHTMLJavaString(MSG.getString(MAPFISH_RIVER)) + "=" + MapUtils.toSaveHTMLJavaString(river)); }