Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/utils/RiverMapfileGenerator.java @ 4798:39885bdfc6fc
Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse".
This is done by figuring out the WST columns that imfold the data and then do
simple "gleichwertige" calculations from the start of the interval. This
is too much because only the Qs are needed for the "Umhuellende".
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Sun, 13 Jan 2013 16:18:28 +0100 |
parents | d93748043cbc |
children | 8062b571884d |
rev | line source |
---|---|
4654
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.utils; |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
2 |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
3 import de.intevation.flys.artifacts.model.LayerInfo; |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
4 import de.intevation.flys.artifacts.model.RiverFactory; |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
5 import de.intevation.flys.model.River; |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
6 |
4656
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
7 import java.io.File; |
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
8 import java.io.FileNotFoundException; |
4702
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
4656
diff
changeset
|
9 import java.util.ArrayList; |
4654
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
10 import java.util.List; |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
11 |
4656
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
12 import org.apache.log4j.Logger; |
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
13 import org.apache.velocity.Template; |
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
14 |
4654
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
15 public class RiverMapfileGenerator extends MapfileGenerator { |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
16 |
4703
38ec171544de
Work on rivers.map Generator.
Christian Lins <christian.lins@intevation.de>
parents:
4702
diff
changeset
|
17 public static final String XPATH_RIVERMAP_RIVER_PROJECTION = |
38ec171544de
Work on rivers.map Generator.
Christian Lins <christian.lins@intevation.de>
parents:
4702
diff
changeset
|
18 "/artifact-database/rivermap/river[@name=$name]/srid/@value"; |
38ec171544de
Work on rivers.map Generator.
Christian Lins <christian.lins@intevation.de>
parents:
4702
diff
changeset
|
19 |
38ec171544de
Work on rivers.map Generator.
Christian Lins <christian.lins@intevation.de>
parents:
4702
diff
changeset
|
20 public static final String XPATH_RIVERMAP_SHAPEFILE_DIR = |
38ec171544de
Work on rivers.map Generator.
Christian Lins <christian.lins@intevation.de>
parents:
4702
diff
changeset
|
21 "/artifact-database/rivermap/shapefile-path/@value"; |
38ec171544de
Work on rivers.map Generator.
Christian Lins <christian.lins@intevation.de>
parents:
4702
diff
changeset
|
22 |
38ec171544de
Work on rivers.map Generator.
Christian Lins <christian.lins@intevation.de>
parents:
4702
diff
changeset
|
23 public static final String XPATH_RIVERMAP_VELOCITY_LOGFILE = |
38ec171544de
Work on rivers.map Generator.
Christian Lins <christian.lins@intevation.de>
parents:
4702
diff
changeset
|
24 "/artifact-database/rivermap/velocity/logfile/@path"; |
38ec171544de
Work on rivers.map Generator.
Christian Lins <christian.lins@intevation.de>
parents:
4702
diff
changeset
|
25 |
38ec171544de
Work on rivers.map Generator.
Christian Lins <christian.lins@intevation.de>
parents:
4702
diff
changeset
|
26 public static final String XPATH_RIVERMAP_MAPSERVER_URL = |
38ec171544de
Work on rivers.map Generator.
Christian Lins <christian.lins@intevation.de>
parents:
4702
diff
changeset
|
27 "/artifact-database/rivermap/mapserver/server/@path"; |
38ec171544de
Work on rivers.map Generator.
Christian Lins <christian.lins@intevation.de>
parents:
4702
diff
changeset
|
28 |
38ec171544de
Work on rivers.map Generator.
Christian Lins <christian.lins@intevation.de>
parents:
4702
diff
changeset
|
29 public static final String XPATH_RIVERMAP_MAPFILE_PATH = |
38ec171544de
Work on rivers.map Generator.
Christian Lins <christian.lins@intevation.de>
parents:
4702
diff
changeset
|
30 "/artifact-database/rivermap/mapserver/mapfile/@path"; |
38ec171544de
Work on rivers.map Generator.
Christian Lins <christian.lins@intevation.de>
parents:
4702
diff
changeset
|
31 |
38ec171544de
Work on rivers.map Generator.
Christian Lins <christian.lins@intevation.de>
parents:
4702
diff
changeset
|
32 public static final String XPATH_RIVERMAP_MAPFILE_TEMPLATE = |
38ec171544de
Work on rivers.map Generator.
Christian Lins <christian.lins@intevation.de>
parents:
4702
diff
changeset
|
33 "/artifact-database/rivermap/mapserver/map-template/@path"; |
38ec171544de
Work on rivers.map Generator.
Christian Lins <christian.lins@intevation.de>
parents:
4702
diff
changeset
|
34 |
38ec171544de
Work on rivers.map Generator.
Christian Lins <christian.lins@intevation.de>
parents:
4702
diff
changeset
|
35 public static final String XPATH_RIVERMAP_MAPSERVER_TEMPLATE_PATH = |
38ec171544de
Work on rivers.map Generator.
Christian Lins <christian.lins@intevation.de>
parents:
4702
diff
changeset
|
36 "/artifact-database/rivermap/mapserver/templates/@path"; |
38ec171544de
Work on rivers.map Generator.
Christian Lins <christian.lins@intevation.de>
parents:
4702
diff
changeset
|
37 |
4656
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
38 private static Logger logger = Logger.getLogger(RiverMapfileGenerator.class); |
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
39 |
4654
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
40 /** |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
41 * Generate river axis mapfile. |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
42 */ |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
43 @Override |
4656
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
44 public void generate() { |
4702
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
4656
diff
changeset
|
45 logger.debug("generate()"); |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
4656
diff
changeset
|
46 |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
4656
diff
changeset
|
47 List<River> rivers = RiverFactory.getRivers(); |
4703
38ec171544de
Work on rivers.map Generator.
Christian Lins <christian.lins@intevation.de>
parents:
4702
diff
changeset
|
48 List<String> riverFiles = new ArrayList<String>(); |
4654
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
49 |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
50 for (River river : rivers) { |
4703
38ec171544de
Work on rivers.map Generator.
Christian Lins <christian.lins@intevation.de>
parents:
4702
diff
changeset
|
51 createRiverAxisLayer( |
4654
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
52 river.getName(), |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
53 river.getId(), |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
54 "41677", |
4738
d93748043cbc
Little work on the RiverMapfileGenerator.
Christian Lins <christian.lins@intevation.de>
parents:
4703
diff
changeset
|
55 "-10000 -10000 10000 10000"); |
4703
38ec171544de
Work on rivers.map Generator.
Christian Lins <christian.lins@intevation.de>
parents:
4702
diff
changeset
|
56 riverFiles.add("river-" + river.getName() + ".map"); |
4654
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
57 } |
4703
38ec171544de
Work on rivers.map Generator.
Christian Lins <christian.lins@intevation.de>
parents:
4702
diff
changeset
|
58 writeMapfile(riverFiles); |
4654
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
59 } |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
60 |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
61 protected void createRiverAxisLayer(String riverName, int riverID, String srid, String extend) { |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
62 LayerInfo layerInfo = new LayerInfo(); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
63 layerInfo.setName(riverName); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
64 layerInfo.setSrid(srid); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
65 layerInfo.setExtent(extend); |
4738
d93748043cbc
Little work on the RiverMapfileGenerator.
Christian Lins <christian.lins@intevation.de>
parents:
4703
diff
changeset
|
66 layerInfo.setType("line"); |
d93748043cbc
Little work on the RiverMapfileGenerator.
Christian Lins <christian.lins@intevation.de>
parents:
4703
diff
changeset
|
67 layerInfo.setData("geom FROM river_axis"); // FIXME: Use templates for that |
d93748043cbc
Little work on the RiverMapfileGenerator.
Christian Lins <christian.lins@intevation.de>
parents:
4703
diff
changeset
|
68 layerInfo.setFilter("river_id = " + riverID); |
d93748043cbc
Little work on the RiverMapfileGenerator.
Christian Lins <christian.lins@intevation.de>
parents:
4703
diff
changeset
|
69 layerInfo.setTitle(riverName + " RiverAxis"); |
4656
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
70 |
4703
38ec171544de
Work on rivers.map Generator.
Christian Lins <christian.lins@intevation.de>
parents:
4702
diff
changeset
|
71 File layerFile = new File("river-" + riverName + ".map"); |
4738
d93748043cbc
Little work on the RiverMapfileGenerator.
Christian Lins <christian.lins@intevation.de>
parents:
4703
diff
changeset
|
72 Template template = getTemplateByName("riveraxis-layer.vm"); |
4656
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
73 if (template == null) { |
4738
d93748043cbc
Little work on the RiverMapfileGenerator.
Christian Lins <christian.lins@intevation.de>
parents:
4703
diff
changeset
|
74 logger.warn("Template riveraxis-layer.vm not found."); |
4656
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
75 return; |
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
76 } |
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
77 |
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
78 try { |
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
79 writeLayer(layerInfo, layerFile, template); |
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
80 } |
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
81 catch (FileNotFoundException e) { |
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
82 logger.warn(e.getLocalizedMessage(), e); |
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
83 } |
4654
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
84 } |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
85 |
4656
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
86 @Override |
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
87 protected String getVelocityLogfile() { |
4703
38ec171544de
Work on rivers.map Generator.
Christian Lins <christian.lins@intevation.de>
parents:
4702
diff
changeset
|
88 return FLYSUtils.getXPathString(XPATH_RIVERMAP_VELOCITY_LOGFILE); |
4656
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
89 } |
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
90 |
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
91 @Override |
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
92 protected String getMapserverTemplatePath() { |
4703
38ec171544de
Work on rivers.map Generator.
Christian Lins <christian.lins@intevation.de>
parents:
4702
diff
changeset
|
93 return FLYSUtils.getXPathString(XPATH_RIVERMAP_MAPSERVER_TEMPLATE_PATH); |
4656
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
94 } |
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
95 |
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
96 @Override |
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
97 protected String getMapserverUrl() { |
4703
38ec171544de
Work on rivers.map Generator.
Christian Lins <christian.lins@intevation.de>
parents:
4702
diff
changeset
|
98 return FLYSUtils.getXPathString(XPATH_RIVERMAP_MAPSERVER_URL); |
4656
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
99 } |
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
100 |
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
101 @Override |
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
102 protected String getMapfilePath() { |
4703
38ec171544de
Work on rivers.map Generator.
Christian Lins <christian.lins@intevation.de>
parents:
4702
diff
changeset
|
103 return FLYSUtils.getXPathString(XPATH_RIVERMAP_MAPFILE_PATH); |
4656
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
104 } |
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
105 |
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
106 @Override |
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
107 protected String getMapfileTemplate() { |
4703
38ec171544de
Work on rivers.map Generator.
Christian Lins <christian.lins@intevation.de>
parents:
4702
diff
changeset
|
108 return FLYSUtils.getXPathString(XPATH_RIVERMAP_MAPFILE_TEMPLATE); |
4656
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
109 } |
4654
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
110 } |