Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/utils/RiverMapfileGenerator.java @ 4809:8062b571884d
Bugs in generated RiverAxis Mapfile fixed. Now the river axes are drawn by the WMS.
author | Christian Lins <christian.lins@intevation.de> |
---|---|
date | Wed, 16 Jan 2013 22:53:58 +0100 |
parents | d93748043cbc |
children | ad0990a82ab8 |
comparison
equal
deleted
inserted
replaced
4808:05ff91146ddd | 4809:8062b571884d |
---|---|
1 package de.intevation.flys.utils; | 1 package de.intevation.flys.utils; |
2 | |
3 import com.vividsolutions.jts.geom.Envelope; | |
4 import com.vividsolutions.jts.geom.LineString; | |
2 | 5 |
3 import de.intevation.flys.artifacts.model.LayerInfo; | 6 import de.intevation.flys.artifacts.model.LayerInfo; |
4 import de.intevation.flys.artifacts.model.RiverFactory; | 7 import de.intevation.flys.artifacts.model.RiverFactory; |
5 import de.intevation.flys.model.River; | 8 import de.intevation.flys.model.River; |
9 import de.intevation.flys.model.RiverAxis; | |
6 | 10 |
7 import java.io.File; | 11 import java.io.File; |
8 import java.io.FileNotFoundException; | 12 import java.io.FileNotFoundException; |
9 import java.util.ArrayList; | 13 import java.util.ArrayList; |
10 import java.util.List; | 14 import java.util.List; |
46 | 50 |
47 List<River> rivers = RiverFactory.getRivers(); | 51 List<River> rivers = RiverFactory.getRivers(); |
48 List<String> riverFiles = new ArrayList<String>(); | 52 List<String> riverFiles = new ArrayList<String>(); |
49 | 53 |
50 for (River river : rivers) { | 54 for (River river : rivers) { |
55 // We expect that every river has only one RiverAxis. | |
56 // This is not correct but currently the case here, see | |
57 // RiverAxis.java. | |
58 List<RiverAxis> riverAxis = RiverAxis.getRiverAxis(river.getName()); | |
59 if (riverAxis == null) { | |
60 logger.warn("River " + river.getName() + " has no river axis!"); | |
61 continue; | |
62 } | |
63 LineString geom = riverAxis.get(0).getGeom(); | |
64 Envelope extent = geom.getEnvelopeInternal(); | |
65 | |
51 createRiverAxisLayer( | 66 createRiverAxisLayer( |
52 river.getName(), | 67 river.getName(), |
53 river.getId(), | 68 river.getId(), |
54 "41677", | 69 Integer.toString(geom.getSRID()), |
55 "-10000 -10000 10000 10000"); | 70 extent.getMinX() + " " + |
71 extent.getMinY() + " " + | |
72 extent.getMaxX() + " " + | |
73 extent.getMaxY()); | |
74 | |
56 riverFiles.add("river-" + river.getName() + ".map"); | 75 riverFiles.add("river-" + river.getName() + ".map"); |
57 } | 76 } |
58 writeMapfile(riverFiles); | 77 writeMapfile(riverFiles); |
59 } | 78 } |
60 | 79 |
62 LayerInfo layerInfo = new LayerInfo(); | 81 LayerInfo layerInfo = new LayerInfo(); |
63 layerInfo.setName(riverName); | 82 layerInfo.setName(riverName); |
64 layerInfo.setSrid(srid); | 83 layerInfo.setSrid(srid); |
65 layerInfo.setExtent(extend); | 84 layerInfo.setExtent(extend); |
66 layerInfo.setType("line"); | 85 layerInfo.setType("line"); |
67 layerInfo.setData("geom FROM river_axis"); // FIXME: Use templates for that | 86 layerInfo.setData("geom FROM river_axes"); // FIXME: Use templates for that |
68 layerInfo.setFilter("river_id = " + riverID); | 87 layerInfo.setFilter("river_id = " + riverID); |
69 layerInfo.setTitle(riverName + " RiverAxis"); | 88 layerInfo.setTitle(riverName + " RiverAxis"); |
70 | 89 |
71 File layerFile = new File("river-" + riverName + ".map"); | 90 File layerFile = new File("river-" + riverName + ".map"); |
72 Template template = getTemplateByName("riveraxis-layer.vm"); | 91 Template template = getTemplateByName("riveraxis-layer.vm"); |