Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/utils/MapfileGenerator.java @ 3456:c1fd75bd893a
Fix data names in access for fixrealizing.
flys-artifacts/trunk@5122 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Wed, 25 Jul 2012 10:07:08 +0000 |
parents | 1b41dc00b1f7 |
children | 3dc26ec2558d |
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 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
|
63 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
|
64 |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
65 private String mapServerUrl; |
da3c3e286c88
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 private String templatePath; |
da3c3e286c88
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 private String velocityLogfile; |
da3c3e286c88
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 VelocityEngine velocityEngine; |
3303
96daa8a4c48f
Fix and workaround NullPointerExceptions
Christian Lins <christian.lins@intevation.de>
parents:
3302
diff
changeset
|
70 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
|
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 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
|
75 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
|
76 } |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
77 |
da3c3e286c88
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 /** |
da3c3e286c88
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 * 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
|
81 * 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
|
82 * <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
|
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 * @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
|
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 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
|
87 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
|
88 } |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
89 |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
90 |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
91 /** |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
92 * 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
|
93 * |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
94 * @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
|
95 */ |
da3c3e286c88
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 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
|
97 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
|
98 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
|
99 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
|
100 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
|
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 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
|
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 |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
106 |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
107 /** |
da3c3e286c88
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 * 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
|
109 */ |
da3c3e286c88
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 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
|
111 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
|
112 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
|
113 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
|
114 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
|
115 } |
da3c3e286c88
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 |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
118 |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
119 /** |
da3c3e286c88
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 * 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
|
121 */ |
da3c3e286c88
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 @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
|
123 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
|
124 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
|
125 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
|
126 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
|
127 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
|
128 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
|
129 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
|
130 } |
da3c3e286c88
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 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
|
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 |
da3c3e286c88
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("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
|
135 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
|
136 } |
da3c3e286c88
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 } |
da3c3e286c88
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 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
|
139 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
|
140 } |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
141 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
|
142 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
|
143 } |
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
|
144 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
|
145 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
|
146 } |
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
|
147 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
|
148 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
|
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 } |
da3c3e286c88
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 |
da3c3e286c88
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 * 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
|
154 * |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
155 * @param 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
|
156 * @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
|
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 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
|
159 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
|
160 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
|
161 } |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
162 |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
163 |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
164 /** |
da3c3e286c88
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 * 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
|
166 * 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
|
167 */ |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
168 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
|
169 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
|
170 { |
da3c3e286c88
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 File[] userDirs = getUserDirs(); |
1781
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
172 |
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
173 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
|
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 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
|
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 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
|
178 } |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
179 |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
180 |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
181 /** |
da3c3e286c88
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 * 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
|
183 * |
da3c3e286c88
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 * @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
|
185 */ |
da3c3e286c88
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 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
|
187 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
|
188 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
|
189 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
|
190 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
|
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 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
|
193 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
|
194 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
|
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 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
|
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 |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
200 |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
201 /** |
da3c3e286c88
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 * 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
|
203 * |
da3c3e286c88
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 * @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
|
205 * @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
|
206 */ |
da3c3e286c88
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 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
|
208 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
|
209 { |
da3c3e286c88
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 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
|
211 "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
|
212 "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
|
213 |
da3c3e286c88
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 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
|
215 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
|
216 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
|
217 |
da3c3e286c88
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 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
|
219 "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
|
220 "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
|
221 |
da3c3e286c88
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 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
|
223 "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
|
224 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
|
225 |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
226 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
|
227 } |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
228 |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
229 |
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
|
230 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
|
231 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
|
232 |
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 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
|
234 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
|
235 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
|
236 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
|
237 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
|
238 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
|
239 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
|
240 } |
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 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
|
242 // 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
|
243 } |
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 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
|
245 // 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
|
246 } |
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
|
247 |
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
|
248 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
|
249 } |
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
|
250 |
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
|
251 |
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
|
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 * 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
|
254 * |
da3c3e286c88
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 * @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
|
256 * @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
|
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 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
|
259 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
|
260 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
|
261 } |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
262 |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
263 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
|
264 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
|
265 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
|
266 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
|
267 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
|
268 } |
da3c3e286c88
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 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
|
271 } |
da3c3e286c88
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 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
|
273 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
|
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 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
|
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 |
da3c3e286c88
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 |
da3c3e286c88
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 * 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
|
282 * |
da3c3e286c88
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 * @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
|
284 * @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
|
285 */ |
da3c3e286c88
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 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
|
287 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
|
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 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
|
290 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
|
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 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
|
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 |
da3c3e286c88
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 /** |
da3c3e286c88
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 * 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
|
298 * |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
299 * @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
|
300 * |
da3c3e286c88
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 * @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
|
302 * 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
|
303 */ |
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
|
304 public File getShapefileBaseDir() |
3306
1b41dc00b1f7
Create shapefile directory instead of shapefile 'file'
Christian Lins <christian.lins@intevation.de>
parents:
3303
diff
changeset
|
305 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
|
306 { |
da3c3e286c88
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 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
|
308 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
|
309 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
|
310 |
da3c3e286c88
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 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
|
312 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
|
313 } |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
314 |
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
|
315 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
|
316 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
|
317 } |
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
|
318 |
0156105222c9
Improved the MapfileGenerator. It offers methods to create barrier and wsplgen layer files for mapserver.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1710
diff
changeset
|
319 if (!shapefileDirectory.exists()) { |
3306
1b41dc00b1f7
Create shapefile directory instead of shapefile 'file'
Christian Lins <christian.lins@intevation.de>
parents:
3303
diff
changeset
|
320 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
|
321 } |
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
|
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 |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
324 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
|
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 |
da3c3e286c88
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 |
da3c3e286c88
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 protected File[] getUserDirs() |
3306
1b41dc00b1f7
Create shapefile directory instead of shapefile 'file'
Christian Lins <christian.lins@intevation.de>
parents:
3303
diff
changeset
|
329 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
|
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 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
|
332 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
|
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 // 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
|
335 |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
336 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
|
337 } |
da3c3e286c88
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 |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
340 |
1781
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
341 protected List<String> parseLayers(File[] dirs) { |
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
342 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
|
343 |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
344 for (File dir: dirs) { |
1781
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
345 File[] layerFiles = dir.listFiles(new FilenameFilter() { |
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
346 @Override |
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
347 public boolean accept(File directory, String name) { |
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
348 return name.startsWith(MS_LAYER_PREFIX); |
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
349 } |
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
350 }); |
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
|
351 |
1781
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
352 for (File layer: layerFiles) { |
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
353 try { |
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
354 layers.add(layer.getCanonicalPath()); |
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
355 } |
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
356 catch (IOException ioe) { |
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
357 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
|
358 } |
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
|
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 } |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
361 |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
362 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
|
363 } |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
364 |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
365 |
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
|
366 /** |
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 * 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
|
368 * 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
|
369 * |
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
|
370 * @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
|
371 * @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
|
372 */ |
2616
27cc95e65f18
Defined a style for WSPLGEN layers which are now modifiable.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1956
diff
changeset
|
373 public void createUeskLayer( |
27cc95e65f18
Defined a style for WSPLGEN layers which are now modifiable.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1956
diff
changeset
|
374 FLYSArtifact flys, |
2638
ccad7a6ddaa4
Issue 560.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2637
diff
changeset
|
375 WSPLGENLayerFacet wms, |
2637
baaf7d125c43
Issue 560.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2616
diff
changeset
|
376 String style, |
baaf7d125c43
Issue 560.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2616
diff
changeset
|
377 CallContext context |
2616
27cc95e65f18
Defined a style for WSPLGEN layers which are now modifiable.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1956
diff
changeset
|
378 ) 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
|
379 { |
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
|
380 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
|
381 |
1816
5364b86a0880
Improved styles of WMS layers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1793
diff
changeset
|
382 LayerInfo layerinfo = new LayerInfo(); |
1956
a5f87f8dbe57
Modified prefix constants for Mapserver layers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1917
diff
changeset
|
383 layerinfo.setName(MS_WSPLGEN_PREFIX + flys.identifier()); |
1816
5364b86a0880
Improved styles of WMS layers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1793
diff
changeset
|
384 layerinfo.setType("POLYGON"); |
5364b86a0880
Improved styles of WMS layers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1793
diff
changeset
|
385 layerinfo.setDirectory(flys.identifier()); |
5364b86a0880
Improved styles of WMS layers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1793
diff
changeset
|
386 layerinfo.setData(WSPLGEN_RESULT_SHAPE); |
2637
baaf7d125c43
Issue 560.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2616
diff
changeset
|
387 layerinfo.setTitle(Resources.getMsg(Resources.getLocale(context.getMeta()), |
baaf7d125c43
Issue 560.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2616
diff
changeset
|
388 "floodmap.uesk", |
baaf7d125c43
Issue 560.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2616
diff
changeset
|
389 "Floodmap")); |
2616
27cc95e65f18
Defined a style for WSPLGEN layers which are now modifiable.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1956
diff
changeset
|
390 layerinfo.setStyle(style); |
2669
7a124cb11d8e
Added a PROJECTION section to all db mapserver layers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2639
diff
changeset
|
391 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
|
392 |
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 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
|
394 |
2637
baaf7d125c43
Issue 560.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2616
diff
changeset
|
395 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
|
396 if (template == null) { |
2637
baaf7d125c43
Issue 560.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2616
diff
changeset
|
397 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
|
398 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
|
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 |
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 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
|
402 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
|
403 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
|
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 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
|
406 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
|
407 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
|
408 } |
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 } |
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 |
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 /** |
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 * 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
|
414 * 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
|
415 * |
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 * @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
|
417 * @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
|
418 */ |
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
|
419 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
|
420 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
|
421 { |
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
|
422 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
|
423 |
3306
1b41dc00b1f7
Create shapefile directory instead of shapefile 'file'
Christian Lins <christian.lins@intevation.de>
parents:
3303
diff
changeset
|
424 //String uuid = flys.identifier(); |
1b41dc00b1f7
Create shapefile directory instead of shapefile 'file'
Christian Lins <christian.lins@intevation.de>
parents:
3303
diff
changeset
|
425 //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
|
426 |
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
|
427 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
|
428 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
|
429 } |
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 |
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 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
|
433 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
|
434 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
|
435 ) |
7bb5bfd3b51f
Create layers for barrier lines and polygons only if they are really existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1816
diff
changeset
|
436 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
|
437 { |
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 String uuid = flys.identifier(); |
1956
a5f87f8dbe57
Modified prefix constants for Mapserver layers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1917
diff
changeset
|
439 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
|
440 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
|
441 |
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
|
442 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
|
443 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
|
444 |
7bb5bfd3b51f
Create layers for barrier lines and polygons only if they are really existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1816
diff
changeset
|
445 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
|
446 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
|
447 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
|
448 } |
7bb5bfd3b51f
Create layers for barrier lines and polygons only if they are really existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1816
diff
changeset
|
449 |
1816
5364b86a0880
Improved styles of WMS layers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1793
diff
changeset
|
450 LayerInfo lineInfo = new LayerInfo(); |
1956
a5f87f8dbe57
Modified prefix constants for Mapserver layers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1917
diff
changeset
|
451 lineInfo.setName(MS_LINE_PREFIX + uuid); |
1816
5364b86a0880
Improved styles of WMS layers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1793
diff
changeset
|
452 lineInfo.setType("LINE"); |
5364b86a0880
Improved styles of WMS layers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1793
diff
changeset
|
453 lineInfo.setDirectory(uuid); |
5364b86a0880
Improved styles of WMS layers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1793
diff
changeset
|
454 lineInfo.setData(WSPLGEN_LINES_SHAPE); |
5364b86a0880
Improved styles of WMS layers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1793
diff
changeset
|
455 lineInfo.setTitle("I18N_LINE_SHAPE"); |
5364b86a0880
Improved styles of WMS layers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1793
diff
changeset
|
456 lineInfo.setGroup(group); |
5364b86a0880
Improved styles of WMS layers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1793
diff
changeset
|
457 lineInfo.setGroupTitle(groupTitle); |
2669
7a124cb11d8e
Added a PROJECTION section to all db mapserver layers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2639
diff
changeset
|
458 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
|
459 |
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
|
460 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
|
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 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
|
463 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
|
464 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
|
465 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
|
466 } |
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 |
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 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
|
469 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
|
470 } |
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
|
471 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
|
472 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
|
473 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
|
474 } |
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
|
475 } |
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 |
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 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
|
479 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
|
480 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
|
481 ) |
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 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
|
483 { |
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 String uuid = flys.identifier(); |
1956
a5f87f8dbe57
Modified prefix constants for Mapserver layers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1917
diff
changeset
|
485 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
|
486 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
|
487 |
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 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
|
489 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
|
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 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
|
492 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
|
493 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
|
494 } |
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 |
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 LayerInfo polygonInfo = new LayerInfo(); |
1956
a5f87f8dbe57
Modified prefix constants for Mapserver layers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1917
diff
changeset
|
497 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
|
498 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
|
499 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
|
500 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
|
501 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
|
502 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
|
503 polygonInfo.setGroupTitle(groupTitle); |
2669
7a124cb11d8e
Added a PROJECTION section to all db mapserver layers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2639
diff
changeset
|
504 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
|
505 |
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 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
|
507 |
7bb5bfd3b51f
Create layers for barrier lines and polygons only if they are really existing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1816
diff
changeset
|
508 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
|
509 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
|
510 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
|
511 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
|
512 } |
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
|
513 |
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
|
514 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
|
515 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
|
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 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
|
518 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
|
519 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
|
520 } |
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
|
521 } |
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
|
522 |
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
|
523 |
1781
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
524 /** |
2639
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
525 * 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
|
526 * shape files uploaded by the user. |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
527 * |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
528 * @param flys The FLYSArtifact that owns <i>wms</i>. |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
529 * @param wms The WMSLayerFacet that contains information for the layer. |
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 public void createUserShapeLayer(FLYSArtifact flys, WMSLayerFacet wms) |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
532 throws FileNotFoundException, IOException |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
533 { |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
534 logger.debug("createUserShapeLayer"); |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
535 |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
536 String uuid = flys.identifier(); |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
537 File dir = new File(getShapefileBaseDir(), uuid); |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
538 File test = new File(dir, WSPLGEN_USER_SHAPE); |
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 if (!test.exists() || !test.canRead()) { |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
541 logger.debug("No user layer existing."); |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
542 return; |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
543 } |
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 File userShape = new File(dir, WSPLGEN_USER_SHAPE); |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
546 ShpFiles sf = new ShpFiles(userShape); |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
547 ShapefileReader sfr = new ShapefileReader(sf, true, false, null); |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
548 ShapefileHeader sfh = sfr.getHeader(); |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
549 |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
550 String group = uuid + MS_USERSHAPE_PREFIX; |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
551 String groupTitle = "I18N_USER_SHAPE_TITLE"; |
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 LayerInfo info = new LayerInfo(); |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
554 info.setName(MS_USERSHAPE_PREFIX + uuid); |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
555 if (sfh.getShapeType().isLineType()) { |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
556 info.setType("LINE"); |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
557 } |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
558 else if (sfh.getShapeType().isPolygonType()) { |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
559 info.setType("POLYGON"); |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
560 } |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
561 else { |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
562 return; |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
563 } |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
564 info.setDirectory(uuid); |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
565 info.setData(WSPLGEN_USER_SHAPE); |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
566 info.setTitle("I18N_USER_SHAPE"); |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
567 info.setGroup(group); |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
568 info.setGroupTitle(groupTitle); |
2669
7a124cb11d8e
Added a PROJECTION section to all db mapserver layers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2639
diff
changeset
|
569 info.setSrid(wms.getSrid()); |
2639
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
570 |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
571 String nameUser = MS_LAYER_PREFIX + wms.getName(); |
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 Template tpl = getTemplateByName(SHP_LAYER_TEMPLATE); |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
574 if (tpl == null) { |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
575 logger.warn("Template '" + SHP_LAYER_TEMPLATE + "' found."); |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
576 return; |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
577 } |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
578 |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
579 try { |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
580 writeLayer(info, dir, nameUser, tpl); |
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 catch (FileNotFoundException fnfe) { |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
583 logger.error(fnfe, fnfe); |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
584 logger.warn("Unable to write layer: " + nameUser); |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
585 } |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
586 |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
587 } |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
588 |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
589 |
a78dafdd8590
Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2638
diff
changeset
|
590 /** |
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
|
591 * 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
|
592 * 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
|
593 * |
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
|
594 * @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
|
595 * @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
|
596 */ |
1793
1636686070f7
Initial commit to support styles in maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1792
diff
changeset
|
597 public void createDatabaseLayer( |
1636686070f7
Initial commit to support styles in maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1792
diff
changeset
|
598 FLYSArtifact flys, |
1636686070f7
Initial commit to support styles in maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1792
diff
changeset
|
599 WMSDBLayerFacet wms, |
1636686070f7
Initial commit to support styles in maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1792
diff
changeset
|
600 String style |
1636686070f7
Initial commit to support styles in maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1792
diff
changeset
|
601 ) |
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
|
602 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
|
603 { |
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
|
604 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
|
605 |
1816
5364b86a0880
Improved styles of WMS layers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1793
diff
changeset
|
606 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
|
607 layerinfo.setName(wms.getName() + "-" + flys.identifier()); |
1816
5364b86a0880
Improved styles of WMS layers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1793
diff
changeset
|
608 layerinfo.setType(wms.getGeometryType()); |
5364b86a0880
Improved styles of WMS layers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1793
diff
changeset
|
609 layerinfo.setFilter(wms.getFilter()); |
5364b86a0880
Improved styles of WMS layers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1793
diff
changeset
|
610 layerinfo.setData(wms.getData()); |
5364b86a0880
Improved styles of WMS layers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1793
diff
changeset
|
611 layerinfo.setTitle(wms.getDescription()); |
1793
1636686070f7
Initial commit to support styles in maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1792
diff
changeset
|
612 layerinfo.setStyle(style); |
3303
96daa8a4c48f
Fix and workaround NullPointerExceptions
Christian Lins <christian.lins@intevation.de>
parents:
3302
diff
changeset
|
613 if(wms.getExtent() != null) { |
96daa8a4c48f
Fix and workaround NullPointerExceptions
Christian Lins <christian.lins@intevation.de>
parents:
3302
diff
changeset
|
614 layerinfo.setExtent(GeometryUtils.jtsBoundsToOLBounds(wms.getExtent())); |
96daa8a4c48f
Fix and workaround NullPointerExceptions
Christian Lins <christian.lins@intevation.de>
parents:
3302
diff
changeset
|
615 } |
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
|
616 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
|
617 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
|
618 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
|
619 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
|
620 |
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 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
|
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 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
|
624 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
|
625 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
|
626 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
|
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 |
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 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
|
630 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
|
631 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
|
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 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
|
634 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
|
635 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
|
636 } |
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
|
637 } |
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
|
638 |
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
|
639 |
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
|
640 /** |
1781
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
641 * 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
|
642 * |
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
643 * @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
|
644 * information to build a Mapserver LAYER section. |
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
645 * @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
|
646 * @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
|
647 * @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
|
648 * section. |
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
649 */ |
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
|
650 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
|
651 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
|
652 File dir, |
1781
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
653 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
|
654 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
|
655 ) |
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
|
656 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
|
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 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
|
659 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
|
660 logger.debug(" directory: " + dir.getName()); |
1781
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
661 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
|
662 } |
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 |
1781
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
664 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
|
665 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
|
666 |
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 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
|
668 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
|
669 |
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
|
670 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
|
671 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
|
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 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
|
674 } |
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 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
|
676 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
|
677 } |
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 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
|
679 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
|
680 } |
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 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
|
682 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
|
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 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
|
685 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
|
686 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
|
687 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
|
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 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
|
691 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
|
692 } |
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
|
693 } |
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
|
694 } |
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
|
695 |
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
|
696 |
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
|
697 /** |
da3c3e286c88
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 * 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
|
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 * @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
|
701 */ |
1781
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
702 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
|
703 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
|
704 |
da3c3e286c88
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 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
|
706 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
|
707 |
da3c3e286c88
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 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
|
709 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
|
710 |
da3c3e286c88
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 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
|
712 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
|
713 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
|
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 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
|
716 |
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
|
717 VelocityContext context = getVelocityContext(); |
1781
ef2300b450bf
Modified the process to create mapfiles.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1775
diff
changeset
|
718 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
|
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 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
|
721 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
|
722 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
|
723 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
|
724 } |
da3c3e286c88
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 |
da3c3e286c88
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 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
|
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 // 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
|
729 // 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
|
730 // 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
|
731 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
|
732 } |
da3c3e286c88
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 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
|
734 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
|
735 } |
da3c3e286c88
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 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
|
737 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
|
738 } |
da3c3e286c88
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 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
|
740 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
|
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 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
|
743 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
|
744 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
|
745 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
|
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 |
da3c3e286c88
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 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
|
749 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
|
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 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
|
753 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
|
754 } |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
755 } |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
756 } |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
757 } |
da3c3e286c88
Introduced a MapfileGenerator that creates Mapserver specific mapfiles based on WSPLGEN results read from filesystem.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
758 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |