annotate flys-artifacts/src/main/java/de/intevation/flys/utils/RiverMapfileGenerator.java @ 4702:13abfb1bcb75

Fix typo in class names and correct file path in floodmap.xml.
author Christian Lins <christian.lins@intevation.de>
date Mon, 17 Dec 2012 23:24:27 +0100
parents 442fbb290fa8
children 38ec171544de
rev   line source
4654
861c47e0a8a0 Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.utils;
861c47e0a8a0 Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
2
861c47e0a8a0 Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
3 import de.intevation.flys.artifacts.model.LayerInfo;
861c47e0a8a0 Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
4 import de.intevation.flys.artifacts.model.RiverFactory;
861c47e0a8a0 Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
5 import de.intevation.flys.model.River;
861c47e0a8a0 Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
6
4656
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4654
diff changeset
7 import java.io.File;
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4654
diff changeset
8 import java.io.FileNotFoundException;
4702
13abfb1bcb75 Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents: 4656
diff changeset
9 import java.util.ArrayList;
4654
861c47e0a8a0 Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
10 import java.util.List;
861c47e0a8a0 Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
11
4656
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4654
diff changeset
12 import org.apache.log4j.Logger;
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4654
diff changeset
13 import org.apache.velocity.Template;
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4654
diff changeset
14
4654
861c47e0a8a0 Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
15 public class RiverMapfileGenerator extends MapfileGenerator {
861c47e0a8a0 Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
16
4656
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4654
diff changeset
17 private static Logger logger = Logger.getLogger(RiverMapfileGenerator.class);
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4654
diff changeset
18
4654
861c47e0a8a0 Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
19 /**
861c47e0a8a0 Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
20 * Generate river axis mapfile.
861c47e0a8a0 Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
21 */
861c47e0a8a0 Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
22 @Override
4656
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4654
diff changeset
23 public void generate() {
4702
13abfb1bcb75 Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents: 4656
diff changeset
24 logger.debug("generate()");
13abfb1bcb75 Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents: 4656
diff changeset
25
13abfb1bcb75 Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents: 4656
diff changeset
26 List<River> rivers = RiverFactory.getRivers();
13abfb1bcb75 Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents: 4656
diff changeset
27 List<String> riverNames = new ArrayList<String>();
4654
861c47e0a8a0 Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
28
861c47e0a8a0 Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
29 for (River river : rivers) {
4702
13abfb1bcb75 Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents: 4656
diff changeset
30 /*createRiverAxisLayer(
4654
861c47e0a8a0 Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
31 river.getName(),
861c47e0a8a0 Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
32 river.getId(),
861c47e0a8a0 Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
33 "41677",
4702
13abfb1bcb75 Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents: 4656
diff changeset
34 "100,100,100,100");*/
13abfb1bcb75 Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents: 4656
diff changeset
35 riverNames.add(river.getName());
4654
861c47e0a8a0 Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
36 }
4702
13abfb1bcb75 Fix typo in class names and correct file path in floodmap.xml.
Christian Lins <christian.lins@intevation.de>
parents: 4656
diff changeset
37 writeMapfile(riverNames);
4654
861c47e0a8a0 Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
38 }
861c47e0a8a0 Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
39
861c47e0a8a0 Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
40 protected void createRiverAxisLayer(String riverName, int riverID, String srid, String extend) {
861c47e0a8a0 Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
41 LayerInfo layerInfo = new LayerInfo();
861c47e0a8a0 Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
42 layerInfo.setName(riverName);
861c47e0a8a0 Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
43 layerInfo.setSrid(srid);
861c47e0a8a0 Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
44 layerInfo.setExtent(extend);
4656
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4654
diff changeset
45
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4654
diff changeset
46 File layerFile = new File(getMapfilePath());
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4654
diff changeset
47 Template template = getTemplateByName(DB_LAYER_TEMPLATE);
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4654
diff changeset
48 if (template == null) {
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4654
diff changeset
49 logger.warn("Template '" + DB_LAYER_TEMPLATE + "' found.");
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4654
diff changeset
50 return;
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4654
diff changeset
51 }
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4654
diff changeset
52
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4654
diff changeset
53 try {
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4654
diff changeset
54 writeLayer(layerInfo, layerFile, template);
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4654
diff changeset
55 }
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4654
diff changeset
56 catch (FileNotFoundException e) {
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4654
diff changeset
57 logger.warn(e.getLocalizedMessage(), e);
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4654
diff changeset
58 }
4654
861c47e0a8a0 Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
59 }
861c47e0a8a0 Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
60
4656
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4654
diff changeset
61 @Override
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4654
diff changeset
62 protected String getVelocityLogfile() {
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4654
diff changeset
63 return FLYSUtils.getXPathString(FLYSUtils.XPATH_RIVERMAP_VELOCITY_LOGFILE);
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4654
diff changeset
64 }
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4654
diff changeset
65
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4654
diff changeset
66 @Override
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4654
diff changeset
67 protected String getMapserverTemplatePath() {
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4654
diff changeset
68 return FLYSUtils.getXPathString(FLYSUtils.XPATH_RIVERMAP_MAPSERVER_TEMPLATE_PATH);
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4654
diff changeset
69 }
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4654
diff changeset
70
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4654
diff changeset
71 @Override
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4654
diff changeset
72 protected String getMapserverUrl() {
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4654
diff changeset
73 return FLYSUtils.getXPathString(FLYSUtils.XPATH_RIVERMAP_MAPSERVER_URL);
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4654
diff changeset
74 }
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4654
diff changeset
75
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4654
diff changeset
76 @Override
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4654
diff changeset
77 protected String getMapfilePath() {
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4654
diff changeset
78 return FLYSUtils.getXPathString(FLYSUtils.XPATH_RIVERMAP_MAPFILE_PATH);
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4654
diff changeset
79 }
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4654
diff changeset
80
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4654
diff changeset
81 @Override
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4654
diff changeset
82 protected String getMapfileTemplate() {
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4654
diff changeset
83 return FLYSUtils.getXPathString(FLYSUtils.XPATH_RIVERMAP_MAPFILE_TEMPLATE);
442fbb290fa8 Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents: 4654
diff changeset
84 }
4654
861c47e0a8a0 Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
85 }

http://dive4elements.wald.intevation.org