Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/utils/ArtefactMapfileGenerator.java @ 4656:442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
On startup the RiverMapfileGeneratorStarter is called by the server app.
The starter invokes a call to RiverMapfileGenerator.generate() which
reads all available rivers from the database and generates
layers for each river (in theory...uncompleted) in a
river.map file.
The old MapfileGenerator which generates layers that have
artifact dependencies is now in ArtifactMapfileGenerator.
author | Christian Lins <christian.lins@intevation.de> |
---|---|
date | Tue, 11 Dec 2012 15:24:24 +0100 |
parents | 861c47e0a8a0 |
children |
rev | line source |
---|---|
4654
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.utils; |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
2 |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
3 import de.intevation.artifacts.CallContext; |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
4 import de.intevation.flys.artifacts.FLYSArtifact; |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
5 import de.intevation.flys.artifacts.model.LayerInfo; |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
6 import de.intevation.flys.artifacts.model.map.WMSDBLayerFacet; |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
7 import de.intevation.flys.artifacts.model.map.WMSLayerFacet; |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
8 import de.intevation.flys.artifacts.model.map.WSPLGENLayerFacet; |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
9 import de.intevation.flys.artifacts.resources.Resources; |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
10 |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
11 import java.io.File; |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
12 import java.io.FileNotFoundException; |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
13 import java.io.IOException; |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
14 import java.util.List; |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
15 |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
16 import org.apache.log4j.Logger; |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
17 import org.apache.velocity.Template; |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
18 import org.geotools.data.shapefile.ShpFiles; |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
19 import org.geotools.data.shapefile.shp.ShapefileHeader; |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
20 import org.geotools.data.shapefile.shp.ShapefileReader; |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
21 |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
22 public class ArtefactMapfileGenerator extends MapfileGenerator { |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
23 |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
24 private static Logger logger = Logger.getLogger(ArtefactMapfileGenerator.class); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
25 |
4656
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
26 @Override |
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
27 protected String getVelocityLogfile() { |
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
28 return FLYSUtils.getXPathString(FLYSUtils.XPATH_FLOODMAP_VELOCITY_LOGFILE); |
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
29 } |
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
30 |
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
31 @Override |
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
32 protected String getMapserverTemplatePath() { |
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
33 return FLYSUtils.getXPathString(FLYSUtils.XPATH_FLOODMAP_MAPSERVER_TEMPLATE_PATH); |
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
34 } |
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
35 |
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
36 @Override |
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
37 protected String getMapserverUrl() { |
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
38 return FLYSUtils.getXPathString(FLYSUtils.XPATH_FLOODMAP_MAPSERVER_URL); |
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
39 } |
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
40 |
4654
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
41 /** |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
42 * Method which starts searching for meta information file and mapfile |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
43 * generation. |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
44 */ |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
45 @Override |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
46 public void generate() throws IOException |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
47 { |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
48 File[] userDirs = getUserDirs(); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
49 List<String> layers = parseLayers(userDirs); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
50 logger.info("Found " + layers.size() + " layers for user mapfile."); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
51 |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
52 writeMapfile(layers); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
53 } |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
54 |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
55 /** |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
56 * Creates a layer file used for Mapserver's mapfile which represents the |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
57 * floodmap. |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
58 * |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
59 * @param flys The FLYSArtifact that owns <i>wms</i>. |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
60 * @param wms The WMSLayerFacet that contains information for the layer. |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
61 */ |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
62 public void createUeskLayer( |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
63 FLYSArtifact flys, |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
64 WSPLGENLayerFacet wms, |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
65 String style, |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
66 CallContext context |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
67 ) throws FileNotFoundException, IOException |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
68 { |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
69 logger.debug("createUeskLayer"); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
70 |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
71 LayerInfo layerinfo = new LayerInfo(); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
72 layerinfo.setName(MS_WSPLGEN_PREFIX + flys.identifier()); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
73 layerinfo.setType("POLYGON"); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
74 layerinfo.setDirectory(flys.identifier()); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
75 layerinfo.setData(WSPLGEN_RESULT_SHAPE); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
76 layerinfo.setTitle(Resources.getMsg(Resources.getLocale(context.getMeta()), |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
77 "floodmap.uesk", |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
78 "Floodmap")); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
79 layerinfo.setStyle(style); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
80 layerinfo.setSrid(wms.getSrid()); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
81 |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
82 String name = MS_LAYER_PREFIX + wms.getName(); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
83 |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
84 Template template = getTemplateByName(WSPLGEN_LAYER_TEMPLATE); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
85 if (template == null) { |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
86 logger.warn("Template '" + WSPLGEN_LAYER_TEMPLATE + "' found."); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
87 return; |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
88 } |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
89 |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
90 try { |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
91 File dir = new File(getShapefileBaseDir(), flys.identifier()); |
4656
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
92 writeLayer(layerinfo, new File(dir, name), template); |
4654
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
93 } |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
94 catch (FileNotFoundException fnfe) { |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
95 logger.error(fnfe, fnfe); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
96 logger.warn("Unable to write layer: " + name); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
97 } |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
98 } |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
99 |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
100 |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
101 /** |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
102 * Creates a layer file used for Mapserver's mapfile which represents the |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
103 * user defined barriers. |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
104 * |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
105 * @param flys The FLYSArtifact that owns <i>wms</i>. |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
106 * @param wms The WMSLayerFacet that contains information for the layer. |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
107 */ |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
108 public void createBarriersLayer(FLYSArtifact flys, WMSLayerFacet wms) |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
109 throws FileNotFoundException, IOException |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
110 { |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
111 logger.debug("createBarriersLayer"); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
112 |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
113 //String uuid = flys.identifier(); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
114 //File dir = new File(getShapefileBaseDir(), uuid); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
115 |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
116 createBarriersLineLayer(flys, wms); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
117 createBarriersPolygonLayer(flys, wms); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
118 } |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
119 |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
120 |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
121 protected void createBarriersLineLayer( |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
122 FLYSArtifact flys, |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
123 WMSLayerFacet wms |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
124 ) |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
125 throws FileNotFoundException, IOException |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
126 { |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
127 String uuid = flys.identifier(); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
128 String group = MS_BARRIERS_PREFIX + uuid; |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
129 String groupTitle = "I18N_BARRIERS_TITLE"; |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
130 |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
131 File dir = new File(getShapefileBaseDir(), uuid); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
132 File test = new File(dir, WSPLGEN_LINES_SHAPE); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
133 |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
134 if (!test.exists() || !test.canRead()) { |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
135 logger.debug("No barrier line layer existing."); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
136 return; |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
137 } |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
138 |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
139 LayerInfo lineInfo = new LayerInfo(); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
140 lineInfo.setName(MS_LINE_PREFIX + uuid); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
141 lineInfo.setType("LINE"); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
142 lineInfo.setDirectory(uuid); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
143 lineInfo.setData(WSPLGEN_LINES_SHAPE); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
144 lineInfo.setTitle("I18N_LINE_SHAPE"); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
145 lineInfo.setGroup(group); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
146 lineInfo.setGroupTitle(groupTitle); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
147 lineInfo.setSrid(wms.getSrid()); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
148 |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
149 String nameLines = MS_LAYER_PREFIX + wms.getName() + "-lines"; |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
150 |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
151 Template tpl = getTemplateByName(SHP_LAYER_TEMPLATE); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
152 if (tpl == null) { |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
153 logger.warn("Template '" + SHP_LAYER_TEMPLATE + "' found."); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
154 return; |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
155 } |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
156 |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
157 try { |
4656
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
158 writeLayer(lineInfo, new File(dir, nameLines), tpl); |
4654
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
159 } |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
160 catch (FileNotFoundException fnfe) { |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
161 logger.error(fnfe, fnfe); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
162 logger.warn("Unable to write layer: " + nameLines); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
163 } |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
164 } |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
165 |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
166 protected void createBarriersPolygonLayer( |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
167 FLYSArtifact flys, |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
168 WMSLayerFacet wms |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
169 ) |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
170 throws FileNotFoundException, IOException |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
171 { |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
172 String uuid = flys.identifier(); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
173 String group = uuid + MS_BARRIERS_PREFIX; |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
174 String groupTitle = "I18N_BARRIERS_TITLE"; |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
175 |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
176 File dir = new File(getShapefileBaseDir(), uuid); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
177 File test = new File(dir, WSPLGEN_POLYGONS_SHAPE); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
178 |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
179 if (!test.exists() || !test.canRead()) { |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
180 logger.debug("No barrier line layer existing."); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
181 return; |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
182 } |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
183 |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
184 LayerInfo polygonInfo = new LayerInfo(); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
185 polygonInfo.setName(MS_POLYGONS_PREFIX + uuid); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
186 polygonInfo.setType("POLYGON"); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
187 polygonInfo.setDirectory(uuid); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
188 polygonInfo.setData(WSPLGEN_POLYGONS_SHAPE); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
189 polygonInfo.setTitle("I18N_POLYGON_SHAPE"); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
190 polygonInfo.setGroup(group); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
191 polygonInfo.setGroupTitle(groupTitle); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
192 polygonInfo.setSrid(wms.getSrid()); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
193 |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
194 String namePolygons = MS_LAYER_PREFIX + wms.getName() + "-polygons"; |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
195 |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
196 Template tpl = getTemplateByName(SHP_LAYER_TEMPLATE); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
197 if (tpl == null) { |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
198 logger.warn("Template '" + SHP_LAYER_TEMPLATE + "' found."); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
199 return; |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
200 } |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
201 |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
202 try { |
4656
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
203 writeLayer(polygonInfo, new File(dir, namePolygons), tpl); |
4654
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
204 } |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
205 catch (FileNotFoundException fnfe) { |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
206 logger.error(fnfe, fnfe); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
207 logger.warn("Unable to write layer: " + namePolygons); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
208 } |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
209 } |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
210 |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
211 |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
212 /** |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
213 * Creates a layer file used for Mapserver's mapfile which represents the |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
214 * shape files uploaded by the user. |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
215 * |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
216 * @param flys The FLYSArtifact that owns <i>wms</i>. |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
217 * @param wms The WMSLayerFacet that contains information for the layer. |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
218 */ |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
219 public void createUserShapeLayer(FLYSArtifact flys, WMSLayerFacet wms) |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
220 throws FileNotFoundException, IOException |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
221 { |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
222 logger.debug("createUserShapeLayer"); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
223 |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
224 String uuid = flys.identifier(); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
225 File dir = new File(getShapefileBaseDir(), uuid); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
226 File test = new File(dir, WSPLGEN_USER_SHAPE); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
227 |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
228 if (!test.exists() || !test.canRead()) { |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
229 logger.debug("No user layer existing."); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
230 return; |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
231 } |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
232 |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
233 File userShape = new File(dir, WSPLGEN_USER_SHAPE); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
234 ShpFiles sf = new ShpFiles(userShape); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
235 ShapefileReader sfr = new ShapefileReader(sf, true, false, null); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
236 ShapefileHeader sfh = sfr.getHeader(); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
237 |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
238 String group = uuid + MS_USERSHAPE_PREFIX; |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
239 String groupTitle = "I18N_USER_SHAPE_TITLE"; |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
240 |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
241 LayerInfo info = new LayerInfo(); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
242 info.setName(MS_USERSHAPE_PREFIX + uuid); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
243 if (sfh.getShapeType().isLineType()) { |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
244 info.setType("LINE"); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
245 } |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
246 else if (sfh.getShapeType().isPolygonType()) { |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
247 info.setType("POLYGON"); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
248 } |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
249 else { |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
250 return; |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
251 } |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
252 info.setDirectory(uuid); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
253 info.setData(WSPLGEN_USER_SHAPE); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
254 info.setTitle("I18N_USER_SHAPE"); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
255 info.setGroup(group); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
256 info.setGroupTitle(groupTitle); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
257 info.setSrid(wms.getSrid()); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
258 |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
259 String nameUser = MS_LAYER_PREFIX + wms.getName(); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
260 |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
261 Template tpl = getTemplateByName(SHP_LAYER_TEMPLATE); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
262 if (tpl == null) { |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
263 logger.warn("Template '" + SHP_LAYER_TEMPLATE + "' found."); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
264 return; |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
265 } |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
266 |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
267 try { |
4656
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
268 writeLayer(info, new File(dir, nameUser), tpl); |
4654
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
269 } |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
270 catch (FileNotFoundException fnfe) { |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
271 logger.error(fnfe, fnfe); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
272 logger.warn("Unable to write layer: " + nameUser); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
273 } |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
274 |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
275 } |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
276 |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
277 |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
278 /** |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
279 * Creates a layer file used for Mapserver's mapfile which represents |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
280 * geometries from database. |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
281 * |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
282 * @param flys The FLYSArtifact that owns <i>wms</i>. |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
283 * @param wms The WMSLayerFacet that contains information for the layer. |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
284 */ |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
285 public void createDatabaseLayer( |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
286 FLYSArtifact flys, |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
287 WMSDBLayerFacet wms, |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
288 String style |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
289 ) |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
290 throws FileNotFoundException, IOException |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
291 { |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
292 logger.debug("createDatabaseLayer"); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
293 |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
294 LayerInfo layerinfo = new LayerInfo(); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
295 layerinfo.setName(wms.getName() + "-" + flys.identifier()); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
296 layerinfo.setType(wms.getGeometryType()); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
297 layerinfo.setFilter(wms.getFilter()); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
298 layerinfo.setData(wms.getData()); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
299 layerinfo.setTitle(wms.getDescription()); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
300 layerinfo.setStyle(style); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
301 if(wms.getExtent() != null) { |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
302 layerinfo.setExtent(GeometryUtils.jtsBoundsToOLBounds(wms.getExtent())); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
303 } |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
304 layerinfo.setConnection(wms.getConnection()); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
305 layerinfo.setConnectionType(wms.getConnectionType()); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
306 layerinfo.setLabelItem(wms.getLabelItem()); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
307 layerinfo.setSrid(wms.getSrid()); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
308 |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
309 String name = MS_LAYER_PREFIX + wms.getName(); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
310 |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
311 Template template = getTemplateByName(DB_LAYER_TEMPLATE); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
312 if (template == null) { |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
313 logger.warn("Template '" + DB_LAYER_TEMPLATE + "' found."); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
314 return; |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
315 } |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
316 |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
317 try { |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
318 File dir = new File(getShapefileBaseDir(), flys.identifier()); |
4656
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
319 writeLayer(layerinfo, new File(dir, name), template); |
4654
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
320 } |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
321 catch (FileNotFoundException fnfe) { |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
322 logger.error(fnfe, fnfe); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
323 logger.warn("Unable to write layer: " + name); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
324 } |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
325 } |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
326 |
4656
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
327 @Override |
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
328 protected String getMapfilePath() { |
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
329 return FLYSUtils.getXPathString(FLYSUtils.XPATH_FLOODMAP_MAPFILE_PATH); |
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
330 } |
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
331 |
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
332 @Override |
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
333 protected String getMapfileTemplate() { |
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
334 return FLYSUtils.getXPathString(FLYSUtils.XPATH_FLOODMAP_MAPFILE_TEMPLATE); |
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
335 } |
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
336 |
4654
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
337 } |