comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/FloodMapState.java @ 1096:9f88cc54570c

Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state. flys-artifacts/trunk@2599 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 26 Aug 2011 15:01:20 +0000
parents 7230e087ef8b
children e9f66d63bdd0
comparison
equal deleted inserted replaced
1095:f465785ed1ae 1096:9f88cc54570c
18 18
19 import de.intevation.flys.artifacts.FLYSArtifact; 19 import de.intevation.flys.artifacts.FLYSArtifact;
20 import de.intevation.flys.artifacts.model.FacetTypes; 20 import de.intevation.flys.artifacts.model.FacetTypes;
21 import de.intevation.flys.artifacts.model.WSPLGENFacet; 21 import de.intevation.flys.artifacts.model.WSPLGENFacet;
22 import de.intevation.flys.artifacts.model.WSPLGENJob; 22 import de.intevation.flys.artifacts.model.WSPLGENJob;
23 import de.intevation.flys.utils.FLYSUtils;
23 24
24 25
25 public class FloodMapState 26 public class FloodMapState
26 extends DefaultState 27 extends DefaultState
27 implements FacetTypes 28 implements FacetTypes
32 33
33 public static final String XPATH_SHAPEFILE_DIR = 34 public static final String XPATH_SHAPEFILE_DIR =
34 "/artifact-database/floodmap/shapefile-path/@value"; 35 "/artifact-database/floodmap/shapefile-path/@value";
35 36
36 public static final String WSPLGEN_PARAMETER_FILE = "wsplgen.par"; 37 public static final String WSPLGEN_PARAMETER_FILE = "wsplgen.par";
38
39 public static final int WSPLGEN_DEFAULT_OUTPUT = 0;
37 40
38 41
39 42
40 @Override 43 @Override
41 public Object computeAdvance( 44 public Object computeAdvance(
129 FLYSArtifact flys = (FLYSArtifact) artifact; 132 FLYSArtifact flys = (FLYSArtifact) artifact;
130 removeDirectory(flys); 133 removeDirectory(flys);
131 } 134 }
132 135
133 136
134
135 protected WSPLGENJob prepareWSPLGENJob( 137 protected WSPLGENJob prepareWSPLGENJob(
136 FLYSArtifact artifact, 138 FLYSArtifact artifact,
137 File artifactDir 139 File artifactDir
138 ) { 140 ) {
139 logger.debug("FloodMapState.prepareWSPLGENJob"); 141 logger.debug("FloodMapState.prepareWSPLGENJob");
140 142
141 WSPLGENJob job = new WSPLGENJob(); 143 WSPLGENJob job = new WSPLGENJob();
142 File paraFile = new File(artifactDir, WSPLGEN_PARAMETER_FILE); 144 File paraFile = new File(artifactDir, WSPLGEN_PARAMETER_FILE);
143 145
146 setOut(artifact, job);
147 setRange(artifact, job);
148 setDelta(artifact, job);
149 setGel(artifact, job);
150 setDist(artifact, job);
151
152 // TODO
153 // setDgm(artifact, job); // SHP
154 // setPro(artifact, job); // SHP
155 // setWsp(artifact, job); // WSP
156 // setWspTag(artifact, job);
157 // setLine(artifact, job); // SHP
158 // setAxis(artifact, job); // SHP
159 // setArea(artifact, job); // SHP
160 // setOutFile(artifact, job);
161
144 try { 162 try {
145 job.toFile(paraFile); 163 job.toFile(paraFile);
146 164
147 return job; 165 return job;
148 } 166 }
153 logger.warn("Cannot write PAR file: " + iae.getMessage()); 171 logger.warn("Cannot write PAR file: " + iae.getMessage());
154 } 172 }
155 173
156 return null; 174 return null;
157 } 175 }
176
177
178 protected void setOut(FLYSArtifact artifact, WSPLGENJob job) {
179 job.setOut(WSPLGEN_DEFAULT_OUTPUT);
180 }
181
182
183 protected void setRange(FLYSArtifact artifact, WSPLGENJob job) {
184 double[] range = FLYSUtils.getKmRange(artifact);
185
186 job.setStart(range[0]);
187 job.setEnd(range[1]);
188 }
189
190
191 protected void setDelta(FLYSArtifact artifact, WSPLGENJob job) {
192 String from = artifact.getDataAsString("diff_from");
193 String to = artifact.getDataAsString("diff_to");
194 String diff = artifact.getDataAsString("diff_diff");
195
196 try {
197 job.setFrom(Double.parseDouble(from));
198 }
199 catch (NumberFormatException nfe) {
200 }
201
202 try {
203 job.setTo(Double.parseDouble(to));
204 }
205 catch (NumberFormatException nfe) {
206 }
207
208 try {
209 job.setDiff(Double.parseDouble(diff));
210 }
211 catch (NumberFormatException nfe) {
212 }
213 }
214
215
216 protected void setGel(FLYSArtifact artifact, WSPLGENJob job) {
217 String gel = artifact.getDataAsString("use_floodplain");
218
219 if (gel != null && gel.length() > 0) {
220 boolean use = Boolean.parseBoolean(gel);
221
222 if (use) {
223 job.setGel(WSPLGENJob.GEL_SPERRE);
224 }
225 else {
226 job.setGel(WSPLGENJob.GEL_NOSPERRE);
227 }
228 }
229 }
230
231
232 protected void setDist(FLYSArtifact artifact, WSPLGENJob job) {
233 String dist = artifact.getDataAsString("profile_distance");
234
235 try {
236 job.setDist(Double.parseDouble(dist));
237 }
238 catch (NumberFormatException nfe) {
239 // nothing to do here
240 }
241 }
158 } 242 }
159 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : 243 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org