Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/utils/MapfileGenerator.java @ 5502:566eea137330
Added i18n strings for static sq data.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Thu, 28 Mar 2013 15:17:52 +0100 |
parents | b55975761708 |
children |
rev | line source |
---|---|
1129
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.utils; |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 |
3303
96daa8a4c48f
Fix and workaround NullPointerExceptions
Christian Lins <christian.lins@intevation.de>
parents:
3302
diff
changeset
|
3 import de.intevation.artifacts.common.utils.Config; |
96daa8a4c48f
Fix and workaround NullPointerExceptions
Christian Lins <christian.lins@intevation.de>
parents:
3302
diff
changeset
|
4 import de.intevation.flys.artifacts.model.LayerInfo; |
96daa8a4c48f
Fix and workaround NullPointerExceptions
Christian Lins <christian.lins@intevation.de>
parents:
3302
diff
changeset
|
5 |
1129
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
6 import java.io.File; |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
7 import java.io.FileNotFoundException; |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
8 import java.io.FileWriter; |
3302
453d2d0c4258
Organized and added missing imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2669
diff
changeset
|
9 import java.io.FilenameFilter; |
1129
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 import java.io.IOException; |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
11 import java.io.Writer; |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
12 import java.util.ArrayList; |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
13 import java.util.Date; |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
14 import java.util.List; |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
15 |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
16 import org.apache.log4j.Logger; |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
17 import org.apache.velocity.Template; |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
18 import org.apache.velocity.VelocityContext; |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 import org.apache.velocity.app.VelocityEngine; |
4656
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
20 import org.apache.velocity.runtime.RuntimeConstants; |
1129
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
21 |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
22 /** |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
23 * This class iterates over a bunch of directories, searches for meta |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 * information coresponding to shapefiles and creates a mapfile which is used by |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 * a <i>MapServer</i>. |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
26 * |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
27 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
28 */ |
4654
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
4648
diff
changeset
|
29 public abstract class MapfileGenerator |
1129
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
30 { |
1134
bcf70a452646
Read barrier layers from filesystem while mapfile creation and build a facet for this layer in the artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1129
diff
changeset
|
31 public static final String WSPLGEN_RESULT_SHAPE = "wsplgen.shp"; |
bcf70a452646
Read barrier layers from filesystem while mapfile creation and build a facet for this layer in the artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1129
diff
changeset
|
32 public static final String WSPLGEN_LINES_SHAPE = "barrier_lines.shp"; |
bcf70a452646
Read barrier layers from filesystem while mapfile creation and build a facet for this layer in the artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1129
diff
changeset
|
33 public static final String WSPLGEN_POLYGONS_SHAPE = "barrier_polygons.shp"; |
2639
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
34 public static final String WSPLGEN_USER_SHAPE = "user-rgd.shp"; |
1134
bcf70a452646
Read barrier layers from filesystem while mapfile creation and build a facet for this layer in the artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1129
diff
changeset
|
35 |
2637
baaf7d125c43
Issue 560.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2616
diff
changeset
|
36 public static final String WSPLGEN_LAYER_TEMPLATE = "wsplgen_layer.vm"; |
1775
0156105222c9
Improved the MapfileGenerator. It offers methods to create barrier and wsplgen layer files for mapserver.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1710
diff
changeset
|
37 public static final String SHP_LAYER_TEMPLATE = "shapefile_layer.vm"; |
1792
49ad801076e4
Enabled the MapGenerator to create WMS layers with database datastore - riveraxis is the first layer that is no longer fetched from static WMS service but from user specific one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1781
diff
changeset
|
38 public static final String DB_LAYER_TEMPLATE = "db_layer.vm"; |
4648
c04db3178d09
Work on river axis mapfile generator.
Christian Lins <christian.lins@intevation.de>
parents:
4633
diff
changeset
|
39 public static final String RIVERAXIS_LAYER_TEMPLATE = "riveraxis-layer.vm"; |
1775
0156105222c9
Improved the MapfileGenerator. It offers methods to create barrier and wsplgen layer files for mapserver.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1710
diff
changeset
|
40 |
2639
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
41 public static final String MS_WSPLGEN_PREFIX = "wsplgen-"; |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
42 public static final String MS_BARRIERS_PREFIX = "barriers-"; |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
43 public static final String MS_LINE_PREFIX = "lines-"; |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
44 public static final String MS_POLYGONS_PREFIX = "polygons-"; |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
45 public static final String MS_LAYER_PREFIX = "ms_layer-"; |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
46 public static final String MS_USERSHAPE_PREFIX = "user-"; |
1129
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
47 |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
48 private static Logger logger = Logger.getLogger(MapfileGenerator.class); |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
49 |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
50 private File shapefileDirectory; |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
51 |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
52 private VelocityEngine velocityEngine; |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
53 |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
54 |
4654
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
4648
diff
changeset
|
55 protected MapfileGenerator() { |
1129
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
56 } |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
57 |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
58 |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
59 /** |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
60 * Method to check the existance of a template file. |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
61 * |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
62 * @param templateID The name of a template. |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
63 * @return true, of the template exists - otherwise false. |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
64 */ |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
65 public boolean templateExists(String templateID){ |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
66 Template template = getTemplateByName(templateID); |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
67 return template != null; |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
68 } |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
69 |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
70 |
4656
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
71 public abstract void generate() throws Exception; |
4648
c04db3178d09
Work on river axis mapfile generator.
Christian Lins <christian.lins@intevation.de>
parents:
4633
diff
changeset
|
72 |
c04db3178d09
Work on river axis mapfile generator.
Christian Lins <christian.lins@intevation.de>
parents:
4633
diff
changeset
|
73 |
c04db3178d09
Work on river axis mapfile generator.
Christian Lins <christian.lins@intevation.de>
parents:
4633
diff
changeset
|
74 /** |
1129
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
75 * Returns the VelocityEngine used for the template mechanism. |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
76 * |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
77 * @return the velocity engine. |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
78 */ |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
79 protected VelocityEngine getVelocityEngine() { |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
80 if (velocityEngine == null) { |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
81 velocityEngine = new VelocityEngine(); |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
82 try { |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
83 setupVelocity(velocityEngine); |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
84 } |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
85 catch (Exception e) { |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
86 logger.error(e, e); |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
87 return null; |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
88 } |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
89 } |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
90 return velocityEngine; |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
91 } |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
92 |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
93 |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
94 /** |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
95 * Initialize velocity. |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
96 * |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
97 * @param engine Velocity engine. |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
98 * @throws Exception if an error occured while initializing velocity. |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
99 */ |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
100 protected void setupVelocity(VelocityEngine engine) |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
101 throws Exception |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
102 { |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
103 engine.setProperty( |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
104 "input.encoding", |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
105 "UTF-8"); |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
106 |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
107 engine.setProperty( |
4656
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
108 RuntimeConstants.RUNTIME_LOG, |
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
109 getVelocityLogfile()); |
1129
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
110 |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
111 engine.setProperty( |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
112 "resource.loader", |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
113 "file"); |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
114 |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
115 engine.setProperty( |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
116 "file.resource.loader.path", |
4656
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
117 getMapserverTemplatePath()); |
1129
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
118 |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
119 engine.init(); |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
120 } |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
121 |
4656
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
122 protected abstract String getVelocityLogfile(); |
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
123 |
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
124 protected abstract String getMapserverTemplatePath(); |
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
125 |
5309
b55975761708
Changed visiblitiy of some methods. TODO: A lot of refactoring.
Raimund Renkert <rrenkert@intevation.de>
parents:
4703
diff
changeset
|
126 public abstract String getMapserverUrl(); |
1129
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
127 |
1792
49ad801076e4
Enabled the MapGenerator to create WMS layers with database datastore - riveraxis is the first layer that is no longer fetched from static WMS service but from user specific one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1781
diff
changeset
|
128 protected VelocityContext getVelocityContext() { |
49ad801076e4
Enabled the MapGenerator to create WMS layers with database datastore - riveraxis is the first layer that is no longer fetched from static WMS service but from user specific one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1781
diff
changeset
|
129 VelocityContext context = new VelocityContext(); |
49ad801076e4
Enabled the MapGenerator to create WMS layers with database datastore - riveraxis is the first layer that is no longer fetched from static WMS service but from user specific one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1781
diff
changeset
|
130 |
49ad801076e4
Enabled the MapGenerator to create WMS layers with database datastore - riveraxis is the first layer that is no longer fetched from static WMS service but from user specific one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1781
diff
changeset
|
131 try { |
49ad801076e4
Enabled the MapGenerator to create WMS layers with database datastore - riveraxis is the first layer that is no longer fetched from static WMS service but from user specific one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1781
diff
changeset
|
132 context.put("MAPSERVERURL", |
4656
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
133 getMapserverUrl()); |
1792
49ad801076e4
Enabled the MapGenerator to create WMS layers with database datastore - riveraxis is the first layer that is no longer fetched from static WMS service but from user specific one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1781
diff
changeset
|
134 context.put("SHAPEFILEPATH", |
49ad801076e4
Enabled the MapGenerator to create WMS layers with database datastore - riveraxis is the first layer that is no longer fetched from static WMS service but from user specific one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1781
diff
changeset
|
135 getShapefileBaseDir().getCanonicalPath()); |
49ad801076e4
Enabled the MapGenerator to create WMS layers with database datastore - riveraxis is the first layer that is no longer fetched from static WMS service but from user specific one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1781
diff
changeset
|
136 context.put("CONFIGDIR", |
49ad801076e4
Enabled the MapGenerator to create WMS layers with database datastore - riveraxis is the first layer that is no longer fetched from static WMS service but from user specific one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1781
diff
changeset
|
137 Config.getConfigDirectory().getCanonicalPath()); |
49ad801076e4
Enabled the MapGenerator to create WMS layers with database datastore - riveraxis is the first layer that is no longer fetched from static WMS service but from user specific one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1781
diff
changeset
|
138 } |
49ad801076e4
Enabled the MapGenerator to create WMS layers with database datastore - riveraxis is the first layer that is no longer fetched from static WMS service but from user specific one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1781
diff
changeset
|
139 catch (FileNotFoundException fnfe) { |
49ad801076e4
Enabled the MapGenerator to create WMS layers with database datastore - riveraxis is the first layer that is no longer fetched from static WMS service but from user specific one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1781
diff
changeset
|
140 // this is bad |
4633
fc52ee878412
Preparations for autogenerated riveraxis WMSs.
Christian Lins <christian.lins@intevation.de>
parents:
4047
diff
changeset
|
141 logger.warn(fnfe, fnfe); |
1792
49ad801076e4
Enabled the MapGenerator to create WMS layers with database datastore - riveraxis is the first layer that is no longer fetched from static WMS service but from user specific one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1781
diff
changeset
|
142 } |
49ad801076e4
Enabled the MapGenerator to create WMS layers with database datastore - riveraxis is the first layer that is no longer fetched from static WMS service but from user specific one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1781
diff
changeset
|
143 catch (IOException ioe) { |
49ad801076e4
Enabled the MapGenerator to create WMS layers with database datastore - riveraxis is the first layer that is no longer fetched from static WMS service but from user specific one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1781
diff
changeset
|
144 // this is also bad |
4633
fc52ee878412
Preparations for autogenerated riveraxis WMSs.
Christian Lins <christian.lins@intevation.de>
parents:
4047
diff
changeset
|
145 logger.warn(ioe, ioe); |
1792
49ad801076e4
Enabled the MapGenerator to create WMS layers with database datastore - riveraxis is the first layer that is no longer fetched from static WMS service but from user specific one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1781
diff
changeset
|
146 } |
49ad801076e4
Enabled the MapGenerator to create WMS layers with database datastore - riveraxis is the first layer that is no longer fetched from static WMS service but from user specific one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1781
diff
changeset
|
147 |
49ad801076e4
Enabled the MapGenerator to create WMS layers with database datastore - riveraxis is the first layer that is no longer fetched from static WMS service but from user specific one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1781
diff
changeset
|
148 return context; |
49ad801076e4
Enabled the MapGenerator to create WMS layers with database datastore - riveraxis is the first layer that is no longer fetched from static WMS service but from user specific one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1781
diff
changeset
|
149 } |
49ad801076e4
Enabled the MapGenerator to create WMS layers with database datastore - riveraxis is the first layer that is no longer fetched from static WMS service but from user specific one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1781
diff
changeset
|
150 |
49ad801076e4
Enabled the MapGenerator to create WMS layers with database datastore - riveraxis is the first layer that is no longer fetched from static WMS service but from user specific one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1781
diff
changeset
|
151 |
1129
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
152 /** |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
153 * Returns a template specified by <i>model</i>. |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
154 * |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
155 * @param model The name of the template. |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
156 * @return a template. |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
157 */ |
5309
b55975761708
Changed visiblitiy of some methods. TODO: A lot of refactoring.
Raimund Renkert <rrenkert@intevation.de>
parents:
4703
diff
changeset
|
158 public Template getTemplateByName(String model) { |
1129
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
159 if (model.indexOf(".vm") < 0) { |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
160 model = model.concat(".vm"); |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
161 } |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
162 |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
163 try { |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
164 VelocityEngine engine = getVelocityEngine(); |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
165 if (engine == null) { |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
166 logger.error("Error while fetching VelocityEngine."); |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
167 return null; |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
168 } |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
169 |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
170 return engine.getTemplate(model); |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
171 } |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
172 catch (Exception e) { |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
173 logger.warn(e, e); |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
174 } |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
175 |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
176 return null; |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
177 } |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
178 |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
179 |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
180 /** |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
181 * Returns the mapfile template. |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
182 * |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
183 * @return the mapfile template. |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
184 * @throws Exception if an error occured while reading the configuration. |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
185 */ |
4656
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
186 protected Template getMapfileTemplateObj() |
1129
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
187 throws Exception |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
188 { |
4703
38ec171544de
Work on rivers.map Generator.
Christian Lins <christian.lins@intevation.de>
parents:
4656
diff
changeset
|
189 String mapfileName = getMapfileTemplate(); |
1129
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
190 return getTemplateByName(mapfileName); |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
191 } |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
192 |
4656
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
193 protected abstract String getMapfilePath(); |
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
194 |
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
195 protected abstract String getMapfileTemplate(); |
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
196 |
1129
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
197 |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
198 /** |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
199 * Returns the base directory storing the shapefiles. |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
200 * |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
201 * @return the shapefile base directory. |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
202 * |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
203 * @throws FileNotFoundException if no shapefile path is found or |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
204 * configured. |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
205 */ |
1792
49ad801076e4
Enabled the MapGenerator to create WMS layers with database datastore - riveraxis is the first layer that is no longer fetched from static WMS service but from user specific one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1781
diff
changeset
|
206 public File getShapefileBaseDir() |
3306
1b41dc00b1f7
Create shapefile directory instead of shapefile 'file'
Christian Lins <christian.lins@intevation.de>
parents:
3303
diff
changeset
|
207 throws FileNotFoundException, IOException |
1129
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
208 { |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
209 if (shapefileDirectory == null) { |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
210 String path = FLYSUtils.getXPathString( |
4656
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
211 FLYSUtils.XPATH_FLOODMAP_SHAPEFILE_DIR); |
1129
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
212 |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
213 if (path != null) { |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
214 shapefileDirectory = new File(path); |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
215 } |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
216 |
1775
0156105222c9
Improved the MapfileGenerator. It offers methods to create barrier and wsplgen layer files for mapserver.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1710
diff
changeset
|
217 if (shapefileDirectory == null) { |
1129
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
218 throw new FileNotFoundException("No shapefile directory given"); |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
219 } |
1775
0156105222c9
Improved the MapfileGenerator. It offers methods to create barrier and wsplgen layer files for mapserver.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1710
diff
changeset
|
220 |
0156105222c9
Improved the MapfileGenerator. It offers methods to create barrier and wsplgen layer files for mapserver.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1710
diff
changeset
|
221 if (!shapefileDirectory.exists()) { |
3306
1b41dc00b1f7
Create shapefile directory instead of shapefile 'file'
Christian Lins <christian.lins@intevation.de>
parents:
3303
diff
changeset
|
222 shapefileDirectory.mkdirs(); |
1775
0156105222c9
Improved the MapfileGenerator. It offers methods to create barrier and wsplgen layer files for mapserver.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1710
diff
changeset
|
223 } |
1129
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
224 } |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
225 |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
226 return shapefileDirectory; |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
227 } |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
228 |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
229 |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
230 protected File[] getUserDirs() |
3306
1b41dc00b1f7
Create shapefile directory instead of shapefile 'file'
Christian Lins <christian.lins@intevation.de>
parents:
3303
diff
changeset
|
231 throws FileNotFoundException, IOException |
1129
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
232 { |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
233 File baseDir = getShapefileBaseDir(); |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
234 File[] artifactDirs = baseDir.listFiles(); |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
235 |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
236 // TODO ONLY RETURN DIRECTORIES OF THE SPECIFIED USER |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
237 |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
238 return artifactDirs; |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
239 } |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
240 |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
241 |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
242 |
1781
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
243 protected List<String> parseLayers(File[] dirs) { |
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
244 List<String> layers = new ArrayList<String>(); |
1129
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
245 |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
246 for (File dir: dirs) { |
1781
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
247 File[] layerFiles = dir.listFiles(new FilenameFilter() { |
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
248 @Override |
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
249 public boolean accept(File directory, String name) { |
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
250 return name.startsWith(MS_LAYER_PREFIX); |
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
251 } |
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
252 }); |
1129
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
253 |
1781
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
254 for (File layer: layerFiles) { |
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
255 try { |
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
256 layers.add(layer.getCanonicalPath()); |
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
257 } |
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
258 catch (IOException ioe) { |
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
259 logger.warn(ioe, ioe); |
1134
bcf70a452646
Read barrier layers from filesystem while mapfile creation and build a facet for this layer in the artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1129
diff
changeset
|
260 } |
1129
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
261 } |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
262 } |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
263 |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
264 return layers; |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
265 } |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
266 |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
267 |
1792
49ad801076e4
Enabled the MapGenerator to create WMS layers with database datastore - riveraxis is the first layer that is no longer fetched from static WMS service but from user specific one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1781
diff
changeset
|
268 |
49ad801076e4
Enabled the MapGenerator to create WMS layers with database datastore - riveraxis is the first layer that is no longer fetched from static WMS service but from user specific one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1781
diff
changeset
|
269 |
49ad801076e4
Enabled the MapGenerator to create WMS layers with database datastore - riveraxis is the first layer that is no longer fetched from static WMS service but from user specific one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1781
diff
changeset
|
270 /** |
1781
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
271 * Creates a layer snippet which might be included in the mapfile. |
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
272 * |
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
273 * @param layerinfo A LayerInfo object that contains all necessary |
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
274 * information to build a Mapserver LAYER section. |
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
275 * @param dir The base dir for the LAYER snippet. |
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
276 * @param filename The name of the file that is written. |
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
277 * @param tpl The Velocity template which is used to create the LAYER |
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
278 * section. |
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
279 */ |
5309
b55975761708
Changed visiblitiy of some methods. TODO: A lot of refactoring.
Raimund Renkert <rrenkert@intevation.de>
parents:
4703
diff
changeset
|
280 public void writeLayer( |
4656
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
281 LayerInfo layerInfo, |
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
282 File layerFile, |
1775
0156105222c9
Improved the MapfileGenerator. It offers methods to create barrier and wsplgen layer files for mapserver.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1710
diff
changeset
|
283 Template tpl |
0156105222c9
Improved the MapfileGenerator. It offers methods to create barrier and wsplgen layer files for mapserver.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1710
diff
changeset
|
284 ) |
0156105222c9
Improved the MapfileGenerator. It offers methods to create barrier and wsplgen layer files for mapserver.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1710
diff
changeset
|
285 throws FileNotFoundException |
0156105222c9
Improved the MapfileGenerator. It offers methods to create barrier and wsplgen layer files for mapserver.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1710
diff
changeset
|
286 { |
0156105222c9
Improved the MapfileGenerator. It offers methods to create barrier and wsplgen layer files for mapserver.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1710
diff
changeset
|
287 if (logger.isDebugEnabled()) { |
0156105222c9
Improved the MapfileGenerator. It offers methods to create barrier and wsplgen layer files for mapserver.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1710
diff
changeset
|
288 logger.debug("Write layer for:"); |
4656
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
289 logger.debug(" directory/file: " + layerFile.getName()); |
1775
0156105222c9
Improved the MapfileGenerator. It offers methods to create barrier and wsplgen layer files for mapserver.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1710
diff
changeset
|
290 } |
0156105222c9
Improved the MapfileGenerator. It offers methods to create barrier and wsplgen layer files for mapserver.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1710
diff
changeset
|
291 |
0156105222c9
Improved the MapfileGenerator. It offers methods to create barrier and wsplgen layer files for mapserver.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1710
diff
changeset
|
292 Writer writer = null; |
0156105222c9
Improved the MapfileGenerator. It offers methods to create barrier and wsplgen layer files for mapserver.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1710
diff
changeset
|
293 |
0156105222c9
Improved the MapfileGenerator. It offers methods to create barrier and wsplgen layer files for mapserver.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1710
diff
changeset
|
294 try { |
4656
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
295 writer = new FileWriter(layerFile); |
1775
0156105222c9
Improved the MapfileGenerator. It offers methods to create barrier and wsplgen layer files for mapserver.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1710
diff
changeset
|
296 |
1792
49ad801076e4
Enabled the MapGenerator to create WMS layers with database datastore - riveraxis is the first layer that is no longer fetched from static WMS service but from user specific one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1781
diff
changeset
|
297 VelocityContext context = getVelocityContext(); |
4656
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
298 context.put("LAYER", layerInfo); |
1775
0156105222c9
Improved the MapfileGenerator. It offers methods to create barrier and wsplgen layer files for mapserver.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1710
diff
changeset
|
299 |
0156105222c9
Improved the MapfileGenerator. It offers methods to create barrier and wsplgen layer files for mapserver.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1710
diff
changeset
|
300 tpl.merge(context, writer); |
0156105222c9
Improved the MapfileGenerator. It offers methods to create barrier and wsplgen layer files for mapserver.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1710
diff
changeset
|
301 } |
0156105222c9
Improved the MapfileGenerator. It offers methods to create barrier and wsplgen layer files for mapserver.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1710
diff
changeset
|
302 catch (FileNotFoundException fnfe) { |
0156105222c9
Improved the MapfileGenerator. It offers methods to create barrier and wsplgen layer files for mapserver.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1710
diff
changeset
|
303 logger.error(fnfe, fnfe); |
0156105222c9
Improved the MapfileGenerator. It offers methods to create barrier and wsplgen layer files for mapserver.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1710
diff
changeset
|
304 } |
0156105222c9
Improved the MapfileGenerator. It offers methods to create barrier and wsplgen layer files for mapserver.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1710
diff
changeset
|
305 catch (IOException ioe) { |
0156105222c9
Improved the MapfileGenerator. It offers methods to create barrier and wsplgen layer files for mapserver.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1710
diff
changeset
|
306 logger.error(ioe, ioe); |
0156105222c9
Improved the MapfileGenerator. It offers methods to create barrier and wsplgen layer files for mapserver.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1710
diff
changeset
|
307 } |
0156105222c9
Improved the MapfileGenerator. It offers methods to create barrier and wsplgen layer files for mapserver.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1710
diff
changeset
|
308 catch (Exception e) { |
0156105222c9
Improved the MapfileGenerator. It offers methods to create barrier and wsplgen layer files for mapserver.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1710
diff
changeset
|
309 logger.error(e, e); |
0156105222c9
Improved the MapfileGenerator. It offers methods to create barrier and wsplgen layer files for mapserver.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1710
diff
changeset
|
310 } |
0156105222c9
Improved the MapfileGenerator. It offers methods to create barrier and wsplgen layer files for mapserver.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1710
diff
changeset
|
311 finally { |
0156105222c9
Improved the MapfileGenerator. It offers methods to create barrier and wsplgen layer files for mapserver.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1710
diff
changeset
|
312 try { |
0156105222c9
Improved the MapfileGenerator. It offers methods to create barrier and wsplgen layer files for mapserver.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1710
diff
changeset
|
313 if (writer != null) { |
0156105222c9
Improved the MapfileGenerator. It offers methods to create barrier and wsplgen layer files for mapserver.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1710
diff
changeset
|
314 writer.close(); |
0156105222c9
Improved the MapfileGenerator. It offers methods to create barrier and wsplgen layer files for mapserver.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1710
diff
changeset
|
315 } |
0156105222c9
Improved the MapfileGenerator. It offers methods to create barrier and wsplgen layer files for mapserver.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1710
diff
changeset
|
316 } |
0156105222c9
Improved the MapfileGenerator. It offers methods to create barrier and wsplgen layer files for mapserver.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1710
diff
changeset
|
317 catch (IOException ioe) { |
0156105222c9
Improved the MapfileGenerator. It offers methods to create barrier and wsplgen layer files for mapserver.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1710
diff
changeset
|
318 logger.debug(ioe, ioe); |
0156105222c9
Improved the MapfileGenerator. It offers methods to create barrier and wsplgen layer files for mapserver.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1710
diff
changeset
|
319 } |
0156105222c9
Improved the MapfileGenerator. It offers methods to create barrier and wsplgen layer files for mapserver.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1710
diff
changeset
|
320 } |
0156105222c9
Improved the MapfileGenerator. It offers methods to create barrier and wsplgen layer files for mapserver.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1710
diff
changeset
|
321 } |
0156105222c9
Improved the MapfileGenerator. It offers methods to create barrier and wsplgen layer files for mapserver.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1710
diff
changeset
|
322 |
0156105222c9
Improved the MapfileGenerator. It offers methods to create barrier and wsplgen layer files for mapserver.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1710
diff
changeset
|
323 |
1129
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
324 /** |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
325 * Creates a mapfile with the layer information stored in <i>layers</i>. |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
326 * |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
327 * @param layers Layer information. |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
328 */ |
5309
b55975761708
Changed visiblitiy of some methods. TODO: A lot of refactoring.
Raimund Renkert <rrenkert@intevation.de>
parents:
4703
diff
changeset
|
329 public void writeMapfile(List<String> layers) { |
1129
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
330 String tmpMapName = "mapfile" + new Date().getTime(); |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
331 |
4656
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
332 File mapfile = new File(getMapfilePath()); |
1129
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
333 |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
334 File tmp = null; |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
335 Writer writer = null; |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
336 |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
337 try { |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
338 tmp = new File(mapfile.getParent(), tmpMapName); |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
339 tmp.createNewFile(); |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
340 |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
341 writer = new FileWriter(tmp); |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
342 |
1792
49ad801076e4
Enabled the MapGenerator to create WMS layers with database datastore - riveraxis is the first layer that is no longer fetched from static WMS service but from user specific one.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1781
diff
changeset
|
343 VelocityContext context = getVelocityContext(); |
1781
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
344 context.put("LAYERS", layers); |
1129
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
345 |
4656
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
346 Template mapTemplate = getMapfileTemplateObj(); |
1129
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
347 if (mapTemplate == null) { |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
348 logger.warn("No mapfile template found."); |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
349 return; |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
350 } |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
351 |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
352 mapTemplate.merge(context, writer); |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
353 |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
354 // we need to create a temporary mapfile first und rename it into |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
355 // real mapfile because we don't run into race conditions on this |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
356 // way. (iw) |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
357 tmp.renameTo(mapfile); |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
358 } |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
359 catch (FileNotFoundException fnfe) { |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
360 logger.error(fnfe, fnfe); |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
361 } |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
362 catch (IOException ioe) { |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
363 logger.error(ioe, ioe); |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
364 } |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
365 catch (Exception e) { |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
366 logger.error(e, e); |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
367 } |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
368 finally { |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
369 try { |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
370 if (writer != null) { |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
371 writer.close(); |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
372 } |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
373 |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
374 if (tmp.exists()) { |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
375 tmp.delete(); |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
376 } |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
377 } |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
378 catch (IOException ioe) { |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
379 logger.debug(ioe, ioe); |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
380 } |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
381 } |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
382 } |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
383 } |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
384 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |