annotate artifacts/src/main/java/org/dive4elements/river/artifacts/states/FloodMapState.java @ 8856:5e38e2924c07 3.2.x

Fix code style.
author Tom Gottfried <tom@intevation.de>
date Thu, 18 Jan 2018 20:12:01 +0100
parents e9d912c97fa8
children 3f49835a00c3 0a5239a1e46e
rev   line source
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
2 * Software engineering by Intevation GmbH
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
3 *
5994
af13ceeba52a Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5913
diff changeset
4 * This file is Free Software under the GNU AGPL (>=v3)
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the
5994
af13ceeba52a Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5913
diff changeset
6 * documentation coming with Dive4Elements River for details.
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
7 */
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
8
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5580
diff changeset
9 package org.dive4elements.river.artifacts.states;
927
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10
6710
ffc9cb39cea7 Remove duplicate code for mapfile generation. ID problem still not fixed (#657).
Christian Lins <christian.lins@intevation.de>
parents: 6330
diff changeset
11 import com.vividsolutions.jts.geom.Coordinate;
ffc9cb39cea7 Remove duplicate code for mapfile generation. ID problem still not fixed (#657).
Christian Lins <christian.lins@intevation.de>
parents: 6330
diff changeset
12 import com.vividsolutions.jts.geom.Geometry;
ffc9cb39cea7 Remove duplicate code for mapfile generation. ID problem still not fixed (#657).
Christian Lins <christian.lins@intevation.de>
parents: 6330
diff changeset
13 import com.vividsolutions.jts.geom.LineString;
ffc9cb39cea7 Remove duplicate code for mapfile generation. ID problem still not fixed (#657).
Christian Lins <christian.lins@intevation.de>
parents: 6330
diff changeset
14 import com.vividsolutions.jts.geom.Polygon;
ffc9cb39cea7 Remove duplicate code for mapfile generation. ID problem still not fixed (#657).
Christian Lins <christian.lins@intevation.de>
parents: 6330
diff changeset
15
5281
cf7e0d9022fa Removed bogus imports.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5181
diff changeset
16 import java.io.File;
cf7e0d9022fa Removed bogus imports.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5181
diff changeset
17 import java.io.FileNotFoundException;
cf7e0d9022fa Removed bogus imports.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5181
diff changeset
18 import java.io.FileOutputStream;
cf7e0d9022fa Removed bogus imports.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5181
diff changeset
19 import java.io.IOException;
cf7e0d9022fa Removed bogus imports.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5181
diff changeset
20 import java.util.ArrayList;
5313
a1cb9a734cc5 Cleaned up imports.#
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5312
diff changeset
21 import java.util.Arrays;
5281
cf7e0d9022fa Removed bogus imports.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5181
diff changeset
22 import java.util.List;
cf7e0d9022fa Removed bogus imports.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5181
diff changeset
23
cf7e0d9022fa Removed bogus imports.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5181
diff changeset
24 import org.apache.log4j.Logger;
5313
a1cb9a734cc5 Cleaned up imports.#
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5312
diff changeset
25 import org.apache.velocity.Template;
8452
b9a8463ac636 (issue1732) When duplication wsplgen artificats fix shapefile layers
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8202
diff changeset
26 import org.apache.commons.io.FileUtils;
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5580
diff changeset
27 import org.dive4elements.artifactdatabase.state.Facet;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5580
diff changeset
28 import org.dive4elements.artifacts.Artifact;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5580
diff changeset
29 import org.dive4elements.artifacts.CallContext;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5580
diff changeset
30 import org.dive4elements.artifacts.CallMeta;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5580
diff changeset
31 import org.dive4elements.artifacts.GlobalContext;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5580
diff changeset
32 import org.dive4elements.artifacts.common.utils.FileTools;
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
33 import org.dive4elements.river.artifacts.D4EArtifact;
7647
786ff139de5e issue1020: When preparing wsts for wsplgen handle other than standard wqkms calculations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7646
diff changeset
34 import org.dive4elements.river.artifacts.StaticWKmsArtifact;
7055
1f38656b68c4 DGM SRIds are now fetched from database instead of configuration.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6983
diff changeset
35 import org.dive4elements.river.artifacts.access.DGMAccess;
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5580
diff changeset
36 import org.dive4elements.river.artifacts.access.RangeAccess;
5866
9a6741ccf6d4 FLYS artifacts: Renamed FLYSContext(Factory) to RiverContext(Factory).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5865
diff changeset
37 import org.dive4elements.river.artifacts.context.RiverContext;
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5580
diff changeset
38 import org.dive4elements.river.artifacts.model.CalculationMessage;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5580
diff changeset
39 import org.dive4elements.river.artifacts.model.CalculationResult;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5580
diff changeset
40 import org.dive4elements.river.artifacts.model.FacetTypes;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5580
diff changeset
41 import org.dive4elements.river.artifacts.model.LayerInfo;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5580
diff changeset
42 import org.dive4elements.river.artifacts.model.WQKms;
7647
786ff139de5e issue1020: When preparing wsts for wsplgen handle other than standard wqkms calculations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7646
diff changeset
43 import org.dive4elements.river.artifacts.model.fixings.FixRealizingResult;
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5580
diff changeset
44 import org.dive4elements.river.artifacts.model.map.HWS;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5580
diff changeset
45 import org.dive4elements.river.artifacts.model.map.HWSContainer;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5580
diff changeset
46 import org.dive4elements.river.artifacts.model.map.HWSFactory;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5580
diff changeset
47 import org.dive4elements.river.artifacts.model.map.WMSLayerFacet;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5580
diff changeset
48 import org.dive4elements.river.artifacts.model.map.WSPLGENCalculation;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5580
diff changeset
49 import org.dive4elements.river.artifacts.model.map.WSPLGENJob;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5580
diff changeset
50 import org.dive4elements.river.artifacts.model.map.WSPLGENReportFacet;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5580
diff changeset
51 import org.dive4elements.river.artifacts.resources.Resources;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5580
diff changeset
52 import org.dive4elements.river.exports.WstWriter;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5580
diff changeset
53 import org.dive4elements.river.model.CrossSectionTrack;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5580
diff changeset
54 import org.dive4elements.river.model.DGM;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5580
diff changeset
55 import org.dive4elements.river.model.Floodplain;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5580
diff changeset
56 import org.dive4elements.river.model.RiverAxis;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5580
diff changeset
57 import org.dive4elements.river.utils.ArtifactMapfileGenerator;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5580
diff changeset
58 import org.dive4elements.river.utils.GeometryUtils;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5580
diff changeset
59 import org.dive4elements.river.utils.MapfileGenerator;
6710
ffc9cb39cea7 Remove duplicate code for mapfile generation. ID problem still not fixed (#657).
Christian Lins <christian.lins@intevation.de>
parents: 6330
diff changeset
60 import org.dive4elements.river.utils.RiverUtils;
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5580
diff changeset
61 import org.dive4elements.river.wsplgen.FacetCreator;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5580
diff changeset
62 import org.dive4elements.river.wsplgen.JobObserver;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5580
diff changeset
63 import org.dive4elements.river.wsplgen.Scheduler;
6710
ffc9cb39cea7 Remove duplicate code for mapfile generation. ID problem still not fixed (#657).
Christian Lins <christian.lins@intevation.de>
parents: 6330
diff changeset
64 import org.geotools.feature.FeatureCollection;
ffc9cb39cea7 Remove duplicate code for mapfile generation. ID problem still not fixed (#657).
Christian Lins <christian.lins@intevation.de>
parents: 6330
diff changeset
65 import org.geotools.feature.FeatureCollections;
ffc9cb39cea7 Remove duplicate code for mapfile generation. ID problem still not fixed (#657).
Christian Lins <christian.lins@intevation.de>
parents: 6330
diff changeset
66 import org.geotools.feature.simple.SimpleFeatureBuilder;
ffc9cb39cea7 Remove duplicate code for mapfile generation. ID problem still not fixed (#657).
Christian Lins <christian.lins@intevation.de>
parents: 6330
diff changeset
67 import org.hibernate.HibernateException;
ffc9cb39cea7 Remove duplicate code for mapfile generation. ID problem still not fixed (#657).
Christian Lins <christian.lins@intevation.de>
parents: 6330
diff changeset
68 import org.opengis.feature.simple.SimpleFeature;
ffc9cb39cea7 Remove duplicate code for mapfile generation. ID problem still not fixed (#657).
Christian Lins <christian.lins@intevation.de>
parents: 6330
diff changeset
69 import org.opengis.feature.simple.SimpleFeatureType;
927
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
70
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
71 public class FloodMapState
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
72 extends DefaultState
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
73 implements FacetTypes
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
74 {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7661
diff changeset
75 /** The log that is used in this state. */
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7661
diff changeset
76 private static Logger log = Logger.getLogger(FloodMapState.class);
927
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
77
935
353ddfa231a7 Introduced a new output 'floodmap' for the FloodMapState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 927
diff changeset
78
1107
005c2964f9af Use the correct SRID while reading GeoJSON barriers and writing line/polygon shapefiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1106
diff changeset
79 public static final String KEEP_ARTIFACT_DIR =
005c2964f9af Use the correct SRID while reading GeoJSON barriers and writing line/polygon shapefiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1106
diff changeset
80 System.getProperty("flys.uesk.keep.artifactsdir", "false");
005c2964f9af Use the correct SRID while reading GeoJSON barriers and writing line/polygon shapefiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1106
diff changeset
81
005c2964f9af Use the correct SRID while reading GeoJSON barriers and writing line/polygon shapefiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1106
diff changeset
82
2095
8cb679d4ec49 Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2093
diff changeset
83 public static final String OUTPUT_NAME = "floodmap";
8cb679d4ec49 Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2093
diff changeset
84
1178
1b432c260e97 Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1168
diff changeset
85 public static final String WSP_ARTIFACT = "wsp";
1118
7398280b11a0 Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1110
diff changeset
86
7398280b11a0 Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1110
diff changeset
87 public static final String WINFO_WSP_STATE_ID = "state.winfo.waterlevel";
7398280b11a0 Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1110
diff changeset
88
1091
7230e087ef8b Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
89 public static final String WSPLGEN_PARAMETER_FILE = "wsplgen.par";
1106
e9f66d63bdd0 Write user defined barriers into a shapefile that is placed in the Artifact's directory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1096
diff changeset
90 public static final String WSPLGEN_BARRIERS_LINES = "barrier_lines.shp";
e9f66d63bdd0 Write user defined barriers into a shapefile that is placed in the Artifact's directory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1096
diff changeset
91 public static final String WSPLGEN_BARRIERS_POLY = "barrier_polygons.shp";
1108
5b1198c27d43 Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1107
diff changeset
92 public static final String WSPLGEN_AXIS = "axis.shp";
5b1198c27d43 Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1107
diff changeset
93 public static final String WSPLGEN_QPS = "qps.shp";
1110
563e015f0f22 Export floodplain to shapefile and add its file path to WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1109
diff changeset
94 public static final String WSPLGEN_FLOODPLAIN = "talaue.shp";
1120
fb3947027e92 Renamed WSPLGEN required waterlevels file to 'waterlevel.wst'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1119
diff changeset
95 public static final String WSPLGEN_WSP_FILE = "waterlevel.wst";
1118
7398280b11a0 Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1110
diff changeset
96 public static final String WSPLGEN_OUTPUT_FILE = "wsplgen.shp";
6710
ffc9cb39cea7 Remove duplicate code for mapfile generation. ID problem still not fixed (#657).
Christian Lins <christian.lins@intevation.de>
parents: 6330
diff changeset
97 public static final String WSPLGEN_USER_RGD_SHAPE = "user-rgd.shp";
ffc9cb39cea7 Remove duplicate code for mapfile generation. ID problem still not fixed (#657).
Christian Lins <christian.lins@intevation.de>
parents: 6330
diff changeset
98 public static final String WSPLGEN_USER_RGD_ZIP = "user-rgd.zip";
ffc9cb39cea7 Remove duplicate code for mapfile generation. ID problem still not fixed (#657).
Christian Lins <christian.lins@intevation.de>
parents: 6330
diff changeset
99 public static final String WSPLGEN_USER_RGD = "user-rgd";
1091
7230e087ef8b Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
100
3070
6875120af2a2 Fetch only 'qps' cross section tracks for WSPLGEN calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2639
diff changeset
101 public static final String WSPLGEN_QPS_NAME = "qps";
6875120af2a2 Fetch only 'qps' cross section tracks for WSPLGEN calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2639
diff changeset
102
1096
9f88cc54570c Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1091
diff changeset
103 public static final int WSPLGEN_DEFAULT_OUTPUT = 0;
9f88cc54570c Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1091
diff changeset
104
5312
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
105 private static final String HWS_LINES_SHAPE = "hws-lines.shp";
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
106
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8747
diff changeset
107 private static final String I18N_HWS_POINTS_OFFICIAL =
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8747
diff changeset
108 "floodmap.hws.points.official";
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8747
diff changeset
109 private static final String I18N_HWS_LINES_OFFICIAL =
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8747
diff changeset
110 "floodmap.hws.lines.official";
5312
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
111 private static final String HWS_LINES = "hws-lines";
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
112 private static final String HWS_POINT_SHAPE = "hws-points.shp";
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
113 private static final String HWS_POINTS = "hws-points";
1091
7230e087ef8b Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
114
8452
b9a8463ac636 (issue1732) When duplication wsplgen artificats fix shapefile layers
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8202
diff changeset
115
b9a8463ac636 (issue1732) When duplication wsplgen artificats fix shapefile layers
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8202
diff changeset
116 /* List of possible map files this state handles . */
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8747
diff changeset
117 private static final String[] POSSIBLE_ADDITIONAL_MAPFILES = {
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8747
diff changeset
118 HWS_LINES,
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8747
diff changeset
119 HWS_POINTS,
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8747
diff changeset
120 WSPLGEN_USER_RGD,
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8747
diff changeset
121 "barriers-lines",
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8747
diff changeset
122 "barriers-poly"};
8452
b9a8463ac636 (issue1732) When duplication wsplgen artificats fix shapefile layers
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8202
diff changeset
123
b9a8463ac636 (issue1732) When duplication wsplgen artificats fix shapefile layers
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8202
diff changeset
124
b9a8463ac636 (issue1732) When duplication wsplgen artificats fix shapefile layers
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8202
diff changeset
125
2095
8cb679d4ec49 Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2093
diff changeset
126 /**
8cb679d4ec49 Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2093
diff changeset
127 * @param orig
8cb679d4ec49 Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2093
diff changeset
128 * @param owner
8cb679d4ec49 Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2093
diff changeset
129 * @param context
8cb679d4ec49 Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2093
diff changeset
130 * @param callMeta
8cb679d4ec49 Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2093
diff changeset
131 */
2093
ebc2aa64c1be Call State.initialize() for each State of an Artifact in FLYSArtifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2078
diff changeset
132 @Override
2095
8cb679d4ec49 Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2093
diff changeset
133 public void initialize(
8cb679d4ec49 Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2093
diff changeset
134 Artifact orig,
8cb679d4ec49 Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2093
diff changeset
135 Artifact owner,
8cb679d4ec49 Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2093
diff changeset
136 Object context,
8cb679d4ec49 Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2093
diff changeset
137 CallMeta callMeta
8cb679d4ec49 Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2093
diff changeset
138 ) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7661
diff changeset
139 log.info("Initialize State with Artifact: " + orig.identifier());
2095
8cb679d4ec49 Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2093
diff changeset
140
8452
b9a8463ac636 (issue1732) When duplication wsplgen artificats fix shapefile layers
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8202
diff changeset
141 copyAndFixShapeDir(orig, owner);
2095
8cb679d4ec49 Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2093
diff changeset
142 modifyFacets(orig, owner, context, callMeta);
4864
dc0d37715e16 Floodmap uses the static River-WMS instead of User-WMS via RiverAxisArtifact.
Christian Lins <christian.lins@intevation.de>
parents: 4854
diff changeset
143
dc0d37715e16 Floodmap uses the static River-WMS instead of User-WMS via RiverAxisArtifact.
Christian Lins <christian.lins@intevation.de>
parents: 4854
diff changeset
144 ArtifactMapfileGenerator amfg = new ArtifactMapfileGenerator();
dc0d37715e16 Floodmap uses the static River-WMS instead of User-WMS via RiverAxisArtifact.
Christian Lins <christian.lins@intevation.de>
parents: 4854
diff changeset
145 try {
dc0d37715e16 Floodmap uses the static River-WMS instead of User-WMS via RiverAxisArtifact.
Christian Lins <christian.lins@intevation.de>
parents: 4854
diff changeset
146 amfg.generate();
dc0d37715e16 Floodmap uses the static River-WMS instead of User-WMS via RiverAxisArtifact.
Christian Lins <christian.lins@intevation.de>
parents: 4854
diff changeset
147 }
dc0d37715e16 Floodmap uses the static River-WMS instead of User-WMS via RiverAxisArtifact.
Christian Lins <christian.lins@intevation.de>
parents: 4854
diff changeset
148 catch (IOException e) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7661
diff changeset
149 log.error(e.getMessage(), e);
4864
dc0d37715e16 Floodmap uses the static River-WMS instead of User-WMS via RiverAxisArtifact.
Christian Lins <christian.lins@intevation.de>
parents: 4854
diff changeset
150 }
2093
ebc2aa64c1be Call State.initialize() for each State of an Artifact in FLYSArtifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2078
diff changeset
151 }
ebc2aa64c1be Call State.initialize() for each State of an Artifact in FLYSArtifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2078
diff changeset
152
ebc2aa64c1be Call State.initialize() for each State of an Artifact in FLYSArtifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2078
diff changeset
153
8452
b9a8463ac636 (issue1732) When duplication wsplgen artificats fix shapefile layers
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8202
diff changeset
154 protected void copyAndFixShapeDir(Artifact orig, Artifact owner) {
b9a8463ac636 (issue1732) When duplication wsplgen artificats fix shapefile layers
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8202
diff changeset
155 /* We have a lot of generated mapfiles in here possibly.
b9a8463ac636 (issue1732) When duplication wsplgen artificats fix shapefile layers
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8202
diff changeset
156 * They use the orig artificact identifier. That has to
b9a8463ac636 (issue1732) When duplication wsplgen artificats fix shapefile layers
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8202
diff changeset
157 * be fixed.*/
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
158 File origDir = getDirectory((D4EArtifact) orig);
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
159 File thisDir = getDirectory((D4EArtifact) owner);
2095
8cb679d4ec49 Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2093
diff changeset
160
8cb679d4ec49 Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2093
diff changeset
161 FileTools.copyDirectory(origDir, thisDir);
8452
b9a8463ac636 (issue1732) When duplication wsplgen artificats fix shapefile layers
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8202
diff changeset
162
b9a8463ac636 (issue1732) When duplication wsplgen artificats fix shapefile layers
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8202
diff changeset
163 for (String candidate: POSSIBLE_ADDITIONAL_MAPFILES) {
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8747
diff changeset
164 File f = new File(
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8747
diff changeset
165 thisDir, MapfileGenerator.MS_LAYER_PREFIX + candidate);
8452
b9a8463ac636 (issue1732) When duplication wsplgen artificats fix shapefile layers
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8202
diff changeset
166 if (f.exists()) {
b9a8463ac636 (issue1732) When duplication wsplgen artificats fix shapefile layers
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8202
diff changeset
167 log.debug("Fixing artifiact id's in: " + f);
b9a8463ac636 (issue1732) When duplication wsplgen artificats fix shapefile layers
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8202
diff changeset
168 try {
b9a8463ac636 (issue1732) When duplication wsplgen artificats fix shapefile layers
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8202
diff changeset
169 String content = FileUtils.readFileToString(f);
b9a8463ac636 (issue1732) When duplication wsplgen artificats fix shapefile layers
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8202
diff changeset
170 FileUtils.writeStringToFile(f,
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8747
diff changeset
171 content.replaceAll(
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8747
diff changeset
172 orig.identifier(), owner.identifier()));
8452
b9a8463ac636 (issue1732) When duplication wsplgen artificats fix shapefile layers
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8202
diff changeset
173 } catch (IOException e) {
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8747
diff changeset
174 log.error("Failed to rewrite file: " + f
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8747
diff changeset
175 + " Error: " + e.getMessage());
8452
b9a8463ac636 (issue1732) When duplication wsplgen artificats fix shapefile layers
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8202
diff changeset
176 }
b9a8463ac636 (issue1732) When duplication wsplgen artificats fix shapefile layers
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8202
diff changeset
177 }
b9a8463ac636 (issue1732) When duplication wsplgen artificats fix shapefile layers
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8202
diff changeset
178 }
2095
8cb679d4ec49 Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2093
diff changeset
179 }
8cb679d4ec49 Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2093
diff changeset
180
8cb679d4ec49 Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2093
diff changeset
181
8cb679d4ec49 Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2093
diff changeset
182 protected void modifyFacets(
8cb679d4ec49 Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2093
diff changeset
183 Artifact orig,
8cb679d4ec49 Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2093
diff changeset
184 Artifact owner,
8cb679d4ec49 Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2093
diff changeset
185 Object context,
8cb679d4ec49 Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2093
diff changeset
186 CallMeta callMeta
8cb679d4ec49 Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2093
diff changeset
187 ) {
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
188 D4EArtifact flys = (D4EArtifact) owner;
2095
8cb679d4ec49 Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2093
diff changeset
189 List<Facet> facets = flys.getFacets();
3555
b1912514e0f5 s/container.size() == 0/container.isEmpty()/
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3302
diff changeset
190 if (facets == null || facets.isEmpty()) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7661
diff changeset
191 log.warn("No facets for '" + OUTPUT_NAME + "' given!");
2095
8cb679d4ec49 Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2093
diff changeset
192 return;
8cb679d4ec49 Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2093
diff changeset
193 }
8cb679d4ec49 Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2093
diff changeset
194
8cb679d4ec49 Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2093
diff changeset
195 for (Facet facet: facets) {
8cb679d4ec49 Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2093
diff changeset
196 if (facet instanceof WMSLayerFacet) {
8cb679d4ec49 Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2093
diff changeset
197 WMSLayerFacet wms = (WMSLayerFacet) facet;
8cb679d4ec49 Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2093
diff changeset
198
8cb679d4ec49 Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2093
diff changeset
199 List<String> layers = wms.getLayers();
8cb679d4ec49 Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2093
diff changeset
200
8cb679d4ec49 Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2093
diff changeset
201 for (String layer: layers) {
8452
b9a8463ac636 (issue1732) When duplication wsplgen artificats fix shapefile layers
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8202
diff changeset
202 log.debug("Have layer: " + layer);
b9a8463ac636 (issue1732) When duplication wsplgen artificats fix shapefile layers
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8202
diff changeset
203 if (layer.contains(orig.identifier())) {
2095
8cb679d4ec49 Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2093
diff changeset
204 wms.removeLayer(layer);
8cb679d4ec49 Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2093
diff changeset
205
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8747
diff changeset
206 String newLayer = layer.replace(
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8747
diff changeset
207 orig.identifier(), owner.identifier());
2095
8cb679d4ec49 Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2093
diff changeset
208
8cb679d4ec49 Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2093
diff changeset
209 wms.addLayer(newLayer);
8cb679d4ec49 Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2093
diff changeset
210
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7661
diff changeset
211 log.debug(
2095
8cb679d4ec49 Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2093
diff changeset
212 "Replaced layer: " + layer + " with " + newLayer);
8cb679d4ec49 Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2093
diff changeset
213 }
8cb679d4ec49 Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2093
diff changeset
214 }
8cb679d4ec49 Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2093
diff changeset
215 }
8cb679d4ec49 Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2093
diff changeset
216 }
8cb679d4ec49 Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2093
diff changeset
217 }
8cb679d4ec49 Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2093
diff changeset
218
1053
bfc2ed20b87c Prepared the FloodMapState to save geometries.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 935
diff changeset
219
bfc2ed20b87c Prepared the FloodMapState to save geometries.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 935
diff changeset
220 @Override
935
353ddfa231a7 Introduced a new output 'floodmap' for the FloodMapState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 927
diff changeset
221 public Object computeAdvance(
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
222 D4EArtifact artifact,
935
353ddfa231a7 Introduced a new output 'floodmap' for the FloodMapState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 927
diff changeset
223 String hash,
353ddfa231a7 Introduced a new output 'floodmap' for the FloodMapState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 927
diff changeset
224 CallContext context,
353ddfa231a7 Introduced a new output 'floodmap' for the FloodMapState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 927
diff changeset
225 List<Facet> facets,
353ddfa231a7 Introduced a new output 'floodmap' for the FloodMapState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 927
diff changeset
226 Object old
353ddfa231a7 Introduced a new output 'floodmap' for the FloodMapState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 927
diff changeset
227 ) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7661
diff changeset
228 log.debug("FloodMapState.computeAdvance");
1091
7230e087ef8b Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
229
7230e087ef8b Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
230 File artifactDir = getDirectory(artifact);
7230e087ef8b Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
231
7230e087ef8b Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
232 if (artifactDir == null) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7661
diff changeset
233 log.error("Could not create directory for WSPLGEN results!");
1091
7230e087ef8b Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
234 return null;
7230e087ef8b Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
235 }
7230e087ef8b Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
236
1149
64b465699a24 Added an Output target for WSPLGEN reports that will be available when an WSPLGEN calculation is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1144
diff changeset
237 WSPLGENCalculation calculation = new WSPLGENCalculation();
64b465699a24 Added an Output target for WSPLGEN reports that will be available when an WSPLGEN calculation is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1144
diff changeset
238
1638
f45bbc80bd3d Bugfix: #296 Set i18n titles for WSPLGEN and barriers WMS layers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1186
diff changeset
239 FacetCreator facetCreator = new FacetCreator(
1650
aaf8d32f85bd Improved Facet creation for floodmaps - WSPLGEN and barriers Facets are only created if the calculation was successful.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1649
diff changeset
240 artifact, context, hash, getID(), facets);
1164
0398c2b8dbaf Do only create WSPLGEN and barrier facets if the WSPLGEN job has been added to the Scheduler and if there are digitized geometries existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1160
diff changeset
241
1149
64b465699a24 Added an Output target for WSPLGEN reports that will be available when an WSPLGEN calculation is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1144
diff changeset
242 WSPLGENJob job = prepareWSPLGENJob(
64b465699a24 Added an Output target for WSPLGEN reports that will be available when an WSPLGEN calculation is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1144
diff changeset
243 artifact,
1164
0398c2b8dbaf Do only create WSPLGEN and barrier facets if the WSPLGEN job has been added to the Scheduler and if there are digitized geometries existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1160
diff changeset
244 facetCreator,
1149
64b465699a24 Added an Output target for WSPLGEN reports that will be available when an WSPLGEN calculation is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1144
diff changeset
245 artifactDir,
64b465699a24 Added an Output target for WSPLGEN reports that will be available when an WSPLGEN calculation is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1144
diff changeset
246 context,
64b465699a24 Added an Output target for WSPLGEN reports that will be available when an WSPLGEN calculation is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1144
diff changeset
247 calculation);
1091
7230e087ef8b Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
248
1168
ace192d3283d Add an error message to the calculation report if an error occured while WSPLGENJob creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1165
diff changeset
249 CalculationResult res = new CalculationResult(null, calculation);
ace192d3283d Add an error message to the calculation report if an error occured while WSPLGENJob creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1165
diff changeset
250 WSPLGENReportFacet report= new WSPLGENReportFacet(
ace192d3283d Add an error message to the calculation report if an error occured while WSPLGENJob creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1165
diff changeset
251 ComputeType.ADVANCE, hash, getID(), res);
ace192d3283d Add an error message to the calculation report if an error occured while WSPLGENJob creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1165
diff changeset
252
ace192d3283d Add an error message to the calculation report if an error occured while WSPLGENJob creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1165
diff changeset
253 facets.add(report);
ace192d3283d Add an error message to the calculation report if an error occured while WSPLGENJob creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1165
diff changeset
254
1091
7230e087ef8b Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
255 if (job == null) {
1107
005c2964f9af Use the correct SRID while reading GeoJSON barriers and writing line/polygon shapefiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1106
diff changeset
256 if (KEEP_ARTIFACT_DIR.equals("false")) {
005c2964f9af Use the correct SRID while reading GeoJSON barriers and writing line/polygon shapefiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1106
diff changeset
257 removeDirectory(artifact);
005c2964f9af Use the correct SRID while reading GeoJSON barriers and writing line/polygon shapefiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1106
diff changeset
258 }
1091
7230e087ef8b Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
259
1168
ace192d3283d Add an error message to the calculation report if an error occured while WSPLGENJob creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1165
diff changeset
260 calculation.addError(-1, Resources.getMsg(
ace192d3283d Add an error message to the calculation report if an error occured while WSPLGENJob creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1165
diff changeset
261 context.getMeta(),
ace192d3283d Add an error message to the calculation report if an error occured while WSPLGENJob creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1165
diff changeset
262 "wsplgen.job.error",
ace192d3283d Add an error message to the calculation report if an error occured while WSPLGENJob creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1165
diff changeset
263 "wsplgen.job.error"));
ace192d3283d Add an error message to the calculation report if an error occured while WSPLGENJob creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1165
diff changeset
264
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7661
diff changeset
265 log.error("No WSPLGEN processing has been started!");
1091
7230e087ef8b Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
266
7230e087ef8b Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
267 return null;
7230e087ef8b Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
268 }
7230e087ef8b Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
269
1128
727c53fd0dc7 Some bugfixes when starting/finishing WSPLGEN jobs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1127
diff changeset
270 context.afterCall(CallContext.BACKGROUND);
1165
3b034bb5fce7 Add status message for queued WSPLGEN jobs to notify users.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1164
diff changeset
271 context.addBackgroundMessage(new CalculationMessage(
3b034bb5fce7 Add status message for queued WSPLGEN jobs to notify users.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1164
diff changeset
272 JobObserver.STEPS.length,
3b034bb5fce7 Add status message for queued WSPLGEN jobs to notify users.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1164
diff changeset
273 0,
3b034bb5fce7 Add status message for queued WSPLGEN jobs to notify users.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1164
diff changeset
274 Resources.getMsg(
3b034bb5fce7 Add status message for queued WSPLGEN jobs to notify users.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1164
diff changeset
275 context.getMeta(),
3b034bb5fce7 Add status message for queued WSPLGEN jobs to notify users.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1164
diff changeset
276 "wsplgen.job.queued",
3b034bb5fce7 Add status message for queued WSPLGEN jobs to notify users.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1164
diff changeset
277 "wsplgen.job.queued")
3b034bb5fce7 Add status message for queued WSPLGEN jobs to notify users.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1164
diff changeset
278 ));
1091
7230e087ef8b Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
279
1970
368040e5c400 Improved the Scheduler to be able to cancel running WSPLGEN jobs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1955
diff changeset
280 GlobalContext gc = (GlobalContext) context.globalContext();
5866
9a6741ccf6d4 FLYS artifacts: Renamed FLYSContext(Factory) to RiverContext(Factory).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5865
diff changeset
281 Scheduler scheduler = (Scheduler) gc.get(RiverContext.SCHEDULER);
1649
74142aa5d938 Improved WSPLGEN start to suppress inconsistent Artifact states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1641
diff changeset
282 scheduler.addJob(job);
74142aa5d938 Improved WSPLGEN start to suppress inconsistent Artifact states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1641
diff changeset
283
1091
7230e087ef8b Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
284 return null;
7230e087ef8b Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
285 }
7230e087ef8b Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
286
7230e087ef8b Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
287
7230e087ef8b Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
288 /**
7230e087ef8b Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
289 * Returns (and creates if not existing) the directory for storing WSPLEN
7230e087ef8b Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
290 * data for the owner artifact.
7230e087ef8b Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
291 *
7230e087ef8b Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
292 * @param artifact The owner Artifact.
7230e087ef8b Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
293 *
7230e087ef8b Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
294 * @return the directory for WSPLEN data.
7230e087ef8b Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
295 */
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
296 protected File getDirectory(D4EArtifact artifact) {
5865
73da40528cf2 River artifacts: Renamed FLYSUtils to RiverUtils.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
297 String shapePath = RiverUtils.getXPathString(
73da40528cf2 River artifacts: Renamed FLYSUtils to RiverUtils.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
298 RiverUtils.XPATH_FLOODMAP_SHAPEFILE_DIR);
1091
7230e087ef8b Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
299
7230e087ef8b Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
300 File artifactDir = FileTools.getDirectory(
7230e087ef8b Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
301 shapePath, artifact.identifier());
7230e087ef8b Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
302
7230e087ef8b Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
303 return artifactDir;
7230e087ef8b Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
304 }
7230e087ef8b Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
305
7230e087ef8b Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
306
7230e087ef8b Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
307 /**
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8747
diff changeset
308 * Removes directory and all its content where the required data and the
1091
7230e087ef8b Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
309 * results of WSPLGEN are stored. Should be called in endOfLife().
7230e087ef8b Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
310 */
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
311 protected void removeDirectory(D4EArtifact artifact) {
5865
73da40528cf2 River artifacts: Renamed FLYSUtils to RiverUtils.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
312 String shapePath = RiverUtils.getXPathString(
73da40528cf2 River artifacts: Renamed FLYSUtils to RiverUtils.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
313 RiverUtils.XPATH_FLOODMAP_SHAPEFILE_DIR);
1129
da3c3e286c88 Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1128
diff changeset
314
da3c3e286c88 Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1128
diff changeset
315 File artifactDir = new File(shapePath, artifact.identifier());
1091
7230e087ef8b Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
316
7230e087ef8b Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
317 if (artifactDir.exists()) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7661
diff changeset
318 log.info("Delete directory: " + artifactDir.getAbsolutePath());
4656
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4654
diff changeset
319 if (!FileTools.deleteRecursive(artifactDir)) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7661
diff changeset
320 log.warn("Could not delete directory: "
4656
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4654
diff changeset
321 + artifactDir.getAbsolutePath());
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4654
diff changeset
322 }
1091
7230e087ef8b Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
323 }
7230e087ef8b Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
324 else {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7661
diff changeset
325 log.debug("There is no directory to remove.");
1091
7230e087ef8b Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
326 }
7230e087ef8b Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
327 }
7230e087ef8b Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
328
7230e087ef8b Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
329
7230e087ef8b Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
330 @Override
7230e087ef8b Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
331 public void endOfLife(Artifact artifact, Object callContext) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7661
diff changeset
332 log.info("FloodMapState.endOfLife: " + artifact.identifier());
1091
7230e087ef8b Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
333
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
334 D4EArtifact flys = (D4EArtifact) artifact;
1782
93fe7debd687 Re-create FLYS mapfile when FloodMapState.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1707
diff changeset
335
1970
368040e5c400 Improved the Scheduler to be able to cancel running WSPLGEN jobs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1955
diff changeset
336 Scheduler scheduler = Scheduler.getInstance();
368040e5c400 Improved the Scheduler to be able to cancel running WSPLGEN jobs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1955
diff changeset
337 scheduler.cancelJob(flys.identifier());
1091
7230e087ef8b Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
338 }
7230e087ef8b Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
339
7230e087ef8b Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
340
7230e087ef8b Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
341 protected WSPLGENJob prepareWSPLGENJob(
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
342 D4EArtifact artifact,
1164
0398c2b8dbaf Do only create WSPLGEN and barrier facets if the WSPLGEN job has been added to the Scheduler and if there are digitized geometries existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1160
diff changeset
343 FacetCreator facetCreator,
1149
64b465699a24 Added an Output target for WSPLGEN reports that will be available when an WSPLGEN calculation is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1144
diff changeset
344 File artifactDir,
64b465699a24 Added an Output target for WSPLGEN reports that will be available when an WSPLGEN calculation is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1144
diff changeset
345 CallContext context,
64b465699a24 Added an Output target for WSPLGEN reports that will be available when an WSPLGEN calculation is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1144
diff changeset
346 WSPLGENCalculation calculation
1091
7230e087ef8b Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
347 ) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7661
diff changeset
348 log.debug("FloodMapState.prepareWSPLGENJob");
5312
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
349 String scenario = artifact.getDataAsString("scenario");
1091
7230e087ef8b Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
350
1149
64b465699a24 Added an Output target for WSPLGEN reports that will be available when an WSPLGEN calculation is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1144
diff changeset
351 WSPLGENJob job = new WSPLGENJob(
64b465699a24 Added an Output target for WSPLGEN reports that will be available when an WSPLGEN calculation is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1144
diff changeset
352 artifact,
64b465699a24 Added an Output target for WSPLGEN reports that will be available when an WSPLGEN calculation is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1144
diff changeset
353 artifactDir,
1650
aaf8d32f85bd Improved Facet creation for floodmaps - WSPLGEN and barriers Facets are only created if the calculation was successful.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1649
diff changeset
354 facetCreator,
1149
64b465699a24 Added an Output target for WSPLGEN reports that will be available when an WSPLGEN calculation is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1144
diff changeset
355 context,
64b465699a24 Added an Output target for WSPLGEN reports that will be available when an WSPLGEN calculation is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1144
diff changeset
356 calculation);
64b465699a24 Added an Output target for WSPLGEN reports that will be available when an WSPLGEN calculation is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1144
diff changeset
357
64b465699a24 Added an Output target for WSPLGEN reports that will be available when an WSPLGEN calculation is finished.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1144
diff changeset
358 File paraFile = new File(artifactDir, WSPLGEN_PARAMETER_FILE);
1091
7230e087ef8b Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
359
1096
9f88cc54570c Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1091
diff changeset
360 setOut(artifact, job);
9f88cc54570c Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1091
diff changeset
361 setRange(artifact, job);
9f88cc54570c Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1091
diff changeset
362 setDelta(artifact, job);
9f88cc54570c Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1091
diff changeset
363 setGel(artifact, job);
9f88cc54570c Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1091
diff changeset
364 setDist(artifact, job);
1108
5b1198c27d43 Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1107
diff changeset
365 setAxis(artifact, artifactDir, job);
5b1198c27d43 Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1107
diff changeset
366 setPro(artifact, artifactDir, job);
5152
b26465581abf Add a configurable path prefix to relative DGM path to allways have an absolute path.
Raimund Renkert <rrenkert@intevation.de>
parents: 5031
diff changeset
367 setDgm(artifact, job, context);
1110
563e015f0f22 Export floodplain to shapefile and add its file path to WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1109
diff changeset
368 setArea(artifact, artifactDir, job);
1118
7398280b11a0 Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1110
diff changeset
369 setOutFile(artifact, job);
7398280b11a0 Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1110
diff changeset
370 setWsp(artifact, context, artifactDir, job); // WSP
5312
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
371 if (scenario.equals("scenario.current")) {
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
372 setOfficialHWS(artifact, facetCreator, artifactDir, job);
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
373 }
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
374 else if (scenario.equals("scenario.scenario")) {
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
375 setAdditionalHWS(artifact, facetCreator, artifactDir, job);
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
376 setLine(artifact, facetCreator, artifactDir, job);
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
377 setUserShape(artifact, facetCreator, artifactDir, job);
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
378 }
1096
9f88cc54570c Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1091
diff changeset
379 // TODO
9f88cc54570c Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1091
diff changeset
380 // setWspTag(artifact, job);
9f88cc54570c Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1091
diff changeset
381
5913
37a0f4f7c54f Added output mode and generator to config and create facet for export.
Raimund Renkert <rrenkert@intevation.de>
parents: 5867
diff changeset
382 facetCreator.createExportFacet("zip");
1091
7230e087ef8b Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
383 try {
7230e087ef8b Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
384 job.toFile(paraFile);
7230e087ef8b Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
385
7230e087ef8b Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
386 return job;
7230e087ef8b Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
387 }
7230e087ef8b Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
388 catch (IOException ioe) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7661
diff changeset
389 log.warn("Cannot write PAR file: " + ioe.getMessage());
1091
7230e087ef8b Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
390 }
7230e087ef8b Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
391 catch (IllegalArgumentException iae) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7661
diff changeset
392 log.warn("Cannot write PAR file: " + iae.getMessage());
1091
7230e087ef8b Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
393 }
7230e087ef8b Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
394
935
353ddfa231a7 Introduced a new output 'floodmap' for the FloodMapState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 927
diff changeset
395 return null;
353ddfa231a7 Introduced a new output 'floodmap' for the FloodMapState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 927
diff changeset
396 }
1096
9f88cc54570c Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1091
diff changeset
397
9f88cc54570c Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1091
diff changeset
398
5312
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
399 private void setAdditionalHWS(
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
400 D4EArtifact artifact,
5312
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
401 FacetCreator facetCreator,
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
402 File dir,
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
403 WSPLGENJob job) {
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
404 File line = new File(dir, HWS_LINES_SHAPE);
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
405 boolean lines = line.exists();
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7661
diff changeset
406 log.debug("shp file exists: " + lines);
5312
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
407 if (lines) {
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
408 job.addLin(dir + "/" + HWS_LINES_SHAPE);
5580
fa5868a52f14 Change HWS Strings in the floodmap for current calculations
Andre Heinecke <aheinecke@intevation.de>
parents: 5349
diff changeset
409 facetCreator.createShapeFacet(I18N_HWS_LINES_OFFICIAL,
5312
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
410 MapfileGenerator.MS_LAYER_PREFIX + HWS_LINES,
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
411 FLOODMAP_LINES, 2);
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
412 }
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
413 File point = new File(dir, HWS_POINT_SHAPE);
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
414 boolean points = point.exists();
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7661
diff changeset
415 log.debug("shp file exists: " + points);
5312
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
416 if (points) {
5580
fa5868a52f14 Change HWS Strings in the floodmap for current calculations
Andre Heinecke <aheinecke@intevation.de>
parents: 5349
diff changeset
417 facetCreator.createShapeFacet(I18N_HWS_POINTS_OFFICIAL,
5312
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
418 MapfileGenerator.MS_LAYER_PREFIX + HWS_POINTS,
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
419 FLOODMAP_FIXPOINTS, 3);
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
420 }
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
421 }
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
422
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
423
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
424 private void setOfficialHWS(
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
425 D4EArtifact artifact,
5312
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
426 FacetCreator facetCreator,
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
427 File artifactDir,
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
428 WSPLGENJob job) {
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
429 String river = artifact.getDataAsString("river");
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
430
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
431 HWSContainer hwsLines = HWSFactory.getHWSLines(river);
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
432 List<HWS> selectedLines = hwsLines.getOfficialHWS();
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
433
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
434 FeatureCollection collectionLines = FeatureCollections.newCollection();
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
435 SimpleFeatureType lineType = null;
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
436 for (HWS h : selectedLines) {
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
437 lineType = h.getFeatureType();
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
438 collectionLines.add(h.getFeature());
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
439 }
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
440 boolean successLines = false;
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
441 if (lineType != null && collectionLines.size() > 0) {
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
442 File shapeLines = new File(artifactDir, HWS_LINES_SHAPE);
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
443 successLines = GeometryUtils.writeShapefile(
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
444 shapeLines, lineType, collectionLines);
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
445 }
7646
f603a53e45dc issue1020: Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7569
diff changeset
446 if (successLines) {
5312
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
447 createMapfile(
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
448 artifact,
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
449 artifactDir,
6710
ffc9cb39cea7 Remove duplicate code for mapfile generation. ID problem still not fixed (#657).
Christian Lins <christian.lins@intevation.de>
parents: 6330
diff changeset
450 MapfileGenerator.MS_LAYER_PREFIX + HWS_LINES,
5312
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
451 HWS_LINES_SHAPE,
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
452 "LINE",
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8747
diff changeset
453 "31467", // XXX: should be dynamically fetched from database.
5312
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
454 "hws");
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
455 job.addLin(artifactDir + "/" + HWS_LINES_SHAPE);
5580
fa5868a52f14 Change HWS Strings in the floodmap for current calculations
Andre Heinecke <aheinecke@intevation.de>
parents: 5349
diff changeset
456 facetCreator.createShapeFacet(I18N_HWS_LINES_OFFICIAL,
5312
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
457 MapfileGenerator.MS_LAYER_PREFIX + HWS_LINES,
5349
d43ef9f709cd Add HWSLines and HWSPoints to datacage for the map
Andre Heinecke <aheinecke@intevation.de>
parents: 5313
diff changeset
458 FLOODMAP_HWS_LINES,2);
5312
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
459 }
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7661
diff changeset
460 else log.warn("no lines written");
5312
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
461 }
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
462
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
463
6710
ffc9cb39cea7 Remove duplicate code for mapfile generation. ID problem still not fixed (#657).
Christian Lins <christian.lins@intevation.de>
parents: 6330
diff changeset
464 public static void createMapfile(
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
465 D4EArtifact artifact,
5312
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
466 File artifactDir,
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
467 String name,
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
468 String hwsShapefile,
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
469 String type,
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
470 String srid,
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
471 String group
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
472 ) {
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
473 LayerInfo info = new LayerInfo();
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
474 info.setName(name + artifact.identifier());
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
475 info.setType(type);
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
476 info.setDirectory(artifact.identifier());
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
477 info.setTitle(name);
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
478 info.setData(hwsShapefile);
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
479 info.setSrid(srid);
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
480 info.setGroupTitle(group);
6330
36dc11244ec3 Group barriers layer and fix polygon layer path to shapefile
Andre Heinecke <aheinecke@intevation.de>
parents: 6101
diff changeset
481 info.setGroup(group + artifact.identifier());
5312
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
482 MapfileGenerator generator = new ArtifactMapfileGenerator();
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8747
diff changeset
483 Template tpl = generator.getTemplateByName(
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8747
diff changeset
484 MapfileGenerator.SHP_LAYER_TEMPLATE);
5312
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
485 try {
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
486 File layer = new File(artifactDir.getCanonicalPath() + "/" + name);
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
487 generator.writeLayer(info, layer, tpl);
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
488 List<String> layers = new ArrayList<String>();
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
489 layers.add(layer.getAbsolutePath());
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
490 generator.generate();
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
491 }
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
492 catch(FileNotFoundException fnfe) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7661
diff changeset
493 log.warn("Could not find mapfile for hws layer");
5312
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
494 }
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
495 catch (Exception ioe) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7661
diff changeset
496 log.warn("Could not create mapfile for hws layer");
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7661
diff changeset
497 log.warn(Arrays.toString(ioe.getStackTrace()));
5312
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
498 }
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
499 }
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
500
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
501
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
502 protected void setOut(D4EArtifact artifact, WSPLGENJob job) {
1096
9f88cc54570c Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1091
diff changeset
503 job.setOut(WSPLGEN_DEFAULT_OUTPUT);
9f88cc54570c Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1091
diff changeset
504 }
9f88cc54570c Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1091
diff changeset
505
9f88cc54570c Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1091
diff changeset
506
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
507 protected void setRange(D4EArtifact artifact, WSPLGENJob job) {
6101
a0078e5e3b39 Removed unused context from RangeAccess and subclasses leading to some dead code removal.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
508 RangeAccess rangeAccess = new RangeAccess(artifact);
4854
c53b3fdc9821 FloodMapState: Updated to use RangeAccess instead of FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4656
diff changeset
509 double[] range = rangeAccess.getKmRange();
1096
9f88cc54570c Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1091
diff changeset
510
9f88cc54570c Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1091
diff changeset
511 job.setStart(range[0]);
9f88cc54570c Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1091
diff changeset
512 job.setEnd(range[1]);
9f88cc54570c Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1091
diff changeset
513 }
9f88cc54570c Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1091
diff changeset
514
9f88cc54570c Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1091
diff changeset
515
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
516 protected void setDelta(D4EArtifact artifact, WSPLGENJob job) {
1096
9f88cc54570c Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1091
diff changeset
517 String from = artifact.getDataAsString("diff_from");
9f88cc54570c Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1091
diff changeset
518 String to = artifact.getDataAsString("diff_to");
9f88cc54570c Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1091
diff changeset
519 String diff = artifact.getDataAsString("diff_diff");
9f88cc54570c Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1091
diff changeset
520
9f88cc54570c Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1091
diff changeset
521 try {
9f88cc54570c Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1091
diff changeset
522 job.setFrom(Double.parseDouble(from));
9f88cc54570c Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1091
diff changeset
523 }
9f88cc54570c Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1091
diff changeset
524 catch (NumberFormatException nfe) {
9f88cc54570c Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1091
diff changeset
525 }
9f88cc54570c Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1091
diff changeset
526
9f88cc54570c Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1091
diff changeset
527 try {
9f88cc54570c Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1091
diff changeset
528 job.setTo(Double.parseDouble(to));
9f88cc54570c Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1091
diff changeset
529 }
9f88cc54570c Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1091
diff changeset
530 catch (NumberFormatException nfe) {
9f88cc54570c Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1091
diff changeset
531 }
9f88cc54570c Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1091
diff changeset
532
9f88cc54570c Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1091
diff changeset
533 try {
9f88cc54570c Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1091
diff changeset
534 job.setDiff(Double.parseDouble(diff));
9f88cc54570c Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1091
diff changeset
535 }
9f88cc54570c Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1091
diff changeset
536 catch (NumberFormatException nfe) {
9f88cc54570c Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1091
diff changeset
537 }
9f88cc54570c Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1091
diff changeset
538 }
9f88cc54570c Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1091
diff changeset
539
9f88cc54570c Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1091
diff changeset
540
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
541 protected void setGel(D4EArtifact artifact, WSPLGENJob job) {
1955
ccf2235035d6 Various bugfixes in WSPLGEN parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1845
diff changeset
542 String gel = artifact.getDataAsString("scenario");
1096
9f88cc54570c Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1091
diff changeset
543
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7661
diff changeset
544 log.debug("Selected gel = '" + gel + "'");
1955
ccf2235035d6 Various bugfixes in WSPLGEN parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1845
diff changeset
545
ccf2235035d6 Various bugfixes in WSPLGEN parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1845
diff changeset
546 if (gel == null || gel.length() == 0) {
ccf2235035d6 Various bugfixes in WSPLGEN parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1845
diff changeset
547 job.setGel(WSPLGENJob.GEL_NOSPERRE);
ccf2235035d6 Various bugfixes in WSPLGEN parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1845
diff changeset
548 }
ccf2235035d6 Various bugfixes in WSPLGEN parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1845
diff changeset
549 else if (gel.equals("scenario.current")) {
ccf2235035d6 Various bugfixes in WSPLGEN parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1845
diff changeset
550 job.setGel(WSPLGENJob.GEL_SPERRE);
ccf2235035d6 Various bugfixes in WSPLGEN parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1845
diff changeset
551 }
ccf2235035d6 Various bugfixes in WSPLGEN parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1845
diff changeset
552 else if (gel.equals("scenario.scenario")) {
ccf2235035d6 Various bugfixes in WSPLGEN parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1845
diff changeset
553 job.setGel(WSPLGENJob.GEL_SPERRE);
ccf2235035d6 Various bugfixes in WSPLGEN parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1845
diff changeset
554 }
ccf2235035d6 Various bugfixes in WSPLGEN parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1845
diff changeset
555 else {
ccf2235035d6 Various bugfixes in WSPLGEN parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1845
diff changeset
556 job.setGel(WSPLGENJob.GEL_NOSPERRE);
1096
9f88cc54570c Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1091
diff changeset
557 }
9f88cc54570c Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1091
diff changeset
558 }
9f88cc54570c Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1091
diff changeset
559
9f88cc54570c Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1091
diff changeset
560
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
561 protected void setDist(D4EArtifact artifact, WSPLGENJob job) {
1096
9f88cc54570c Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1091
diff changeset
562 String dist = artifact.getDataAsString("profile_distance");
9f88cc54570c Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1091
diff changeset
563
9f88cc54570c Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1091
diff changeset
564 try {
9f88cc54570c Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1091
diff changeset
565 job.setDist(Double.parseDouble(dist));
9f88cc54570c Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1091
diff changeset
566 }
9f88cc54570c Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1091
diff changeset
567 catch (NumberFormatException nfe) {
9f88cc54570c Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1091
diff changeset
568 // nothing to do here
9f88cc54570c Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1091
diff changeset
569 }
9f88cc54570c Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1091
diff changeset
570 }
1106
e9f66d63bdd0 Write user defined barriers into a shapefile that is placed in the Artifact's directory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1096
diff changeset
571
e9f66d63bdd0 Write user defined barriers into a shapefile that is placed in the Artifact's directory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1096
diff changeset
572
1164
0398c2b8dbaf Do only create WSPLGEN and barrier facets if the WSPLGEN job has been added to the Scheduler and if there are digitized geometries existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1160
diff changeset
573 protected void setLine(
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
574 D4EArtifact artifact,
1164
0398c2b8dbaf Do only create WSPLGEN and barrier facets if the WSPLGEN job has been added to the Scheduler and if there are digitized geometries existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1160
diff changeset
575 FacetCreator facetCreator,
0398c2b8dbaf Do only create WSPLGEN and barrier facets if the WSPLGEN job has been added to the Scheduler and if there are digitized geometries existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1160
diff changeset
576 File dir,
0398c2b8dbaf Do only create WSPLGEN and barrier facets if the WSPLGEN job has been added to the Scheduler and if there are digitized geometries existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1160
diff changeset
577 WSPLGENJob job
0398c2b8dbaf Do only create WSPLGEN and barrier facets if the WSPLGEN job has been added to the Scheduler and if there are digitized geometries existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1160
diff changeset
578 ) {
7055
1f38656b68c4 DGM SRIds are now fetched from database instead of configuration.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6983
diff changeset
579 DGMAccess access = new DGMAccess(artifact);
1f38656b68c4 DGM SRIds are now fetched from database instead of configuration.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6983
diff changeset
580 String geoJSON = access.getGeoJSON();
1106
e9f66d63bdd0 Write user defined barriers into a shapefile that is placed in the Artifact's directory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1096
diff changeset
581
1164
0398c2b8dbaf Do only create WSPLGEN and barrier facets if the WSPLGEN job has been added to the Scheduler and if there are digitized geometries existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1160
diff changeset
582 if (geoJSON == null || geoJSON.length() == 0) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7661
diff changeset
583 log.debug("No barrier features in parameterization existing.");
1164
0398c2b8dbaf Do only create WSPLGEN and barrier facets if the WSPLGEN job has been added to the Scheduler and if there are digitized geometries existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1160
diff changeset
584 return;
0398c2b8dbaf Do only create WSPLGEN and barrier facets if the WSPLGEN job has been added to the Scheduler and if there are digitized geometries existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1160
diff changeset
585 }
0398c2b8dbaf Do only create WSPLGEN and barrier facets if the WSPLGEN job has been added to the Scheduler and if there are digitized geometries existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1160
diff changeset
586
7055
1f38656b68c4 DGM SRIds are now fetched from database instead of configuration.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6983
diff changeset
587 String srid = String.valueOf(access.getDGM().getSrid());
1f38656b68c4 DGM SRIds are now fetched from database instead of configuration.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6983
diff changeset
588
1f38656b68c4 DGM SRIds are now fetched from database instead of configuration.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6983
diff changeset
589 String srs = "EPSG:" + srid;
1f38656b68c4 DGM SRIds are now fetched from database instead of configuration.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6983
diff changeset
590
1123
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
591 SimpleFeatureType ft = getBarriersFeatureType(
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
592 "barriers", srs, Geometry.class);
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
593
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
594 List<SimpleFeature> features = GeometryUtils.parseGeoJSON(geoJSON, ft);
3555
b1912514e0f5 s/container.size() == 0/container.isEmpty()/
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3302
diff changeset
595 if (features == null || features.isEmpty()) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7661
diff changeset
596 log.debug("No barrier features extracted.");
1107
005c2964f9af Use the correct SRID while reading GeoJSON barriers and writing line/polygon shapefiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1106
diff changeset
597 return;
005c2964f9af Use the correct SRID while reading GeoJSON barriers and writing line/polygon shapefiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1106
diff changeset
598 }
1106
e9f66d63bdd0 Write user defined barriers into a shapefile that is placed in the Artifact's directory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1096
diff changeset
599
e9f66d63bdd0 Write user defined barriers into a shapefile that is placed in the Artifact's directory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1096
diff changeset
600 FeatureCollection[] fcs = splitLinesAndPolygons(features);
e9f66d63bdd0 Write user defined barriers into a shapefile that is placed in the Artifact's directory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1096
diff changeset
601
e9f66d63bdd0 Write user defined barriers into a shapefile that is placed in the Artifact's directory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1096
diff changeset
602 File shapeLines = new File(dir, WSPLGEN_BARRIERS_LINES);
e9f66d63bdd0 Write user defined barriers into a shapefile that is placed in the Artifact's directory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1096
diff changeset
603 File shapePolys = new File(dir, WSPLGEN_BARRIERS_POLY);
e9f66d63bdd0 Write user defined barriers into a shapefile that is placed in the Artifact's directory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1096
diff changeset
604
1124
28a595b32980 Set the 'typ' attribute of lines and polygons in barrier shapefiles while shapefile creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1123
diff changeset
605 Object[][] obj = new Object[][] {
28a595b32980 Set the 'typ' attribute of lines and polygons in barrier shapefiles while shapefile creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1123
diff changeset
606 new Object[] { "typ", String.class }
28a595b32980 Set the 'typ' attribute of lines and polygons in barrier shapefiles while shapefile creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1123
diff changeset
607 };
28a595b32980 Set the 'typ' attribute of lines and polygons in barrier shapefiles while shapefile creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1123
diff changeset
608
1955
ccf2235035d6 Various bugfixes in WSPLGEN parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1845
diff changeset
609 String scenario = job.getGel();
ccf2235035d6 Various bugfixes in WSPLGEN parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1845
diff changeset
610
1121
66783d957201 Close open shapefile transactions properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1120
diff changeset
611 boolean l = GeometryUtils.writeShapefile(
66783d957201 Close open shapefile transactions properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1120
diff changeset
612 shapeLines,
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8747
diff changeset
613 GeometryUtils.buildFeatureType(
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8747
diff changeset
614 "lines", srs, LineString.class, obj),
1121
66783d957201 Close open shapefile transactions properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1120
diff changeset
615 fcs[0]);
1106
e9f66d63bdd0 Write user defined barriers into a shapefile that is placed in the Artifact's directory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1096
diff changeset
616
1121
66783d957201 Close open shapefile transactions properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1120
diff changeset
617 if (l) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7661
diff changeset
618 log.debug(
1123
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
619 "Successfully created barrier line shapefile. " +
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
620 "Write shapefile path into WSPLGEN job.");
5312
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
621 createMapfile(
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
622 artifact,
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
623 dir,
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
624 MapfileGenerator.MS_LAYER_PREFIX + "barriers-lines",
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
625 WSPLGEN_BARRIERS_LINES,
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
626 "LINE",
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
627 srid,
6330
36dc11244ec3 Group barriers layer and fix polygon layer path to shapefile
Andre Heinecke <aheinecke@intevation.de>
parents: 6101
diff changeset
628 MapfileGenerator.MS_BARRIERS_PREFIX);
1955
ccf2235035d6 Various bugfixes in WSPLGEN parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1845
diff changeset
629
ccf2235035d6 Various bugfixes in WSPLGEN parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1845
diff changeset
630 if (scenario.equals(WSPLGENJob.GEL_NOSPERRE)) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7661
diff changeset
631 log.debug("WSPLGEN will not use barrier features.");
1955
ccf2235035d6 Various bugfixes in WSPLGEN parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1845
diff changeset
632 }
ccf2235035d6 Various bugfixes in WSPLGEN parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1845
diff changeset
633 else {
ccf2235035d6 Various bugfixes in WSPLGEN parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1845
diff changeset
634 job.addLin(shapeLines.getAbsolutePath());
ccf2235035d6 Various bugfixes in WSPLGEN parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1845
diff changeset
635 }
1121
66783d957201 Close open shapefile transactions properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1120
diff changeset
636 }
66783d957201 Close open shapefile transactions properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1120
diff changeset
637
66783d957201 Close open shapefile transactions properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1120
diff changeset
638 boolean p = GeometryUtils.writeShapefile(
66783d957201 Close open shapefile transactions properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1120
diff changeset
639 shapePolys,
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8747
diff changeset
640 GeometryUtils.buildFeatureType(
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8747
diff changeset
641 "polygons", srs, Polygon.class, obj),
1121
66783d957201 Close open shapefile transactions properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1120
diff changeset
642 fcs[1]);
66783d957201 Close open shapefile transactions properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1120
diff changeset
643
5312
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
644
1121
66783d957201 Close open shapefile transactions properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1120
diff changeset
645 if (p) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7661
diff changeset
646 log.debug(
1123
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
647 "Successfully created barrier polygon shapefile. " +
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
648 "Write shapefile path into WSPLGEN job.");
5312
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
649 createMapfile(
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
650 artifact,
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
651 dir,
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
652 MapfileGenerator.MS_LAYER_PREFIX + "barriers-poly",
6330
36dc11244ec3 Group barriers layer and fix polygon layer path to shapefile
Andre Heinecke <aheinecke@intevation.de>
parents: 6101
diff changeset
653 WSPLGEN_BARRIERS_POLY,
5312
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
654 "POLYGON",
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
655 srid,
6330
36dc11244ec3 Group barriers layer and fix polygon layer path to shapefile
Andre Heinecke <aheinecke@intevation.de>
parents: 6101
diff changeset
656 MapfileGenerator.MS_BARRIERS_PREFIX);
1955
ccf2235035d6 Various bugfixes in WSPLGEN parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1845
diff changeset
657
ccf2235035d6 Various bugfixes in WSPLGEN parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1845
diff changeset
658 if (scenario.equals(WSPLGENJob.GEL_NOSPERRE)) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7661
diff changeset
659 log.debug("WSPLGEN will not use barrier features.");
1955
ccf2235035d6 Various bugfixes in WSPLGEN parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1845
diff changeset
660 }
ccf2235035d6 Various bugfixes in WSPLGEN parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1845
diff changeset
661 else {
ccf2235035d6 Various bugfixes in WSPLGEN parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1845
diff changeset
662 job.addLin(shapePolys.getAbsolutePath());
ccf2235035d6 Various bugfixes in WSPLGEN parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1845
diff changeset
663 }
1106
e9f66d63bdd0 Write user defined barriers into a shapefile that is placed in the Artifact's directory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1096
diff changeset
664 }
1164
0398c2b8dbaf Do only create WSPLGEN and barrier facets if the WSPLGEN job has been added to the Scheduler and if there are digitized geometries existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1160
diff changeset
665
0398c2b8dbaf Do only create WSPLGEN and barrier facets if the WSPLGEN job has been added to the Scheduler and if there are digitized geometries existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1160
diff changeset
666 if (p || l) {
0398c2b8dbaf Do only create WSPLGEN and barrier facets if the WSPLGEN job has been added to the Scheduler and if there are digitized geometries existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1160
diff changeset
667 facetCreator.createBarrierFacet();
0398c2b8dbaf Do only create WSPLGEN and barrier facets if the WSPLGEN job has been added to the Scheduler and if there are digitized geometries existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1160
diff changeset
668 }
1107
005c2964f9af Use the correct SRID while reading GeoJSON barriers and writing line/polygon shapefiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1106
diff changeset
669 }
005c2964f9af Use the correct SRID while reading GeoJSON barriers and writing line/polygon shapefiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1106
diff changeset
670
005c2964f9af Use the correct SRID while reading GeoJSON barriers and writing line/polygon shapefiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1106
diff changeset
671
2639
a78dafdd8590 Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2095
diff changeset
672 protected void setUserShape(
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
673 D4EArtifact artifact,
2639
a78dafdd8590 Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2095
diff changeset
674 FacetCreator facetCreator,
a78dafdd8590 Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2095
diff changeset
675 File dir,
a78dafdd8590 Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2095
diff changeset
676 WSPLGENJob job
a78dafdd8590 Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2095
diff changeset
677 ) {
6710
ffc9cb39cea7 Remove duplicate code for mapfile generation. ID problem still not fixed (#657).
Christian Lins <christian.lins@intevation.de>
parents: 6330
diff changeset
678 File archive = new File(dir, WSPLGEN_USER_RGD_SHAPE);
2639
a78dafdd8590 Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2095
diff changeset
679 boolean exists = archive.exists();
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7661
diff changeset
680 log.debug("shp file exists: " + exists);
2639
a78dafdd8590 Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2095
diff changeset
681 if (exists) {
6710
ffc9cb39cea7 Remove duplicate code for mapfile generation. ID problem still not fixed (#657).
Christian Lins <christian.lins@intevation.de>
parents: 6330
diff changeset
682 job.addLin(dir + "/" + WSPLGEN_USER_RGD_SHAPE);
5312
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
683 facetCreator.createShapeFacet(FacetCreator.I18N_USERSHAPE,
6710
ffc9cb39cea7 Remove duplicate code for mapfile generation. ID problem still not fixed (#657).
Christian Lins <christian.lins@intevation.de>
parents: 6330
diff changeset
684 MapfileGenerator.MS_LAYER_PREFIX + WSPLGEN_USER_RGD,
5312
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
685 FLOODMAP_USERSHAPE,
2c1045a1e3fe Added new states and transitions to UESK calculation and adjusted states and UI.
Raimund Renkert <rrenkert@intevation.de>
parents: 5281
diff changeset
686 4);
2639
a78dafdd8590 Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2095
diff changeset
687 }
a78dafdd8590 Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2095
diff changeset
688 }
a78dafdd8590 Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2095
diff changeset
689
1123
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
690 protected SimpleFeatureType getBarriersFeatureType(
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
691 String name,
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
692 String srs,
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
693 Class type
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
694 ) {
1707
3bf464ec436f Added a further attribute to the feature type description for barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1650
diff changeset
695 Object[][] attrs = new Object[3][];
1123
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
696 attrs[0] = new Object[] { "typ", String.class };
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
697 attrs[1] = new Object[] { "elevation", Double.class };
1707
3bf464ec436f Added a further attribute to the feature type description for barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1650
diff changeset
698 attrs[2] = new Object[] { "mark.selected", Integer.class };
1107
005c2964f9af Use the correct SRID while reading GeoJSON barriers and writing line/polygon shapefiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1106
diff changeset
699
1123
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
700 return GeometryUtils.buildFeatureType(name, srs, type, attrs);
1106
e9f66d63bdd0 Write user defined barriers into a shapefile that is placed in the Artifact's directory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1096
diff changeset
701 }
e9f66d63bdd0 Write user defined barriers into a shapefile that is placed in the Artifact's directory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1096
diff changeset
702
e9f66d63bdd0 Write user defined barriers into a shapefile that is placed in the Artifact's directory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1096
diff changeset
703
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8747
diff changeset
704 protected FeatureCollection[] splitLinesAndPolygons(
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8747
diff changeset
705 List<SimpleFeature> f
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8747
diff changeset
706 ) {
1106
e9f66d63bdd0 Write user defined barriers into a shapefile that is placed in the Artifact's directory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1096
diff changeset
707 FeatureCollection lines = FeatureCollections.newCollection();
e9f66d63bdd0 Write user defined barriers into a shapefile that is placed in the Artifact's directory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1096
diff changeset
708 FeatureCollection polygons = FeatureCollections.newCollection();
e9f66d63bdd0 Write user defined barriers into a shapefile that is placed in the Artifact's directory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1096
diff changeset
709
e9f66d63bdd0 Write user defined barriers into a shapefile that is placed in the Artifact's directory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1096
diff changeset
710 for (SimpleFeature feature: f) {
1119
faca1825818e Write additional attributes ELEVATION and KILOMETER into crosssection track shapefiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1118
diff changeset
711 Geometry geom = (Geometry) feature.getDefaultGeometry();
1106
e9f66d63bdd0 Write user defined barriers into a shapefile that is placed in the Artifact's directory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1096
diff changeset
712
1123
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
713
1106
e9f66d63bdd0 Write user defined barriers into a shapefile that is placed in the Artifact's directory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1096
diff changeset
714 if (geom instanceof LineString) {
4569
276d9bd3c77d Workaround for NPE in FloodMapState.
Christian Lins <christian.lins@intevation.de>
parents: 3555
diff changeset
715 geom = applyElevationAttribute(feature, geom);
1106
e9f66d63bdd0 Write user defined barriers into a shapefile that is placed in the Artifact's directory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1096
diff changeset
716 lines.add(feature);
e9f66d63bdd0 Write user defined barriers into a shapefile that is placed in the Artifact's directory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1096
diff changeset
717 }
e9f66d63bdd0 Write user defined barriers into a shapefile that is placed in the Artifact's directory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1096
diff changeset
718 else if (geom instanceof Polygon) {
4569
276d9bd3c77d Workaround for NPE in FloodMapState.
Christian Lins <christian.lins@intevation.de>
parents: 3555
diff changeset
719 geom = applyElevationAttribute(feature, geom);
1106
e9f66d63bdd0 Write user defined barriers into a shapefile that is placed in the Artifact's directory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1096
diff changeset
720 polygons.add(feature);
e9f66d63bdd0 Write user defined barriers into a shapefile that is placed in the Artifact's directory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1096
diff changeset
721 }
e9f66d63bdd0 Write user defined barriers into a shapefile that is placed in the Artifact's directory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1096
diff changeset
722 else {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7661
diff changeset
723 log.warn("Feature not supported: " + geom.getClass());
1106
e9f66d63bdd0 Write user defined barriers into a shapefile that is placed in the Artifact's directory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1096
diff changeset
724 }
e9f66d63bdd0 Write user defined barriers into a shapefile that is placed in the Artifact's directory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1096
diff changeset
725 }
e9f66d63bdd0 Write user defined barriers into a shapefile that is placed in the Artifact's directory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1096
diff changeset
726
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7661
diff changeset
727 log.debug("Found " + lines.size() + " barrier lines.");
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7661
diff changeset
728 log.debug("Found " + polygons.size() + " barrier polygons.");
1106
e9f66d63bdd0 Write user defined barriers into a shapefile that is placed in the Artifact's directory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1096
diff changeset
729
e9f66d63bdd0 Write user defined barriers into a shapefile that is placed in the Artifact's directory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1096
diff changeset
730 return new FeatureCollection[] { lines, polygons };
e9f66d63bdd0 Write user defined barriers into a shapefile that is placed in the Artifact's directory.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1096
diff changeset
731 }
1108
5b1198c27d43 Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1107
diff changeset
732
5b1198c27d43 Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1107
diff changeset
733
1123
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
734 protected static Geometry applyElevationAttribute(
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
735 SimpleFeature feature,
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
736 Geometry geom
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
737 ) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7661
diff changeset
738 log.debug("Apply elevations for: " + geom.getClass());
1123
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
739
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
740 List<Double> elevations = extractElevations(feature);
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
741 int numPoints = geom.getNumPoints();
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
742 int numElevation = elevations.size();
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
743
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
744 String typ = (String) feature.getAttribute("typ");
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
745
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
746 if (numPoints > numElevation) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7661
diff changeset
747 log.warn("More vertices in Geometry than elevations given.");
1123
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
748 }
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
749
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
750 Coordinate[] c = geom.getCoordinates();
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
751 for (int i = 0; i < numPoints; i++) {
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
752 if (i < numElevation) {
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
753 c[i].z = elevations.get(i);
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
754 }
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
755 else if (typ != null && typ.equals("Graben")) {
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
756 c[i].z = -9999d;
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
757 }
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
758 else {
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
759 c[i].z = 9999d;
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
760 }
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
761 }
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
762
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
763 return geom;
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
764 }
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
765
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
766
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
767 protected static List<Double> extractElevations(SimpleFeature feature) {
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
768 String tmp = (String) feature.getAttribute("elevation");
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
769 String typ = (String) feature.getAttribute("typ");
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
770
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
771 String[] elevations = tmp == null ? null : tmp.split(" ");
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
772
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
773 int num = elevations != null ? elevations.length : 0;
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
774
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
775 List<Double> list = new ArrayList<Double>(num);
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
776
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
777 for (int i = 0; i < num; i++) {
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
778 try {
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
779 list.add(Double.parseDouble(elevations[i]));
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
780 }
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
781 catch (NumberFormatException nfe) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7661
diff changeset
782 log.warn("Error while parsing elevation at pos: " + i);
1123
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
783 if (typ != null && typ.equals("Graben")) {
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
784 list.add(new Double(-9999.0));
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
785 }
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
786 else {
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
787 list.add(new Double(9999.0));
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
788 }
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
789 }
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
790 }
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
791
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
792 return list;
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
793 }
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
794
be9bb260b835 Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1121
diff changeset
795
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
796 protected void setAxis(D4EArtifact artifact, File dir, WSPLGENJob job) {
7055
1f38656b68c4 DGM SRIds are now fetched from database instead of configuration.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6983
diff changeset
797 DGMAccess access = new DGMAccess(artifact);
7261
a56fe3bc6700 Refactoring: Let RiverAccess.getRiver return an River.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7055
diff changeset
798 String river = access.getRiverName();
7055
1f38656b68c4 DGM SRIds are now fetched from database instead of configuration.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6983
diff changeset
799 String srid = String.valueOf(access.getDGM().getSrid());
1f38656b68c4 DGM SRIds are now fetched from database instead of configuration.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6983
diff changeset
800 String srs = "EPSG:" + srid;
5170
c1b60f8c3390 Made river mapfile generator more tolerant.
Raimund Renkert <rrenkert@intevation.de>
parents: 5152
diff changeset
801
8747
e9d912c97fa8 We expect that every river has only one RiverAxis of kind 1
Tom Gottfried <tom@intevation.de>
parents: 8456
diff changeset
802 RiverAxis axis = null;
5170
c1b60f8c3390 Made river mapfile generator more tolerant.
Raimund Renkert <rrenkert@intevation.de>
parents: 5152
diff changeset
803 try {
8747
e9d912c97fa8 We expect that every river has only one RiverAxis of kind 1
Tom Gottfried <tom@intevation.de>
parents: 8456
diff changeset
804 axis = RiverAxis.getRiverAxis(river);
5170
c1b60f8c3390 Made river mapfile generator more tolerant.
Raimund Renkert <rrenkert@intevation.de>
parents: 5152
diff changeset
805 }
5181
9d36ddf7dbd3 Change IllegalArgumentException to HibernateException.
Raimund Renkert <rrenkert@intevation.de>
parents: 5173
diff changeset
806 catch (HibernateException iae) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7661
diff changeset
807 log.warn("No valid river axis found for " + river);
5170
c1b60f8c3390 Made river mapfile generator more tolerant.
Raimund Renkert <rrenkert@intevation.de>
parents: 5152
diff changeset
808 return;
c1b60f8c3390 Made river mapfile generator more tolerant.
Raimund Renkert <rrenkert@intevation.de>
parents: 5152
diff changeset
809 }
8747
e9d912c97fa8 We expect that every river has only one RiverAxis of kind 1
Tom Gottfried <tom@intevation.de>
parents: 8456
diff changeset
810 if (axis == null) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7661
diff changeset
811 log.warn("Could not find river axis for: '" + river + "'");
1108
5b1198c27d43 Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1107
diff changeset
812 return;
5b1198c27d43 Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1107
diff changeset
813 }
5b1198c27d43 Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1107
diff changeset
814
5b1198c27d43 Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1107
diff changeset
815 SimpleFeatureType ft = GeometryUtils.buildFeatureType(
5b1198c27d43 Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1107
diff changeset
816 "axis", srs, LineString.class);
5b1198c27d43 Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1107
diff changeset
817
5b1198c27d43 Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1107
diff changeset
818 SimpleFeatureBuilder builder = new SimpleFeatureBuilder(ft);
2078
cbeeaaad1056 #440 Support river axes that consist of more than a single geometry.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1970
diff changeset
819 FeatureCollection collection = FeatureCollections.newCollection();
1108
5b1198c27d43 Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1107
diff changeset
820
8747
e9d912c97fa8 We expect that every river has only one RiverAxis of kind 1
Tom Gottfried <tom@intevation.de>
parents: 8456
diff changeset
821 builder.add(axis.getGeom());
e9d912c97fa8 We expect that every river has only one RiverAxis of kind 1
Tom Gottfried <tom@intevation.de>
parents: 8456
diff changeset
822 collection.add(builder.buildFeature("0"));
1108
5b1198c27d43 Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1107
diff changeset
823
5b1198c27d43 Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1107
diff changeset
824 File axisShape = new File(dir, WSPLGEN_AXIS);
5b1198c27d43 Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1107
diff changeset
825
1121
66783d957201 Close open shapefile transactions properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1120
diff changeset
826 boolean a = GeometryUtils.writeShapefile(
66783d957201 Close open shapefile transactions properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1120
diff changeset
827 axisShape,
66783d957201 Close open shapefile transactions properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1120
diff changeset
828 GeometryUtils.buildFeatureType("axis", srs, LineString.class),
66783d957201 Close open shapefile transactions properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1120
diff changeset
829 collection);
66783d957201 Close open shapefile transactions properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1120
diff changeset
830
66783d957201 Close open shapefile transactions properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1120
diff changeset
831 if (a) {
1108
5b1198c27d43 Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1107
diff changeset
832 job.setAxis(axisShape.getAbsolutePath());
5b1198c27d43 Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1107
diff changeset
833 }
5b1198c27d43 Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1107
diff changeset
834 }
5b1198c27d43 Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1107
diff changeset
835
5b1198c27d43 Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1107
diff changeset
836
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
837 protected void setPro(D4EArtifact artifact, File dir, WSPLGENJob job) {
7055
1f38656b68c4 DGM SRIds are now fetched from database instead of configuration.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6983
diff changeset
838 DGMAccess access = new DGMAccess(artifact);
7261
a56fe3bc6700 Refactoring: Let RiverAccess.getRiver return an River.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7055
diff changeset
839 String river = access.getRiverName();
7055
1f38656b68c4 DGM SRIds are now fetched from database instead of configuration.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6983
diff changeset
840 String srid = String.valueOf(access.getDGM().getSrid());
1f38656b68c4 DGM SRIds are now fetched from database instead of configuration.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6983
diff changeset
841 String srs = "EPSG:" + srid;
1108
5b1198c27d43 Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1107
diff changeset
842
5b1198c27d43 Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1107
diff changeset
843 List<CrossSectionTrack> cst =
3070
6875120af2a2 Fetch only 'qps' cross section tracks for WSPLGEN calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2639
diff changeset
844 CrossSectionTrack.getCrossSectionTrack(river, WSPLGEN_QPS_NAME);
1108
5b1198c27d43 Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1107
diff changeset
845
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7661
diff changeset
846 log.debug("Found " + cst.size() + " CrossSectionTracks.");
1108
5b1198c27d43 Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1107
diff changeset
847
1119
faca1825818e Write additional attributes ELEVATION and KILOMETER into crosssection track shapefiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1118
diff changeset
848 Object[][] attrs = new Object[2][];
faca1825818e Write additional attributes ELEVATION and KILOMETER into crosssection track shapefiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1118
diff changeset
849 attrs[0] = new Object[] { "ELEVATION", Double.class };
faca1825818e Write additional attributes ELEVATION and KILOMETER into crosssection track shapefiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1118
diff changeset
850 attrs[1] = new Object[] { "KILOMETER", Double.class };
faca1825818e Write additional attributes ELEVATION and KILOMETER into crosssection track shapefiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1118
diff changeset
851
1108
5b1198c27d43 Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1107
diff changeset
852 SimpleFeatureType ft = GeometryUtils.buildFeatureType(
1119
faca1825818e Write additional attributes ELEVATION and KILOMETER into crosssection track shapefiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1118
diff changeset
853 "qps", srs, LineString.class, attrs);
1108
5b1198c27d43 Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1107
diff changeset
854
5b1198c27d43 Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1107
diff changeset
855 SimpleFeatureBuilder builder = new SimpleFeatureBuilder(ft);
5b1198c27d43 Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1107
diff changeset
856 FeatureCollection collection = FeatureCollections.newCollection();
5b1198c27d43 Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1107
diff changeset
857
5b1198c27d43 Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1107
diff changeset
858 int i = 0;
5b1198c27d43 Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1107
diff changeset
859 for (CrossSectionTrack track: cst) {
5b1198c27d43 Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1107
diff changeset
860 builder.reset();
5b1198c27d43 Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1107
diff changeset
861 builder.add(track.getGeom());
1119
faca1825818e Write additional attributes ELEVATION and KILOMETER into crosssection track shapefiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1118
diff changeset
862 builder.add(track.getZ().doubleValue());
faca1825818e Write additional attributes ELEVATION and KILOMETER into crosssection track shapefiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1118
diff changeset
863 builder.add(track.getKm().doubleValue());
1108
5b1198c27d43 Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1107
diff changeset
864
5b1198c27d43 Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1107
diff changeset
865 collection.add(builder.buildFeature(String.valueOf(i++)));
5b1198c27d43 Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1107
diff changeset
866 }
5b1198c27d43 Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1107
diff changeset
867
5b1198c27d43 Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1107
diff changeset
868 File qpsShape = new File(dir, WSPLGEN_QPS);
5b1198c27d43 Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1107
diff changeset
869
1121
66783d957201 Close open shapefile transactions properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1120
diff changeset
870 boolean q = GeometryUtils.writeShapefile(
66783d957201 Close open shapefile transactions properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1120
diff changeset
871 qpsShape,
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8747
diff changeset
872 GeometryUtils.buildFeatureType(
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8747
diff changeset
873 "qps", srs, LineString.class, attrs),
1121
66783d957201 Close open shapefile transactions properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1120
diff changeset
874 collection);
66783d957201 Close open shapefile transactions properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1120
diff changeset
875
66783d957201 Close open shapefile transactions properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1120
diff changeset
876 if (q) {
1108
5b1198c27d43 Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1107
diff changeset
877 job.setPro(qpsShape.getAbsolutePath());
5b1198c27d43 Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1107
diff changeset
878 }
5b1198c27d43 Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1107
diff changeset
879 }
1109
ba9fa72dd6f5 Write file path of DMGs into the WSPLGEN job while preparing WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1108
diff changeset
880
ba9fa72dd6f5 Write file path of DMGs into the WSPLGEN job while preparing WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1108
diff changeset
881
5152
b26465581abf Add a configurable path prefix to relative DGM path to allways have an absolute path.
Raimund Renkert <rrenkert@intevation.de>
parents: 5031
diff changeset
882 protected void setDgm(
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
883 D4EArtifact artifact,
7055
1f38656b68c4 DGM SRIds are now fetched from database instead of configuration.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6983
diff changeset
884 WSPLGENJob job,
5152
b26465581abf Add a configurable path prefix to relative DGM path to allways have an absolute path.
Raimund Renkert <rrenkert@intevation.de>
parents: 5031
diff changeset
885 CallContext context
b26465581abf Add a configurable path prefix to relative DGM path to allways have an absolute path.
Raimund Renkert <rrenkert@intevation.de>
parents: 5031
diff changeset
886 ) {
7055
1f38656b68c4 DGM SRIds are now fetched from database instead of configuration.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6983
diff changeset
887 DGMAccess access = new DGMAccess(artifact);
1f38656b68c4 DGM SRIds are now fetched from database instead of configuration.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6983
diff changeset
888 DGM dgm = access.getDGM();
1109
ba9fa72dd6f5 Write file path of DMGs into the WSPLGEN job while preparing WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1108
diff changeset
889
ba9fa72dd6f5 Write file path of DMGs into the WSPLGEN job while preparing WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1108
diff changeset
890 if (dgm == null) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7661
diff changeset
891 log.warn("Could not find specified DGM.");
1109
ba9fa72dd6f5 Write file path of DMGs into the WSPLGEN job while preparing WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1108
diff changeset
892 return;
ba9fa72dd6f5 Write file path of DMGs into the WSPLGEN job while preparing WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1108
diff changeset
893 }
ba9fa72dd6f5 Write file path of DMGs into the WSPLGEN job while preparing WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1108
diff changeset
894
7055
1f38656b68c4 DGM SRIds are now fetched from database instead of configuration.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6983
diff changeset
895 File dgmPath = new File(dgm.getPath());
5152
b26465581abf Add a configurable path prefix to relative DGM path to allways have an absolute path.
Raimund Renkert <rrenkert@intevation.de>
parents: 5031
diff changeset
896 if (dgmPath.isAbsolute()) {
b26465581abf Add a configurable path prefix to relative DGM path to allways have an absolute path.
Raimund Renkert <rrenkert@intevation.de>
parents: 5031
diff changeset
897 job.setDgm(dgm.getPath());
b26465581abf Add a configurable path prefix to relative DGM path to allways have an absolute path.
Raimund Renkert <rrenkert@intevation.de>
parents: 5031
diff changeset
898 }
b26465581abf Add a configurable path prefix to relative DGM path to allways have an absolute path.
Raimund Renkert <rrenkert@intevation.de>
parents: 5031
diff changeset
899 else {
5866
9a6741ccf6d4 FLYS artifacts: Renamed FLYSContext(Factory) to RiverContext(Factory).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5865
diff changeset
900 RiverContext fc = (RiverContext)context.globalContext();
7055
1f38656b68c4 DGM SRIds are now fetched from database instead of configuration.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6983
diff changeset
901 File prefix = new File((String)fc.get("dgm-path"));
1f38656b68c4 DGM SRIds are now fetched from database instead of configuration.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6983
diff changeset
902 job.setDgm(new File(prefix, dgm.getPath()).getAbsolutePath());
5152
b26465581abf Add a configurable path prefix to relative DGM path to allways have an absolute path.
Raimund Renkert <rrenkert@intevation.de>
parents: 5031
diff changeset
903 }
1109
ba9fa72dd6f5 Write file path of DMGs into the WSPLGEN job while preparing WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1108
diff changeset
904 }
1110
563e015f0f22 Export floodplain to shapefile and add its file path to WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1109
diff changeset
905
563e015f0f22 Export floodplain to shapefile and add its file path to WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1109
diff changeset
906
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
907 protected void setArea(D4EArtifact artifact, File dir, WSPLGENJob job) {
1955
ccf2235035d6 Various bugfixes in WSPLGEN parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1845
diff changeset
908 String useFloodplain = artifact.getDataAsString("use_floodplain");
ccf2235035d6 Various bugfixes in WSPLGEN parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1845
diff changeset
909 if (!Boolean.valueOf(useFloodplain)) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7661
diff changeset
910 log.debug("WSPLGEN will not use floodplain.");
1955
ccf2235035d6 Various bugfixes in WSPLGEN parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1845
diff changeset
911 return;
ccf2235035d6 Various bugfixes in WSPLGEN parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1845
diff changeset
912 }
ccf2235035d6 Various bugfixes in WSPLGEN parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1845
diff changeset
913
7055
1f38656b68c4 DGM SRIds are now fetched from database instead of configuration.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6983
diff changeset
914 DGMAccess access = new DGMAccess(artifact);
7261
a56fe3bc6700 Refactoring: Let RiverAccess.getRiver return an River.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7055
diff changeset
915 String river = access.getRiverName();
7055
1f38656b68c4 DGM SRIds are now fetched from database instead of configuration.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6983
diff changeset
916 String srid = String.valueOf(access.getDGM().getSrid());
1110
563e015f0f22 Export floodplain to shapefile and add its file path to WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1109
diff changeset
917 String srs = "EPSG:" + srid;
563e015f0f22 Export floodplain to shapefile and add its file path to WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1109
diff changeset
918
563e015f0f22 Export floodplain to shapefile and add its file path to WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1109
diff changeset
919 Floodplain plain = Floodplain.getFloodplain(river);
563e015f0f22 Export floodplain to shapefile and add its file path to WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1109
diff changeset
920
6983
93e7f947f6fa flys/issue1417 Be more fault tolerant if a river has no flood plain.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6710
diff changeset
921 if (plain == null) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7661
diff changeset
922 log.debug("No flood plain for river '" + river + "'");
6983
93e7f947f6fa flys/issue1417 Be more fault tolerant if a river has no flood plain.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6710
diff changeset
923 return;
93e7f947f6fa flys/issue1417 Be more fault tolerant if a river has no flood plain.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6710
diff changeset
924 }
93e7f947f6fa flys/issue1417 Be more fault tolerant if a river has no flood plain.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6710
diff changeset
925
93e7f947f6fa flys/issue1417 Be more fault tolerant if a river has no flood plain.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6710
diff changeset
926 Polygon polygon = plain.getGeom();
93e7f947f6fa flys/issue1417 Be more fault tolerant if a river has no flood plain.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6710
diff changeset
927 if (polygon == null) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7661
diff changeset
928 log.warn("Floodplain has no geometry.");
6983
93e7f947f6fa flys/issue1417 Be more fault tolerant if a river has no flood plain.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6710
diff changeset
929 return;
93e7f947f6fa flys/issue1417 Be more fault tolerant if a river has no flood plain.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6710
diff changeset
930 }
93e7f947f6fa flys/issue1417 Be more fault tolerant if a river has no flood plain.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6710
diff changeset
931
1110
563e015f0f22 Export floodplain to shapefile and add its file path to WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1109
diff changeset
932 SimpleFeatureType ft = GeometryUtils.buildFeatureType(
1845
06c157848c8f Made the floodmap compatible with an Oracle database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1782
diff changeset
933 "talaue", srs, Polygon.class);
1110
563e015f0f22 Export floodplain to shapefile and add its file path to WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1109
diff changeset
934
563e015f0f22 Export floodplain to shapefile and add its file path to WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1109
diff changeset
935 SimpleFeatureBuilder builder = new SimpleFeatureBuilder(ft);
6983
93e7f947f6fa flys/issue1417 Be more fault tolerant if a river has no flood plain.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6710
diff changeset
936 builder.add(polygon);
1110
563e015f0f22 Export floodplain to shapefile and add its file path to WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1109
diff changeset
937
563e015f0f22 Export floodplain to shapefile and add its file path to WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1109
diff changeset
938 FeatureCollection collection = FeatureCollections.newCollection();
563e015f0f22 Export floodplain to shapefile and add its file path to WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1109
diff changeset
939 collection.add(builder.buildFeature("0"));
563e015f0f22 Export floodplain to shapefile and add its file path to WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1109
diff changeset
940
563e015f0f22 Export floodplain to shapefile and add its file path to WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1109
diff changeset
941 File talaueShape = new File(dir, WSPLGEN_FLOODPLAIN);
563e015f0f22 Export floodplain to shapefile and add its file path to WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1109
diff changeset
942
1121
66783d957201 Close open shapefile transactions properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1120
diff changeset
943 boolean t = GeometryUtils.writeShapefile(
66783d957201 Close open shapefile transactions properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1120
diff changeset
944 talaueShape,
1845
06c157848c8f Made the floodmap compatible with an Oracle database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1782
diff changeset
945 GeometryUtils.buildFeatureType("talaue", srs, Polygon.class),
1121
66783d957201 Close open shapefile transactions properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1120
diff changeset
946 collection);
66783d957201 Close open shapefile transactions properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1120
diff changeset
947
66783d957201 Close open shapefile transactions properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1120
diff changeset
948 if (t) {
1110
563e015f0f22 Export floodplain to shapefile and add its file path to WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1109
diff changeset
949 job.setArea(talaueShape.getAbsolutePath());
563e015f0f22 Export floodplain to shapefile and add its file path to WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1109
diff changeset
950 }
563e015f0f22 Export floodplain to shapefile and add its file path to WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1109
diff changeset
951 }
1118
7398280b11a0 Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1110
diff changeset
952
7398280b11a0 Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1110
diff changeset
953
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
954 protected void setOutFile(D4EArtifact artifact, WSPLGENJob job) {
1118
7398280b11a0 Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1110
diff changeset
955 job.setOutFile(WSPLGEN_OUTPUT_FILE);
7398280b11a0 Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1110
diff changeset
956 }
7398280b11a0 Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1110
diff changeset
957
7398280b11a0 Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1110
diff changeset
958
7646
f603a53e45dc issue1020: Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7569
diff changeset
959 /** Gets the Waterlevel of chosen artifact as base for flooding. */
f603a53e45dc issue1020: Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7569
diff changeset
960 // Challenge equals WaterlevelSelectState#getLabel
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
961 protected WQKms getWQKms(D4EArtifact flys, CallContext cc) {
7646
f603a53e45dc issue1020: Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7569
diff changeset
962 String wspString = flys.getDataAsString(WSP_ARTIFACT);
4569
276d9bd3c77d Workaround for NPE in FloodMapState.
Christian Lins <christian.lins@intevation.de>
parents: 3555
diff changeset
963 if (wspString == null) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7661
diff changeset
964 log.debug("getWQKms(): wspString == null");
4569
276d9bd3c77d Workaround for NPE in FloodMapState.
Christian Lins <christian.lins@intevation.de>
parents: 3555
diff changeset
965 return null;
276d9bd3c77d Workaround for NPE in FloodMapState.
Christian Lins <christian.lins@intevation.de>
parents: 3555
diff changeset
966 }
276d9bd3c77d Workaround for NPE in FloodMapState.
Christian Lins <christian.lins@intevation.de>
parents: 3555
diff changeset
967 String[] parts = wspString.split(";");
1178
1b432c260e97 Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1168
diff changeset
968 String otherArtifact = parts[0];
1b432c260e97 Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1168
diff changeset
969
1b432c260e97 Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1168
diff changeset
970 int idx = -1;
1b432c260e97 Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1168
diff changeset
971 try {
1b432c260e97 Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1168
diff changeset
972 idx = Integer.parseInt(parts[2]);
1b432c260e97 Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1168
diff changeset
973 }
1b432c260e97 Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1168
diff changeset
974 catch (NumberFormatException nfe) { /* do nothing */ }
1b432c260e97 Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1168
diff changeset
975
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
976 D4EArtifact src = otherArtifact != null
5865
73da40528cf2 River artifacts: Renamed FLYSUtils to RiverUtils.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
977 ? RiverUtils.getArtifact(otherArtifact, cc)
1178
1b432c260e97 Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1168
diff changeset
978 : flys;
1b432c260e97 Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1168
diff changeset
979
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7661
diff changeset
980 log.debug("Use waterlevel provided by Artifact: " + src.identifier());
1178
1b432c260e97 Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1168
diff changeset
981
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8747
diff changeset
982 // The state actually depends on the kind of artifact.
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8747
diff changeset
983 // E.g. StaticWQKmsArtifact needs other state
7647
786ff139de5e issue1020: When preparing wsts for wsplgen handle other than standard wqkms calculations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7646
diff changeset
984 Object computed = src.compute(
1178
1b432c260e97 Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1168
diff changeset
985 cc,
7647
786ff139de5e issue1020: When preparing wsts for wsplgen handle other than standard wqkms calculations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7646
diff changeset
986 //null,
786ff139de5e issue1020: When preparing wsts for wsplgen handle other than standard wqkms calculations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7646
diff changeset
987 //WINFO_WSP_STATE_ID,
1178
1b432c260e97 Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1168
diff changeset
988 ComputeType.ADVANCE,
1b432c260e97 Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1168
diff changeset
989 false);
1b432c260e97 Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1168
diff changeset
990
7647
786ff139de5e issue1020: When preparing wsts for wsplgen handle other than standard wqkms calculations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7646
diff changeset
991 // Depending on the artifact and calculation we have different results
786ff139de5e issue1020: When preparing wsts for wsplgen handle other than standard wqkms calculations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7646
diff changeset
992 // in place. Note that the same conditions exist in
786ff139de5e issue1020: When preparing wsts for wsplgen handle other than standard wqkms calculations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7646
diff changeset
993 // WaterlevelSelectState#getLabel .
1178
1b432c260e97 Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1168
diff changeset
994
7647
786ff139de5e issue1020: When preparing wsts for wsplgen handle other than standard wqkms calculations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7646
diff changeset
995 // Regular WSP calculation
786ff139de5e issue1020: When preparing wsts for wsplgen handle other than standard wqkms calculations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7646
diff changeset
996 if (computed instanceof CalculationResult) {
786ff139de5e issue1020: When preparing wsts for wsplgen handle other than standard wqkms calculations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7646
diff changeset
997 CalculationResult rawData = (CalculationResult) computed;
786ff139de5e issue1020: When preparing wsts for wsplgen handle other than standard wqkms calculations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7646
diff changeset
998 WQKms[] wqkms;
786ff139de5e issue1020: When preparing wsts for wsplgen handle other than standard wqkms calculations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7646
diff changeset
999 if (rawData.getData() instanceof FixRealizingResult) {
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8747
diff changeset
1000 wqkms = (WQKms[])((FixRealizingResult)rawData.getData())
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8747
diff changeset
1001 .getWQKms();
7647
786ff139de5e issue1020: When preparing wsts for wsplgen handle other than standard wqkms calculations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7646
diff changeset
1002 }
786ff139de5e issue1020: When preparing wsts for wsplgen handle other than standard wqkms calculations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7646
diff changeset
1003 else {
786ff139de5e issue1020: When preparing wsts for wsplgen handle other than standard wqkms calculations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7646
diff changeset
1004 wqkms = (WQKms[]) rawData.getData();
786ff139de5e issue1020: When preparing wsts for wsplgen handle other than standard wqkms calculations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7646
diff changeset
1005 }
786ff139de5e issue1020: When preparing wsts for wsplgen handle other than standard wqkms calculations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7646
diff changeset
1006 return wqkms == null || idx == -1 || idx >= wqkms.length
786ff139de5e issue1020: When preparing wsts for wsplgen handle other than standard wqkms calculations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7646
diff changeset
1007 ? null
786ff139de5e issue1020: When preparing wsts for wsplgen handle other than standard wqkms calculations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7646
diff changeset
1008 : wqkms[idx];
786ff139de5e issue1020: When preparing wsts for wsplgen handle other than standard wqkms calculations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7646
diff changeset
1009 }
786ff139de5e issue1020: When preparing wsts for wsplgen handle other than standard wqkms calculations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7646
diff changeset
1010 else if (computed instanceof WQKms) {
786ff139de5e issue1020: When preparing wsts for wsplgen handle other than standard wqkms calculations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7646
diff changeset
1011 // e.g. Fixations
786ff139de5e issue1020: When preparing wsts for wsplgen handle other than standard wqkms calculations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7646
diff changeset
1012 WQKms wqkms = (WQKms) computed;
786ff139de5e issue1020: When preparing wsts for wsplgen handle other than standard wqkms calculations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7646
diff changeset
1013 return (WQKms) computed;
786ff139de5e issue1020: When preparing wsts for wsplgen handle other than standard wqkms calculations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7646
diff changeset
1014 }
786ff139de5e issue1020: When preparing wsts for wsplgen handle other than standard wqkms calculations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7646
diff changeset
1015 else if (computed == null && src instanceof StaticWKmsArtifact) {
786ff139de5e issue1020: When preparing wsts for wsplgen handle other than standard wqkms calculations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7646
diff changeset
1016 // Floodmarks and protection.
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8747
diff changeset
1017 WQKms wqkms = WQKms.fromWKms(
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8747
diff changeset
1018 ((StaticWKmsArtifact)src).getWKms(0), 1d);
7647
786ff139de5e issue1020: When preparing wsts for wsplgen handle other than standard wqkms calculations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7646
diff changeset
1019 return wqkms;
786ff139de5e issue1020: When preparing wsts for wsplgen handle other than standard wqkms calculations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7646
diff changeset
1020 }
786ff139de5e issue1020: When preparing wsts for wsplgen handle other than standard wqkms calculations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7646
diff changeset
1021
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8747
diff changeset
1022 log.warn("getWQKms cannot handle " + computed.getClass()
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8747
diff changeset
1023 + " " + src.getClass());
7647
786ff139de5e issue1020: When preparing wsts for wsplgen handle other than standard wqkms calculations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7646
diff changeset
1024 return null;
1178
1b432c260e97 Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1168
diff changeset
1025 }
1b432c260e97 Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1168
diff changeset
1026
1b432c260e97 Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1168
diff changeset
1027
1118
7398280b11a0 Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1110
diff changeset
1028 protected void setWsp(
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5866
diff changeset
1029 D4EArtifact artifact,
1118
7398280b11a0 Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1110
diff changeset
1030 CallContext context,
7398280b11a0 Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1110
diff changeset
1031 File dir,
7398280b11a0 Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1110
diff changeset
1032 WSPLGENJob job)
7398280b11a0 Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1110
diff changeset
1033 {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7661
diff changeset
1034 log.debug("FloodMapState.setWsp");
1118
7398280b11a0 Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1110
diff changeset
1035
1178
1b432c260e97 Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1168
diff changeset
1036 WQKms data = getWQKms(artifact, context);
1118
7398280b11a0 Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1110
diff changeset
1037
1178
1b432c260e97 Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1168
diff changeset
1038 if (data == null) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7661
diff changeset
1039 log.warn("No WST data found!");
1118
7398280b11a0 Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1110
diff changeset
1040 return;
7398280b11a0 Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1110
diff changeset
1041 }
7398280b11a0 Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1110
diff changeset
1042
7659
2e1392067986 issue1020: Do not write Q-Lines with wstwriter from floodmapstate.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7647
diff changeset
1043 WstWriter writer = new WstWriter(0, true);
1118
7398280b11a0 Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1110
diff changeset
1044
7398280b11a0 Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1110
diff changeset
1045 // TODO REMOVE job.setWspTag(...) This is only used until the user is
7398280b11a0 Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1110
diff changeset
1046 // able to select the WSP column himself!
7398280b11a0 Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1110
diff changeset
1047 boolean writeWspTag = true;
7398280b11a0 Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1110
diff changeset
1048
7398280b11a0 Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1110
diff changeset
1049 double[] buf = new double[4];
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7661
diff changeset
1050 log.debug("Add WST column: " + data.getName());
1178
1b432c260e97 Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1168
diff changeset
1051 writer.addColumn(data.getName());
1118
7398280b11a0 Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1110
diff changeset
1052
1178
1b432c260e97 Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1168
diff changeset
1053 if (writeWspTag) {
1b432c260e97 Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1168
diff changeset
1054 job.setWspTag(data.getName());
1b432c260e97 Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1168
diff changeset
1055 writeWspTag = false;
1b432c260e97 Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1168
diff changeset
1056 }
1118
7398280b11a0 Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1110
diff changeset
1057
1178
1b432c260e97 Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1168
diff changeset
1058 for (int i = 0, num = data.size(); i < num; i++) {
1b432c260e97 Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1168
diff changeset
1059 data.get(i, buf);
1b432c260e97 Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1168
diff changeset
1060 writer.add(buf);
1118
7398280b11a0 Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1110
diff changeset
1061 }
7398280b11a0 Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1110
diff changeset
1062
7398280b11a0 Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1110
diff changeset
1063 FileOutputStream fout = null;
7398280b11a0 Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1110
diff changeset
1064
7398280b11a0 Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1110
diff changeset
1065 try {
7398280b11a0 Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1110
diff changeset
1066 File wspFile = new File(dir, WSPLGEN_WSP_FILE);
7398280b11a0 Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1110
diff changeset
1067 fout = new FileOutputStream(wspFile);
7398280b11a0 Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1110
diff changeset
1068
7398280b11a0 Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1110
diff changeset
1069 writer.write(fout);
7398280b11a0 Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1110
diff changeset
1070
7398280b11a0 Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1110
diff changeset
1071 job.setWsp(wspFile.getAbsolutePath());
7398280b11a0 Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1110
diff changeset
1072 }
7398280b11a0 Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1110
diff changeset
1073 catch (FileNotFoundException fnfe) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7661
diff changeset
1074 log.warn("Error while writing wsp file: " + fnfe.getMessage());
1118
7398280b11a0 Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1110
diff changeset
1075 }
7398280b11a0 Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1110
diff changeset
1076 finally {
7398280b11a0 Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1110
diff changeset
1077 if (fout != null) {
7398280b11a0 Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1110
diff changeset
1078 try {
7398280b11a0 Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1110
diff changeset
1079 fout.close();
7398280b11a0 Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1110
diff changeset
1080 }
7398280b11a0 Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1110
diff changeset
1081 catch (IOException ioe) { /* do nothing */ }
7398280b11a0 Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1110
diff changeset
1082 }
7398280b11a0 Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1110
diff changeset
1083 }
7398280b11a0 Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1110
diff changeset
1084 }
927
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1085 }
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1086 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org