comparison flys-artifacts/src/main/java/de/intevation/flys/utils/RiverMapfileGenerator.java @ 4841:ad0990a82ab8

Insert db connection into riveraxis map files. * Added new MapUtils. * Moved connection specific strings to maputils. * Updated mapfile template.
author Raimund Renkert <rrenkert@intevation.de>
date Wed, 23 Jan 2013 17:32:30 +0100
parents 8062b571884d
children 88014b9852d0
comparison
equal deleted inserted replaced
4840:8cd2f20b1d8c 4841:ad0990a82ab8
3 import com.vividsolutions.jts.geom.Envelope; 3 import com.vividsolutions.jts.geom.Envelope;
4 import com.vividsolutions.jts.geom.LineString; 4 import com.vividsolutions.jts.geom.LineString;
5 5
6 import de.intevation.flys.artifacts.model.LayerInfo; 6 import de.intevation.flys.artifacts.model.LayerInfo;
7 import de.intevation.flys.artifacts.model.RiverFactory; 7 import de.intevation.flys.artifacts.model.RiverFactory;
8 import de.intevation.flys.backend.SessionFactoryProvider;
8 import de.intevation.flys.model.River; 9 import de.intevation.flys.model.River;
9 import de.intevation.flys.model.RiverAxis; 10 import de.intevation.flys.model.RiverAxis;
10 11
11 import java.io.File; 12 import java.io.File;
12 import java.io.FileNotFoundException; 13 import java.io.FileNotFoundException;
13 import java.util.ArrayList; 14 import java.util.ArrayList;
14 import java.util.List; 15 import java.util.List;
16 import java.util.regex.Matcher;
17 import java.util.regex.Pattern;
15 18
16 import org.apache.log4j.Logger; 19 import org.apache.log4j.Logger;
17 import org.apache.velocity.Template; 20 import org.apache.velocity.Template;
21 import org.hibernate.impl.SessionFactoryImpl;
18 22
19 public class RiverMapfileGenerator extends MapfileGenerator { 23 public class RiverMapfileGenerator extends MapfileGenerator {
20 24
21 public static final String XPATH_RIVERMAP_RIVER_PROJECTION = 25 public static final String XPATH_RIVERMAP_RIVER_PROJECTION =
22 "/artifact-database/rivermap/river[@name=$name]/srid/@value"; 26 "/artifact-database/rivermap/river[@name=$name]/srid/@value";
36 public static final String XPATH_RIVERMAP_MAPFILE_TEMPLATE = 40 public static final String XPATH_RIVERMAP_MAPFILE_TEMPLATE =
37 "/artifact-database/rivermap/mapserver/map-template/@path"; 41 "/artifact-database/rivermap/mapserver/map-template/@path";
38 42
39 public static final String XPATH_RIVERMAP_MAPSERVER_TEMPLATE_PATH = 43 public static final String XPATH_RIVERMAP_MAPSERVER_TEMPLATE_PATH =
40 "/artifact-database/rivermap/mapserver/templates/@path"; 44 "/artifact-database/rivermap/mapserver/templates/@path";
45
46 public static final Pattern DB_URL_PATTERN =
47 Pattern.compile("(.*)\\/\\/(.*):([0-9]+)\\/([a-zA-Z]+)");
48
49 public static final Pattern DB_PSQL_URL_PATTERN =
50 Pattern.compile("(.*)\\/\\/(.*):([0-9]+)\\/([a-zA-Z0-9]+)");
41 51
42 private static Logger logger = Logger.getLogger(RiverMapfileGenerator.class); 52 private static Logger logger = Logger.getLogger(RiverMapfileGenerator.class);
43 53
44 /** 54 /**
45 * Generate river axis mapfile. 55 * Generate river axis mapfile.
78 } 88 }
79 89
80 protected void createRiverAxisLayer(String riverName, int riverID, String srid, String extend) { 90 protected void createRiverAxisLayer(String riverName, int riverID, String srid, String extend) {
81 LayerInfo layerInfo = new LayerInfo(); 91 LayerInfo layerInfo = new LayerInfo();
82 layerInfo.setName(riverName); 92 layerInfo.setName(riverName);
93 layerInfo.setConnection(MapUtils.getConnection());
94 layerInfo.setConnectionType(MapUtils.getConnectionType());
83 layerInfo.setSrid(srid); 95 layerInfo.setSrid(srid);
84 layerInfo.setExtent(extend); 96 layerInfo.setExtent(extend);
85 layerInfo.setType("line"); 97 layerInfo.setType("line");
86 layerInfo.setData("geom FROM river_axes"); // FIXME: Use templates for that 98 layerInfo.setData("geom FROM river_axes"); // FIXME: Use templates for that
87 layerInfo.setFilter("river_id = " + riverID); 99 layerInfo.setFilter("river_id = " + riverID);

http://dive4elements.wald.intevation.org