Mercurial > dive4elements > river
changeset 8714:4e8c80ff07e3
(issue1602) We don't distinguish between types since sometime but we want to have metadata at the facet.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Fri, 24 Apr 2015 18:01:18 +0200 |
parents | 6b68777aaeab |
children | b5cff23bf308 |
files | artifacts/src/main/java/org/dive4elements/river/artifacts/BedHeightsArtifact.java artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedHeightFacet.java |
diffstat | 2 files changed, 32 insertions(+), 42 deletions(-) [+] |
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/BedHeightsArtifact.java Fri Apr 24 17:54:12 2015 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/BedHeightsArtifact.java Fri Apr 24 18:01:18 2015 +0200 @@ -123,8 +123,7 @@ facet = new BedHeightSoundingWidthFacet(facetType, bedHName); } else { - facet = new BedHeightFacet( - facetType, bedHName, type); + facet = new BedHeightFacet(facetType, bedHName); }
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedHeightFacet.java Fri Apr 24 17:54:12 2015 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedHeightFacet.java Fri Apr 24 18:01:18 2015 +0200 @@ -16,6 +16,7 @@ import org.dive4elements.artifacts.Artifact; import org.dive4elements.artifacts.CallContext; import org.dive4elements.river.artifacts.D4EArtifact; +import org.dive4elements.river.artifacts.resources.Resources; import org.dive4elements.river.artifacts.access.BedHeightAccess; import org.dive4elements.river.artifacts.model.BlackboardDataFacet; import org.dive4elements.river.artifacts.model.FacetTypes; @@ -28,12 +29,9 @@ private static final Logger log = Logger.getLogger(BedHeightFacet.class); - private String type; - - public BedHeightFacet(String name, String description, String type) { + public BedHeightFacet(String name, String description) { this.name = name; this.description = description; - this.type = type; this.index = 0; this.metaData.put("X", "chart.longitudinal.section.xaxis.label"); this.metaData.put("Y", "chart.bedheight_middle.section.yaxis.label"); @@ -50,43 +48,36 @@ @Override public Object getData(Artifact artifact, CallContext context) { BedHeightAccess access = new BedHeightAccess((D4EArtifact)artifact); - if (type.equals("singlevalues")) { - /* Former doc (from BedHeightAccess): - * Return a {@link List} of {@link BedHeightValue}s - * at the range of the artifact - * @return List of {@link BedHeightValue}s */ - BedHeight single = BedHeight.getBedHeightById( - access.getHeightId()); - List<BedHeightValue> bedheightValues = - BedHeightValue.getBedHeightValues( - single, - access.getFrom(true), - access.getTo(true)); - double[][] values = new double[2][bedheightValues.size()]; - int i = 0; - for (BedHeightValue bedheightValue : bedheightValues) { - values[0][i] = bedheightValue.getStation(); - values[1][i] = bedheightValue.getHeight(); - i++; - } - return values; + BedHeight single = BedHeight.getBedHeightById(access.getHeightId()); + List<BedHeightValue> bedheightValues = + BedHeightValue.getBedHeightValues( + single, + access.getFrom(true), + access.getTo(true)); + double[][] values = new double[2][bedheightValues.size()]; + int i = 0; + for (BedHeightValue bedheightValue : bedheightValues) { + values[0][i] = bedheightValue.getStation(); + values[1][i] = bedheightValue.getHeight(); + i++; } - else { - /* Former doc (from BedHeightAccess): - * Return the {@link BedHeight} at the height_id and time of the artifact - * @return {@link BedHeight} */ - BedHeightData data = BedHeightFactory.getHeight( - access.getType(), - access.getHeightId()); - //data.removeNaNs(); - TDoubleArrayList stations= data.getStations(); - double[][] values = new double[2][stations.size()]; - for (int i = 0; i < stations.size(); i++) { - values[0][i] = stations.get(i); - values[1][i] = data.getHeight(i); - } - return values; + + this.addMetaData(Resources.getMsg( + context.getMeta(), + "meta.bedheight.cur.elevation"), + single.getCurElevationModel().getName()); + if (single.getOldElevationModel() != null) { + this.addMetaData(Resources.getMsg( + context.getMeta(), + "meta.bedheight.old.elevation"), + single.getOldElevationModel().getName()); } + this.addMetaData(Resources.getMsg( + context.getMeta(), + "meta.bedheight.river.elevation"), + access.getRiver().getWstUnit().getName()); + + return values; } /** @@ -95,7 +86,7 @@ */ @Override public BedHeightFacet deepCopy() { - BedHeightFacet copy = new BedHeightFacet(name, description, type); + BedHeightFacet copy = new BedHeightFacet(name, description); copy.set(this); return copy; }