Mercurial > dive4elements > river
changeset 7647:786ff139de5e
issue1020: When preparing wsts for wsplgen handle other than standard wqkms calculations.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Thu, 05 Dec 2013 15:38:35 +0100 |
parents | f603a53e45dc |
children | b0e2e4e0e2d2 |
files | artifacts/src/main/java/org/dive4elements/river/artifacts/states/FloodMapState.java |
diffstat | 1 files changed, 37 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/FloodMapState.java Thu Dec 05 15:35:53 2013 +0100 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/FloodMapState.java Thu Dec 05 15:38:35 2013 +0100 @@ -30,6 +30,7 @@ import org.dive4elements.artifacts.GlobalContext; import org.dive4elements.artifacts.common.utils.FileTools; import org.dive4elements.river.artifacts.D4EArtifact; +import org.dive4elements.river.artifacts.StaticWKmsArtifact; import org.dive4elements.river.artifacts.access.DGMAccess; import org.dive4elements.river.artifacts.access.RangeAccess; import org.dive4elements.river.artifacts.context.RiverContext; @@ -37,7 +38,9 @@ import org.dive4elements.river.artifacts.model.CalculationResult; import org.dive4elements.river.artifacts.model.FacetTypes; import org.dive4elements.river.artifacts.model.LayerInfo; +import org.dive4elements.river.artifacts.model.WKms; import org.dive4elements.river.artifacts.model.WQKms; +import org.dive4elements.river.artifacts.model.fixings.FixRealizingResult; import org.dive4elements.river.artifacts.model.map.HWS; import org.dive4elements.river.artifacts.model.map.HWSContainer; import org.dive4elements.river.artifacts.model.map.HWSFactory; @@ -936,27 +939,51 @@ } catch (NumberFormatException nfe) { /* do nothing */ } - // issue1020: Other kinds of artifacts might calculate other stuff than - // WQKms or provide data in more static manner (shiver). - D4EArtifact src = otherArtifact != null ? RiverUtils.getArtifact(otherArtifact, cc) : flys; logger.debug("Use waterlevel provided by Artifact: " + src.identifier()); - CalculationResult rawData = (CalculationResult) src.compute( + // The state actually depends on the kind of artifact. E.g. StaticWQKmsArtifact needs other state + Object computed = src.compute( cc, - null, - WINFO_WSP_STATE_ID, + //null, + //WINFO_WSP_STATE_ID, ComputeType.ADVANCE, false); - WQKms[] wqkms = (WQKms[]) rawData.getData(); + // Depending on the artifact and calculation we have different results + // in place. Note that the same conditions exist in + // WaterlevelSelectState#getLabel . - return wqkms == null || idx == -1 || idx >= wqkms.length - ? null - : wqkms[idx]; + // Regular WSP calculation + if (computed instanceof CalculationResult) { + CalculationResult rawData = (CalculationResult) computed; + WQKms[] wqkms; + if (rawData.getData() instanceof FixRealizingResult) { + wqkms = (WQKms[]) ((FixRealizingResult) rawData.getData()).getWQKms(); + } + else { + wqkms = (WQKms[]) rawData.getData(); + } + return wqkms == null || idx == -1 || idx >= wqkms.length + ? null + : wqkms[idx]; + } + else if (computed instanceof WQKms) { + // e.g. Fixations + WQKms wqkms = (WQKms) computed; + return (WQKms) computed; + } + else if (computed == null && src instanceof StaticWKmsArtifact) { + // Floodmarks and protection. + WQKms wqkms = WQKms.fromWKms(((StaticWKmsArtifact) src).getWKms(0), 1d); + return wqkms; + } + + logger.warn("getWQKms cannot handle " + computed.getClass() + " " + src.getClass()); + return null; } @@ -990,8 +1017,6 @@ writeWspTag = false; } - // TODO issue1020: data might be something different than wqkms, - // abstract this here a little away. for (int i = 0, num = data.size(); i < num; i++) { data.get(i, buf); writer.add(buf);