Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/FloodMapState.java @ 2303:da35b8a23ffb
Fix flys/issue468 (Fehler beim Projekt-Duplizieren)
flys-artifacts/trunk@3971 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Wed, 08 Feb 2012 15:31:24 +0000 |
parents | 8cb679d4ec49 |
children | a78dafdd8590 |
rev | line source |
---|---|
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
|
1 package de.intevation.flys.artifacts.states; |
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
|
2 |
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
|
3 import java.io.File; |
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
|
4 import java.io.FileNotFoundException; |
7398280b11a0
Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1110
diff
changeset
|
5 import java.io.FileOutputStream; |
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
|
6 import java.io.IOException; |
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
|
7 import java.util.ArrayList; |
935
353ddfa231a7
Introduced a new output 'floodmap' for the FloodMapState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
927
diff
changeset
|
8 import java.util.List; |
353ddfa231a7
Introduced a new output 'floodmap' for the FloodMapState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
927
diff
changeset
|
9 |
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
|
10 import com.vividsolutions.jts.geom.Coordinate; |
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
|
11 import com.vividsolutions.jts.geom.Geometry; |
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
|
12 import com.vividsolutions.jts.geom.LineString; |
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
|
13 import com.vividsolutions.jts.geom.Polygon; |
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
|
14 |
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
|
15 import org.apache.log4j.Logger; |
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
|
16 |
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
|
17 import org.opengis.feature.simple.SimpleFeature; |
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
|
18 import org.opengis.feature.simple.SimpleFeatureType; |
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
|
19 |
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
|
20 import org.geotools.feature.FeatureCollection; |
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
|
21 import org.geotools.feature.FeatureCollections; |
1108
5b1198c27d43
Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1107
diff
changeset
|
22 import org.geotools.feature.simple.SimpleFeatureBuilder; |
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
|
23 |
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
|
24 import de.intevation.artifacts.Artifact; |
935
353ddfa231a7
Introduced a new output 'floodmap' for the FloodMapState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
927
diff
changeset
|
25 import de.intevation.artifacts.CallContext; |
2093
ebc2aa64c1be
Call State.initialize() for each State of an Artifact in FLYSArtifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2078
diff
changeset
|
26 import de.intevation.artifacts.CallMeta; |
1970
368040e5c400
Improved the Scheduler to be able to cancel running WSPLGEN jobs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1955
diff
changeset
|
27 import de.intevation.artifacts.GlobalContext; |
935
353ddfa231a7
Introduced a new output 'floodmap' for the FloodMapState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
927
diff
changeset
|
28 |
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
|
29 import de.intevation.artifacts.common.utils.FileTools; |
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
|
30 |
935
353ddfa231a7
Introduced a new output 'floodmap' for the FloodMapState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
927
diff
changeset
|
31 import de.intevation.artifactdatabase.state.Facet; |
353ddfa231a7
Introduced a new output 'floodmap' for the FloodMapState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
927
diff
changeset
|
32 |
1108
5b1198c27d43
Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1107
diff
changeset
|
33 import de.intevation.flys.model.CrossSectionTrack; |
1109
ba9fa72dd6f5
Write file path of DMGs into the WSPLGEN job while preparing WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1108
diff
changeset
|
34 import de.intevation.flys.model.DGM; |
1110
563e015f0f22
Export floodplain to shapefile and add its file path to WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1109
diff
changeset
|
35 import de.intevation.flys.model.Floodplain; |
1108
5b1198c27d43
Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1107
diff
changeset
|
36 import de.intevation.flys.model.RiverAxis; |
5b1198c27d43
Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1107
diff
changeset
|
37 |
935
353ddfa231a7
Introduced a new output 'floodmap' for the FloodMapState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
927
diff
changeset
|
38 import de.intevation.flys.artifacts.FLYSArtifact; |
1970
368040e5c400
Improved the Scheduler to be able to cancel running WSPLGEN jobs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1955
diff
changeset
|
39 import de.intevation.flys.artifacts.context.FLYSContext; |
1165
3b034bb5fce7
Add status message for queued WSPLGEN jobs to notify users.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1164
diff
changeset
|
40 import de.intevation.flys.artifacts.model.CalculationMessage; |
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
|
41 import de.intevation.flys.artifacts.model.CalculationResult; |
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
|
42 import de.intevation.flys.artifacts.model.FacetTypes; |
2095
8cb679d4ec49
Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2093
diff
changeset
|
43 import de.intevation.flys.artifacts.model.WMSLayerFacet; |
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
|
44 import de.intevation.flys.artifacts.model.WQKms; |
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
|
45 import de.intevation.flys.artifacts.model.WSPLGENCalculation; |
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
|
46 import de.intevation.flys.artifacts.model.WSPLGENJob; |
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
|
47 import de.intevation.flys.artifacts.model.WSPLGENReportFacet; |
1165
3b034bb5fce7
Add status message for queued WSPLGEN jobs to notify users.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1164
diff
changeset
|
48 import de.intevation.flys.artifacts.resources.Resources; |
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
|
49 import de.intevation.flys.artifacts.states.DefaultState.ComputeType; |
7398280b11a0
Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1110
diff
changeset
|
50 import de.intevation.flys.exports.WstWriter; |
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
|
51 import de.intevation.flys.utils.FLYSUtils; |
1782
93fe7debd687
Re-create FLYS mapfile when FloodMapState.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1707
diff
changeset
|
52 import de.intevation.flys.utils.MapfileGenerator; |
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
|
53 import de.intevation.flys.utils.GeometryUtils; |
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
|
54 import de.intevation.flys.wsplgen.FacetCreator; |
1165
3b034bb5fce7
Add status message for queued WSPLGEN jobs to notify users.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1164
diff
changeset
|
55 import de.intevation.flys.wsplgen.JobObserver; |
1127
6b9877a9f6c1
Added infrastructure to start WSPLGEN calculations - the FloodMapState already start such calculations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1124
diff
changeset
|
56 import de.intevation.flys.wsplgen.Scheduler; |
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
|
57 |
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
|
58 |
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
|
59 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
|
60 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
|
61 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
|
62 { |
1160
efe1b8545f5c
Cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1149
diff
changeset
|
63 /** The logger that is used in this state. */ |
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
|
64 private static Logger logger = Logger.getLogger(FloodMapState.class); |
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
|
65 |
935
353ddfa231a7
Introduced a new output 'floodmap' for the FloodMapState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
927
diff
changeset
|
66 |
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
|
67 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
|
68 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
|
69 |
005c2964f9af
Use the correct SRID while reading GeoJSON barriers and writing line/polygon shapefiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1106
diff
changeset
|
70 |
2095
8cb679d4ec49
Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2093
diff
changeset
|
71 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
|
72 |
1178
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1168
diff
changeset
|
73 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
|
74 |
7398280b11a0
Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1110
diff
changeset
|
75 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
|
76 |
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
|
77 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
|
78 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
|
79 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
|
80 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
|
81 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
|
82 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
|
83 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
|
84 public static final String WSPLGEN_OUTPUT_FILE = "wsplgen.shp"; |
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
|
85 |
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
|
86 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
|
87 |
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
|
88 |
2095
8cb679d4ec49
Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2093
diff
changeset
|
89 /** |
8cb679d4ec49
Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2093
diff
changeset
|
90 * @param orig |
8cb679d4ec49
Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2093
diff
changeset
|
91 * @param owner |
8cb679d4ec49
Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2093
diff
changeset
|
92 * @param context |
8cb679d4ec49
Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2093
diff
changeset
|
93 * @param callMeta |
8cb679d4ec49
Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2093
diff
changeset
|
94 */ |
2093
ebc2aa64c1be
Call State.initialize() for each State of an Artifact in FLYSArtifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2078
diff
changeset
|
95 @Override |
2095
8cb679d4ec49
Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2093
diff
changeset
|
96 public void initialize( |
8cb679d4ec49
Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2093
diff
changeset
|
97 Artifact orig, |
8cb679d4ec49
Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2093
diff
changeset
|
98 Artifact owner, |
8cb679d4ec49
Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2093
diff
changeset
|
99 Object context, |
8cb679d4ec49
Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2093
diff
changeset
|
100 CallMeta callMeta |
8cb679d4ec49
Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2093
diff
changeset
|
101 ) { |
2093
ebc2aa64c1be
Call State.initialize() for each State of an Artifact in FLYSArtifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2078
diff
changeset
|
102 logger.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
|
103 |
8cb679d4ec49
Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2093
diff
changeset
|
104 copyShapeDir(orig, owner); |
8cb679d4ec49
Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2093
diff
changeset
|
105 modifyFacets(orig, owner, context, callMeta); |
8cb679d4ec49
Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2093
diff
changeset
|
106 |
8cb679d4ec49
Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2093
diff
changeset
|
107 MapfileGenerator.getInstance().update(); |
2093
ebc2aa64c1be
Call State.initialize() for each State of an Artifact in FLYSArtifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2078
diff
changeset
|
108 } |
ebc2aa64c1be
Call State.initialize() for each State of an Artifact in FLYSArtifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2078
diff
changeset
|
109 |
ebc2aa64c1be
Call State.initialize() for each State of an Artifact in FLYSArtifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2078
diff
changeset
|
110 |
2095
8cb679d4ec49
Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2093
diff
changeset
|
111 protected void copyShapeDir(Artifact orig, Artifact owner) { |
8cb679d4ec49
Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2093
diff
changeset
|
112 File origDir = getDirectory((FLYSArtifact) orig); |
8cb679d4ec49
Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2093
diff
changeset
|
113 File thisDir = getDirectory((FLYSArtifact) owner); |
8cb679d4ec49
Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2093
diff
changeset
|
114 |
8cb679d4ec49
Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2093
diff
changeset
|
115 FileTools.copyDirectory(origDir, thisDir); |
8cb679d4ec49
Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2093
diff
changeset
|
116 } |
8cb679d4ec49
Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2093
diff
changeset
|
117 |
8cb679d4ec49
Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2093
diff
changeset
|
118 |
8cb679d4ec49
Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2093
diff
changeset
|
119 protected void modifyFacets( |
8cb679d4ec49
Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2093
diff
changeset
|
120 Artifact orig, |
8cb679d4ec49
Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2093
diff
changeset
|
121 Artifact owner, |
8cb679d4ec49
Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2093
diff
changeset
|
122 Object context, |
8cb679d4ec49
Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2093
diff
changeset
|
123 CallMeta callMeta |
8cb679d4ec49
Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2093
diff
changeset
|
124 ) { |
8cb679d4ec49
Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2093
diff
changeset
|
125 FLYSArtifact flys = (FLYSArtifact) owner; |
8cb679d4ec49
Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2093
diff
changeset
|
126 List<Facet> facets = flys.getFacets(); |
8cb679d4ec49
Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2093
diff
changeset
|
127 if (facets == null || facets.size() == 0) { |
8cb679d4ec49
Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2093
diff
changeset
|
128 logger.warn("No facets for '" + OUTPUT_NAME + "' given!"); |
8cb679d4ec49
Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2093
diff
changeset
|
129 return; |
8cb679d4ec49
Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2093
diff
changeset
|
130 } |
8cb679d4ec49
Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2093
diff
changeset
|
131 |
8cb679d4ec49
Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2093
diff
changeset
|
132 for (Facet facet: facets) { |
8cb679d4ec49
Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2093
diff
changeset
|
133 if (facet instanceof WMSLayerFacet) { |
8cb679d4ec49
Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2093
diff
changeset
|
134 WMSLayerFacet wms = (WMSLayerFacet) facet; |
8cb679d4ec49
Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2093
diff
changeset
|
135 |
8cb679d4ec49
Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2093
diff
changeset
|
136 List<String> layers = wms.getLayers(); |
8cb679d4ec49
Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2093
diff
changeset
|
137 |
8cb679d4ec49
Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2093
diff
changeset
|
138 for (String layer: layers) { |
8cb679d4ec49
Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2093
diff
changeset
|
139 if (layer.startsWith(MapfileGenerator.MS_WSPLGEN_PREFIX)) { |
8cb679d4ec49
Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2093
diff
changeset
|
140 wms.removeLayer(layer); |
8cb679d4ec49
Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2093
diff
changeset
|
141 |
8cb679d4ec49
Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2093
diff
changeset
|
142 String newLayer = MapfileGenerator.MS_WSPLGEN_PREFIX + |
8cb679d4ec49
Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2093
diff
changeset
|
143 owner.identifier(); |
8cb679d4ec49
Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2093
diff
changeset
|
144 |
8cb679d4ec49
Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2093
diff
changeset
|
145 wms.addLayer(newLayer); |
8cb679d4ec49
Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2093
diff
changeset
|
146 |
8cb679d4ec49
Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2093
diff
changeset
|
147 logger.debug( |
8cb679d4ec49
Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2093
diff
changeset
|
148 "Replaced layer: " + layer + " with " + newLayer); |
8cb679d4ec49
Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2093
diff
changeset
|
149 } |
8cb679d4ec49
Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2093
diff
changeset
|
150 } |
8cb679d4ec49
Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2093
diff
changeset
|
151 } |
8cb679d4ec49
Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2093
diff
changeset
|
152 } |
8cb679d4ec49
Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2093
diff
changeset
|
153 } |
8cb679d4ec49
Implemented initialize() in FloodMapState to enable cloning floodmaps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2093
diff
changeset
|
154 |
1053
bfc2ed20b87c
Prepared the FloodMapState to save geometries.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
935
diff
changeset
|
155 |
bfc2ed20b87c
Prepared the FloodMapState to save geometries.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
935
diff
changeset
|
156 @Override |
935
353ddfa231a7
Introduced a new output 'floodmap' for the FloodMapState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
927
diff
changeset
|
157 public Object computeAdvance( |
353ddfa231a7
Introduced a new output 'floodmap' for the FloodMapState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
927
diff
changeset
|
158 FLYSArtifact artifact, |
353ddfa231a7
Introduced a new output 'floodmap' for the FloodMapState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
927
diff
changeset
|
159 String hash, |
353ddfa231a7
Introduced a new output 'floodmap' for the FloodMapState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
927
diff
changeset
|
160 CallContext context, |
353ddfa231a7
Introduced a new output 'floodmap' for the FloodMapState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
927
diff
changeset
|
161 List<Facet> facets, |
353ddfa231a7
Introduced a new output 'floodmap' for the FloodMapState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
927
diff
changeset
|
162 Object old |
353ddfa231a7
Introduced a new output 'floodmap' for the FloodMapState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
927
diff
changeset
|
163 ) { |
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
|
164 logger.debug("FloodMapState.computeAdvance"); |
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
|
165 |
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
|
166 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
|
167 |
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
|
168 if (artifactDir == 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
|
169 logger.error("Could not create directory for WSPLGEN results!"); |
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
|
170 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
|
171 } |
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
|
172 |
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
|
173 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
|
174 |
1638
f45bbc80bd3d
Bugfix: #296 Set i18n titles for WSPLGEN and barriers WMS layers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1186
diff
changeset
|
175 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
|
176 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
|
177 |
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
|
178 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
|
179 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
|
180 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
|
181 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
|
182 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
|
183 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
|
184 |
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
|
185 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
|
186 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
|
187 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
|
188 |
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
|
189 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
|
190 |
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
|
191 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
|
192 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
|
193 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
|
194 } |
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
|
195 |
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
|
196 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
|
197 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
|
198 "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
|
199 "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
|
200 |
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
|
201 logger.error("No WSPLGEN processing has been started!"); |
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
|
202 |
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
|
203 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
|
204 } |
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
|
205 |
1128
727c53fd0dc7
Some bugfixes when starting/finishing WSPLGEN jobs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1127
diff
changeset
|
206 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
|
207 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
|
208 JobObserver.STEPS.length, |
3b034bb5fce7
Add status message for queued WSPLGEN jobs to notify users.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1164
diff
changeset
|
209 0, |
3b034bb5fce7
Add status message for queued WSPLGEN jobs to notify users.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1164
diff
changeset
|
210 Resources.getMsg( |
3b034bb5fce7
Add status message for queued WSPLGEN jobs to notify users.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1164
diff
changeset
|
211 context.getMeta(), |
3b034bb5fce7
Add status message for queued WSPLGEN jobs to notify users.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1164
diff
changeset
|
212 "wsplgen.job.queued", |
3b034bb5fce7
Add status message for queued WSPLGEN jobs to notify users.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1164
diff
changeset
|
213 "wsplgen.job.queued") |
3b034bb5fce7
Add status message for queued WSPLGEN jobs to notify users.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1164
diff
changeset
|
214 )); |
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
|
215 |
1970
368040e5c400
Improved the Scheduler to be able to cancel running WSPLGEN jobs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1955
diff
changeset
|
216 GlobalContext gc = (GlobalContext) context.globalContext(); |
368040e5c400
Improved the Scheduler to be able to cancel running WSPLGEN jobs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1955
diff
changeset
|
217 Scheduler scheduler = (Scheduler) gc.get(FLYSContext.SCHEDULER); |
1649
74142aa5d938
Improved WSPLGEN start to suppress inconsistent Artifact states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1641
diff
changeset
|
218 scheduler.addJob(job); |
74142aa5d938
Improved WSPLGEN start to suppress inconsistent Artifact states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1641
diff
changeset
|
219 |
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
|
220 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
|
221 } |
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
|
222 |
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
|
223 |
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
|
224 /** |
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
|
225 * 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
|
226 * 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
|
227 * |
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
|
228 * @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
|
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 * @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
|
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 protected File getDirectory(FLYSArtifact artifact) { |
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
|
233 String shapePath = FLYSUtils.getXPathString( |
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
|
234 FLYSUtils.XPATH_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
|
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 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
|
237 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
|
238 |
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
|
239 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
|
240 } |
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
|
241 |
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
|
242 |
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
|
243 /** |
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
|
244 * Removes the directory and all its content where the required data and the |
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
|
245 * 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
|
246 */ |
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
|
247 protected void removeDirectory(FLYSArtifact artifact) { |
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
|
248 String shapePath = FLYSUtils.getXPathString( |
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
|
249 FLYSUtils.XPATH_SHAPEFILE_DIR); |
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
|
250 |
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
|
251 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
|
252 |
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
|
253 if (artifactDir.exists()) { |
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
|
254 logger.info("Delete directory: " + artifactDir.getAbsolutePath()); |
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 boolean success = FileTools.deleteRecursive(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
|
256 } |
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
|
257 else { |
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
|
258 logger.debug("There is no directory to remove."); |
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 } |
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
|
260 } |
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
|
261 |
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
|
262 |
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
|
263 @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
|
264 public void endOfLife(Artifact artifact, Object callContext) { |
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
|
265 logger.info("FloodMapState.endOfLife: " + 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
|
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 FLYSArtifact flys = (FLYSArtifact) 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
|
268 removeDirectory(flys); |
1782
93fe7debd687
Re-create FLYS mapfile when FloodMapState.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1707
diff
changeset
|
269 |
1970
368040e5c400
Improved the Scheduler to be able to cancel running WSPLGEN jobs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1955
diff
changeset
|
270 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
|
271 scheduler.cancelJob(flys.identifier()); |
368040e5c400
Improved the Scheduler to be able to cancel running WSPLGEN jobs.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1955
diff
changeset
|
272 |
1782
93fe7debd687
Re-create FLYS mapfile when FloodMapState.endOfLife() is called.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1707
diff
changeset
|
273 MapfileGenerator.getInstance().update(); |
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
|
274 } |
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
|
275 |
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
|
276 |
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
|
277 protected WSPLGENJob prepareWSPLGENJob( |
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
|
278 FLYSArtifact 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
|
279 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
|
280 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
|
281 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
|
282 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
|
283 ) { |
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 logger.debug("FloodMapState.prepareWSPLGENJob"); |
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 |
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
|
286 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
|
287 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
|
288 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
|
289 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
|
290 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
|
291 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
|
292 |
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
|
293 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
|
294 |
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
|
295 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
|
296 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
|
297 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
|
298 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
|
299 setDist(artifact, job); |
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
|
300 setLine(artifact, facetCreator, artifactDir, job); |
1108
5b1198c27d43
Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1107
diff
changeset
|
301 setAxis(artifact, artifactDir, job); |
5b1198c27d43
Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1107
diff
changeset
|
302 setPro(artifact, artifactDir, job); |
1109
ba9fa72dd6f5
Write file path of DMGs into the WSPLGEN job while preparing WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1108
diff
changeset
|
303 setDgm(artifact, job); |
1110
563e015f0f22
Export floodplain to shapefile and add its file path to WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1109
diff
changeset
|
304 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
|
305 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
|
306 setWsp(artifact, context, artifactDir, job); // WSP |
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
|
307 |
9f88cc54570c
Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1091
diff
changeset
|
308 // 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
|
309 // 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
|
310 |
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
|
311 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
|
312 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
|
313 |
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
|
314 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
|
315 } |
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 catch (IOException ioe) { |
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 logger.warn("Cannot write PAR file: " + ioe.getMessage()); |
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
|
318 } |
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
|
319 catch (IllegalArgumentException iae) { |
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
|
320 logger.warn("Cannot write PAR file: " + iae.getMessage()); |
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
|
321 } |
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
|
322 |
935
353ddfa231a7
Introduced a new output 'floodmap' for the FloodMapState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
927
diff
changeset
|
323 return null; |
353ddfa231a7
Introduced a new output 'floodmap' for the FloodMapState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
927
diff
changeset
|
324 } |
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
|
325 |
9f88cc54570c
Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1091
diff
changeset
|
326 |
9f88cc54570c
Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1091
diff
changeset
|
327 protected void setOut(FLYSArtifact artifact, WSPLGENJob 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
|
328 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
|
329 } |
9f88cc54570c
Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1091
diff
changeset
|
330 |
9f88cc54570c
Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1091
diff
changeset
|
331 |
9f88cc54570c
Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1091
diff
changeset
|
332 protected void setRange(FLYSArtifact artifact, WSPLGENJob 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
|
333 double[] range = FLYSUtils.getKmRange(artifact); |
9f88cc54570c
Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1091
diff
changeset
|
334 |
9f88cc54570c
Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1091
diff
changeset
|
335 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
|
336 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
|
337 } |
9f88cc54570c
Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1091
diff
changeset
|
338 |
9f88cc54570c
Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1091
diff
changeset
|
339 |
9f88cc54570c
Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1091
diff
changeset
|
340 protected void setDelta(FLYSArtifact artifact, WSPLGENJob 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
|
341 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
|
342 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
|
343 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
|
344 |
9f88cc54570c
Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1091
diff
changeset
|
345 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
|
346 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
|
347 } |
9f88cc54570c
Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1091
diff
changeset
|
348 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
|
349 } |
9f88cc54570c
Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1091
diff
changeset
|
350 |
9f88cc54570c
Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1091
diff
changeset
|
351 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
|
352 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
|
353 } |
9f88cc54570c
Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1091
diff
changeset
|
354 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
|
355 } |
9f88cc54570c
Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1091
diff
changeset
|
356 |
9f88cc54570c
Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1091
diff
changeset
|
357 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
|
358 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
|
359 } |
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 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
|
361 } |
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 } |
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 |
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 |
9f88cc54570c
Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1091
diff
changeset
|
365 protected void setGel(FLYSArtifact artifact, WSPLGENJob job) { |
1955
ccf2235035d6
Various bugfixes in WSPLGEN parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1845
diff
changeset
|
366 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
|
367 |
1955
ccf2235035d6
Various bugfixes in WSPLGEN parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1845
diff
changeset
|
368 logger.debug("Selected gel = '" + gel + "'"); |
ccf2235035d6
Various bugfixes in WSPLGEN parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1845
diff
changeset
|
369 |
ccf2235035d6
Various bugfixes in WSPLGEN parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1845
diff
changeset
|
370 if (gel == null || gel.length() == 0) { |
ccf2235035d6
Various bugfixes in WSPLGEN parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1845
diff
changeset
|
371 job.setGel(WSPLGENJob.GEL_NOSPERRE); |
ccf2235035d6
Various bugfixes in WSPLGEN parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1845
diff
changeset
|
372 } |
ccf2235035d6
Various bugfixes in WSPLGEN parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1845
diff
changeset
|
373 else if (gel.equals("scenario.current")) { |
ccf2235035d6
Various bugfixes in WSPLGEN parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1845
diff
changeset
|
374 job.setGel(WSPLGENJob.GEL_SPERRE); |
ccf2235035d6
Various bugfixes in WSPLGEN parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1845
diff
changeset
|
375 } |
ccf2235035d6
Various bugfixes in WSPLGEN parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1845
diff
changeset
|
376 else if (gel.equals("scenario.scenario")) { |
ccf2235035d6
Various bugfixes in WSPLGEN parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1845
diff
changeset
|
377 job.setGel(WSPLGENJob.GEL_SPERRE); |
ccf2235035d6
Various bugfixes in WSPLGEN parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1845
diff
changeset
|
378 } |
ccf2235035d6
Various bugfixes in WSPLGEN parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1845
diff
changeset
|
379 else { |
ccf2235035d6
Various bugfixes in WSPLGEN parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1845
diff
changeset
|
380 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
|
381 } |
9f88cc54570c
Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1091
diff
changeset
|
382 } |
9f88cc54570c
Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1091
diff
changeset
|
383 |
9f88cc54570c
Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1091
diff
changeset
|
384 |
9f88cc54570c
Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1091
diff
changeset
|
385 protected void setDist(FLYSArtifact artifact, WSPLGENJob 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
|
386 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
|
387 |
9f88cc54570c
Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1091
diff
changeset
|
388 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
|
389 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
|
390 } |
9f88cc54570c
Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1091
diff
changeset
|
391 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
|
392 // 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
|
393 } |
9f88cc54570c
Set some WSPLGENJob parameters which are stored in FLYSArtifact in the Floodmap state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1091
diff
changeset
|
394 } |
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
|
395 |
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
|
396 |
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
|
397 protected void setLine( |
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
|
398 FLYSArtifact artifact, |
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
|
399 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
|
400 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
|
401 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
|
402 ) { |
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
|
403 String geoJSON = artifact.getDataAsString("uesk.barriers"); |
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
|
404 String srid = FLYSUtils.getRiverSrid(artifact); |
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
|
405 String srs = "EPSG:" + srid; |
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
|
406 |
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
|
407 if (geoJSON == null || geoJSON.length() == 0) { |
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
|
408 logger.debug("No barrier features in parameterization existing."); |
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
|
409 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
|
410 } |
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
|
411 |
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
|
412 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
|
413 "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
|
414 |
be9bb260b835
Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1121
diff
changeset
|
415 List<SimpleFeature> features = GeometryUtils.parseGeoJSON(geoJSON, ft); |
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
|
416 if (features == null || features.size() == 0) { |
005c2964f9af
Use the correct SRID while reading GeoJSON barriers and writing line/polygon shapefiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1106
diff
changeset
|
417 logger.debug("No barrier features extracted."); |
005c2964f9af
Use the correct SRID while reading GeoJSON barriers and writing line/polygon shapefiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1106
diff
changeset
|
418 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
|
419 } |
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
|
420 |
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
|
421 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
|
422 |
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
|
423 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
|
424 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
|
425 |
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
|
426 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
|
427 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
|
428 }; |
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
|
429 |
1955
ccf2235035d6
Various bugfixes in WSPLGEN parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1845
diff
changeset
|
430 String scenario = job.getGel(); |
ccf2235035d6
Various bugfixes in WSPLGEN parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1845
diff
changeset
|
431 |
1121
66783d957201
Close open shapefile transactions properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1120
diff
changeset
|
432 boolean l = GeometryUtils.writeShapefile( |
66783d957201
Close open shapefile transactions properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1120
diff
changeset
|
433 shapeLines, |
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
|
434 GeometryUtils.buildFeatureType("lines", srs, LineString.class, obj), |
1121
66783d957201
Close open shapefile transactions properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1120
diff
changeset
|
435 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
|
436 |
1121
66783d957201
Close open shapefile transactions properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1120
diff
changeset
|
437 if (l) { |
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
|
438 logger.debug( |
be9bb260b835
Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1121
diff
changeset
|
439 "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
|
440 "Write shapefile path into WSPLGEN job."); |
1955
ccf2235035d6
Various bugfixes in WSPLGEN parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1845
diff
changeset
|
441 |
ccf2235035d6
Various bugfixes in WSPLGEN parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1845
diff
changeset
|
442 if (scenario.equals(WSPLGENJob.GEL_NOSPERRE)) { |
ccf2235035d6
Various bugfixes in WSPLGEN parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1845
diff
changeset
|
443 logger.debug("WSPLGEN will not use barrier features."); |
ccf2235035d6
Various bugfixes in WSPLGEN parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1845
diff
changeset
|
444 } |
ccf2235035d6
Various bugfixes in WSPLGEN parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1845
diff
changeset
|
445 else { |
ccf2235035d6
Various bugfixes in WSPLGEN parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1845
diff
changeset
|
446 job.addLin(shapeLines.getAbsolutePath()); |
ccf2235035d6
Various bugfixes in WSPLGEN parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1845
diff
changeset
|
447 } |
1121
66783d957201
Close open shapefile transactions properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1120
diff
changeset
|
448 } |
66783d957201
Close open shapefile transactions properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1120
diff
changeset
|
449 |
66783d957201
Close open shapefile transactions properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1120
diff
changeset
|
450 boolean p = GeometryUtils.writeShapefile( |
66783d957201
Close open shapefile transactions properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1120
diff
changeset
|
451 shapePolys, |
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
|
452 GeometryUtils.buildFeatureType("polygons", srs, Polygon.class, obj), |
1121
66783d957201
Close open shapefile transactions properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1120
diff
changeset
|
453 fcs[1]); |
66783d957201
Close open shapefile transactions properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1120
diff
changeset
|
454 |
66783d957201
Close open shapefile transactions properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1120
diff
changeset
|
455 if (p) { |
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
|
456 logger.debug( |
be9bb260b835
Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1121
diff
changeset
|
457 "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
|
458 "Write shapefile path into WSPLGEN job."); |
1955
ccf2235035d6
Various bugfixes in WSPLGEN parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1845
diff
changeset
|
459 |
ccf2235035d6
Various bugfixes in WSPLGEN parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1845
diff
changeset
|
460 if (scenario.equals(WSPLGENJob.GEL_NOSPERRE)) { |
ccf2235035d6
Various bugfixes in WSPLGEN parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1845
diff
changeset
|
461 logger.debug("WSPLGEN will not use barrier features."); |
ccf2235035d6
Various bugfixes in WSPLGEN parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1845
diff
changeset
|
462 } |
ccf2235035d6
Various bugfixes in WSPLGEN parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1845
diff
changeset
|
463 else { |
ccf2235035d6
Various bugfixes in WSPLGEN parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1845
diff
changeset
|
464 job.addLin(shapePolys.getAbsolutePath()); |
ccf2235035d6
Various bugfixes in WSPLGEN parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1845
diff
changeset
|
465 } |
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
|
466 } |
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
|
467 |
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
|
468 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
|
469 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
|
470 } |
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
|
471 } |
005c2964f9af
Use the correct SRID while reading GeoJSON barriers and writing line/polygon shapefiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1106
diff
changeset
|
472 |
005c2964f9af
Use the correct SRID while reading GeoJSON barriers and writing line/polygon shapefiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1106
diff
changeset
|
473 |
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
|
474 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
|
475 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
|
476 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
|
477 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
|
478 ) { |
1707
3bf464ec436f
Added a further attribute to the feature type description for barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1650
diff
changeset
|
479 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
|
480 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
|
481 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
|
482 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
|
483 |
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
|
484 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
|
485 } |
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
|
486 |
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
|
487 |
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
|
488 protected FeatureCollection[] splitLinesAndPolygons(List<SimpleFeature> f) { |
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
|
489 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
|
490 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
|
491 |
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
|
492 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
|
493 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
|
494 |
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
|
495 |
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
|
496 if (geom instanceof LineString) { |
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
|
497 geom = applyElevationAttribute(feature, (LineString) 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
|
498 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
|
499 } |
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
|
500 else if (geom instanceof Polygon) { |
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
|
501 geom = applyElevationAttribute(feature, (Polygon) 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
|
502 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
|
503 } |
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
|
504 else { |
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
|
505 logger.warn("Feature not supported: " + geom.getClass()); |
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
|
506 } |
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
|
507 } |
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
|
508 |
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
|
509 logger.debug("Found " + lines.size() + " barrier 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
|
510 logger.debug("Found " + polygons.size() + " barrier 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
|
511 |
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
|
512 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
|
513 } |
1108
5b1198c27d43
Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1107
diff
changeset
|
514 |
5b1198c27d43
Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1107
diff
changeset
|
515 |
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
|
516 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
|
517 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
|
518 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
|
519 ) { |
be9bb260b835
Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1121
diff
changeset
|
520 logger.debug("Apply elevations for: " + geom.getClass()); |
be9bb260b835
Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1121
diff
changeset
|
521 |
be9bb260b835
Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1121
diff
changeset
|
522 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
|
523 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
|
524 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
|
525 |
be9bb260b835
Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1121
diff
changeset
|
526 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
|
527 |
be9bb260b835
Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1121
diff
changeset
|
528 if (numPoints > 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
|
529 logger.warn("More vertices in Geometry than elevations given."); |
be9bb260b835
Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1121
diff
changeset
|
530 } |
be9bb260b835
Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1121
diff
changeset
|
531 |
be9bb260b835
Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1121
diff
changeset
|
532 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
|
533 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
|
534 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
|
535 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
|
536 } |
be9bb260b835
Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1121
diff
changeset
|
537 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
|
538 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
|
539 } |
be9bb260b835
Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1121
diff
changeset
|
540 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
|
541 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
|
542 } |
be9bb260b835
Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1121
diff
changeset
|
543 } |
be9bb260b835
Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1121
diff
changeset
|
544 |
be9bb260b835
Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1121
diff
changeset
|
545 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
|
546 } |
be9bb260b835
Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1121
diff
changeset
|
547 |
be9bb260b835
Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1121
diff
changeset
|
548 |
be9bb260b835
Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1121
diff
changeset
|
549 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
|
550 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
|
551 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
|
552 |
be9bb260b835
Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1121
diff
changeset
|
553 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
|
554 |
be9bb260b835
Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1121
diff
changeset
|
555 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
|
556 |
be9bb260b835
Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1121
diff
changeset
|
557 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
|
558 |
be9bb260b835
Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1121
diff
changeset
|
559 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
|
560 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
|
561 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
|
562 } |
be9bb260b835
Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1121
diff
changeset
|
563 catch (NumberFormatException nfe) { |
be9bb260b835
Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1121
diff
changeset
|
564 logger.warn("Error while parsing elevation at pos: " + 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
|
565 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
|
566 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
|
567 } |
be9bb260b835
Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1121
diff
changeset
|
568 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
|
569 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
|
570 } |
be9bb260b835
Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1121
diff
changeset
|
571 } |
be9bb260b835
Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1121
diff
changeset
|
572 } |
be9bb260b835
Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1121
diff
changeset
|
573 |
be9bb260b835
Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1121
diff
changeset
|
574 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
|
575 } |
be9bb260b835
Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1121
diff
changeset
|
576 |
be9bb260b835
Set the Z values of line and polygon barrier geometries used for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1121
diff
changeset
|
577 |
1108
5b1198c27d43
Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1107
diff
changeset
|
578 protected void setAxis(FLYSArtifact artifact, File dir, WSPLGENJob job) { |
5b1198c27d43
Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1107
diff
changeset
|
579 String river = artifact.getDataAsString("river"); |
5b1198c27d43
Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1107
diff
changeset
|
580 String srid = FLYSUtils.getRiverSrid(artifact); |
5b1198c27d43
Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1107
diff
changeset
|
581 String srs = "EPSG:" + srid; |
5b1198c27d43
Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1107
diff
changeset
|
582 |
2078
cbeeaaad1056
#440 Support river axes that consist of more than a single geometry.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1970
diff
changeset
|
583 List<RiverAxis> axes = RiverAxis.getRiverAxis(river); |
cbeeaaad1056
#440 Support river axes that consist of more than a single geometry.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1970
diff
changeset
|
584 if (axes == null || axes.size() == 0) { |
1108
5b1198c27d43
Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1107
diff
changeset
|
585 logger.warn("Could not find river axis for: '" + river + "'"); |
5b1198c27d43
Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1107
diff
changeset
|
586 return; |
5b1198c27d43
Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1107
diff
changeset
|
587 } |
5b1198c27d43
Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1107
diff
changeset
|
588 |
5b1198c27d43
Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1107
diff
changeset
|
589 SimpleFeatureType ft = GeometryUtils.buildFeatureType( |
5b1198c27d43
Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1107
diff
changeset
|
590 "axis", srs, LineString.class); |
5b1198c27d43
Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1107
diff
changeset
|
591 |
5b1198c27d43
Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1107
diff
changeset
|
592 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
|
593 FeatureCollection collection = FeatureCollections.newCollection(); |
1108
5b1198c27d43
Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1107
diff
changeset
|
594 |
2078
cbeeaaad1056
#440 Support river axes that consist of more than a single geometry.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1970
diff
changeset
|
595 for (int i = 0, n = axes.size(); i < n; i++) { |
cbeeaaad1056
#440 Support river axes that consist of more than a single geometry.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1970
diff
changeset
|
596 RiverAxis axis = axes.get(i); |
cbeeaaad1056
#440 Support river axes that consist of more than a single geometry.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1970
diff
changeset
|
597 |
cbeeaaad1056
#440 Support river axes that consist of more than a single geometry.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1970
diff
changeset
|
598 builder.add(axis.getGeom()); |
cbeeaaad1056
#440 Support river axes that consist of more than a single geometry.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1970
diff
changeset
|
599 collection.add(builder.buildFeature(String.valueOf(i))); |
cbeeaaad1056
#440 Support river axes that consist of more than a single geometry.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1970
diff
changeset
|
600 |
cbeeaaad1056
#440 Support river axes that consist of more than a single geometry.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1970
diff
changeset
|
601 builder.reset(); |
cbeeaaad1056
#440 Support river axes that consist of more than a single geometry.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1970
diff
changeset
|
602 } |
1108
5b1198c27d43
Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1107
diff
changeset
|
603 |
5b1198c27d43
Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1107
diff
changeset
|
604 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
|
605 |
1121
66783d957201
Close open shapefile transactions properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1120
diff
changeset
|
606 boolean a = GeometryUtils.writeShapefile( |
66783d957201
Close open shapefile transactions properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1120
diff
changeset
|
607 axisShape, |
66783d957201
Close open shapefile transactions properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1120
diff
changeset
|
608 GeometryUtils.buildFeatureType("axis", srs, LineString.class), |
66783d957201
Close open shapefile transactions properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1120
diff
changeset
|
609 collection); |
66783d957201
Close open shapefile transactions properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1120
diff
changeset
|
610 |
66783d957201
Close open shapefile transactions properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1120
diff
changeset
|
611 if (a) { |
1108
5b1198c27d43
Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1107
diff
changeset
|
612 job.setAxis(axisShape.getAbsolutePath()); |
5b1198c27d43
Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1107
diff
changeset
|
613 } |
5b1198c27d43
Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1107
diff
changeset
|
614 } |
5b1198c27d43
Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1107
diff
changeset
|
615 |
5b1198c27d43
Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1107
diff
changeset
|
616 |
5b1198c27d43
Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1107
diff
changeset
|
617 protected void setPro(FLYSArtifact artifact, File dir, WSPLGENJob job) { |
5b1198c27d43
Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1107
diff
changeset
|
618 String river = artifact.getDataAsString("river"); |
5b1198c27d43
Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1107
diff
changeset
|
619 String srid = FLYSUtils.getRiverSrid(artifact); |
5b1198c27d43
Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1107
diff
changeset
|
620 String srs = "EPSG:" + srid; |
5b1198c27d43
Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1107
diff
changeset
|
621 |
5b1198c27d43
Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1107
diff
changeset
|
622 List<CrossSectionTrack> cst = |
5b1198c27d43
Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1107
diff
changeset
|
623 CrossSectionTrack.getCrossSectionTrack(river); |
5b1198c27d43
Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1107
diff
changeset
|
624 |
5b1198c27d43
Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1107
diff
changeset
|
625 logger.debug("Found " + cst.size() + " CrossSectionTracks."); |
5b1198c27d43
Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1107
diff
changeset
|
626 |
1119
faca1825818e
Write additional attributes ELEVATION and KILOMETER into crosssection track shapefiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1118
diff
changeset
|
627 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
|
628 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
|
629 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
|
630 |
1108
5b1198c27d43
Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1107
diff
changeset
|
631 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
|
632 "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
|
633 |
5b1198c27d43
Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1107
diff
changeset
|
634 SimpleFeatureBuilder builder = new SimpleFeatureBuilder(ft); |
5b1198c27d43
Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1107
diff
changeset
|
635 FeatureCollection collection = FeatureCollections.newCollection(); |
5b1198c27d43
Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1107
diff
changeset
|
636 |
5b1198c27d43
Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1107
diff
changeset
|
637 int i = 0; |
5b1198c27d43
Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1107
diff
changeset
|
638 for (CrossSectionTrack track: cst) { |
5b1198c27d43
Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1107
diff
changeset
|
639 builder.reset(); |
5b1198c27d43
Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1107
diff
changeset
|
640 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
|
641 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
|
642 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
|
643 |
5b1198c27d43
Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1107
diff
changeset
|
644 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
|
645 } |
5b1198c27d43
Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1107
diff
changeset
|
646 |
5b1198c27d43
Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1107
diff
changeset
|
647 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
|
648 |
1121
66783d957201
Close open shapefile transactions properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1120
diff
changeset
|
649 boolean q = GeometryUtils.writeShapefile( |
66783d957201
Close open shapefile transactions properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1120
diff
changeset
|
650 qpsShape, |
66783d957201
Close open shapefile transactions properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1120
diff
changeset
|
651 GeometryUtils.buildFeatureType("qps", srs, LineString.class, attrs), |
66783d957201
Close open shapefile transactions properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1120
diff
changeset
|
652 collection); |
66783d957201
Close open shapefile transactions properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1120
diff
changeset
|
653 |
66783d957201
Close open shapefile transactions properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1120
diff
changeset
|
654 if (q) { |
1108
5b1198c27d43
Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1107
diff
changeset
|
655 job.setPro(qpsShape.getAbsolutePath()); |
5b1198c27d43
Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1107
diff
changeset
|
656 } |
5b1198c27d43
Export riveraxis and crosssections to shapefiles for WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1107
diff
changeset
|
657 } |
1109
ba9fa72dd6f5
Write file path of DMGs into the WSPLGEN job while preparing WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1108
diff
changeset
|
658 |
ba9fa72dd6f5
Write file path of DMGs into the WSPLGEN job while preparing WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1108
diff
changeset
|
659 |
ba9fa72dd6f5
Write file path of DMGs into the WSPLGEN job while preparing WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1108
diff
changeset
|
660 protected void setDgm(FLYSArtifact artifact, WSPLGENJob job) { |
1186
be8b5c06a1f8
Use DGM Id in FLYSArtifact's data pool to query DGMs for floodmaps instead of querying DGMs by given range values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
661 String dgm_id = artifact.getDataAsString("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
|
662 |
1186
be8b5c06a1f8
Use DGM Id in FLYSArtifact's data pool to query DGMs for floodmaps instead of querying DGMs by given range values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
663 int id = -1; |
be8b5c06a1f8
Use DGM Id in FLYSArtifact's data pool to query DGMs for floodmaps instead of querying DGMs by given range values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
664 try { |
be8b5c06a1f8
Use DGM Id in FLYSArtifact's data pool to query DGMs for floodmaps instead of querying DGMs by given range values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
665 id = Integer.parseInt(dgm_id); |
be8b5c06a1f8
Use DGM Id in FLYSArtifact's data pool to query DGMs for floodmaps instead of querying DGMs by given range values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
666 } |
be8b5c06a1f8
Use DGM Id in FLYSArtifact's data pool to query DGMs for floodmaps instead of querying DGMs by given range values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
667 catch (NumberFormatException nfe) { /* do nothing */ } |
be8b5c06a1f8
Use DGM Id in FLYSArtifact's data pool to query DGMs for floodmaps instead of querying DGMs by given range values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
668 |
be8b5c06a1f8
Use DGM Id in FLYSArtifact's data pool to query DGMs for floodmaps instead of querying DGMs by given range values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
669 DGM dgm = DGM.getDGM(id); |
1109
ba9fa72dd6f5
Write file path of DMGs into the WSPLGEN job while preparing WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1108
diff
changeset
|
670 |
ba9fa72dd6f5
Write file path of DMGs into the WSPLGEN job while preparing WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1108
diff
changeset
|
671 if (dgm == null) { |
1186
be8b5c06a1f8
Use DGM Id in FLYSArtifact's data pool to query DGMs for floodmaps instead of querying DGMs by given range values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1178
diff
changeset
|
672 logger.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
|
673 |
ba9fa72dd6f5
Write file path of DMGs into the WSPLGEN job while preparing WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1108
diff
changeset
|
674 return; |
ba9fa72dd6f5
Write file path of DMGs into the WSPLGEN job while preparing WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1108
diff
changeset
|
675 } |
ba9fa72dd6f5
Write file path of DMGs into the WSPLGEN job while preparing WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1108
diff
changeset
|
676 |
ba9fa72dd6f5
Write file path of DMGs into the WSPLGEN job while preparing WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1108
diff
changeset
|
677 job.setDgm(dgm.getPath()); |
ba9fa72dd6f5
Write file path of DMGs into the WSPLGEN job while preparing WSPLGEN.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1108
diff
changeset
|
678 } |
1110
563e015f0f22
Export floodplain to shapefile and add its file path to WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1109
diff
changeset
|
679 |
563e015f0f22
Export floodplain to shapefile and add its file path to WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1109
diff
changeset
|
680 |
563e015f0f22
Export floodplain to shapefile and add its file path to WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1109
diff
changeset
|
681 protected void setArea(FLYSArtifact artifact, File dir, WSPLGENJob job) { |
1955
ccf2235035d6
Various bugfixes in WSPLGEN parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1845
diff
changeset
|
682 String useFloodplain = artifact.getDataAsString("use_floodplain"); |
ccf2235035d6
Various bugfixes in WSPLGEN parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1845
diff
changeset
|
683 if (!Boolean.valueOf(useFloodplain)) { |
ccf2235035d6
Various bugfixes in WSPLGEN parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1845
diff
changeset
|
684 logger.debug("WSPLGEN will not use floodplain."); |
ccf2235035d6
Various bugfixes in WSPLGEN parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1845
diff
changeset
|
685 return; |
ccf2235035d6
Various bugfixes in WSPLGEN parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1845
diff
changeset
|
686 } |
ccf2235035d6
Various bugfixes in WSPLGEN parameterization.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1845
diff
changeset
|
687 |
1110
563e015f0f22
Export floodplain to shapefile and add its file path to WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1109
diff
changeset
|
688 String river = artifact.getDataAsString("river"); |
563e015f0f22
Export floodplain to shapefile and add its file path to WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1109
diff
changeset
|
689 String srid = FLYSUtils.getRiverSrid(artifact); |
563e015f0f22
Export floodplain to shapefile and add its file path to WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1109
diff
changeset
|
690 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
|
691 |
563e015f0f22
Export floodplain to shapefile and add its file path to WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1109
diff
changeset
|
692 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
|
693 |
563e015f0f22
Export floodplain to shapefile and add its file path to WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1109
diff
changeset
|
694 SimpleFeatureType ft = GeometryUtils.buildFeatureType( |
1845
06c157848c8f
Made the floodmap compatible with an Oracle database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1782
diff
changeset
|
695 "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
|
696 |
563e015f0f22
Export floodplain to shapefile and add its file path to WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1109
diff
changeset
|
697 SimpleFeatureBuilder builder = new SimpleFeatureBuilder(ft); |
563e015f0f22
Export floodplain to shapefile and add its file path to WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1109
diff
changeset
|
698 builder.add(plain.getGeom()); |
563e015f0f22
Export floodplain to shapefile and add its file path to WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1109
diff
changeset
|
699 |
563e015f0f22
Export floodplain to shapefile and add its file path to WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1109
diff
changeset
|
700 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
|
701 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
|
702 |
563e015f0f22
Export floodplain to shapefile and add its file path to WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1109
diff
changeset
|
703 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
|
704 |
1121
66783d957201
Close open shapefile transactions properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1120
diff
changeset
|
705 boolean t = GeometryUtils.writeShapefile( |
66783d957201
Close open shapefile transactions properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1120
diff
changeset
|
706 talaueShape, |
1845
06c157848c8f
Made the floodmap compatible with an Oracle database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1782
diff
changeset
|
707 GeometryUtils.buildFeatureType("talaue", srs, Polygon.class), |
1121
66783d957201
Close open shapefile transactions properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1120
diff
changeset
|
708 collection); |
66783d957201
Close open shapefile transactions properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1120
diff
changeset
|
709 |
66783d957201
Close open shapefile transactions properly.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1120
diff
changeset
|
710 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
|
711 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
|
712 } |
563e015f0f22
Export floodplain to shapefile and add its file path to WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1109
diff
changeset
|
713 } |
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
|
714 |
7398280b11a0
Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1110
diff
changeset
|
715 |
7398280b11a0
Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1110
diff
changeset
|
716 protected void setOutFile(FLYSArtifact artifact, 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
|
717 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
|
718 } |
7398280b11a0
Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1110
diff
changeset
|
719 |
7398280b11a0
Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1110
diff
changeset
|
720 |
1178
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1168
diff
changeset
|
721 protected WQKms getWQKms(FLYSArtifact flys, CallContext cc) { |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1168
diff
changeset
|
722 String wspString = flys.getDataAsString(WSP_ARTIFACT); |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1168
diff
changeset
|
723 String[] parts = wspString.split(";"); |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1168
diff
changeset
|
724 |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1168
diff
changeset
|
725 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
|
726 |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1168
diff
changeset
|
727 int idx = -1; |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1168
diff
changeset
|
728 try { |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1168
diff
changeset
|
729 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
|
730 } |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1168
diff
changeset
|
731 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
|
732 |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1168
diff
changeset
|
733 FLYSArtifact src = otherArtifact != null |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1168
diff
changeset
|
734 ? FLYSUtils.getArtifact(otherArtifact, cc) |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1168
diff
changeset
|
735 : flys; |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1168
diff
changeset
|
736 |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1168
diff
changeset
|
737 logger.debug("Use waterlevel provided by Artifact: " + src.identifier()); |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1168
diff
changeset
|
738 |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1168
diff
changeset
|
739 CalculationResult rawData = (CalculationResult) src.compute( |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1168
diff
changeset
|
740 cc, |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1168
diff
changeset
|
741 null, |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1168
diff
changeset
|
742 WINFO_WSP_STATE_ID, |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1168
diff
changeset
|
743 ComputeType.ADVANCE, |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1168
diff
changeset
|
744 false); |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1168
diff
changeset
|
745 |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1168
diff
changeset
|
746 WQKms[] wqkms = (WQKms[]) rawData.getData(); |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1168
diff
changeset
|
747 |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1168
diff
changeset
|
748 return wqkms == null || idx == -1 || idx >= wqkms.length |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1168
diff
changeset
|
749 ? null |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1168
diff
changeset
|
750 : wqkms[idx]; |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1168
diff
changeset
|
751 } |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1168
diff
changeset
|
752 |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1168
diff
changeset
|
753 |
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
|
754 protected void setWsp( |
7398280b11a0
Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1110
diff
changeset
|
755 FLYSArtifact artifact, |
7398280b11a0
Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1110
diff
changeset
|
756 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
|
757 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
|
758 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
|
759 { |
7398280b11a0
Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1110
diff
changeset
|
760 logger.debug("FloodMapState.setWsp"); |
7398280b11a0
Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1110
diff
changeset
|
761 |
1178
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1168
diff
changeset
|
762 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
|
763 |
1178
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1168
diff
changeset
|
764 if (data == null) { |
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
|
765 logger.warn("No WST data found!"); |
7398280b11a0
Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1110
diff
changeset
|
766 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
|
767 } |
7398280b11a0
Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1110
diff
changeset
|
768 |
1178
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1168
diff
changeset
|
769 WstWriter writer = new WstWriter(1); |
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
|
770 |
7398280b11a0
Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1110
diff
changeset
|
771 // 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
|
772 // 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
|
773 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
|
774 |
7398280b11a0
Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1110
diff
changeset
|
775 double[] buf = new double[4]; |
1178
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1168
diff
changeset
|
776 logger.debug("Add WST column: " + data.getName()); |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1168
diff
changeset
|
777 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
|
778 |
1178
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1168
diff
changeset
|
779 if (writeWspTag) { |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1168
diff
changeset
|
780 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
|
781 writeWspTag = false; |
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1168
diff
changeset
|
782 } |
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
|
783 |
1178
1b432c260e97
Enabled the FloodMapState to fetch waterlevel data from external Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1168
diff
changeset
|
784 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
|
785 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
|
786 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
|
787 } |
7398280b11a0
Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1110
diff
changeset
|
788 |
7398280b11a0
Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1110
diff
changeset
|
789 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
|
790 |
7398280b11a0
Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1110
diff
changeset
|
791 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
|
792 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
|
793 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
|
794 |
7398280b11a0
Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1110
diff
changeset
|
795 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
|
796 |
7398280b11a0
Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1110
diff
changeset
|
797 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
|
798 } |
7398280b11a0
Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1110
diff
changeset
|
799 catch (FileNotFoundException fnfe) { |
7398280b11a0
Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1110
diff
changeset
|
800 logger.warn("Error while writing wsp file: " + fnfe.getMessage()); |
7398280b11a0
Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1110
diff
changeset
|
801 } |
7398280b11a0
Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1110
diff
changeset
|
802 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
|
803 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
|
804 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
|
805 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
|
806 } |
7398280b11a0
Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1110
diff
changeset
|
807 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
|
808 } |
7398280b11a0
Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1110
diff
changeset
|
809 } |
7398280b11a0
Write WSP file for WSPLGEN and add its filepath to the WSPLGEN job.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1110
diff
changeset
|
810 } |
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
|
811 } |
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
|
812 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |