# HG changeset patch # User Felix Wolfsteller # Date 1316172650 0 # Node ID 9c1cda9e2bc4109f846e2acad433b7a9a5585715 # Parent 8ad0331e444f1651565d36d104f0479bd05bc120 Load given artifacts for w-diff calculation. flys-artifacts/trunk@2776 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 8ad0331e444f -r 9c1cda9e2bc4 flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Fri Sep 16 10:49:04 2011 +0000 +++ b/flys-artifacts/ChangeLog Fri Sep 16 11:30:50 2011 +0000 @@ -1,3 +1,10 @@ +2011-09-16 Felix Wolfsteller + + Take a given WaterlevelPair-String, load artifact and plot the diff. + + * src/main/java/de/intevation/flys/artifacts/state/WDifferencesState.java: + Load correct artifacts. + 2011-09-16 Bjoern Schilberg * doc/mapserver/*: Added inital mapserver configuration files. diff -r 8ad0331e444f -r 9c1cda9e2bc4 flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WDifferencesState.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WDifferencesState.java Fri Sep 16 10:49:04 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WDifferencesState.java Fri Sep 16 11:30:50 2011 +0000 @@ -22,7 +22,6 @@ import de.intevation.flys.utils.FLYSUtils; -//import net.sf.json.JSONObject; public class WDifferencesState extends DefaultState @@ -44,6 +43,25 @@ @Override + public boolean validate(Artifact artifact) + throws IllegalArgumentException + { + FLYSArtifact flys = (FLYSArtifact) artifact; + + StateData data = flys.getData("diffids"); + + if (data == null) { + throw new IllegalArgumentException("diffids is empty"); + } + + // TODO: Also validate format. + + return true; + } + + + + @Override public Object computeAdvance( FLYSArtifact artifact, String hash, @@ -54,16 +72,30 @@ WINFOArtifact winfo = (WINFOArtifact)artifact; String id = getID(); - // Get a data item (uuids) or parameterization of the respective - // artifacts. - // TODO Fix, choose artifacts/parameterization dynamically. + // Load the Artifacts/facets that we want to subtract and display. + // Expected format is: + // [42537f1e-3522-42ef-8968-635b03d8e9c6;longitudinal_section.w;0]#[1231f2-....] + String datas[] = winfo.getDataAsString("diffids"); + + // Validate the Data-Strings. + for (String s: datas) { + if (!WaterlevelSelectState.isValid(winfo.getDataAsString("diffids"))) { + // TODO: escalate. + } + } + + if (datas.length != 2) { + // TODO crash with style + ; + } + String uuid1 = WaterlevelSelectState.strip(datas[0]).split(";")[0]; + String uuid2 = WaterlevelSelectState.strip(datas[1]).split(";")[0]; + WINFOArtifact flys1 = (WINFOArtifact) FLYSUtils.getArtifact( - //"a110a16d-d155-4115-ab0d-c4c61101c9cb", //Collection - "a0ec533f-b05b-4dcd-9db3-7850686f90a2", + uuid1, context); WINFOArtifact flys2 = (WINFOArtifact) FLYSUtils.getArtifact( - //"8ebb696d-771a-4540-bd18-15e19744a6e2", //Collection - "ce5a2c4e-3f9c-4c4d-a35c-109dd8670992", + uuid2, context); if (flys1 == null) { @@ -83,14 +115,13 @@ wkms = WKmsOperation.SUBTRACTION.operate(minuend[0], subtrahend[0]); facetName = "W ("+minuend[0].getName() + ") - W (" + subtrahend[0].getName()+")"; logger.warn("Did a WKMSSubtraction"); - // Add these datasets also as facets. - // TODO Store parameterization. - // Therefore need: getKmRange, getQs, getRiver, eventually getWs + // Add these datasets also as facets ("absolutes"). + /* Facet minuendAbsFacet = new WaterlevelFacet(0, LONGITUDINAL_W, "Minuend: W (_todo_)", ComputeType.ADVANCE, id, hash); Facet subtrahendAbsFacet = new WaterlevelFacet(1, LONGITUDINAL_W, "Subtrahend: W (_todo_)", ComputeType.ADVANCE, id, hash); - //JSONObject jsonObject = new JSONObject().accumulate("string", 2.0f); + */ //facets.add(minuendAbsFacet); //facets.add(subtrahendAbsFacet); }