Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/utils/RiverMapfileGenerator.java @ 4666:28eb979ae31b
Reordered some attributes in editor ui and use the hidden attribute.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Wed, 12 Dec 2012 10:38:50 +0100 |
parents | 442fbb290fa8 |
children | 13abfb1bcb75 |
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; |
4654
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
9 import java.util.List; |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
10 |
4656
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
11 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
|
12 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
|
13 |
4654
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
14 public class RiverMapfileGenerator extends MapfileGenerator { |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
15 |
4656
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
16 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
|
17 |
4654
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
18 /** |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
19 * Generate river axis mapfile. |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
20 */ |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
21 @Override |
4656
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
22 public void generate() { |
4654
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
23 List<River> rivers = RiverFactory.getRivers(); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
24 |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
25 for (River river : rivers) { |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
26 createRiverAxisLayer( |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
27 river.getName(), |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
28 river.getId(), |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
29 "41677", |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
30 "100,100,100,100"); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
31 } |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
32 } |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
33 |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
34 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
|
35 LayerInfo layerInfo = new LayerInfo(); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
36 layerInfo.setName(riverName); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
37 layerInfo.setSrid(srid); |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
38 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
|
39 |
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
40 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
|
41 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
|
42 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
|
43 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
|
44 return; |
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 |
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
47 try { |
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
48 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
|
49 } |
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
50 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
|
51 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
|
52 } |
4654
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
53 } |
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
54 |
4656
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
55 @Override |
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
56 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
|
57 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
|
58 } |
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
59 |
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
60 @Override |
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
61 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
|
62 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
|
63 } |
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 @Override |
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
66 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
|
67 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
|
68 } |
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 @Override |
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
71 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
|
72 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
|
73 } |
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 @Override |
442fbb290fa8
Introduce river mapfile generation (WARNING: Changes in config xml files required!).
Christian Lins <christian.lins@intevation.de>
parents:
4654
diff
changeset
|
76 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
|
77 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
|
78 } |
4654
861c47e0a8a0
Refactor Mapserver mapfile generation.
Christian Lins <christian.lins@intevation.de>
parents:
diff
changeset
|
79 } |