# HG changeset patch # User Felix Wolfsteller # Date 1386261490 -3600 # Node ID e609722a1e86bec429b9c1b25a62eae6c668fd64 # Parent 974c858a5042630b2b9a4aefa55a4e36ef552bb0 issue1020 and others: Let StaticWQKmsState spawn other facets, implement computeAdvance. diff -r 974c858a5042 -r e609722a1e86 artifacts/src/main/java/org/dive4elements/river/artifacts/states/StaticWQKmsState.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/StaticWQKmsState.java Thu Dec 05 17:34:10 2013 +0100 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/StaticWQKmsState.java Thu Dec 05 17:38:10 2013 +0100 @@ -23,6 +23,7 @@ import org.dive4elements.river.artifacts.StaticWQKmsArtifact; import org.dive4elements.river.artifacts.model.CrossSectionWaterLineFacet; +import org.dive4elements.river.artifacts.model.DataFacet; import org.dive4elements.river.artifacts.model.FacetTypes; import org.dive4elements.river.artifacts.model.RelativePointFacet; import org.dive4elements.river.artifacts.model.WQKms; @@ -59,7 +60,10 @@ Object old ) { String id = getID(); + String code = artifact.getDataAsString("ids"); + String [] parts = code.split("-"); + // Return from cache, if present. WQKms res = old instanceof WQKms ? (WQKms)old : artifact.getWQKms(); @@ -70,6 +74,18 @@ return res; } + String wkmsName = wqkms.getName(); + + Facet wqfacet = new WQKmsFacet( + STATIC_WQ, + wkmsName); + facets.add(wqfacet); + + if (parts[0].equals("officials_wq")) { + // Early stop. We only want wq-points in that case. + return res; + } + /* * TODO: re-enable HEIGHTMARKS_POINTS-thing @@ -92,7 +108,7 @@ } } - String wkmsName = wqkms.getName(); + // issue1494: Only spawn qfacet if discharges are given if (!qEmpty) { Facet qfacet = new WQKmsFacet( STATIC_WQKMS_Q, @@ -109,12 +125,12 @@ Facet rpFacet = new RelativePointFacet(wkmsName); facets.add(rpFacet); - wkmsName = "W (" + wkmsName + ")"; - Facet csFacet = new CrossSectionWaterLineFacet(0, wkmsName); facets.add(csFacet); + wkmsName = "W (" + wkmsName + ")"; + Facet wfacet = new WQKmsFacet( STATIC_WQKMS_W, wkmsName @@ -126,9 +142,26 @@ wkmsName)*/); facets.add(wfacet); + Facet wstfacet = new DataFacet( + WST, + wkmsName, + ComputeType.ADVANCE, hash, id); + facets.add(wstfacet); + return res; } + @Override + public Object computeAdvance( + D4EArtifact artifact, + String hash, + CallContext context, + List facets, + Object old + ) { + return compute((StaticWQKmsArtifact) artifact, context.getMeta(), + hash, facets, old); + } /** * Get data, create the facets. @@ -160,8 +193,8 @@ CallMeta meta, List facets ) { - return compute((StaticWQKmsArtifact) artifact, meta, hash, facets, - null); + return compute((StaticWQKmsArtifact) artifact, meta, + hash, facets, null); } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :