Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/utils/MapfileGenerator.java @ 4352:823c8afa1335
Refactor Converter to use common code
author | Björn Ricks <bjoern.ricks@intevation.de> |
---|---|
date | Thu, 01 Nov 2012 14:49:43 +0100 |
parents | 3dc26ec2558d |
children | fc52ee878412 |
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.CallContext; |
96daa8a4c48f
Fix and workaround NullPointerExceptions
Christian Lins <christian.lins@intevation.de>
parents:
3302
diff
changeset
|
4 import de.intevation.artifacts.common.utils.Config; |
96daa8a4c48f
Fix and workaround NullPointerExceptions
Christian Lins <christian.lins@intevation.de>
parents:
3302
diff
changeset
|
5 import de.intevation.flys.artifacts.FLYSArtifact; |
96daa8a4c48f
Fix and workaround NullPointerExceptions
Christian Lins <christian.lins@intevation.de>
parents:
3302
diff
changeset
|
6 import de.intevation.flys.artifacts.model.LayerInfo; |
96daa8a4c48f
Fix and workaround NullPointerExceptions
Christian Lins <christian.lins@intevation.de>
parents:
3302
diff
changeset
|
7 import de.intevation.flys.artifacts.model.map.WMSDBLayerFacet; |
96daa8a4c48f
Fix and workaround NullPointerExceptions
Christian Lins <christian.lins@intevation.de>
parents:
3302
diff
changeset
|
8 import de.intevation.flys.artifacts.model.map.WMSLayerFacet; |
96daa8a4c48f
Fix and workaround NullPointerExceptions
Christian Lins <christian.lins@intevation.de>
parents:
3302
diff
changeset
|
9 import de.intevation.flys.artifacts.model.map.WSPLGENLayerFacet; |
96daa8a4c48f
Fix and workaround NullPointerExceptions
Christian Lins <christian.lins@intevation.de>
parents:
3302
diff
changeset
|
10 import de.intevation.flys.artifacts.resources.Resources; |
96daa8a4c48f
Fix and workaround NullPointerExceptions
Christian Lins <christian.lins@intevation.de>
parents:
3302
diff
changeset
|
11 |
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
|
12 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
|
13 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
|
14 import java.io.FileWriter; |
3302
453d2d0c4258
Organized and added missing imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2669
diff
changeset
|
15 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
|
16 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
|
17 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
|
18 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
|
19 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
|
20 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
|
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 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
|
23 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
|
24 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
|
25 import org.apache.velocity.app.VelocityEngine; |
3302
453d2d0c4258
Organized and added missing imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2669
diff
changeset
|
26 import org.geotools.data.shapefile.ShpFiles; |
453d2d0c4258
Organized and added missing imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2669
diff
changeset
|
27 import org.geotools.data.shapefile.shp.ShapefileHeader; |
453d2d0c4258
Organized and added missing imports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2669
diff
changeset
|
28 import org.geotools.data.shapefile.shp.ShapefileReader; |
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
|
29 |
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 /** |
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
|
31 * 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
|
32 * 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
|
33 * 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
|
34 * |
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
|
35 * @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
|
36 */ |
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
|
37 public class MapfileGenerator |
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
|
38 extends Thread |
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
|
39 { |
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
|
40 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
|
41 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
|
42 public static final String WSPLGEN_POLYGONS_SHAPE = "barrier_polygons.shp"; |
2639
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
43 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
|
44 |
2637
baaf7d125c43
Issue 560.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2616
diff
changeset
|
45 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
|
46 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
|
47 public static final String DB_LAYER_TEMPLATE = "db_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
|
48 |
2639
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
49 public static final String MS_WSPLGEN_PREFIX = "wsplgen-"; |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
50 public static final String MS_BARRIERS_PREFIX = "barriers-"; |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
51 public static final String MS_LINE_PREFIX = "lines-"; |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
52 public static final String MS_POLYGONS_PREFIX = "polygons-"; |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
53 public static final String MS_LAYER_PREFIX = "ms_layer-"; |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
54 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
|
55 |
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 protected static final long SLEEPTIME = 10 * 1000L; // 10 seconds |
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 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
|
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 private static MapfileGenerator instance; |
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 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
|
63 |
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 private VelocityEngine velocityEngine; |
3303
96daa8a4c48f
Fix and workaround NullPointerExceptions
Christian Lins <christian.lins@intevation.de>
parents:
3302
diff
changeset
|
65 private final boolean lock[]; |
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
|
66 |
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 |
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 private MapfileGenerator() { |
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 lock = new boolean[1]; |
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
|
71 } |
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
|
72 |
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
|
73 |
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
|
74 /** |
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 * A main method which can be used to create a mapfile without a running |
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 * artifact server.<br> |
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 * <b>NOTE:</b> This method is not implemented yet! |
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 * @param args Arguments. |
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 */ |
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 public static void main(String[] args) { |
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 throw new Error("MapfileGenerator.main() is CURRENTLY NOT IMPLEMENTED!"); |
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 } |
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 |
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 /** |
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 * Returns the instance of this generator. |
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 * @return the instance. |
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 */ |
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 public static synchronized MapfileGenerator getInstance() { |
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 if (instance == 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
|
93 instance = new MapfileGenerator(); |
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 instance.setDaemon(true); |
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 instance.start(); |
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 |
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 return instance; |
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 |
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 |
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 * Triggers the mapfile generation process. |
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 */ |
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 public void update() { |
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 synchronized (lock) { |
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 logger.debug("update"); |
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
|
108 lock[0] = true; |
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
|
109 lock.notify(); |
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 } |
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 |
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 |
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 * Thread to generate a 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
|
116 */ |
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
|
117 @Override |
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 public void run() { |
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 logger.debug("Start MapfileGenerator thread..."); |
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 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
|
121 for (;;) { |
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
|
122 synchronized (lock) { |
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
|
123 while (!lock[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
|
124 lock.wait(SLEEPTIME); |
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
|
125 } |
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
|
126 lock[0] = 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
|
127 } |
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
|
128 |
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
|
129 logger.debug("Start sync process now..."); |
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
|
130 generate(); |
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
|
131 } |
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
|
132 } |
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
|
133 catch (InterruptedException ie) { |
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
|
134 logger.debug("MapfileGenerator thread got an interrupt."); |
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
|
135 } |
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
|
136 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
|
137 logger.debug("Error while mapfile creation: " + fnfe.getMessage()); |
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
|
138 } |
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
|
139 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
|
140 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
|
141 } |
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
|
142 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
|
143 logger.debug("THREAD END"); |
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
|
144 } |
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
|
145 } |
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
|
146 |
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
|
147 /** |
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
|
148 * 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
|
149 * |
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
|
150 * @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
|
151 * @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
|
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 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
|
154 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
|
155 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
|
156 } |
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 |
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
|
158 |
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 /** |
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 * Method which starts searching for meta information file and 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
|
161 * generation. |
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 protected void generate() |
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
|
164 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
|
165 { |
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 File[] userDirs = getUserDirs(); |
1781
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
167 |
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
168 List<String> layers = parseLayers(userDirs); |
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
|
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 logger.info("Found " + layers.size() + " layers for user 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
|
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 writeMapfile(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
|
173 } |
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 /** |
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 * 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
|
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 * @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
|
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 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
|
182 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
|
183 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
|
184 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
|
185 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
|
186 } |
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 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
|
188 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
|
189 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
|
190 } |
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 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
|
193 } |
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
|
194 |
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
|
195 |
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
|
196 /** |
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 * 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
|
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 * @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
|
200 * @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
|
201 */ |
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 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
|
203 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
|
204 { |
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 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
|
206 "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
|
207 "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
|
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 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
|
210 VelocityEngine.RUNTIME_LOG, |
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
|
211 FLYSUtils.getXPathString(FLYSUtils.XPATH_VELOCITY_LOGFILE)); |
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 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
|
214 "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
|
215 "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
|
216 |
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
|
217 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
|
218 "file.resource.loader.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
|
219 FLYSUtils.getXPathString(FLYSUtils.XPATH_MAPSERVER_TEMPLATE_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
|
220 |
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
|
221 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
|
222 } |
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
|
223 |
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 |
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
|
225 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
|
226 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
|
227 |
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
|
228 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
|
229 context.put("MAPSERVERURL", |
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
|
230 FLYSUtils.getXPathString(FLYSUtils.XPATH_MAPSERVER_URL)); |
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
|
231 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
|
232 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
|
233 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
|
234 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
|
235 } |
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
|
236 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
|
237 // this is bad |
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
|
238 } |
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
|
239 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
|
240 // this is also bad |
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
|
241 } |
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
|
242 |
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
|
243 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
|
244 } |
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
|
245 |
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
|
246 |
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
|
247 /** |
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
|
248 * 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
|
249 * |
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
|
250 * @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
|
251 * @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
|
252 */ |
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 protected Template getTemplateByName(String 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
|
254 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
|
255 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
|
256 } |
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
|
257 |
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
|
258 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
|
259 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
|
260 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
|
261 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
|
262 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
|
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 |
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 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
|
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 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
|
268 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
|
269 } |
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
|
270 |
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
|
271 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
|
272 } |
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
|
273 |
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
|
274 |
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
|
275 /** |
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
|
276 * 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
|
277 * |
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
|
278 * @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
|
279 * @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
|
280 */ |
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
|
281 protected Template getMapfileTemplate() |
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
|
282 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
|
283 { |
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
|
284 String mapfileName = FLYSUtils.getXPathString( |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
285 FLYSUtils.XPATH_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
|
286 |
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
|
287 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
|
288 } |
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
|
289 |
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
|
290 |
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
|
291 /** |
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
|
292 * 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
|
293 * |
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
|
294 * @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
|
295 * |
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
|
296 * @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
|
297 * 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
|
298 */ |
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
|
299 public File getShapefileBaseDir() |
3306
1b41dc00b1f7
Create shapefile directory instead of shapefile 'file'
Christian Lins <christian.lins@intevation.de>
parents:
3303
diff
changeset
|
300 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
|
301 { |
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
|
302 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
|
303 String path = FLYSUtils.getXPathString( |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
304 FLYSUtils.XPATH_SHAPEFILE_DIR); |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
305 |
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
|
306 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
|
307 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
|
308 } |
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
|
309 |
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
|
310 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
|
311 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
|
312 } |
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
|
313 |
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 if (!shapefileDirectory.exists()) { |
3306
1b41dc00b1f7
Create shapefile directory instead of shapefile 'file'
Christian Lins <christian.lins@intevation.de>
parents:
3303
diff
changeset
|
315 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
|
316 } |
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
|
317 } |
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
|
318 |
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
|
319 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
|
320 } |
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
|
321 |
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
|
322 |
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
|
323 protected File[] getUserDirs() |
3306
1b41dc00b1f7
Create shapefile directory instead of shapefile 'file'
Christian Lins <christian.lins@intevation.de>
parents:
3303
diff
changeset
|
324 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
|
325 { |
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 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
|
327 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
|
328 |
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
|
329 // 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
|
330 |
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 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
|
332 } |
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 |
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 |
1781
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
336 protected List<String> parseLayers(File[] dirs) { |
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
337 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
|
338 |
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 for (File dir: dirs) { |
1781
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
340 File[] layerFiles = dir.listFiles(new FilenameFilter() { |
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
341 @Override |
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
342 public boolean accept(File directory, String name) { |
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
343 return name.startsWith(MS_LAYER_PREFIX); |
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
344 } |
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
345 }); |
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
|
346 |
1781
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
347 for (File layer: layerFiles) { |
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
348 try { |
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
349 layers.add(layer.getCanonicalPath()); |
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
350 } |
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
351 catch (IOException ioe) { |
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
352 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
|
353 } |
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
|
354 } |
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 } |
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 |
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 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
|
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 |
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 |
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
|
361 /** |
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
|
362 * Creates a layer file used for Mapserver's mapfile which represents the |
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
|
363 * floodmap. |
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
|
364 * |
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
|
365 * @param flys The FLYSArtifact that owns <i>wms</i>. |
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
|
366 * @param wms The WMSLayerFacet that contains information for the layer. |
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
|
367 */ |
2616
27cc95e65f18
Defined a style for WSPLGEN layers which are now modifiable.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1956
diff
changeset
|
368 public void createUeskLayer( |
27cc95e65f18
Defined a style for WSPLGEN layers which are now modifiable.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1956
diff
changeset
|
369 FLYSArtifact flys, |
2638
ccad7a6ddaa4
Issue 560.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2637
diff
changeset
|
370 WSPLGENLayerFacet wms, |
2637
baaf7d125c43
Issue 560.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2616
diff
changeset
|
371 String style, |
baaf7d125c43
Issue 560.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2616
diff
changeset
|
372 CallContext context |
2616
27cc95e65f18
Defined a style for WSPLGEN layers which are now modifiable.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1956
diff
changeset
|
373 ) throws FileNotFoundException, IOException |
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
|
374 { |
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
|
375 logger.debug("createUeskLayer"); |
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
|
376 |
1816
5364b86a0880
Improved styles of WMS layers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1793
diff
changeset
|
377 LayerInfo layerinfo = new LayerInfo(); |
1956
a5f87f8dbe57
Modified prefix constants for Mapserver layers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1917
diff
changeset
|
378 layerinfo.setName(MS_WSPLGEN_PREFIX + flys.identifier()); |
1816
5364b86a0880
Improved styles of WMS layers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1793
diff
changeset
|
379 layerinfo.setType("POLYGON"); |
5364b86a0880
Improved styles of WMS layers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1793
diff
changeset
|
380 layerinfo.setDirectory(flys.identifier()); |
5364b86a0880
Improved styles of WMS layers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1793
diff
changeset
|
381 layerinfo.setData(WSPLGEN_RESULT_SHAPE); |
2637
baaf7d125c43
Issue 560.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2616
diff
changeset
|
382 layerinfo.setTitle(Resources.getMsg(Resources.getLocale(context.getMeta()), |
baaf7d125c43
Issue 560.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2616
diff
changeset
|
383 "floodmap.uesk", |
baaf7d125c43
Issue 560.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2616
diff
changeset
|
384 "Floodmap")); |
2616
27cc95e65f18
Defined a style for WSPLGEN layers which are now modifiable.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1956
diff
changeset
|
385 layerinfo.setStyle(style); |
2669
7a124cb11d8e
Added a PROJECTION section to all db mapserver layers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2639
diff
changeset
|
386 layerinfo.setSrid(wms.getSrid()); |
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
|
387 |
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
|
388 String name = MS_LAYER_PREFIX + wms.getName(); |
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
|
389 |
2637
baaf7d125c43
Issue 560.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2616
diff
changeset
|
390 Template template = getTemplateByName(WSPLGEN_LAYER_TEMPLATE); |
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
|
391 if (template == null) { |
2637
baaf7d125c43
Issue 560.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2616
diff
changeset
|
392 logger.warn("Template '" + WSPLGEN_LAYER_TEMPLATE + "' found."); |
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
|
393 return; |
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
|
394 } |
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
|
395 |
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
|
396 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
|
397 File dir = new File(getShapefileBaseDir(), flys.identifier()); |
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
|
398 writeLayer(layerinfo, dir, name, template); |
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
|
399 } |
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
|
400 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
|
401 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
|
402 logger.warn("Unable to write layer: " + name); |
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
|
403 } |
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
|
404 } |
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
|
405 |
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
|
406 |
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
|
407 /** |
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
|
408 * Creates a layer file used for Mapserver's mapfile which represents the |
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
|
409 * user defined barriers. |
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
|
410 * |
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
|
411 * @param flys The FLYSArtifact that owns <i>wms</i>. |
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
|
412 * @param wms The WMSLayerFacet that contains information for the layer. |
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
|
413 */ |
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
|
414 public void createBarriersLayer(FLYSArtifact flys, WMSLayerFacet wms) |
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
|
415 throws FileNotFoundException, IOException |
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
|
416 { |
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
|
417 logger.debug("createBarriersLayer"); |
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
|
418 |
3306
1b41dc00b1f7
Create shapefile directory instead of shapefile 'file'
Christian Lins <christian.lins@intevation.de>
parents:
3303
diff
changeset
|
419 //String uuid = flys.identifier(); |
1b41dc00b1f7
Create shapefile directory instead of shapefile 'file'
Christian Lins <christian.lins@intevation.de>
parents:
3303
diff
changeset
|
420 //File dir = new File(getShapefileBaseDir(), uuid); |
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
|
421 |
1830
7bb5bfd3b51f
Create layers for barrier lines and polygons only if they are really existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1816
diff
changeset
|
422 createBarriersLineLayer(flys, wms); |
7bb5bfd3b51f
Create layers for barrier lines and polygons only if they are really existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1816
diff
changeset
|
423 createBarriersPolygonLayer(flys, wms); |
7bb5bfd3b51f
Create layers for barrier lines and polygons only if they are really existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1816
diff
changeset
|
424 } |
7bb5bfd3b51f
Create layers for barrier lines and polygons only if they are really existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1816
diff
changeset
|
425 |
7bb5bfd3b51f
Create layers for barrier lines and polygons only if they are really existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1816
diff
changeset
|
426 |
7bb5bfd3b51f
Create layers for barrier lines and polygons only if they are really existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1816
diff
changeset
|
427 protected void createBarriersLineLayer( |
7bb5bfd3b51f
Create layers for barrier lines and polygons only if they are really existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1816
diff
changeset
|
428 FLYSArtifact flys, |
7bb5bfd3b51f
Create layers for barrier lines and polygons only if they are really existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1816
diff
changeset
|
429 WMSLayerFacet wms |
7bb5bfd3b51f
Create layers for barrier lines and polygons only if they are really existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1816
diff
changeset
|
430 ) |
7bb5bfd3b51f
Create layers for barrier lines and polygons only if they are really existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1816
diff
changeset
|
431 throws FileNotFoundException, IOException |
7bb5bfd3b51f
Create layers for barrier lines and polygons only if they are really existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1816
diff
changeset
|
432 { |
7bb5bfd3b51f
Create layers for barrier lines and polygons only if they are really existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1816
diff
changeset
|
433 String uuid = flys.identifier(); |
1956
a5f87f8dbe57
Modified prefix constants for Mapserver layers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1917
diff
changeset
|
434 String group = MS_BARRIERS_PREFIX + uuid; |
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
|
435 String groupTitle = "I18N_BARRIERS_TITLE"; |
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
|
436 |
1830
7bb5bfd3b51f
Create layers for barrier lines and polygons only if they are really existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1816
diff
changeset
|
437 File dir = new File(getShapefileBaseDir(), uuid); |
7bb5bfd3b51f
Create layers for barrier lines and polygons only if they are really existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1816
diff
changeset
|
438 File test = new File(dir, WSPLGEN_LINES_SHAPE); |
7bb5bfd3b51f
Create layers for barrier lines and polygons only if they are really existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1816
diff
changeset
|
439 |
7bb5bfd3b51f
Create layers for barrier lines and polygons only if they are really existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1816
diff
changeset
|
440 if (!test.exists() || !test.canRead()) { |
7bb5bfd3b51f
Create layers for barrier lines and polygons only if they are really existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1816
diff
changeset
|
441 logger.debug("No barrier line layer existing."); |
7bb5bfd3b51f
Create layers for barrier lines and polygons only if they are really existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1816
diff
changeset
|
442 return; |
7bb5bfd3b51f
Create layers for barrier lines and polygons only if they are really existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1816
diff
changeset
|
443 } |
7bb5bfd3b51f
Create layers for barrier lines and polygons only if they are really existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1816
diff
changeset
|
444 |
1816
5364b86a0880
Improved styles of WMS layers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1793
diff
changeset
|
445 LayerInfo lineInfo = new LayerInfo(); |
1956
a5f87f8dbe57
Modified prefix constants for Mapserver layers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1917
diff
changeset
|
446 lineInfo.setName(MS_LINE_PREFIX + uuid); |
1816
5364b86a0880
Improved styles of WMS layers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1793
diff
changeset
|
447 lineInfo.setType("LINE"); |
5364b86a0880
Improved styles of WMS layers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1793
diff
changeset
|
448 lineInfo.setDirectory(uuid); |
5364b86a0880
Improved styles of WMS layers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1793
diff
changeset
|
449 lineInfo.setData(WSPLGEN_LINES_SHAPE); |
5364b86a0880
Improved styles of WMS layers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1793
diff
changeset
|
450 lineInfo.setTitle("I18N_LINE_SHAPE"); |
5364b86a0880
Improved styles of WMS layers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1793
diff
changeset
|
451 lineInfo.setGroup(group); |
5364b86a0880
Improved styles of WMS layers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1793
diff
changeset
|
452 lineInfo.setGroupTitle(groupTitle); |
2669
7a124cb11d8e
Added a PROJECTION section to all db mapserver layers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2639
diff
changeset
|
453 lineInfo.setSrid(wms.getSrid()); |
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
|
454 |
1830
7bb5bfd3b51f
Create layers for barrier lines and polygons only if they are really existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1816
diff
changeset
|
455 String nameLines = MS_LAYER_PREFIX + wms.getName() + "-lines"; |
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
|
456 |
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
|
457 Template tpl = getTemplateByName(SHP_LAYER_TEMPLATE); |
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
|
458 if (tpl == 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
|
459 logger.warn("Template '" + SHP_LAYER_TEMPLATE + "' found."); |
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
|
460 return; |
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
|
461 } |
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
|
462 |
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
|
463 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
|
464 writeLayer(lineInfo, dir, nameLines, 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
|
465 } |
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
|
466 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
|
467 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
|
468 logger.warn("Unable to write layer: " + nameLines); |
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
|
469 } |
1830
7bb5bfd3b51f
Create layers for barrier lines and polygons only if they are really existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1816
diff
changeset
|
470 } |
7bb5bfd3b51f
Create layers for barrier lines and polygons only if they are really existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1816
diff
changeset
|
471 |
7bb5bfd3b51f
Create layers for barrier lines and polygons only if they are really existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1816
diff
changeset
|
472 |
7bb5bfd3b51f
Create layers for barrier lines and polygons only if they are really existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1816
diff
changeset
|
473 protected void createBarriersPolygonLayer( |
7bb5bfd3b51f
Create layers for barrier lines and polygons only if they are really existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1816
diff
changeset
|
474 FLYSArtifact flys, |
7bb5bfd3b51f
Create layers for barrier lines and polygons only if they are really existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1816
diff
changeset
|
475 WMSLayerFacet wms |
7bb5bfd3b51f
Create layers for barrier lines and polygons only if they are really existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1816
diff
changeset
|
476 ) |
7bb5bfd3b51f
Create layers for barrier lines and polygons only if they are really existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1816
diff
changeset
|
477 throws FileNotFoundException, IOException |
7bb5bfd3b51f
Create layers for barrier lines and polygons only if they are really existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1816
diff
changeset
|
478 { |
7bb5bfd3b51f
Create layers for barrier lines and polygons only if they are really existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1816
diff
changeset
|
479 String uuid = flys.identifier(); |
1956
a5f87f8dbe57
Modified prefix constants for Mapserver layers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1917
diff
changeset
|
480 String group = uuid + MS_BARRIERS_PREFIX; |
1830
7bb5bfd3b51f
Create layers for barrier lines and polygons only if they are really existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1816
diff
changeset
|
481 String groupTitle = "I18N_BARRIERS_TITLE"; |
7bb5bfd3b51f
Create layers for barrier lines and polygons only if they are really existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1816
diff
changeset
|
482 |
7bb5bfd3b51f
Create layers for barrier lines and polygons only if they are really existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1816
diff
changeset
|
483 File dir = new File(getShapefileBaseDir(), uuid); |
7bb5bfd3b51f
Create layers for barrier lines and polygons only if they are really existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1816
diff
changeset
|
484 File test = new File(dir, WSPLGEN_POLYGONS_SHAPE); |
7bb5bfd3b51f
Create layers for barrier lines and polygons only if they are really existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1816
diff
changeset
|
485 |
7bb5bfd3b51f
Create layers for barrier lines and polygons only if they are really existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1816
diff
changeset
|
486 if (!test.exists() || !test.canRead()) { |
7bb5bfd3b51f
Create layers for barrier lines and polygons only if they are really existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1816
diff
changeset
|
487 logger.debug("No barrier line layer existing."); |
7bb5bfd3b51f
Create layers for barrier lines and polygons only if they are really existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1816
diff
changeset
|
488 return; |
7bb5bfd3b51f
Create layers for barrier lines and polygons only if they are really existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1816
diff
changeset
|
489 } |
7bb5bfd3b51f
Create layers for barrier lines and polygons only if they are really existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1816
diff
changeset
|
490 |
7bb5bfd3b51f
Create layers for barrier lines and polygons only if they are really existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1816
diff
changeset
|
491 LayerInfo polygonInfo = new LayerInfo(); |
1956
a5f87f8dbe57
Modified prefix constants for Mapserver layers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1917
diff
changeset
|
492 polygonInfo.setName(MS_POLYGONS_PREFIX + uuid); |
1830
7bb5bfd3b51f
Create layers for barrier lines and polygons only if they are really existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1816
diff
changeset
|
493 polygonInfo.setType("POLYGON"); |
7bb5bfd3b51f
Create layers for barrier lines and polygons only if they are really existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1816
diff
changeset
|
494 polygonInfo.setDirectory(uuid); |
7bb5bfd3b51f
Create layers for barrier lines and polygons only if they are really existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1816
diff
changeset
|
495 polygonInfo.setData(WSPLGEN_POLYGONS_SHAPE); |
7bb5bfd3b51f
Create layers for barrier lines and polygons only if they are really existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1816
diff
changeset
|
496 polygonInfo.setTitle("I18N_POLYGON_SHAPE"); |
7bb5bfd3b51f
Create layers for barrier lines and polygons only if they are really existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1816
diff
changeset
|
497 polygonInfo.setGroup(group); |
7bb5bfd3b51f
Create layers for barrier lines and polygons only if they are really existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1816
diff
changeset
|
498 polygonInfo.setGroupTitle(groupTitle); |
2669
7a124cb11d8e
Added a PROJECTION section to all db mapserver layers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2639
diff
changeset
|
499 polygonInfo.setSrid(wms.getSrid()); |
1830
7bb5bfd3b51f
Create layers for barrier lines and polygons only if they are really existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1816
diff
changeset
|
500 |
7bb5bfd3b51f
Create layers for barrier lines and polygons only if they are really existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1816
diff
changeset
|
501 String namePolygons = MS_LAYER_PREFIX + wms.getName() + "-polygons"; |
7bb5bfd3b51f
Create layers for barrier lines and polygons only if they are really existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1816
diff
changeset
|
502 |
7bb5bfd3b51f
Create layers for barrier lines and polygons only if they are really existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1816
diff
changeset
|
503 Template tpl = getTemplateByName(SHP_LAYER_TEMPLATE); |
7bb5bfd3b51f
Create layers for barrier lines and polygons only if they are really existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1816
diff
changeset
|
504 if (tpl == null) { |
7bb5bfd3b51f
Create layers for barrier lines and polygons only if they are really existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1816
diff
changeset
|
505 logger.warn("Template '" + SHP_LAYER_TEMPLATE + "' found."); |
7bb5bfd3b51f
Create layers for barrier lines and polygons only if they are really existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1816
diff
changeset
|
506 return; |
7bb5bfd3b51f
Create layers for barrier lines and polygons only if they are really existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1816
diff
changeset
|
507 } |
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
|
508 |
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
|
509 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
|
510 writeLayer(polygonInfo, dir, namePolygons, 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
|
511 } |
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
|
512 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
|
513 logger.error(fnfe, fnfe); |
1830
7bb5bfd3b51f
Create layers for barrier lines and polygons only if they are really existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1816
diff
changeset
|
514 logger.warn("Unable to write layer: " + namePolygons); |
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
|
515 } |
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
|
516 } |
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
|
517 |
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
|
518 |
1781
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
519 /** |
2639
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
520 * Creates a layer file used for Mapserver's mapfile which represents the |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
521 * shape files uploaded by the user. |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
522 * |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
523 * @param flys The FLYSArtifact that owns <i>wms</i>. |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
524 * @param wms The WMSLayerFacet that contains information for the layer. |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
525 */ |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
526 public void createUserShapeLayer(FLYSArtifact flys, WMSLayerFacet wms) |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
527 throws FileNotFoundException, IOException |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
528 { |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
529 logger.debug("createUserShapeLayer"); |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
530 |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
531 String uuid = flys.identifier(); |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
532 File dir = new File(getShapefileBaseDir(), uuid); |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
533 File test = new File(dir, WSPLGEN_USER_SHAPE); |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
534 |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
535 if (!test.exists() || !test.canRead()) { |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
536 logger.debug("No user layer existing."); |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
537 return; |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
538 } |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
539 |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
540 File userShape = new File(dir, WSPLGEN_USER_SHAPE); |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
541 ShpFiles sf = new ShpFiles(userShape); |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
542 ShapefileReader sfr = new ShapefileReader(sf, true, false, null); |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
543 ShapefileHeader sfh = sfr.getHeader(); |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
544 |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
545 String group = uuid + MS_USERSHAPE_PREFIX; |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
546 String groupTitle = "I18N_USER_SHAPE_TITLE"; |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
547 |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
548 LayerInfo info = new LayerInfo(); |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
549 info.setName(MS_USERSHAPE_PREFIX + uuid); |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
550 if (sfh.getShapeType().isLineType()) { |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
551 info.setType("LINE"); |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
552 } |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
553 else if (sfh.getShapeType().isPolygonType()) { |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
554 info.setType("POLYGON"); |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
555 } |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
556 else { |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
557 return; |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
558 } |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
559 info.setDirectory(uuid); |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
560 info.setData(WSPLGEN_USER_SHAPE); |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
561 info.setTitle("I18N_USER_SHAPE"); |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
562 info.setGroup(group); |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
563 info.setGroupTitle(groupTitle); |
2669
7a124cb11d8e
Added a PROJECTION section to all db mapserver layers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2639
diff
changeset
|
564 info.setSrid(wms.getSrid()); |
2639
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
565 |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
566 String nameUser = MS_LAYER_PREFIX + wms.getName(); |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
567 |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
568 Template tpl = getTemplateByName(SHP_LAYER_TEMPLATE); |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
569 if (tpl == null) { |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
570 logger.warn("Template '" + SHP_LAYER_TEMPLATE + "' found."); |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
571 return; |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
572 } |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
573 |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
574 try { |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
575 writeLayer(info, dir, nameUser, tpl); |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
576 } |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
577 catch (FileNotFoundException fnfe) { |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
578 logger.error(fnfe, fnfe); |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
579 logger.warn("Unable to write layer: " + nameUser); |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
580 } |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
581 |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
582 } |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
583 |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
584 |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
585 /** |
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
|
586 * Creates a layer file used for Mapserver's mapfile which represents |
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
|
587 * geometries from database. |
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
|
588 * |
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
|
589 * @param flys The FLYSArtifact that owns <i>wms</i>. |
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
|
590 * @param wms The WMSLayerFacet that contains information for the layer. |
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
|
591 */ |
1793
1636686070f7
Initial commit to support styles in maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1792
diff
changeset
|
592 public void createDatabaseLayer( |
1636686070f7
Initial commit to support styles in maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1792
diff
changeset
|
593 FLYSArtifact flys, |
1636686070f7
Initial commit to support styles in maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1792
diff
changeset
|
594 WMSDBLayerFacet wms, |
1636686070f7
Initial commit to support styles in maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1792
diff
changeset
|
595 String style |
1636686070f7
Initial commit to support styles in maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1792
diff
changeset
|
596 ) |
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
|
597 throws FileNotFoundException, IOException |
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
|
598 { |
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
|
599 logger.debug("createDatabaseLayer"); |
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
|
600 |
1816
5364b86a0880
Improved styles of WMS layers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1793
diff
changeset
|
601 LayerInfo layerinfo = new LayerInfo(); |
1917
71139016cd0f
Avoid WMS layer names that begin with digits to ensure valid WMS GetFeatureInfo responses.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1876
diff
changeset
|
602 layerinfo.setName(wms.getName() + "-" + flys.identifier()); |
1816
5364b86a0880
Improved styles of WMS layers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1793
diff
changeset
|
603 layerinfo.setType(wms.getGeometryType()); |
5364b86a0880
Improved styles of WMS layers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1793
diff
changeset
|
604 layerinfo.setFilter(wms.getFilter()); |
5364b86a0880
Improved styles of WMS layers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1793
diff
changeset
|
605 layerinfo.setData(wms.getData()); |
5364b86a0880
Improved styles of WMS layers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1793
diff
changeset
|
606 layerinfo.setTitle(wms.getDescription()); |
1793
1636686070f7
Initial commit to support styles in maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1792
diff
changeset
|
607 layerinfo.setStyle(style); |
3303
96daa8a4c48f
Fix and workaround NullPointerExceptions
Christian Lins <christian.lins@intevation.de>
parents:
3302
diff
changeset
|
608 if(wms.getExtent() != null) { |
96daa8a4c48f
Fix and workaround NullPointerExceptions
Christian Lins <christian.lins@intevation.de>
parents:
3302
diff
changeset
|
609 layerinfo.setExtent(GeometryUtils.jtsBoundsToOLBounds(wms.getExtent())); |
96daa8a4c48f
Fix and workaround NullPointerExceptions
Christian Lins <christian.lins@intevation.de>
parents:
3302
diff
changeset
|
610 } |
1854
e372934f0c42
Replaced the dbconnection.include used by Mapserver - these information are provided by LayerInfo objects now, which reduces config overhead.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1830
diff
changeset
|
611 layerinfo.setConnection(wms.getConnection()); |
e372934f0c42
Replaced the dbconnection.include used by Mapserver - these information are provided by LayerInfo objects now, which reduces config overhead.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1830
diff
changeset
|
612 layerinfo.setConnectionType(wms.getConnectionType()); |
1876
dd467951335c
Added support for labels in Mapserver layers and options to modify its style.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1854
diff
changeset
|
613 layerinfo.setLabelItem(wms.getLabelItem()); |
2669
7a124cb11d8e
Added a PROJECTION section to all db mapserver layers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2639
diff
changeset
|
614 layerinfo.setSrid(wms.getSrid()); |
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
|
615 |
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
|
616 String name = MS_LAYER_PREFIX + wms.getName(); |
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
|
617 |
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
|
618 Template template = getTemplateByName(DB_LAYER_TEMPLATE); |
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
|
619 if (template == null) { |
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
|
620 logger.warn("Template '" + DB_LAYER_TEMPLATE + "' found."); |
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
|
621 return; |
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
|
622 } |
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
|
623 |
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
|
624 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
|
625 File dir = new File(getShapefileBaseDir(), flys.identifier()); |
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
|
626 writeLayer(layerinfo, dir, name, template); |
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
|
627 } |
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
|
628 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
|
629 logger.error(fnfe, 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
|
630 logger.warn("Unable to write layer: " + name); |
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
|
631 } |
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
|
632 } |
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
|
633 |
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
|
634 |
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
|
635 /** |
1781
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
636 * 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
|
637 * |
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
638 * @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
|
639 * information to build a Mapserver LAYER section. |
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
640 * @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
|
641 * @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
|
642 * @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
|
643 * section. |
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
644 */ |
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
|
645 protected void writeLayer( |
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
|
646 LayerInfo layerinfo, |
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
|
647 File dir, |
1781
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
648 String filename, |
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
|
649 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
|
650 ) |
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
|
651 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
|
652 { |
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
|
653 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
|
654 logger.debug("Write layer for:"); |
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
|
655 logger.debug(" directory: " + dir.getName()); |
1781
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
656 logger.debug(" name: " + filename); |
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
|
657 } |
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
|
658 |
1781
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
659 File layer = new File(dir, filename); |
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
|
660 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
|
661 |
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
|
662 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
|
663 writer = new FileWriter(layer); |
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
|
664 |
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
|
665 VelocityContext context = getVelocityContext(); |
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
|
666 context.put("LAYER", layerinfo); |
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
|
667 |
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
|
668 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
|
669 } |
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
|
670 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
|
671 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
|
672 } |
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
|
673 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
|
674 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
|
675 } |
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
|
676 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
|
677 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
|
678 } |
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
|
679 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
|
680 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
|
681 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
|
682 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
|
683 } |
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
|
684 } |
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
|
685 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
|
686 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
|
687 } |
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
|
688 } |
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
|
689 } |
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
|
690 |
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
|
691 |
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
|
692 /** |
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
|
693 * 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
|
694 * |
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
|
695 * @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
|
696 */ |
1781
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
697 protected 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
|
698 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
|
699 |
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
|
700 File mapfile = new 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
|
701 FLYSUtils.getXPathString(FLYSUtils.XPATH_MAPFILE_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
|
702 |
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
|
703 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
|
704 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
|
705 |
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
|
706 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
|
707 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
|
708 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
|
709 |
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
|
710 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
|
711 |
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
|
712 VelocityContext context = getVelocityContext(); |
1781
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
713 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
|
714 |
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
|
715 Template mapTemplate = getMapfileTemplate(); |
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
|
716 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
|
717 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
|
718 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
|
719 } |
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
|
720 |
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
|
721 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
|
722 |
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
|
723 // 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
|
724 // 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
|
725 // 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
|
726 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
|
727 } |
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
|
728 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
|
729 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
|
730 } |
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
|
731 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
|
732 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
|
733 } |
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
|
734 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
|
735 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
|
736 } |
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
|
737 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
|
738 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
|
739 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
|
740 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
|
741 } |
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
|
742 |
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
|
743 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
|
744 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
|
745 } |
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
|
746 } |
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
|
747 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
|
748 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
|
749 } |
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
|
750 } |
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
|
751 } |
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
|
752 } |
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
|
753 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |