Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/states/FloodMapState.java @ 8202:e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Fri, 05 Sep 2014 12:58:17 +0200 |
parents | 894daf8a6fa4 |
children | b9a8463ac636 |
comparison
equal
deleted
inserted
replaced
8201:4b8c5a08de04 | 8202:e4606eae8ea5 |
---|---|
69 | 69 |
70 public class FloodMapState | 70 public class FloodMapState |
71 extends DefaultState | 71 extends DefaultState |
72 implements FacetTypes | 72 implements FacetTypes |
73 { | 73 { |
74 /** The logger that is used in this state. */ | 74 /** The log that is used in this state. */ |
75 private static Logger logger = Logger.getLogger(FloodMapState.class); | 75 private static Logger log = Logger.getLogger(FloodMapState.class); |
76 | 76 |
77 | 77 |
78 public static final String KEEP_ARTIFACT_DIR = | 78 public static final String KEEP_ARTIFACT_DIR = |
79 System.getProperty("flys.uesk.keep.artifactsdir", "false"); | 79 System.getProperty("flys.uesk.keep.artifactsdir", "false"); |
80 | 80 |
120 Artifact orig, | 120 Artifact orig, |
121 Artifact owner, | 121 Artifact owner, |
122 Object context, | 122 Object context, |
123 CallMeta callMeta | 123 CallMeta callMeta |
124 ) { | 124 ) { |
125 logger.info("Initialize State with Artifact: " + orig.identifier()); | 125 log.info("Initialize State with Artifact: " + orig.identifier()); |
126 | 126 |
127 copyShapeDir(orig, owner); | 127 copyShapeDir(orig, owner); |
128 modifyFacets(orig, owner, context, callMeta); | 128 modifyFacets(orig, owner, context, callMeta); |
129 | 129 |
130 ArtifactMapfileGenerator amfg = new ArtifactMapfileGenerator(); | 130 ArtifactMapfileGenerator amfg = new ArtifactMapfileGenerator(); |
131 try { | 131 try { |
132 amfg.generate(); | 132 amfg.generate(); |
133 } | 133 } |
134 catch (IOException e) { | 134 catch (IOException e) { |
135 logger.error(e.getMessage(), e); | 135 log.error(e.getMessage(), e); |
136 } | 136 } |
137 } | 137 } |
138 | 138 |
139 | 139 |
140 protected void copyShapeDir(Artifact orig, Artifact owner) { | 140 protected void copyShapeDir(Artifact orig, Artifact owner) { |
152 CallMeta callMeta | 152 CallMeta callMeta |
153 ) { | 153 ) { |
154 D4EArtifact flys = (D4EArtifact) owner; | 154 D4EArtifact flys = (D4EArtifact) owner; |
155 List<Facet> facets = flys.getFacets(); | 155 List<Facet> facets = flys.getFacets(); |
156 if (facets == null || facets.isEmpty()) { | 156 if (facets == null || facets.isEmpty()) { |
157 logger.warn("No facets for '" + OUTPUT_NAME + "' given!"); | 157 log.warn("No facets for '" + OUTPUT_NAME + "' given!"); |
158 return; | 158 return; |
159 } | 159 } |
160 | 160 |
161 for (Facet facet: facets) { | 161 for (Facet facet: facets) { |
162 if (facet instanceof WMSLayerFacet) { | 162 if (facet instanceof WMSLayerFacet) { |
171 String newLayer = MapfileGenerator.MS_WSPLGEN_PREFIX + | 171 String newLayer = MapfileGenerator.MS_WSPLGEN_PREFIX + |
172 owner.identifier(); | 172 owner.identifier(); |
173 | 173 |
174 wms.addLayer(newLayer); | 174 wms.addLayer(newLayer); |
175 | 175 |
176 logger.debug( | 176 log.debug( |
177 "Replaced layer: " + layer + " with " + newLayer); | 177 "Replaced layer: " + layer + " with " + newLayer); |
178 } | 178 } |
179 } | 179 } |
180 } | 180 } |
181 } | 181 } |
188 String hash, | 188 String hash, |
189 CallContext context, | 189 CallContext context, |
190 List<Facet> facets, | 190 List<Facet> facets, |
191 Object old | 191 Object old |
192 ) { | 192 ) { |
193 logger.debug("FloodMapState.computeAdvance"); | 193 log.debug("FloodMapState.computeAdvance"); |
194 | 194 |
195 File artifactDir = getDirectory(artifact); | 195 File artifactDir = getDirectory(artifact); |
196 | 196 |
197 if (artifactDir == null) { | 197 if (artifactDir == null) { |
198 logger.error("Could not create directory for WSPLGEN results!"); | 198 log.error("Could not create directory for WSPLGEN results!"); |
199 return null; | 199 return null; |
200 } | 200 } |
201 | 201 |
202 WSPLGENCalculation calculation = new WSPLGENCalculation(); | 202 WSPLGENCalculation calculation = new WSPLGENCalculation(); |
203 | 203 |
225 calculation.addError(-1, Resources.getMsg( | 225 calculation.addError(-1, Resources.getMsg( |
226 context.getMeta(), | 226 context.getMeta(), |
227 "wsplgen.job.error", | 227 "wsplgen.job.error", |
228 "wsplgen.job.error")); | 228 "wsplgen.job.error")); |
229 | 229 |
230 logger.error("No WSPLGEN processing has been started!"); | 230 log.error("No WSPLGEN processing has been started!"); |
231 | 231 |
232 return null; | 232 return null; |
233 } | 233 } |
234 | 234 |
235 context.afterCall(CallContext.BACKGROUND); | 235 context.afterCall(CallContext.BACKGROUND); |
278 RiverUtils.XPATH_FLOODMAP_SHAPEFILE_DIR); | 278 RiverUtils.XPATH_FLOODMAP_SHAPEFILE_DIR); |
279 | 279 |
280 File artifactDir = new File(shapePath, artifact.identifier()); | 280 File artifactDir = new File(shapePath, artifact.identifier()); |
281 | 281 |
282 if (artifactDir.exists()) { | 282 if (artifactDir.exists()) { |
283 logger.info("Delete directory: " + artifactDir.getAbsolutePath()); | 283 log.info("Delete directory: " + artifactDir.getAbsolutePath()); |
284 if (!FileTools.deleteRecursive(artifactDir)) { | 284 if (!FileTools.deleteRecursive(artifactDir)) { |
285 logger.warn("Could not delete directory: " | 285 log.warn("Could not delete directory: " |
286 + artifactDir.getAbsolutePath()); | 286 + artifactDir.getAbsolutePath()); |
287 } | 287 } |
288 } | 288 } |
289 else { | 289 else { |
290 logger.debug("There is no directory to remove."); | 290 log.debug("There is no directory to remove."); |
291 } | 291 } |
292 } | 292 } |
293 | 293 |
294 | 294 |
295 @Override | 295 @Override |
296 public void endOfLife(Artifact artifact, Object callContext) { | 296 public void endOfLife(Artifact artifact, Object callContext) { |
297 logger.info("FloodMapState.endOfLife: " + artifact.identifier()); | 297 log.info("FloodMapState.endOfLife: " + artifact.identifier()); |
298 | 298 |
299 D4EArtifact flys = (D4EArtifact) artifact; | 299 D4EArtifact flys = (D4EArtifact) artifact; |
300 | 300 |
301 Scheduler scheduler = Scheduler.getInstance(); | 301 Scheduler scheduler = Scheduler.getInstance(); |
302 scheduler.cancelJob(flys.identifier()); | 302 scheduler.cancelJob(flys.identifier()); |
308 FacetCreator facetCreator, | 308 FacetCreator facetCreator, |
309 File artifactDir, | 309 File artifactDir, |
310 CallContext context, | 310 CallContext context, |
311 WSPLGENCalculation calculation | 311 WSPLGENCalculation calculation |
312 ) { | 312 ) { |
313 logger.debug("FloodMapState.prepareWSPLGENJob"); | 313 log.debug("FloodMapState.prepareWSPLGENJob"); |
314 String scenario = artifact.getDataAsString("scenario"); | 314 String scenario = artifact.getDataAsString("scenario"); |
315 | 315 |
316 WSPLGENJob job = new WSPLGENJob( | 316 WSPLGENJob job = new WSPLGENJob( |
317 artifact, | 317 artifact, |
318 artifactDir, | 318 artifactDir, |
349 job.toFile(paraFile); | 349 job.toFile(paraFile); |
350 | 350 |
351 return job; | 351 return job; |
352 } | 352 } |
353 catch (IOException ioe) { | 353 catch (IOException ioe) { |
354 logger.warn("Cannot write PAR file: " + ioe.getMessage()); | 354 log.warn("Cannot write PAR file: " + ioe.getMessage()); |
355 } | 355 } |
356 catch (IllegalArgumentException iae) { | 356 catch (IllegalArgumentException iae) { |
357 logger.warn("Cannot write PAR file: " + iae.getMessage()); | 357 log.warn("Cannot write PAR file: " + iae.getMessage()); |
358 } | 358 } |
359 | 359 |
360 return null; | 360 return null; |
361 } | 361 } |
362 | 362 |
366 FacetCreator facetCreator, | 366 FacetCreator facetCreator, |
367 File dir, | 367 File dir, |
368 WSPLGENJob job) { | 368 WSPLGENJob job) { |
369 File line = new File(dir, HWS_LINES_SHAPE); | 369 File line = new File(dir, HWS_LINES_SHAPE); |
370 boolean lines = line.exists(); | 370 boolean lines = line.exists(); |
371 logger.debug("shp file exists: " + lines); | 371 log.debug("shp file exists: " + lines); |
372 if (lines) { | 372 if (lines) { |
373 job.addLin(dir + "/" + HWS_LINES_SHAPE); | 373 job.addLin(dir + "/" + HWS_LINES_SHAPE); |
374 facetCreator.createShapeFacet(I18N_HWS_LINES_OFFICIAL, | 374 facetCreator.createShapeFacet(I18N_HWS_LINES_OFFICIAL, |
375 MapfileGenerator.MS_LAYER_PREFIX + HWS_LINES, | 375 MapfileGenerator.MS_LAYER_PREFIX + HWS_LINES, |
376 FLOODMAP_LINES, 2); | 376 FLOODMAP_LINES, 2); |
377 } | 377 } |
378 File point = new File(dir, HWS_POINT_SHAPE); | 378 File point = new File(dir, HWS_POINT_SHAPE); |
379 boolean points = point.exists(); | 379 boolean points = point.exists(); |
380 logger.debug("shp file exists: " + points); | 380 log.debug("shp file exists: " + points); |
381 if (points) { | 381 if (points) { |
382 facetCreator.createShapeFacet(I18N_HWS_POINTS_OFFICIAL, | 382 facetCreator.createShapeFacet(I18N_HWS_POINTS_OFFICIAL, |
383 MapfileGenerator.MS_LAYER_PREFIX + HWS_POINTS, | 383 MapfileGenerator.MS_LAYER_PREFIX + HWS_POINTS, |
384 FLOODMAP_FIXPOINTS, 3); | 384 FLOODMAP_FIXPOINTS, 3); |
385 } | 385 } |
420 job.addLin(artifactDir + "/" + HWS_LINES_SHAPE); | 420 job.addLin(artifactDir + "/" + HWS_LINES_SHAPE); |
421 facetCreator.createShapeFacet(I18N_HWS_LINES_OFFICIAL, | 421 facetCreator.createShapeFacet(I18N_HWS_LINES_OFFICIAL, |
422 MapfileGenerator.MS_LAYER_PREFIX + HWS_LINES, | 422 MapfileGenerator.MS_LAYER_PREFIX + HWS_LINES, |
423 FLOODMAP_HWS_LINES,2); | 423 FLOODMAP_HWS_LINES,2); |
424 } | 424 } |
425 else logger.warn("no lines written"); | 425 else log.warn("no lines written"); |
426 } | 426 } |
427 | 427 |
428 | 428 |
429 public static void createMapfile( | 429 public static void createMapfile( |
430 D4EArtifact artifact, | 430 D4EArtifact artifact, |
452 List<String> layers = new ArrayList<String>(); | 452 List<String> layers = new ArrayList<String>(); |
453 layers.add(layer.getAbsolutePath()); | 453 layers.add(layer.getAbsolutePath()); |
454 generator.generate(); | 454 generator.generate(); |
455 } | 455 } |
456 catch(FileNotFoundException fnfe) { | 456 catch(FileNotFoundException fnfe) { |
457 logger.warn("Could not find mapfile for hws layer"); | 457 log.warn("Could not find mapfile for hws layer"); |
458 } | 458 } |
459 catch (Exception ioe) { | 459 catch (Exception ioe) { |
460 logger.warn("Could not create mapfile for hws layer"); | 460 log.warn("Could not create mapfile for hws layer"); |
461 logger.warn(Arrays.toString(ioe.getStackTrace())); | 461 log.warn(Arrays.toString(ioe.getStackTrace())); |
462 } | 462 } |
463 } | 463 } |
464 | 464 |
465 | 465 |
466 protected void setOut(D4EArtifact artifact, WSPLGENJob job) { | 466 protected void setOut(D4EArtifact artifact, WSPLGENJob job) { |
503 | 503 |
504 | 504 |
505 protected void setGel(D4EArtifact artifact, WSPLGENJob job) { | 505 protected void setGel(D4EArtifact artifact, WSPLGENJob job) { |
506 String gel = artifact.getDataAsString("scenario"); | 506 String gel = artifact.getDataAsString("scenario"); |
507 | 507 |
508 logger.debug("Selected gel = '" + gel + "'"); | 508 log.debug("Selected gel = '" + gel + "'"); |
509 | 509 |
510 if (gel == null || gel.length() == 0) { | 510 if (gel == null || gel.length() == 0) { |
511 job.setGel(WSPLGENJob.GEL_NOSPERRE); | 511 job.setGel(WSPLGENJob.GEL_NOSPERRE); |
512 } | 512 } |
513 else if (gel.equals("scenario.current")) { | 513 else if (gel.equals("scenario.current")) { |
542 ) { | 542 ) { |
543 DGMAccess access = new DGMAccess(artifact); | 543 DGMAccess access = new DGMAccess(artifact); |
544 String geoJSON = access.getGeoJSON(); | 544 String geoJSON = access.getGeoJSON(); |
545 | 545 |
546 if (geoJSON == null || geoJSON.length() == 0) { | 546 if (geoJSON == null || geoJSON.length() == 0) { |
547 logger.debug("No barrier features in parameterization existing."); | 547 log.debug("No barrier features in parameterization existing."); |
548 return; | 548 return; |
549 } | 549 } |
550 | 550 |
551 String srid = String.valueOf(access.getDGM().getSrid()); | 551 String srid = String.valueOf(access.getDGM().getSrid()); |
552 | 552 |
555 SimpleFeatureType ft = getBarriersFeatureType( | 555 SimpleFeatureType ft = getBarriersFeatureType( |
556 "barriers", srs, Geometry.class); | 556 "barriers", srs, Geometry.class); |
557 | 557 |
558 List<SimpleFeature> features = GeometryUtils.parseGeoJSON(geoJSON, ft); | 558 List<SimpleFeature> features = GeometryUtils.parseGeoJSON(geoJSON, ft); |
559 if (features == null || features.isEmpty()) { | 559 if (features == null || features.isEmpty()) { |
560 logger.debug("No barrier features extracted."); | 560 log.debug("No barrier features extracted."); |
561 return; | 561 return; |
562 } | 562 } |
563 | 563 |
564 FeatureCollection[] fcs = splitLinesAndPolygons(features); | 564 FeatureCollection[] fcs = splitLinesAndPolygons(features); |
565 | 565 |
576 shapeLines, | 576 shapeLines, |
577 GeometryUtils.buildFeatureType("lines", srs, LineString.class, obj), | 577 GeometryUtils.buildFeatureType("lines", srs, LineString.class, obj), |
578 fcs[0]); | 578 fcs[0]); |
579 | 579 |
580 if (l) { | 580 if (l) { |
581 logger.debug( | 581 log.debug( |
582 "Successfully created barrier line shapefile. " + | 582 "Successfully created barrier line shapefile. " + |
583 "Write shapefile path into WSPLGEN job."); | 583 "Write shapefile path into WSPLGEN job."); |
584 createMapfile( | 584 createMapfile( |
585 artifact, | 585 artifact, |
586 dir, | 586 dir, |
589 "LINE", | 589 "LINE", |
590 srid, | 590 srid, |
591 MapfileGenerator.MS_BARRIERS_PREFIX); | 591 MapfileGenerator.MS_BARRIERS_PREFIX); |
592 | 592 |
593 if (scenario.equals(WSPLGENJob.GEL_NOSPERRE)) { | 593 if (scenario.equals(WSPLGENJob.GEL_NOSPERRE)) { |
594 logger.debug("WSPLGEN will not use barrier features."); | 594 log.debug("WSPLGEN will not use barrier features."); |
595 } | 595 } |
596 else { | 596 else { |
597 job.addLin(shapeLines.getAbsolutePath()); | 597 job.addLin(shapeLines.getAbsolutePath()); |
598 } | 598 } |
599 } | 599 } |
603 GeometryUtils.buildFeatureType("polygons", srs, Polygon.class, obj), | 603 GeometryUtils.buildFeatureType("polygons", srs, Polygon.class, obj), |
604 fcs[1]); | 604 fcs[1]); |
605 | 605 |
606 | 606 |
607 if (p) { | 607 if (p) { |
608 logger.debug( | 608 log.debug( |
609 "Successfully created barrier polygon shapefile. " + | 609 "Successfully created barrier polygon shapefile. " + |
610 "Write shapefile path into WSPLGEN job."); | 610 "Write shapefile path into WSPLGEN job."); |
611 createMapfile( | 611 createMapfile( |
612 artifact, | 612 artifact, |
613 dir, | 613 dir, |
616 "POLYGON", | 616 "POLYGON", |
617 srid, | 617 srid, |
618 MapfileGenerator.MS_BARRIERS_PREFIX); | 618 MapfileGenerator.MS_BARRIERS_PREFIX); |
619 | 619 |
620 if (scenario.equals(WSPLGENJob.GEL_NOSPERRE)) { | 620 if (scenario.equals(WSPLGENJob.GEL_NOSPERRE)) { |
621 logger.debug("WSPLGEN will not use barrier features."); | 621 log.debug("WSPLGEN will not use barrier features."); |
622 } | 622 } |
623 else { | 623 else { |
624 job.addLin(shapePolys.getAbsolutePath()); | 624 job.addLin(shapePolys.getAbsolutePath()); |
625 } | 625 } |
626 } | 626 } |
637 File dir, | 637 File dir, |
638 WSPLGENJob job | 638 WSPLGENJob job |
639 ) { | 639 ) { |
640 File archive = new File(dir, WSPLGEN_USER_RGD_SHAPE); | 640 File archive = new File(dir, WSPLGEN_USER_RGD_SHAPE); |
641 boolean exists = archive.exists(); | 641 boolean exists = archive.exists(); |
642 logger.debug("shp file exists: " + exists); | 642 log.debug("shp file exists: " + exists); |
643 if (exists) { | 643 if (exists) { |
644 job.addLin(dir + "/" + WSPLGEN_USER_RGD_SHAPE); | 644 job.addLin(dir + "/" + WSPLGEN_USER_RGD_SHAPE); |
645 facetCreator.createShapeFacet(FacetCreator.I18N_USERSHAPE, | 645 facetCreator.createShapeFacet(FacetCreator.I18N_USERSHAPE, |
646 MapfileGenerator.MS_LAYER_PREFIX + WSPLGEN_USER_RGD, | 646 MapfileGenerator.MS_LAYER_PREFIX + WSPLGEN_USER_RGD, |
647 FLOODMAP_USERSHAPE, | 647 FLOODMAP_USERSHAPE, |
678 else if (geom instanceof Polygon) { | 678 else if (geom instanceof Polygon) { |
679 geom = applyElevationAttribute(feature, geom); | 679 geom = applyElevationAttribute(feature, geom); |
680 polygons.add(feature); | 680 polygons.add(feature); |
681 } | 681 } |
682 else { | 682 else { |
683 logger.warn("Feature not supported: " + geom.getClass()); | 683 log.warn("Feature not supported: " + geom.getClass()); |
684 } | 684 } |
685 } | 685 } |
686 | 686 |
687 logger.debug("Found " + lines.size() + " barrier lines."); | 687 log.debug("Found " + lines.size() + " barrier lines."); |
688 logger.debug("Found " + polygons.size() + " barrier polygons."); | 688 log.debug("Found " + polygons.size() + " barrier polygons."); |
689 | 689 |
690 return new FeatureCollection[] { lines, polygons }; | 690 return new FeatureCollection[] { lines, polygons }; |
691 } | 691 } |
692 | 692 |
693 | 693 |
694 protected static Geometry applyElevationAttribute( | 694 protected static Geometry applyElevationAttribute( |
695 SimpleFeature feature, | 695 SimpleFeature feature, |
696 Geometry geom | 696 Geometry geom |
697 ) { | 697 ) { |
698 logger.debug("Apply elevations for: " + geom.getClass()); | 698 log.debug("Apply elevations for: " + geom.getClass()); |
699 | 699 |
700 List<Double> elevations = extractElevations(feature); | 700 List<Double> elevations = extractElevations(feature); |
701 int numPoints = geom.getNumPoints(); | 701 int numPoints = geom.getNumPoints(); |
702 int numElevation = elevations.size(); | 702 int numElevation = elevations.size(); |
703 | 703 |
704 String typ = (String) feature.getAttribute("typ"); | 704 String typ = (String) feature.getAttribute("typ"); |
705 | 705 |
706 if (numPoints > numElevation) { | 706 if (numPoints > numElevation) { |
707 logger.warn("More vertices in Geometry than elevations given."); | 707 log.warn("More vertices in Geometry than elevations given."); |
708 } | 708 } |
709 | 709 |
710 Coordinate[] c = geom.getCoordinates(); | 710 Coordinate[] c = geom.getCoordinates(); |
711 for (int i = 0; i < numPoints; i++) { | 711 for (int i = 0; i < numPoints; i++) { |
712 if (i < numElevation) { | 712 if (i < numElevation) { |
737 for (int i = 0; i < num; i++) { | 737 for (int i = 0; i < num; i++) { |
738 try { | 738 try { |
739 list.add(Double.parseDouble(elevations[i])); | 739 list.add(Double.parseDouble(elevations[i])); |
740 } | 740 } |
741 catch (NumberFormatException nfe) { | 741 catch (NumberFormatException nfe) { |
742 logger.warn("Error while parsing elevation at pos: " + i); | 742 log.warn("Error while parsing elevation at pos: " + i); |
743 if (typ != null && typ.equals("Graben")) { | 743 if (typ != null && typ.equals("Graben")) { |
744 list.add(new Double(-9999.0)); | 744 list.add(new Double(-9999.0)); |
745 } | 745 } |
746 else { | 746 else { |
747 list.add(new Double(9999.0)); | 747 list.add(new Double(9999.0)); |
762 List<RiverAxis> axes = null; | 762 List<RiverAxis> axes = null; |
763 try { | 763 try { |
764 axes = RiverAxis.getRiverAxis(river); | 764 axes = RiverAxis.getRiverAxis(river); |
765 } | 765 } |
766 catch (HibernateException iae) { | 766 catch (HibernateException iae) { |
767 logger.warn("No valid river axis found for " + river); | 767 log.warn("No valid river axis found for " + river); |
768 return; | 768 return; |
769 } | 769 } |
770 if (axes == null || axes.isEmpty()) { | 770 if (axes == null || axes.isEmpty()) { |
771 logger.warn("Could not find river axis for: '" + river + "'"); | 771 log.warn("Could not find river axis for: '" + river + "'"); |
772 return; | 772 return; |
773 } | 773 } |
774 | 774 |
775 SimpleFeatureType ft = GeometryUtils.buildFeatureType( | 775 SimpleFeatureType ft = GeometryUtils.buildFeatureType( |
776 "axis", srs, LineString.class); | 776 "axis", srs, LineString.class); |
807 String srs = "EPSG:" + srid; | 807 String srs = "EPSG:" + srid; |
808 | 808 |
809 List<CrossSectionTrack> cst = | 809 List<CrossSectionTrack> cst = |
810 CrossSectionTrack.getCrossSectionTrack(river, WSPLGEN_QPS_NAME); | 810 CrossSectionTrack.getCrossSectionTrack(river, WSPLGEN_QPS_NAME); |
811 | 811 |
812 logger.debug("Found " + cst.size() + " CrossSectionTracks."); | 812 log.debug("Found " + cst.size() + " CrossSectionTracks."); |
813 | 813 |
814 Object[][] attrs = new Object[2][]; | 814 Object[][] attrs = new Object[2][]; |
815 attrs[0] = new Object[] { "ELEVATION", Double.class }; | 815 attrs[0] = new Object[] { "ELEVATION", Double.class }; |
816 attrs[1] = new Object[] { "KILOMETER", Double.class }; | 816 attrs[1] = new Object[] { "KILOMETER", Double.class }; |
817 | 817 |
851 ) { | 851 ) { |
852 DGMAccess access = new DGMAccess(artifact); | 852 DGMAccess access = new DGMAccess(artifact); |
853 DGM dgm = access.getDGM(); | 853 DGM dgm = access.getDGM(); |
854 | 854 |
855 if (dgm == null) { | 855 if (dgm == null) { |
856 logger.warn("Could not find specified DGM."); | 856 log.warn("Could not find specified DGM."); |
857 return; | 857 return; |
858 } | 858 } |
859 | 859 |
860 File dgmPath = new File(dgm.getPath()); | 860 File dgmPath = new File(dgm.getPath()); |
861 if (dgmPath.isAbsolute()) { | 861 if (dgmPath.isAbsolute()) { |
870 | 870 |
871 | 871 |
872 protected void setArea(D4EArtifact artifact, File dir, WSPLGENJob job) { | 872 protected void setArea(D4EArtifact artifact, File dir, WSPLGENJob job) { |
873 String useFloodplain = artifact.getDataAsString("use_floodplain"); | 873 String useFloodplain = artifact.getDataAsString("use_floodplain"); |
874 if (!Boolean.valueOf(useFloodplain)) { | 874 if (!Boolean.valueOf(useFloodplain)) { |
875 logger.debug("WSPLGEN will not use floodplain."); | 875 log.debug("WSPLGEN will not use floodplain."); |
876 return; | 876 return; |
877 } | 877 } |
878 | 878 |
879 DGMAccess access = new DGMAccess(artifact); | 879 DGMAccess access = new DGMAccess(artifact); |
880 String river = access.getRiverName(); | 880 String river = access.getRiverName(); |
882 String srs = "EPSG:" + srid; | 882 String srs = "EPSG:" + srid; |
883 | 883 |
884 Floodplain plain = Floodplain.getFloodplain(river); | 884 Floodplain plain = Floodplain.getFloodplain(river); |
885 | 885 |
886 if (plain == null) { | 886 if (plain == null) { |
887 logger.debug("No flood plain for river '" + river + "'"); | 887 log.debug("No flood plain for river '" + river + "'"); |
888 return; | 888 return; |
889 } | 889 } |
890 | 890 |
891 Polygon polygon = plain.getGeom(); | 891 Polygon polygon = plain.getGeom(); |
892 if (polygon == null) { | 892 if (polygon == null) { |
893 logger.warn("Floodplain has no geometry."); | 893 log.warn("Floodplain has no geometry."); |
894 return; | 894 return; |
895 } | 895 } |
896 | 896 |
897 SimpleFeatureType ft = GeometryUtils.buildFeatureType( | 897 SimpleFeatureType ft = GeometryUtils.buildFeatureType( |
898 "talaue", srs, Polygon.class); | 898 "talaue", srs, Polygon.class); |
924 /** Gets the Waterlevel of chosen artifact as base for flooding. */ | 924 /** Gets the Waterlevel of chosen artifact as base for flooding. */ |
925 // Challenge equals WaterlevelSelectState#getLabel | 925 // Challenge equals WaterlevelSelectState#getLabel |
926 protected WQKms getWQKms(D4EArtifact flys, CallContext cc) { | 926 protected WQKms getWQKms(D4EArtifact flys, CallContext cc) { |
927 String wspString = flys.getDataAsString(WSP_ARTIFACT); | 927 String wspString = flys.getDataAsString(WSP_ARTIFACT); |
928 if (wspString == null) { | 928 if (wspString == null) { |
929 logger.debug("getWQKms(): wspString == null"); | 929 log.debug("getWQKms(): wspString == null"); |
930 return null; | 930 return null; |
931 } | 931 } |
932 String[] parts = wspString.split(";"); | 932 String[] parts = wspString.split(";"); |
933 String otherArtifact = parts[0]; | 933 String otherArtifact = parts[0]; |
934 | 934 |
940 | 940 |
941 D4EArtifact src = otherArtifact != null | 941 D4EArtifact src = otherArtifact != null |
942 ? RiverUtils.getArtifact(otherArtifact, cc) | 942 ? RiverUtils.getArtifact(otherArtifact, cc) |
943 : flys; | 943 : flys; |
944 | 944 |
945 logger.debug("Use waterlevel provided by Artifact: " + src.identifier()); | 945 log.debug("Use waterlevel provided by Artifact: " + src.identifier()); |
946 | 946 |
947 // The state actually depends on the kind of artifact. E.g. StaticWQKmsArtifact needs other state | 947 // The state actually depends on the kind of artifact. E.g. StaticWQKmsArtifact needs other state |
948 Object computed = src.compute( | 948 Object computed = src.compute( |
949 cc, | 949 cc, |
950 //null, | 950 //null, |
979 // Floodmarks and protection. | 979 // Floodmarks and protection. |
980 WQKms wqkms = WQKms.fromWKms(((StaticWKmsArtifact) src).getWKms(0), 1d); | 980 WQKms wqkms = WQKms.fromWKms(((StaticWKmsArtifact) src).getWKms(0), 1d); |
981 return wqkms; | 981 return wqkms; |
982 } | 982 } |
983 | 983 |
984 logger.warn("getWQKms cannot handle " + computed.getClass() + " " + src.getClass()); | 984 log.warn("getWQKms cannot handle " + computed.getClass() + " " + src.getClass()); |
985 return null; | 985 return null; |
986 } | 986 } |
987 | 987 |
988 | 988 |
989 protected void setWsp( | 989 protected void setWsp( |
990 D4EArtifact artifact, | 990 D4EArtifact artifact, |
991 CallContext context, | 991 CallContext context, |
992 File dir, | 992 File dir, |
993 WSPLGENJob job) | 993 WSPLGENJob job) |
994 { | 994 { |
995 logger.debug("FloodMapState.setWsp"); | 995 log.debug("FloodMapState.setWsp"); |
996 | 996 |
997 WQKms data = getWQKms(artifact, context); | 997 WQKms data = getWQKms(artifact, context); |
998 | 998 |
999 if (data == null) { | 999 if (data == null) { |
1000 logger.warn("No WST data found!"); | 1000 log.warn("No WST data found!"); |
1001 return; | 1001 return; |
1002 } | 1002 } |
1003 | 1003 |
1004 WstWriter writer = new WstWriter(0, true); | 1004 WstWriter writer = new WstWriter(0, true); |
1005 | 1005 |
1006 // TODO REMOVE job.setWspTag(...) This is only used until the user is | 1006 // TODO REMOVE job.setWspTag(...) This is only used until the user is |
1007 // able to select the WSP column himself! | 1007 // able to select the WSP column himself! |
1008 boolean writeWspTag = true; | 1008 boolean writeWspTag = true; |
1009 | 1009 |
1010 double[] buf = new double[4]; | 1010 double[] buf = new double[4]; |
1011 logger.debug("Add WST column: " + data.getName()); | 1011 log.debug("Add WST column: " + data.getName()); |
1012 writer.addColumn(data.getName()); | 1012 writer.addColumn(data.getName()); |
1013 | 1013 |
1014 if (writeWspTag) { | 1014 if (writeWspTag) { |
1015 job.setWspTag(data.getName()); | 1015 job.setWspTag(data.getName()); |
1016 writeWspTag = false; | 1016 writeWspTag = false; |
1030 writer.write(fout); | 1030 writer.write(fout); |
1031 | 1031 |
1032 job.setWsp(wspFile.getAbsolutePath()); | 1032 job.setWsp(wspFile.getAbsolutePath()); |
1033 } | 1033 } |
1034 catch (FileNotFoundException fnfe) { | 1034 catch (FileNotFoundException fnfe) { |
1035 logger.warn("Error while writing wsp file: " + fnfe.getMessage()); | 1035 log.warn("Error while writing wsp file: " + fnfe.getMessage()); |
1036 } | 1036 } |
1037 finally { | 1037 finally { |
1038 if (fout != null) { | 1038 if (fout != null) { |
1039 try { | 1039 try { |
1040 fout.close(); | 1040 fout.close(); |