annotate flys-artifacts/src/main/java/de/intevation/flys/utils/ArtifactMapfileGenerator.java @ 4952:5a0225ddae2b dami

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

http://dive4elements.wald.intevation.org