Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/mapserver/MapfileGenerator.java @ 5379:61bf64b102bc mapgenfix
Merge with default branch
author | Christian Lins <christian.lins@intevation.de> |
---|---|
date | Fri, 22 Mar 2013 11:25:54 +0100 |
parents | cfc5540a4eec |
children |
rev | line source |
---|---|
5022
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.mapserver; |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
2 |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
3 import de.intevation.artifacts.common.utils.Config; |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
4 import de.intevation.flys.artifacts.model.LayerInfo; |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
5 import de.intevation.flys.utils.FLYSUtils; |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
6 |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
7 import java.io.File; |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
8 import java.io.FileNotFoundException; |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
9 import java.io.FileWriter; |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
10 import java.io.FilenameFilter; |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
11 import java.io.IOException; |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
12 import java.io.Writer; |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
13 import java.util.ArrayList; |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
14 import java.util.Date; |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
15 import java.util.List; |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
16 |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
17 import org.apache.log4j.Logger; |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
18 import org.apache.velocity.Template; |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
19 import org.apache.velocity.VelocityContext; |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
20 import org.apache.velocity.app.VelocityEngine; |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
21 import org.apache.velocity.runtime.RuntimeConstants; |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
22 |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
23 /** |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
24 * This class iterates over a bunch of directories, searches for meta |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
25 * information coresponding to shapefiles and creates a mapfile which is used by |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
26 * a <i>MapServer</i>. |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
27 * |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
28 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
29 */ |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
30 public abstract class MapfileGenerator |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
31 { |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
32 public static final String WSPLGEN_RESULT_SHAPE = "wsplgen.shp"; |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
33 public static final String WSPLGEN_LINES_SHAPE = "barrier_lines.shp"; |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
34 public static final String WSPLGEN_POLYGONS_SHAPE = "barrier_polygons.shp"; |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
35 public static final String WSPLGEN_USER_SHAPE = "user-rgd.shp"; |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
36 |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
37 public static final String WSPLGEN_LAYER_TEMPLATE = "wsplgen_layer.vm"; |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
38 public static final String SHP_LAYER_TEMPLATE = "shapefile_layer.vm"; |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
39 public static final String DB_LAYER_TEMPLATE = "db_layer.vm"; |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
40 public static final String RIVERAXIS_LAYER_TEMPLATE = "riveraxis-layer.vm"; |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
41 |
5175
cfc5540a4eec
Re-add layer generation for floodmap layers (somewhat buggy though).
Christian Lins <christian.lins@intevation.de>
parents:
5087
diff
changeset
|
42 public static final String MS_PREFIX_WSPLGEN = "wsplgen"; |
5023
1da61095040c
Renaming methods and fields. Start refactoring with ArtifactMapfileGenerator.generate() which should be the main entry point.
Christian Lins <christian.lins@intevation.de>
parents:
5022
diff
changeset
|
43 public static final String MS_PREFIX_BARRIERS = "barriers-"; |
5076
cc50e1b9fc60
Work on ArtifactMapfileGenerator.createUserShapefileLayer()
Christian Lins <christian.lins@intevation.de>
parents:
5023
diff
changeset
|
44 public static final String MS_LINE_PREFIX = "lines-"; |
cc50e1b9fc60
Work on ArtifactMapfileGenerator.createUserShapefileLayer()
Christian Lins <christian.lins@intevation.de>
parents:
5023
diff
changeset
|
45 public static final String MS_POLYGONS_PREFIX = "polygons-"; |
cc50e1b9fc60
Work on ArtifactMapfileGenerator.createUserShapefileLayer()
Christian Lins <christian.lins@intevation.de>
parents:
5023
diff
changeset
|
46 public static final String MS_LAYER_PREFIX = "ms_layer-"; |
5023
1da61095040c
Renaming methods and fields. Start refactoring with ArtifactMapfileGenerator.generate() which should be the main entry point.
Christian Lins <christian.lins@intevation.de>
parents:
5022
diff
changeset
|
47 public static final String MS_PREFIX_USER = "user-"; |
5022
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
48 |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
49 private static Logger logger = Logger.getLogger(MapfileGenerator.class); |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
50 |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
51 private File shapefileDirectory; |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
52 |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
53 private VelocityEngine velocityEngine; |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
54 |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
55 |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
56 protected MapfileGenerator() { |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
57 } |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
58 |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
59 |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
60 /** |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
61 * Method to check the existance of a template file. |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
62 * |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
63 * @param templateID The name of a template. |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
64 * @return true, of the template exists - otherwise false. |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
65 */ |
5023
1da61095040c
Renaming methods and fields. Start refactoring with ArtifactMapfileGenerator.generate() which should be the main entry point.
Christian Lins <christian.lins@intevation.de>
parents:
5022
diff
changeset
|
66 protected boolean templateExists(String templateID){ |
5022
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
67 Template template = getTemplateByName(templateID); |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
68 return template != null; |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
69 } |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
70 |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
71 |
5023
1da61095040c
Renaming methods and fields. Start refactoring with ArtifactMapfileGenerator.generate() which should be the main entry point.
Christian Lins <christian.lins@intevation.de>
parents:
5022
diff
changeset
|
72 /** |
1da61095040c
Renaming methods and fields. Start refactoring with ArtifactMapfileGenerator.generate() which should be the main entry point.
Christian Lins <christian.lins@intevation.de>
parents:
5022
diff
changeset
|
73 * Starts the mapfile generation. This is the main entry point for |
1da61095040c
Renaming methods and fields. Start refactoring with ArtifactMapfileGenerator.generate() which should be the main entry point.
Christian Lins <christian.lins@intevation.de>
parents:
5022
diff
changeset
|
74 * the mapfile generation, all other methods of this class/package |
1da61095040c
Renaming methods and fields. Start refactoring with ArtifactMapfileGenerator.generate() which should be the main entry point.
Christian Lins <christian.lins@intevation.de>
parents:
5022
diff
changeset
|
75 * *should* be non-public. |
1da61095040c
Renaming methods and fields. Start refactoring with ArtifactMapfileGenerator.generate() which should be the main entry point.
Christian Lins <christian.lins@intevation.de>
parents:
5022
diff
changeset
|
76 * @throws Exception |
1da61095040c
Renaming methods and fields. Start refactoring with ArtifactMapfileGenerator.generate() which should be the main entry point.
Christian Lins <christian.lins@intevation.de>
parents:
5022
diff
changeset
|
77 */ |
5022
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
78 public abstract void generate() throws Exception; |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
79 |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
80 |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
81 /** |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
82 * Returns the VelocityEngine used for the template mechanism. |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
83 * |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
84 * @return the velocity engine. |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
85 */ |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
86 protected VelocityEngine getVelocityEngine() { |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
87 if (velocityEngine == null) { |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
88 velocityEngine = new VelocityEngine(); |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
89 try { |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
90 setupVelocity(velocityEngine); |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
91 } |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
92 catch (Exception e) { |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
93 logger.error(e, e); |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
94 return null; |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
95 } |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
96 } |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
97 return velocityEngine; |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
98 } |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
99 |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
100 |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
101 /** |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
102 * Initialize velocity. |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
103 * |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
104 * @param engine Velocity engine. |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
105 * @throws Exception if an error occured while initializing velocity. |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
106 */ |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
107 protected void setupVelocity(VelocityEngine engine) |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
108 throws Exception |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
109 { |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
110 engine.setProperty( |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
111 "input.encoding", |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
112 "UTF-8"); |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
113 |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
114 engine.setProperty( |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
115 RuntimeConstants.RUNTIME_LOG, |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
116 getVelocityLogfile()); |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
117 |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
118 engine.setProperty( |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
119 "resource.loader", |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
120 "file"); |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
121 |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
122 engine.setProperty( |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
123 "file.resource.loader.path", |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
124 getMapserverTemplatePath()); |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
125 |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
126 engine.init(); |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
127 } |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
128 |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
129 protected abstract String getVelocityLogfile(); |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
130 |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
131 protected abstract String getMapserverTemplatePath(); |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
132 |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
133 protected abstract String getMapserverUrl(); |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
134 |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
135 protected VelocityContext getVelocityContext() { |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
136 VelocityContext context = new VelocityContext(); |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
137 |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
138 try { |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
139 context.put("MAPSERVERURL", |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
140 getMapserverUrl()); |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
141 context.put("SHAPEFILEPATH", |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
142 getShapefileBaseDir().getCanonicalPath()); |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
143 context.put("CONFIGDIR", |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
144 Config.getConfigDirectory().getCanonicalPath()); |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
145 } |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
146 catch (FileNotFoundException fnfe) { |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
147 // this is bad |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
148 logger.warn(fnfe, fnfe); |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
149 } |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
150 catch (IOException ioe) { |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
151 // this is also bad |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
152 logger.warn(ioe, ioe); |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
153 } |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
154 |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
155 return context; |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
156 } |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
157 |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
158 |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
159 /** |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
160 * Returns a template specified by <i>model</i>. |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
161 * |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
162 * @param model The name of the template. |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
163 * @return a template. |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
164 */ |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
165 protected Template getTemplateByName(String model) { |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
166 if (model.indexOf(".vm") < 0) { |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
167 model = model.concat(".vm"); |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
168 } |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
169 |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
170 try { |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
171 VelocityEngine engine = getVelocityEngine(); |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
172 if (engine == null) { |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
173 logger.error("Error while fetching VelocityEngine."); |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
174 return null; |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
175 } |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
176 |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
177 return engine.getTemplate(model); |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
178 } |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
179 catch (Exception e) { |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
180 logger.warn(e, e); |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
181 } |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
182 |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
183 return null; |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
184 } |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
185 |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
186 |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
187 /** |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
188 * Returns the mapfile template. |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
189 * |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
190 * @return the mapfile template. |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
191 * @throws Exception if an error occured while reading the configuration. |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
192 */ |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
193 protected Template getMapfileTemplateObj() |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
194 throws Exception |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
195 { |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
196 String mapfileName = getMapfileTemplate(); |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
197 return getTemplateByName(mapfileName); |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
198 } |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
199 |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
200 protected abstract String getMapfilePath(); |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
201 |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
202 protected abstract String getMapfileTemplate(); |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
203 |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
204 |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
205 /** |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
206 * Returns the base directory storing the shapefiles. |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
207 * |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
208 * @return the shapefile base directory. |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
209 * |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
210 * @throws FileNotFoundException if no shapefile path is found or |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
211 * configured. |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
212 */ |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
213 public File getShapefileBaseDir() |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
214 throws FileNotFoundException, IOException |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
215 { |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
216 if (shapefileDirectory == null) { |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
217 String path = FLYSUtils.getXPathString( |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
218 FLYSUtils.XPATH_FLOODMAP_SHAPEFILE_DIR); |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
219 |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
220 if (path != null) { |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
221 shapefileDirectory = new File(path); |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
222 } |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
223 |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
224 if (shapefileDirectory == null) { |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
225 throw new FileNotFoundException("No shapefile directory given"); |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
226 } |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
227 |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
228 if (!shapefileDirectory.exists()) { |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
229 shapefileDirectory.mkdirs(); |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
230 } |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
231 } |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
232 |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
233 return shapefileDirectory; |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
234 } |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
235 |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
236 |
5023
1da61095040c
Renaming methods and fields. Start refactoring with ArtifactMapfileGenerator.generate() which should be the main entry point.
Christian Lins <christian.lins@intevation.de>
parents:
5022
diff
changeset
|
237 protected File[] getProjectDirs() |
5022
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
238 throws FileNotFoundException, IOException |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
239 { |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
240 File baseDir = getShapefileBaseDir(); |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
241 File[] artifactDirs = baseDir.listFiles(); |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
242 |
5087
cbfdd7376009
ArtifactMapfileGenerator can now generate user shape mapfiles again.
Christian Lins <christian.lins@intevation.de>
parents:
5076
diff
changeset
|
243 logger.debug("getProjectDirs(): found " + artifactDirs.length + " project directories"); |
5022
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
244 return artifactDirs; |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
245 } |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
246 |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
247 |
5023
1da61095040c
Renaming methods and fields. Start refactoring with ArtifactMapfileGenerator.generate() which should be the main entry point.
Christian Lins <christian.lins@intevation.de>
parents:
5022
diff
changeset
|
248 /** |
1da61095040c
Renaming methods and fields. Start refactoring with ArtifactMapfileGenerator.generate() which should be the main entry point.
Christian Lins <christian.lins@intevation.de>
parents:
5022
diff
changeset
|
249 * Search in all given directories for shapefiles that can be used |
1da61095040c
Renaming methods and fields. Start refactoring with ArtifactMapfileGenerator.generate() which should be the main entry point.
Christian Lins <christian.lins@intevation.de>
parents:
5022
diff
changeset
|
250 * as barrier, user oder wsplgen layers. |
1da61095040c
Renaming methods and fields. Start refactoring with ArtifactMapfileGenerator.generate() which should be the main entry point.
Christian Lins <christian.lins@intevation.de>
parents:
5022
diff
changeset
|
251 * @param dirs |
1da61095040c
Renaming methods and fields. Start refactoring with ArtifactMapfileGenerator.generate() which should be the main entry point.
Christian Lins <christian.lins@intevation.de>
parents:
5022
diff
changeset
|
252 * @return |
1da61095040c
Renaming methods and fields. Start refactoring with ArtifactMapfileGenerator.generate() which should be the main entry point.
Christian Lins <christian.lins@intevation.de>
parents:
5022
diff
changeset
|
253 */ |
1da61095040c
Renaming methods and fields. Start refactoring with ArtifactMapfileGenerator.generate() which should be the main entry point.
Christian Lins <christian.lins@intevation.de>
parents:
5022
diff
changeset
|
254 protected List<File> searchForLayerShapes(File[] dirs) { |
1da61095040c
Renaming methods and fields. Start refactoring with ArtifactMapfileGenerator.generate() which should be the main entry point.
Christian Lins <christian.lins@intevation.de>
parents:
5022
diff
changeset
|
255 List<File> shapes = new ArrayList<File>(); |
5022
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
256 |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
257 for (File dir: dirs) { |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
258 File[] layerFiles = dir.listFiles(new FilenameFilter() { |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
259 @Override |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
260 public boolean accept(File directory, String name) { |
5087
cbfdd7376009
ArtifactMapfileGenerator can now generate user shape mapfiles again.
Christian Lins <christian.lins@intevation.de>
parents:
5076
diff
changeset
|
261 return name.endsWith(".shp") && |
cbfdd7376009
ArtifactMapfileGenerator can now generate user shape mapfiles again.
Christian Lins <christian.lins@intevation.de>
parents:
5076
diff
changeset
|
262 (name.startsWith(MS_PREFIX_BARRIERS) || |
cbfdd7376009
ArtifactMapfileGenerator can now generate user shape mapfiles again.
Christian Lins <christian.lins@intevation.de>
parents:
5076
diff
changeset
|
263 name.startsWith(MS_PREFIX_USER) || |
cbfdd7376009
ArtifactMapfileGenerator can now generate user shape mapfiles again.
Christian Lins <christian.lins@intevation.de>
parents:
5076
diff
changeset
|
264 name.startsWith(MS_PREFIX_WSPLGEN)); |
5022
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
265 } |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
266 }); |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
267 |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
268 for (File layer: layerFiles) { |
5023
1da61095040c
Renaming methods and fields. Start refactoring with ArtifactMapfileGenerator.generate() which should be the main entry point.
Christian Lins <christian.lins@intevation.de>
parents:
5022
diff
changeset
|
269 shapes.add(layer); |
5022
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
270 } |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
271 } |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
272 |
5087
cbfdd7376009
ArtifactMapfileGenerator can now generate user shape mapfiles again.
Christian Lins <christian.lins@intevation.de>
parents:
5076
diff
changeset
|
273 logger.debug("searchForLayerShapes(): found " + shapes.size() + " shapefiles"); |
5023
1da61095040c
Renaming methods and fields. Start refactoring with ArtifactMapfileGenerator.generate() which should be the main entry point.
Christian Lins <christian.lins@intevation.de>
parents:
5022
diff
changeset
|
274 return shapes; |
5022
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
275 } |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
276 |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
277 |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
278 /** |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
279 * Creates a layer snippet which might be included in the mapfile. |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
280 * |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
281 * @param layerinfo A LayerInfo object that contains all necessary |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
282 * information to build a Mapserver LAYER section. |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
283 * @param dir The base dir for the LAYER snippet. |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
284 * @param filename The name of the file that is written. |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
285 * @param tpl The Velocity template which is used to create the LAYER |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
286 * section. |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
287 */ |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
288 protected void writeLayer( |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
289 LayerInfo layerInfo, |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
290 File layerFile, |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
291 Template tpl |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
292 ) |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
293 throws FileNotFoundException |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
294 { |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
295 if (logger.isDebugEnabled()) { |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
296 logger.debug("Write layer for:"); |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
297 logger.debug(" directory/file: " + layerFile.getName()); |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
298 } |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
299 |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
300 Writer writer = null; |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
301 |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
302 try { |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
303 writer = new FileWriter(layerFile); |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
304 |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
305 VelocityContext context = getVelocityContext(); |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
306 context.put("LAYER", layerInfo); |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
307 |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
308 tpl.merge(context, writer); |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
309 } |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
310 catch (FileNotFoundException fnfe) { |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
311 logger.error(fnfe, fnfe); |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
312 } |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
313 catch (IOException ioe) { |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
314 logger.error(ioe, ioe); |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
315 } |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
316 catch (Exception e) { |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
317 logger.error(e, e); |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
318 } |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
319 finally { |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
320 try { |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
321 if (writer != null) { |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
322 writer.close(); |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
323 } |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
324 } |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
325 catch (IOException ioe) { |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
326 logger.debug(ioe, ioe); |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
327 } |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
328 } |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
329 } |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
330 |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
331 |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
332 /** |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
333 * Creates a mapfile with the layer information stored in <i>layers</i>. |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
334 * |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
335 * @param layers Layer information. |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
336 */ |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
337 protected void writeMapfile(List<String> layers) { |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
338 String tmpMapName = "mapfile" + new Date().getTime(); |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
339 |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
340 File mapfile = new File(getMapfilePath()); |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
341 |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
342 File tmp = null; |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
343 Writer writer = null; |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
344 |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
345 try { |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
346 tmp = new File(mapfile.getParent(), tmpMapName); |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
347 tmp.createNewFile(); |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
348 |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
349 writer = new FileWriter(tmp); |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
350 |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
351 VelocityContext context = getVelocityContext(); |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
352 context.put("LAYERS", layers); |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
353 |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
354 Template mapTemplate = getMapfileTemplateObj(); |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
355 if (mapTemplate == null) { |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
356 logger.warn("No mapfile template found."); |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
357 return; |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
358 } |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
359 |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
360 mapTemplate.merge(context, writer); |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
361 |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
362 // we need to create a temporary mapfile first und rename it into |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
363 // real mapfile because we don't run into race conditions on this |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
364 // way. (iw) |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
365 tmp.renameTo(mapfile); |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
366 } |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
367 catch (FileNotFoundException fnfe) { |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
368 logger.error(fnfe, fnfe); |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
369 } |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
370 catch (IOException ioe) { |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
371 logger.error(ioe, ioe); |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
372 } |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
373 catch (Exception e) { |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
374 logger.error(e, e); |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
375 } |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
376 finally { |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
377 try { |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
378 if (writer != null) { |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
379 writer.close(); |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
380 } |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
381 |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
382 if (tmp.exists()) { |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
383 tmp.delete(); |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
384 } |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
385 } |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
386 catch (IOException ioe) { |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
387 logger.debug(ioe, ioe); |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
388 } |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
389 } |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
390 } |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
391 } |
a9243df307b1
Move all classes of mapfile generation to de.intevation.flys.mapserver package.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
392 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |