comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WDifferencesState.java @ 1626:b9b47af71564

Preparations for ability to display multiple differences in one plot. flys-artifacts/trunk@2801 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 21 Sep 2011 13:49:50 +0000
parents 47ecf98f09eb
children ff7bffb7d5f0
comparison
equal deleted inserted replaced
1625:c45e8d6b99a2 1626:b9b47af71564
83 if (!WaterlevelSelectState.isValueValid(winfo.getDataAsString("diffids"))) { 83 if (!WaterlevelSelectState.isValueValid(winfo.getDataAsString("diffids"))) {
84 // TODO: escalate. 84 // TODO: escalate.
85 } 85 }
86 } 86 }
87 87
88 if (datas.length != 2) { 88 if (datas.length < 2) {
89 // TODO crash with style 89 // TODO crash with style
90 ; 90 ;
91 } 91 }
92 String uuid1 = WaterlevelSelectState.strip(datas[0]).split(";")[0];
93 String uuid2 = WaterlevelSelectState.strip(datas[1]).split(";")[0];
94 92
95 WINFOArtifact flys1 = (WINFOArtifact) FLYSUtils.getArtifact( 93 WKms wkms = null;
96 uuid1,
97 context);
98 WINFOArtifact flys2 = (WINFOArtifact) FLYSUtils.getArtifact(
99 uuid2,
100 context);
101 94
102 if (flys1 == null) { 95 for(int i = 0; i < datas.length /2; i++) {
103 logger.warn("One of the artifacts (1) for diff calculation could not be loaded"); 96 String uuid1 = WaterlevelSelectState.strip(datas[i+0]).split(";")[0];
104 } 97 String uuid2 = WaterlevelSelectState.strip(datas[i+1]).split(";")[0];
105 if (flys2 == null) { 98
106 logger.warn("One of the artifacts (2) for diff calculation could not be loaded"); 99 WINFOArtifact flys1 = (WINFOArtifact) FLYSUtils.getArtifact(
107 } 100 uuid1,
108 WKms wkms = null; 101 context);
109 String facetName = "diff ()"; 102 WINFOArtifact flys2 = (WINFOArtifact) FLYSUtils.getArtifact(
103 uuid2,
104 context);
105
106 if (flys1 == null) {
107 logger.warn("One of the artifacts (1) for diff calculation could not be loaded");
108 }
109 if (flys2 == null) {
110 logger.warn("One of the artifacts (2) for diff calculation could not be loaded");
111 }
112 // TODO: Issue of multiple results in calculation
113 //WKms wkms = null;
114 String facetName = "diff ()";
115
116 if (flys1 != null && flys2 != null) {
117 // TODO Also check size.
118 // TODO Also need index of wqkms.
119 WQKms[] minuend = (WQKms[]) flys1.getWaterlevelData().getData();
120 WQKms[] subtrahend = (WQKms[]) flys2.getWaterlevelData().getData();
110 121
111 if (flys1 != null && flys2 != null) { 122 if (datas.length > 2) {
112 // TODO also check size. 123 logger.error("Cannot keep more than one calculation.");
113 // TODO also need index of wqkms. 124 }
114 WQKms[] minuend = (WQKms[]) flys1.getWaterlevelData().getData(); 125 wkms = WKmsOperation.SUBTRACTION.operate(minuend[0], subtrahend[0]);
115 WQKms[] subtrahend = (WQKms[]) flys2.getWaterlevelData().getData(); 126 facetName = "W ("+minuend[0].getName() + ") - W (" + subtrahend[0].getName()+")";
116 wkms = WKmsOperation.SUBTRACTION.operate(minuend[0], subtrahend[0]); 127 logger.debug("WKMSSubtraction happened");
117 facetName = "W ("+minuend[0].getName() + ") - W (" + subtrahend[0].getName()+")"; 128 }
118 logger.warn("Did a WKMSSubtraction"); 129
119 // Add these datasets also as facets ("absolutes"). 130 if (facets != null) {
120 /* 131 // TODO: pass computetype and state id.
121 Facet minuendAbsFacet = new WaterlevelFacet(0, LONGITUDINAL_W, 132 //, ComputeType.ADVANCE, getID(), hash));
122 "Minuend: W (_todo_)", ComputeType.ADVANCE, id, hash); 133 facets.add(new DataFacet(W_DIFFERENCES, facetName));
123 Facet subtrahendAbsFacet = new WaterlevelFacet(1, LONGITUDINAL_W, 134 facets.add(new DataFacet(CSV, "CSV data"));
124 "Subtrahend: W (_todo_)", ComputeType.ADVANCE, id, hash); 135 }
125 */ 136 else {
126 //facets.add(minuendAbsFacet); 137 logger.debug("Not adding facets in WDifferencesState.");
127 //facets.add(subtrahendAbsFacet); 138 }
128 }
129
130 if (facets != null) {
131 // TODO: pass computetype and state id.
132 //, ComputeType.ADVANCE, getID(), hash));
133 facets.add(new DataFacet(W_DIFFERENCES, facetName));
134 facets.add(new DataFacet(CSV, "CSV data"));
135 }
136 else {
137 logger.debug("Not adding facets in WDifferencesState.");
138 } 139 }
139 140
140 return wkms; 141 return wkms;
141 } 142 }
142 } 143 }

http://dive4elements.wald.intevation.org