Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/states/FloodMapState.java @ 5867:59ff03ff48f1
River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Sun, 28 Apr 2013 15:23:01 +0200 |
parents | 9a6741ccf6d4 |
children | 37a0f4f7c54f |
comparison
equal
deleted
inserted
replaced
5866:9a6741ccf6d4 | 5867:59ff03ff48f1 |
---|---|
43 import org.dive4elements.artifacts.CallMeta; | 43 import org.dive4elements.artifacts.CallMeta; |
44 import org.dive4elements.artifacts.GlobalContext; | 44 import org.dive4elements.artifacts.GlobalContext; |
45 | 45 |
46 import org.dive4elements.artifacts.common.utils.FileTools; | 46 import org.dive4elements.artifacts.common.utils.FileTools; |
47 | 47 |
48 import org.dive4elements.river.artifacts.FLYSArtifact; | 48 import org.dive4elements.river.artifacts.D4EArtifact; |
49 | 49 |
50 import org.dive4elements.river.artifacts.access.RangeAccess; | 50 import org.dive4elements.river.artifacts.access.RangeAccess; |
51 | 51 |
52 import org.dive4elements.river.artifacts.context.RiverContext; | 52 import org.dive4elements.river.artifacts.context.RiverContext; |
53 | 53 |
152 } | 152 } |
153 } | 153 } |
154 | 154 |
155 | 155 |
156 protected void copyShapeDir(Artifact orig, Artifact owner) { | 156 protected void copyShapeDir(Artifact orig, Artifact owner) { |
157 File origDir = getDirectory((FLYSArtifact) orig); | 157 File origDir = getDirectory((D4EArtifact) orig); |
158 File thisDir = getDirectory((FLYSArtifact) owner); | 158 File thisDir = getDirectory((D4EArtifact) owner); |
159 | 159 |
160 FileTools.copyDirectory(origDir, thisDir); | 160 FileTools.copyDirectory(origDir, thisDir); |
161 } | 161 } |
162 | 162 |
163 | 163 |
165 Artifact orig, | 165 Artifact orig, |
166 Artifact owner, | 166 Artifact owner, |
167 Object context, | 167 Object context, |
168 CallMeta callMeta | 168 CallMeta callMeta |
169 ) { | 169 ) { |
170 FLYSArtifact flys = (FLYSArtifact) owner; | 170 D4EArtifact flys = (D4EArtifact) owner; |
171 List<Facet> facets = flys.getFacets(); | 171 List<Facet> facets = flys.getFacets(); |
172 if (facets == null || facets.isEmpty()) { | 172 if (facets == null || facets.isEmpty()) { |
173 logger.warn("No facets for '" + OUTPUT_NAME + "' given!"); | 173 logger.warn("No facets for '" + OUTPUT_NAME + "' given!"); |
174 return; | 174 return; |
175 } | 175 } |
198 } | 198 } |
199 | 199 |
200 | 200 |
201 @Override | 201 @Override |
202 public Object computeAdvance( | 202 public Object computeAdvance( |
203 FLYSArtifact artifact, | 203 D4EArtifact artifact, |
204 String hash, | 204 String hash, |
205 CallContext context, | 205 CallContext context, |
206 List<Facet> facets, | 206 List<Facet> facets, |
207 Object old | 207 Object old |
208 ) { | 208 ) { |
272 * | 272 * |
273 * @param artifact The owner Artifact. | 273 * @param artifact The owner Artifact. |
274 * | 274 * |
275 * @return the directory for WSPLEN data. | 275 * @return the directory for WSPLEN data. |
276 */ | 276 */ |
277 protected File getDirectory(FLYSArtifact artifact) { | 277 protected File getDirectory(D4EArtifact artifact) { |
278 String shapePath = RiverUtils.getXPathString( | 278 String shapePath = RiverUtils.getXPathString( |
279 RiverUtils.XPATH_FLOODMAP_SHAPEFILE_DIR); | 279 RiverUtils.XPATH_FLOODMAP_SHAPEFILE_DIR); |
280 | 280 |
281 File artifactDir = FileTools.getDirectory( | 281 File artifactDir = FileTools.getDirectory( |
282 shapePath, artifact.identifier()); | 282 shapePath, artifact.identifier()); |
287 | 287 |
288 /** | 288 /** |
289 * Removes the directory and all its content where the required data and the | 289 * Removes the directory and all its content where the required data and the |
290 * results of WSPLGEN are stored. Should be called in endOfLife(). | 290 * results of WSPLGEN are stored. Should be called in endOfLife(). |
291 */ | 291 */ |
292 protected void removeDirectory(FLYSArtifact artifact) { | 292 protected void removeDirectory(D4EArtifact artifact) { |
293 String shapePath = RiverUtils.getXPathString( | 293 String shapePath = RiverUtils.getXPathString( |
294 RiverUtils.XPATH_FLOODMAP_SHAPEFILE_DIR); | 294 RiverUtils.XPATH_FLOODMAP_SHAPEFILE_DIR); |
295 | 295 |
296 File artifactDir = new File(shapePath, artifact.identifier()); | 296 File artifactDir = new File(shapePath, artifact.identifier()); |
297 | 297 |
310 | 310 |
311 @Override | 311 @Override |
312 public void endOfLife(Artifact artifact, Object callContext) { | 312 public void endOfLife(Artifact artifact, Object callContext) { |
313 logger.info("FloodMapState.endOfLife: " + artifact.identifier()); | 313 logger.info("FloodMapState.endOfLife: " + artifact.identifier()); |
314 | 314 |
315 FLYSArtifact flys = (FLYSArtifact) artifact; | 315 D4EArtifact flys = (D4EArtifact) artifact; |
316 | 316 |
317 Scheduler scheduler = Scheduler.getInstance(); | 317 Scheduler scheduler = Scheduler.getInstance(); |
318 scheduler.cancelJob(flys.identifier()); | 318 scheduler.cancelJob(flys.identifier()); |
319 } | 319 } |
320 | 320 |
321 | 321 |
322 protected WSPLGENJob prepareWSPLGENJob( | 322 protected WSPLGENJob prepareWSPLGENJob( |
323 FLYSArtifact artifact, | 323 D4EArtifact artifact, |
324 FacetCreator facetCreator, | 324 FacetCreator facetCreator, |
325 File artifactDir, | 325 File artifactDir, |
326 CallContext context, | 326 CallContext context, |
327 WSPLGENCalculation calculation | 327 WSPLGENCalculation calculation |
328 ) { | 328 ) { |
375 return null; | 375 return null; |
376 } | 376 } |
377 | 377 |
378 | 378 |
379 private void setAdditionalHWS( | 379 private void setAdditionalHWS( |
380 FLYSArtifact artifact, | 380 D4EArtifact artifact, |
381 FacetCreator facetCreator, | 381 FacetCreator facetCreator, |
382 File dir, | 382 File dir, |
383 WSPLGENJob job) { | 383 WSPLGENJob job) { |
384 File line = new File(dir, HWS_LINES_SHAPE); | 384 File line = new File(dir, HWS_LINES_SHAPE); |
385 boolean lines = line.exists(); | 385 boolean lines = line.exists(); |
400 } | 400 } |
401 } | 401 } |
402 | 402 |
403 | 403 |
404 private void setOfficialHWS( | 404 private void setOfficialHWS( |
405 FLYSArtifact artifact, | 405 D4EArtifact artifact, |
406 FacetCreator facetCreator, | 406 FacetCreator facetCreator, |
407 File artifactDir, | 407 File artifactDir, |
408 WSPLGENJob job) { | 408 WSPLGENJob job) { |
409 String river = artifact.getDataAsString("river"); | 409 String river = artifact.getDataAsString("river"); |
410 | 410 |
439 } | 439 } |
440 } | 440 } |
441 | 441 |
442 | 442 |
443 private void createMapfile( | 443 private void createMapfile( |
444 FLYSArtifact artifact, | 444 D4EArtifact artifact, |
445 File artifactDir, | 445 File artifactDir, |
446 String name, | 446 String name, |
447 String hwsShapefile, | 447 String hwsShapefile, |
448 String type, | 448 String type, |
449 String srid, | 449 String srid, |
474 logger.warn(Arrays.toString(ioe.getStackTrace())); | 474 logger.warn(Arrays.toString(ioe.getStackTrace())); |
475 } | 475 } |
476 } | 476 } |
477 | 477 |
478 | 478 |
479 protected void setOut(FLYSArtifact artifact, WSPLGENJob job) { | 479 protected void setOut(D4EArtifact artifact, WSPLGENJob job) { |
480 job.setOut(WSPLGEN_DEFAULT_OUTPUT); | 480 job.setOut(WSPLGEN_DEFAULT_OUTPUT); |
481 } | 481 } |
482 | 482 |
483 | 483 |
484 protected void setRange(FLYSArtifact artifact, WSPLGENJob job) { | 484 protected void setRange(D4EArtifact artifact, WSPLGENJob job) { |
485 RangeAccess rangeAccess = new RangeAccess(artifact, null); | 485 RangeAccess rangeAccess = new RangeAccess(artifact, null); |
486 double[] range = rangeAccess.getKmRange(); | 486 double[] range = rangeAccess.getKmRange(); |
487 | 487 |
488 job.setStart(range[0]); | 488 job.setStart(range[0]); |
489 job.setEnd(range[1]); | 489 job.setEnd(range[1]); |
490 } | 490 } |
491 | 491 |
492 | 492 |
493 protected void setDelta(FLYSArtifact artifact, WSPLGENJob job) { | 493 protected void setDelta(D4EArtifact artifact, WSPLGENJob job) { |
494 String from = artifact.getDataAsString("diff_from"); | 494 String from = artifact.getDataAsString("diff_from"); |
495 String to = artifact.getDataAsString("diff_to"); | 495 String to = artifact.getDataAsString("diff_to"); |
496 String diff = artifact.getDataAsString("diff_diff"); | 496 String diff = artifact.getDataAsString("diff_diff"); |
497 | 497 |
498 try { | 498 try { |
513 catch (NumberFormatException nfe) { | 513 catch (NumberFormatException nfe) { |
514 } | 514 } |
515 } | 515 } |
516 | 516 |
517 | 517 |
518 protected void setGel(FLYSArtifact artifact, WSPLGENJob job) { | 518 protected void setGel(D4EArtifact artifact, WSPLGENJob job) { |
519 String gel = artifact.getDataAsString("scenario"); | 519 String gel = artifact.getDataAsString("scenario"); |
520 | 520 |
521 logger.debug("Selected gel = '" + gel + "'"); | 521 logger.debug("Selected gel = '" + gel + "'"); |
522 | 522 |
523 if (gel == null || gel.length() == 0) { | 523 if (gel == null || gel.length() == 0) { |
533 job.setGel(WSPLGENJob.GEL_NOSPERRE); | 533 job.setGel(WSPLGENJob.GEL_NOSPERRE); |
534 } | 534 } |
535 } | 535 } |
536 | 536 |
537 | 537 |
538 protected void setDist(FLYSArtifact artifact, WSPLGENJob job) { | 538 protected void setDist(D4EArtifact artifact, WSPLGENJob job) { |
539 String dist = artifact.getDataAsString("profile_distance"); | 539 String dist = artifact.getDataAsString("profile_distance"); |
540 | 540 |
541 try { | 541 try { |
542 job.setDist(Double.parseDouble(dist)); | 542 job.setDist(Double.parseDouble(dist)); |
543 } | 543 } |
546 } | 546 } |
547 } | 547 } |
548 | 548 |
549 | 549 |
550 protected void setLine( | 550 protected void setLine( |
551 FLYSArtifact artifact, | 551 D4EArtifact artifact, |
552 FacetCreator facetCreator, | 552 FacetCreator facetCreator, |
553 File dir, | 553 File dir, |
554 WSPLGENJob job | 554 WSPLGENJob job |
555 ) { | 555 ) { |
556 String river = artifact.getDataAsString("river"); | 556 String river = artifact.getDataAsString("river"); |
641 } | 641 } |
642 } | 642 } |
643 | 643 |
644 | 644 |
645 protected void setUserShape( | 645 protected void setUserShape( |
646 FLYSArtifact artifact, | 646 D4EArtifact artifact, |
647 FacetCreator facetCreator, | 647 FacetCreator facetCreator, |
648 File dir, | 648 File dir, |
649 WSPLGENJob job | 649 WSPLGENJob job |
650 ) { | 650 ) { |
651 File archive = new File(dir, WSPLGEN_USER_SHAPE); | 651 File archive = new File(dir, WSPLGEN_USER_SHAPE); |
762 | 762 |
763 return list; | 763 return list; |
764 } | 764 } |
765 | 765 |
766 | 766 |
767 protected void setAxis(FLYSArtifact artifact, File dir, WSPLGENJob job) { | 767 protected void setAxis(D4EArtifact artifact, File dir, WSPLGENJob job) { |
768 String river = artifact.getDataAsString("river"); | 768 String river = artifact.getDataAsString("river"); |
769 String srid = RiverUtils.getRiverDGMSrid(river); | 769 String srid = RiverUtils.getRiverDGMSrid(river); |
770 String srs = "EPSG:" + srid; | 770 String srs = "EPSG:" + srid; |
771 | 771 |
772 List<RiverAxis> axes = null; | 772 List<RiverAxis> axes = null; |
808 job.setAxis(axisShape.getAbsolutePath()); | 808 job.setAxis(axisShape.getAbsolutePath()); |
809 } | 809 } |
810 } | 810 } |
811 | 811 |
812 | 812 |
813 protected void setPro(FLYSArtifact artifact, File dir, WSPLGENJob job) { | 813 protected void setPro(D4EArtifact artifact, File dir, WSPLGENJob job) { |
814 String river = artifact.getDataAsString("river"); | 814 String river = artifact.getDataAsString("river"); |
815 String srid = RiverUtils.getRiverDGMSrid(river); | 815 String srid = RiverUtils.getRiverDGMSrid(river); |
816 String srs = "EPSG:" + srid; | 816 String srs = "EPSG:" + srid; |
817 | 817 |
818 List<CrossSectionTrack> cst = | 818 List<CrossSectionTrack> cst = |
852 } | 852 } |
853 } | 853 } |
854 | 854 |
855 | 855 |
856 protected void setDgm( | 856 protected void setDgm( |
857 FLYSArtifact artifact, | 857 D4EArtifact artifact, |
858 WSPLGENJob job, | 858 WSPLGENJob job, |
859 CallContext context | 859 CallContext context |
860 ) { | 860 ) { |
861 String dgm_id = artifact.getDataAsString("dgm"); | 861 String dgm_id = artifact.getDataAsString("dgm"); |
862 | 862 |
884 job.setDgm(prefix.trim() + dgm.getPath().trim()); | 884 job.setDgm(prefix.trim() + dgm.getPath().trim()); |
885 } | 885 } |
886 } | 886 } |
887 | 887 |
888 | 888 |
889 protected void setArea(FLYSArtifact artifact, File dir, WSPLGENJob job) { | 889 protected void setArea(D4EArtifact artifact, File dir, WSPLGENJob job) { |
890 String useFloodplain = artifact.getDataAsString("use_floodplain"); | 890 String useFloodplain = artifact.getDataAsString("use_floodplain"); |
891 if (!Boolean.valueOf(useFloodplain)) { | 891 if (!Boolean.valueOf(useFloodplain)) { |
892 logger.debug("WSPLGEN will not use floodplain."); | 892 logger.debug("WSPLGEN will not use floodplain."); |
893 return; | 893 return; |
894 } | 894 } |
919 job.setArea(talaueShape.getAbsolutePath()); | 919 job.setArea(talaueShape.getAbsolutePath()); |
920 } | 920 } |
921 } | 921 } |
922 | 922 |
923 | 923 |
924 protected void setOutFile(FLYSArtifact artifact, WSPLGENJob job) { | 924 protected void setOutFile(D4EArtifact artifact, WSPLGENJob job) { |
925 job.setOutFile(WSPLGEN_OUTPUT_FILE); | 925 job.setOutFile(WSPLGEN_OUTPUT_FILE); |
926 } | 926 } |
927 | 927 |
928 | 928 |
929 protected WQKms getWQKms(FLYSArtifact flys, CallContext cc) { | 929 protected WQKms getWQKms(D4EArtifact flys, CallContext cc) { |
930 String wspString = flys.getDataAsString(WSP_ARTIFACT); | 930 String wspString = flys.getDataAsString(WSP_ARTIFACT); |
931 if (wspString == null) { | 931 if (wspString == null) { |
932 logger.debug("getWQKms(): wspString == null"); | 932 logger.debug("getWQKms(): wspString == null"); |
933 return null; | 933 return null; |
934 } | 934 } |
939 try { | 939 try { |
940 idx = Integer.parseInt(parts[2]); | 940 idx = Integer.parseInt(parts[2]); |
941 } | 941 } |
942 catch (NumberFormatException nfe) { /* do nothing */ } | 942 catch (NumberFormatException nfe) { /* do nothing */ } |
943 | 943 |
944 FLYSArtifact src = otherArtifact != null | 944 D4EArtifact src = otherArtifact != null |
945 ? RiverUtils.getArtifact(otherArtifact, cc) | 945 ? RiverUtils.getArtifact(otherArtifact, cc) |
946 : flys; | 946 : flys; |
947 | 947 |
948 logger.debug("Use waterlevel provided by Artifact: " + src.identifier()); | 948 logger.debug("Use waterlevel provided by Artifact: " + src.identifier()); |
949 | 949 |
961 : wqkms[idx]; | 961 : wqkms[idx]; |
962 } | 962 } |
963 | 963 |
964 | 964 |
965 protected void setWsp( | 965 protected void setWsp( |
966 FLYSArtifact artifact, | 966 D4EArtifact artifact, |
967 CallContext context, | 967 CallContext context, |
968 File dir, | 968 File dir, |
969 WSPLGENJob job) | 969 WSPLGENJob job) |
970 { | 970 { |
971 logger.debug("FloodMapState.setWsp"); | 971 logger.debug("FloodMapState.setWsp"); |