Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/utils/ArtifactMapfileGenerator.java @ 6332:f5bb53106ae8
Remove createBarriersLayer and createBarriers
The generated mapfiles did not work and were just confusing. This
looks like historical cruft that was never deleted. The real barrier
mapfiles are created in the Floodmap state
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Thu, 13 Jun 2013 17:24:56 +0200 |
parents | af13ceeba52a |
children | 74a437805e2a |
comparison
equal
deleted
inserted
replaced
6331:91dfd6425f11 | 6332:f5bb53106ae8 |
---|---|
109 } | 109 } |
110 | 110 |
111 | 111 |
112 /** | 112 /** |
113 * Creates a layer file used for Mapserver's mapfile which represents the | 113 * Creates a layer file used for Mapserver's mapfile which represents the |
114 * user defined barriers. | 114 * shape files uploaded by the user. |
115 * | 115 * |
116 * @param flys The D4EArtifact that owns <i>wms</i>. | 116 * @param flys The D4EArtifact that owns <i>wms</i>. |
117 * @param wms The WMSLayerFacet that contains information for the layer. | 117 * @param wms The WMSLayerFacet that contains information for the layer. |
118 */ | 118 */ |
119 public void createBarriersLayer(D4EArtifact flys, WMSLayerFacet wms) | 119 public void createUserShapeLayer(D4EArtifact flys, WMSLayerFacet wms) |
120 throws FileNotFoundException, IOException | 120 throws FileNotFoundException, IOException |
121 { | 121 { |
122 logger.debug("createBarriersLayer"); | 122 logger.debug("createUserShapeLayer"); |
123 | 123 |
124 //String uuid = flys.identifier(); | 124 String uuid = flys.identifier(); |
125 //File dir = new File(getShapefileBaseDir(), uuid); | 125 File dir = new File(getShapefileBaseDir(), uuid); |
126 | 126 File test = new File(dir, WSPLGEN_USER_SHAPE); |
127 createBarriersLineLayer(flys, wms); | |
128 createBarriersPolygonLayer(flys, wms); | |
129 } | |
130 | |
131 | |
132 protected void createBarriersLineLayer( | |
133 D4EArtifact flys, | |
134 WMSLayerFacet wms | |
135 ) | |
136 throws FileNotFoundException, IOException | |
137 { | |
138 String uuid = flys.identifier(); | |
139 String group = MS_BARRIERS_PREFIX + uuid; | |
140 String groupTitle = "I18N_BARRIERS_TITLE"; | |
141 | |
142 File dir = new File(getShapefileBaseDir(), uuid); | |
143 File test = new File(dir, WSPLGEN_LINES_SHAPE); | |
144 | 127 |
145 if (!test.exists() || !test.canRead()) { | 128 if (!test.exists() || !test.canRead()) { |
146 logger.debug("No barrier line layer existing."); | 129 logger.debug("No user layer existing."); |
147 return; | 130 return; |
148 } | 131 } |
149 | 132 |
150 LayerInfo lineInfo = new LayerInfo(); | 133 File userShape = new File(dir, WSPLGEN_USER_SHAPE); |
151 lineInfo.setName(MS_LINE_PREFIX + uuid); | 134 ShpFiles sf = new ShpFiles(userShape); |
152 lineInfo.setType("LINE"); | 135 ShapefileReader sfr = new ShapefileReader(sf, true, false, null); |
153 lineInfo.setDirectory(uuid); | 136 ShapefileHeader sfh = sfr.getHeader(); |
154 lineInfo.setData(WSPLGEN_LINES_SHAPE); | 137 |
155 lineInfo.setTitle("I18N_LINE_SHAPE"); | 138 String group = uuid + MS_USERSHAPE_PREFIX; |
156 lineInfo.setGroup(group); | 139 String groupTitle = "I18N_USER_SHAPE_TITLE"; |
157 lineInfo.setGroupTitle(groupTitle); | 140 |
158 lineInfo.setSrid(wms.getSrid()); | 141 LayerInfo info = new LayerInfo(); |
159 | 142 info.setName(MS_USERSHAPE_PREFIX + uuid); |
160 String nameLines = MS_LAYER_PREFIX + wms.getName() + "-lines"; | 143 if (sfh.getShapeType().isLineType()) { |
144 info.setType("LINE"); | |
145 } | |
146 else if (sfh.getShapeType().isPolygonType()) { | |
147 info.setType("POLYGON"); | |
148 } | |
149 else { | |
150 return; | |
151 } | |
152 info.setDirectory(uuid); | |
153 info.setData(WSPLGEN_USER_SHAPE); | |
154 info.setTitle("I18N_USER_SHAPE"); | |
155 info.setGroup(group); | |
156 info.setGroupTitle(groupTitle); | |
157 info.setSrid(wms.getSrid()); | |
158 | |
159 String nameUser = MS_LAYER_PREFIX + wms.getName(); | |
161 | 160 |
162 Template tpl = getTemplateByName(SHP_LAYER_TEMPLATE); | 161 Template tpl = getTemplateByName(SHP_LAYER_TEMPLATE); |
163 if (tpl == null) { | 162 if (tpl == null) { |
164 logger.warn("Template '" + SHP_LAYER_TEMPLATE + "' found."); | 163 logger.warn("Template '" + SHP_LAYER_TEMPLATE + "' found."); |
165 return; | 164 return; |
166 } | 165 } |
167 | 166 |
168 try { | 167 try { |
169 writeLayer(lineInfo, new File(dir, nameLines), tpl); | 168 writeLayer(info, new File(dir, nameUser), tpl); |
170 } | 169 } |
171 catch (FileNotFoundException fnfe) { | 170 catch (FileNotFoundException fnfe) { |
172 logger.error(fnfe, fnfe); | 171 logger.error(fnfe, fnfe); |
173 logger.warn("Unable to write layer: " + nameLines); | 172 logger.warn("Unable to write layer: " + nameUser); |
174 } | 173 } |
175 } | 174 |
176 | 175 } |
177 protected void createBarriersPolygonLayer( | 176 |
178 D4EArtifact flys, | 177 |
179 WMSLayerFacet wms | 178 /** |
180 ) | 179 * Creates a layer file used for Mapserver's mapfile which represents |
181 throws FileNotFoundException, IOException | 180 * geometries from database. |
182 { | 181 * |
183 String uuid = flys.identifier(); | 182 * @param flys The D4EArtifact that owns <i>wms</i>. |
184 String group = uuid + MS_BARRIERS_PREFIX; | 183 * @param wms The WMSLayerFacet that contains information for the layer. |
185 String groupTitle = "I18N_BARRIERS_TITLE"; | 184 */ |
186 | 185 public void createDatabaseLayer( |
187 File dir = new File(getShapefileBaseDir(), uuid); | |
188 File test = new File(dir, WSPLGEN_POLYGONS_SHAPE); | |
189 | |
190 if (!test.exists() || !test.canRead()) { | |
191 logger.debug("No barrier line layer existing."); | |
192 return; | |
193 } | |
194 | |
195 LayerInfo polygonInfo = new LayerInfo(); | |
196 polygonInfo.setName(MS_POLYGONS_PREFIX + uuid); | |
197 polygonInfo.setType("POLYGON"); | |
198 polygonInfo.setDirectory(uuid); | |
199 polygonInfo.setData(WSPLGEN_POLYGONS_SHAPE); | |
200 polygonInfo.setTitle("I18N_POLYGON_SHAPE"); | |
201 polygonInfo.setGroup(group); | |
202 polygonInfo.setGroupTitle(groupTitle); | |
203 polygonInfo.setSrid(wms.getSrid()); | |
204 | |
205 String namePolygons = MS_LAYER_PREFIX + wms.getName() + "-polygons"; | |
206 | |
207 Template tpl = getTemplateByName(SHP_LAYER_TEMPLATE); | |
208 if (tpl == null) { | |
209 logger.warn("Template '" + SHP_LAYER_TEMPLATE + "' found."); | |
210 return; | |
211 } | |
212 | |
213 try { | |
214 writeLayer(polygonInfo, new File(dir, namePolygons), tpl); | |
215 } | |
216 catch (FileNotFoundException fnfe) { | |
217 logger.error(fnfe, fnfe); | |
218 logger.warn("Unable to write layer: " + namePolygons); | |
219 } | |
220 } | |
221 | |
222 | |
223 /** | |
224 * Creates a layer file used for Mapserver's mapfile which represents the | |
225 * shape files uploaded by the user. | |
226 * | |
227 * @param flys The D4EArtifact that owns <i>wms</i>. | |
228 * @param wms The WMSLayerFacet that contains information for the layer. | |
229 */ | |
230 public void createUserShapeLayer(D4EArtifact flys, WMSLayerFacet wms) | |
231 throws FileNotFoundException, IOException | |
232 { | |
233 logger.debug("createUserShapeLayer"); | |
234 | |
235 String uuid = flys.identifier(); | |
236 File dir = new File(getShapefileBaseDir(), uuid); | |
237 File test = new File(dir, WSPLGEN_USER_SHAPE); | |
238 | |
239 if (!test.exists() || !test.canRead()) { | |
240 logger.debug("No user layer existing."); | |
241 return; | |
242 } | |
243 | |
244 File userShape = new File(dir, WSPLGEN_USER_SHAPE); | |
245 ShpFiles sf = new ShpFiles(userShape); | |
246 ShapefileReader sfr = new ShapefileReader(sf, true, false, null); | |
247 ShapefileHeader sfh = sfr.getHeader(); | |
248 | |
249 String group = uuid + MS_USERSHAPE_PREFIX; | |
250 String groupTitle = "I18N_USER_SHAPE_TITLE"; | |
251 | |
252 LayerInfo info = new LayerInfo(); | |
253 info.setName(MS_USERSHAPE_PREFIX + uuid); | |
254 if (sfh.getShapeType().isLineType()) { | |
255 info.setType("LINE"); | |
256 } | |
257 else if (sfh.getShapeType().isPolygonType()) { | |
258 info.setType("POLYGON"); | |
259 } | |
260 else { | |
261 return; | |
262 } | |
263 info.setDirectory(uuid); | |
264 info.setData(WSPLGEN_USER_SHAPE); | |
265 info.setTitle("I18N_USER_SHAPE"); | |
266 info.setGroup(group); | |
267 info.setGroupTitle(groupTitle); | |
268 info.setSrid(wms.getSrid()); | |
269 | |
270 String nameUser = MS_LAYER_PREFIX + wms.getName(); | |
271 | |
272 Template tpl = getTemplateByName(SHP_LAYER_TEMPLATE); | |
273 if (tpl == null) { | |
274 logger.warn("Template '" + SHP_LAYER_TEMPLATE + "' found."); | |
275 return; | |
276 } | |
277 | |
278 try { | |
279 writeLayer(info, new File(dir, nameUser), tpl); | |
280 } | |
281 catch (FileNotFoundException fnfe) { | |
282 logger.error(fnfe, fnfe); | |
283 logger.warn("Unable to write layer: " + nameUser); | |
284 } | |
285 | |
286 } | |
287 | |
288 | |
289 /** | |
290 * Creates a layer file used for Mapserver's mapfile which represents | |
291 * geometries from database. | |
292 * | |
293 * @param flys The D4EArtifact that owns <i>wms</i>. | |
294 * @param wms The WMSLayerFacet that contains information for the layer. | |
295 */ | |
296 public void createDatabaseLayer( | |
297 D4EArtifact flys, | 186 D4EArtifact flys, |
298 WMSDBLayerFacet wms, | 187 WMSDBLayerFacet wms, |
299 String style | 188 String style |
300 ) | 189 ) |
301 throws FileNotFoundException, IOException | 190 throws FileNotFoundException, IOException |
302 { | 191 { |
303 logger.debug("createDatabaseLayer"); | 192 logger.debug("createDatabaseLayer"); |
304 | 193 |
305 LayerInfo layerinfo = new LayerInfo(); | 194 LayerInfo layerinfo = new LayerInfo(); |
306 layerinfo.setName(wms.getName() + "-" + flys.identifier()); | 195 layerinfo.setName(wms.getName() + "-" + flys.identifier()); |
307 layerinfo.setType(wms.getGeometryType()); | 196 layerinfo.setType(wms.getGeometryType()); |
308 layerinfo.setFilter(wms.getFilter()); | 197 layerinfo.setFilter(wms.getFilter()); |
309 layerinfo.setData(wms.getData()); | 198 layerinfo.setData(wms.getData()); |
310 layerinfo.setTitle(wms.getDescription()); | 199 layerinfo.setTitle(wms.getDescription()); |
311 layerinfo.setStyle(style); | 200 layerinfo.setStyle(style); |
312 if(wms.getExtent() != null) { | 201 if(wms.getExtent() != null) { |
313 layerinfo.setExtent(GeometryUtils.jtsBoundsToOLBounds(wms.getExtent())); | 202 layerinfo.setExtent(GeometryUtils.jtsBoundsToOLBounds(wms.getExtent())); |
314 } | 203 } |
315 layerinfo.setConnection(wms.getConnection()); | 204 layerinfo.setConnection(wms.getConnection()); |
316 layerinfo.setConnectionType(wms.getConnectionType()); | 205 layerinfo.setConnectionType(wms.getConnectionType()); |
317 layerinfo.setLabelItem(wms.getLabelItem()); | 206 layerinfo.setLabelItem(wms.getLabelItem()); |
318 layerinfo.setSrid(wms.getSrid()); | 207 layerinfo.setSrid(wms.getSrid()); |
319 | 208 |
320 String name = MS_LAYER_PREFIX + wms.getName(); | 209 String name = MS_LAYER_PREFIX + wms.getName(); |
321 | 210 |
322 Template template = getTemplateByName(DB_LAYER_TEMPLATE); | 211 Template template = getTemplateByName(DB_LAYER_TEMPLATE); |
323 if (template == null) { | 212 if (template == null) { |
324 logger.warn("Template '" + DB_LAYER_TEMPLATE + "' found."); | 213 logger.warn("Template '" + DB_LAYER_TEMPLATE + "' found."); |
325 return; | 214 return; |
326 } | 215 } |
327 | 216 |
328 try { | 217 try { |
329 File dir = new File(getShapefileBaseDir(), flys.identifier()); | 218 File dir = new File(getShapefileBaseDir(), flys.identifier()); |
330 writeLayer(layerinfo, new File(dir, name), template); | 219 writeLayer(layerinfo, new File(dir, name), template); |
331 } | 220 } |
332 catch (FileNotFoundException fnfe) { | 221 catch (FileNotFoundException fnfe) { |
333 logger.error(fnfe, fnfe); | 222 logger.error(fnfe, fnfe); |
334 logger.warn("Unable to write layer: " + name); | 223 logger.warn("Unable to write layer: " + name); |
335 } | 224 } |
336 } | 225 } |
337 | 226 |
338 @Override | 227 @Override |
339 protected String getMapfilePath() { | 228 protected String getMapfilePath() { |
340 return RiverUtils.getXPathString(RiverUtils.XPATH_FLOODMAP_MAPFILE_PATH); | 229 return RiverUtils.getXPathString(RiverUtils.XPATH_FLOODMAP_MAPFILE_PATH); |
341 } | 230 } |
342 | 231 |
343 @Override | 232 @Override |
344 protected String getMapfileTemplate() { | 233 protected String getMapfileTemplate() { |
345 return RiverUtils.getXPathString(RiverUtils.XPATH_FLOODMAP_MAPFILE_TEMPLATE); | 234 return RiverUtils.getXPathString(RiverUtils.XPATH_FLOODMAP_MAPFILE_TEMPLATE); |
346 } | 235 } |
347 | 236 |
348 } | 237 } |