Mercurial > dive4elements > river
changeset 1803:51e59f221333
Minor preparations for WINFO/CrossSection to handle multiple cross-sections.
flys-artifacts/trunk@3128 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Tue, 01 Nov 2011 12:23:59 +0000 |
parents | 26d7077e42d2 |
children | 00f14b837e65 |
files | flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/CrossSectionFacet.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WaterlevelState.java |
diffstat | 4 files changed, 57 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog Tue Nov 01 10:40:05 2011 +0000 +++ b/flys-artifacts/ChangeLog Tue Nov 01 12:23:59 2011 +0000 @@ -1,3 +1,23 @@ +2011-11-01 Felix Wolfsteller <felix.wolfsteller@intevation.de> + + Minor preparations to handle multiple cross sections in one + diagram/artifact, faking certain aspects (e.g. ability to display + multiple cross sections, but let these fetch the exactly same data + for now). + + * src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java: + Parameterize but fake access to cross-section (always take first + one). + (getCrossSectionName,getCrossSectionNames): Renamed, access names + of all cross-sections, so that at least facets with different names + are created (they will still deliver the same data). + + * src/main/java/de/intevation/flys/artifacts/model/CrossSectionFacet.java: + Allow indexing. + + * src/main/java/de/intevation/flys/artifacts/states/WaterlevelState.java: + Index created cross-sections. + 2011-11-01 Felix Wolfsteller <felix.wolfsteller@intevation.de> Show multiple water lines and facets in cross-section diagram if @@ -14,7 +34,6 @@ * src/main/java/de/intevation/flys/artifacts/states/WaterlevelState.java: Add one Facet for each of the computed waterlevels. - 2011-10-31 Sascha L. Teichmann <sascha.teichmann@intevation.de> * src/main/java/de/intevation/flys/artifacts/geom/VectorUtils.java:
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java Tue Nov 01 10:40:05 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java Tue Nov 01 12:23:59 2011 +0000 @@ -670,7 +670,7 @@ /** * Get CrossSectionLine spatially closest to what is specified in the data - * "cross_section.km". + * "cross_section.km" (and from "cross_section.index"). * * @return CrossSectionLine closest to "cross_section.km". */ @@ -680,17 +680,26 @@ wishKM = Double.parseDouble(getDataAsString("cross_section.km")); } catch (Exception e) { - logger.warn(e); + logger.warn("Exception when parsing cross_section.km", e); + } + + int crossSectionIdx = 0; + + List<CrossSection> sections = getCrossSections(); + if (sections.size() < crossSectionIdx) { + logger.error("Cross-section not found: " + crossSectionIdx); + return null; + } + if (sections.size() == 0 + || sections.get(crossSectionIdx).getLines().size() == 0) + { + return null; } // Get the cross section closest to requested km. // Naive, linear approach. - List<CrossSection> sections = getCrossSections(); - if (sections.size() == 0 || sections.get(0).getLines().size() == 0) { - return null; - } List<CrossSectionLine> crossSectionLines = - sections.get(0).getLines(); + sections.get(crossSectionIdx).getLines(); CrossSectionLine oldLine = crossSectionLines.get(0); double oldDiff = Math.abs(wishKM - oldLine.getKm().doubleValue()); for (CrossSectionLine line: crossSectionLines) { @@ -734,7 +743,10 @@ logger.info("getCrossSectionData() for cross_section.km " + getDataAsString("cross_section.km")); CrossSectionLine line = searchCrossSectionKmLine(); - return line != null ? line.fetchCrossSectionProfile() : null; + + return line != null + ? line.fetchCrossSectionProfile() + : null; } @@ -771,7 +783,7 @@ wishKM = Double.parseDouble(getDataAsString("cross_section.km")); } catch (Exception e) { - logger.warn(e); + logger.warn("Exception when trying to get cross_section.km", e); } if (triple.size() == 0) { @@ -796,17 +808,17 @@ /** - * Get name of cross section. + * Get name of cross sections. + * @return list of names of cross-sections. */ - public String getCrossSectionName() { - List<CrossSection> sections = getCrossSections(); + public List<String> getCrossSectionNames() { + List<String> names = new ArrayList<String>(); - if (sections.size() > 0) { - return sections.get(0).getDescription(); + for (CrossSection section: getCrossSections()) { + names.add(section.getDescription()); } - else { - return ""; - } + + return names; }
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/CrossSectionFacet.java Tue Nov 01 10:40:05 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/CrossSectionFacet.java Tue Nov 01 12:23:59 2011 +0000 @@ -25,8 +25,8 @@ protected ComputeType type; /** Trivial constructor, set (maybe localized) description. */ - public CrossSectionFacet(String description) { - super(0, CROSS_SECTION, description); + public CrossSectionFacet(int idx, String description) { + super(idx, CROSS_SECTION, description); type = ComputeType.ADVANCE; } @@ -46,7 +46,7 @@ /** Do a deep copy. */ @Override public Facet deepCopy() { - CrossSectionFacet copy = new CrossSectionFacet(this.description); + CrossSectionFacet copy = new CrossSectionFacet(this.index, this.description); copy.set(this); return copy; }
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WaterlevelState.java Tue Nov 01 10:40:05 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WaterlevelState.java Tue Nov 01 12:23:59 2011 +0000 @@ -85,8 +85,11 @@ facets.add(wst); facets.add(csv); - // Also register the CrossSectionFacet (added to respective out). - facets.add(new CrossSectionFacet(winfo.getCrossSectionName())); + // Also register the CrossSectionFacets. + int idx = 0; + for (String name: winfo.getCrossSectionNames()) { + facets.add(new CrossSectionFacet(idx++, name)); + } } if (res.getReport().hasProblems()) {