Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/utils/ArtifactMapfileGenerator.java @ 5677:413798463dfe
Do ordering in the data dictionary and replace "null" strings with empty strings
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Fri, 12 Apr 2013 12:58:46 +0200 |
parents | b55975761708 |
children |
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; |
4994
63617e142dfe
Quick-fix for floodmaps. Use the correct projection for DGM.
Raimund Renkert <rrenkert@intevation.de>
parents:
4702
diff
changeset
|
5 import de.intevation.flys.artifacts.access.RiverAccess; |
4702
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.LayerInfo; |
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.WMSDBLayerFacet; |
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.WMSLayerFacet; |
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.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
|
10 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
|
11 |
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.File; |
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.FileNotFoundException; |
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.io.IOException; |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
15 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
|
16 |
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.log4j.Logger; |
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.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
|
19 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
|
20 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
|
21 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
|
22 |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
23 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
|
24 |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
25 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
|
26 |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
27 @Override |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
28 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
|
29 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
|
30 } |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
31 |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
32 @Override |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
33 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
|
34 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
|
35 } |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
36 |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
37 @Override |
5309
b55975761708
Changed visiblitiy of some methods. TODO: A lot of refactoring.
Raimund Renkert <rrenkert@intevation.de>
parents:
4994
diff
changeset
|
38 public String getMapserverUrl() { |
4702
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
39 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
|
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 /** |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
43 * 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
|
44 * generation. |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
45 */ |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
46 @Override |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
47 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
|
48 { |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
49 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
|
50 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
|
51 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
|
52 |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
53 writeMapfile(layers); |
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 /** |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
57 * 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
|
58 * floodmap. |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
59 * |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
60 * @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
|
61 * @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
|
62 */ |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
63 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
|
64 FLYSArtifact flys, |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
65 WSPLGENLayerFacet wms, |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
66 String style, |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
67 CallContext context |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
68 ) 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
|
69 { |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
70 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
|
71 |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
72 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
|
73 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
|
74 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
|
75 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
|
76 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
|
77 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
|
78 "floodmap.uesk", |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
79 "Floodmap")); |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
80 layerinfo.setStyle(style); |
4994
63617e142dfe
Quick-fix for floodmaps. Use the correct projection for DGM.
Raimund Renkert <rrenkert@intevation.de>
parents:
4702
diff
changeset
|
81 RiverAccess access = new RiverAccess(flys); |
63617e142dfe
Quick-fix for floodmaps. Use the correct projection for DGM.
Raimund Renkert <rrenkert@intevation.de>
parents:
4702
diff
changeset
|
82 String river = access.getRiver(); |
63617e142dfe
Quick-fix for floodmaps. Use the correct projection for DGM.
Raimund Renkert <rrenkert@intevation.de>
parents:
4702
diff
changeset
|
83 layerinfo.setSrid(FLYSUtils.getRiverDGMSrid(river)); |
4702
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
84 |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
85 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
|
86 |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
87 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
|
88 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
|
89 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
|
90 return; |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
91 } |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
92 |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
93 try { |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
94 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
|
95 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
|
96 } |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
97 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
|
98 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
|
99 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
|
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 |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
103 |
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 * 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
|
106 * 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
|
107 * |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
108 * @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
|
109 * @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
|
110 */ |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
111 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
|
112 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
|
113 { |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
114 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
|
115 |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
116 //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
|
117 //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
|
118 |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
119 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
|
120 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
|
121 } |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
122 |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
123 |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
124 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
|
125 FLYSArtifact flys, |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
126 WMSLayerFacet wms |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
127 ) |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
128 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
|
129 { |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
130 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
|
131 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
|
132 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
|
133 |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
134 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
|
135 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
|
136 |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
137 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
|
138 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
|
139 return; |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
140 } |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
141 |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
142 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
|
143 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
|
144 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
|
145 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
|
146 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
|
147 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
|
148 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
|
149 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
|
150 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
|
151 |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
152 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
|
153 |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
154 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
|
155 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
|
156 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
|
157 return; |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
158 } |
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 try { |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
161 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
|
162 } |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
163 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
|
164 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
|
165 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
|
166 } |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
167 } |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
168 |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
169 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
|
170 FLYSArtifact flys, |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
171 WMSLayerFacet wms |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
172 ) |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
173 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
|
174 { |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
175 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
|
176 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
|
177 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
|
178 |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
179 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
|
180 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
|
181 |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
182 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
|
183 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
|
184 return; |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
185 } |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
186 |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
187 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
|
188 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
|
189 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
|
190 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
|
191 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
|
192 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
|
193 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
|
194 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
|
195 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
|
196 |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
197 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
|
198 |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
199 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
|
200 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
|
201 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
|
202 return; |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
203 } |
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 try { |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
206 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
|
207 } |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
208 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
|
209 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
|
210 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
|
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 |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
214 |
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 * 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
|
217 * 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
|
218 * |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
219 * @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
|
220 * @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
|
221 */ |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
222 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
|
223 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
|
224 { |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
225 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
|
226 |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
227 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
|
228 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
|
229 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
|
230 |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
231 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
|
232 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
|
233 return; |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
234 } |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
235 |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
236 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
|
237 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
|
238 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
|
239 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
|
240 |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
241 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
|
242 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
|
243 |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
244 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
|
245 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
|
246 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
|
247 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
|
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 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
|
250 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
|
251 } |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
252 else { |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
253 return; |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
254 } |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
255 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
|
256 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
|
257 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
|
258 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
|
259 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
|
260 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
|
261 |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
262 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
|
263 |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
264 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
|
265 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
|
266 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
|
267 return; |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
268 } |
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 try { |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
271 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
|
272 } |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
273 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
|
274 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
|
275 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
|
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 |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
280 |
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 * 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
|
283 * 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
|
284 * |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
285 * @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
|
286 * @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
|
287 */ |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
288 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
|
289 FLYSArtifact flys, |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
290 WMSDBLayerFacet wms, |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
291 String style |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
292 ) |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
293 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
|
294 { |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
295 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
|
296 |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
297 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
|
298 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
|
299 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
|
300 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
|
301 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
|
302 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
|
303 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
|
304 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
|
305 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
|
306 } |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
307 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
|
308 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
|
309 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
|
310 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
|
311 |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
312 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
|
313 |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
314 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
|
315 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
|
316 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
|
317 return; |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
318 } |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
319 |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
320 try { |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
321 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
|
322 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
|
323 } |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
324 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
|
325 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
|
326 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
|
327 } |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
328 } |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
329 |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
330 @Override |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
331 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
|
332 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
|
333 } |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
334 |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
335 @Override |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
336 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
|
337 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
|
338 } |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
339 |
13abfb1bcb75
Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
340 } |