annotate src/java/de/intevation/mxd/Converter.java @ 25:cbd67b1100d8

Initial commit of the first prototype.
author Raimund Renkert <rrenkert@intevation.de>
date Fri, 08 Apr 2011 11:47:59 +0200
parents c0060abb7457
children 0e71a1f71ec0
rev   line source
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
1 //package de.intevation.mxd;
24
c0060abb7457 Added source directory and an initial entry class for a MXD converter tool.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
2
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
3 import java.io.IOException;
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
4 import java.io.File;
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
5 import java.io.FileOutputStream;
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
6 import java.io.OutputStream;
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
7
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
8 import org.apache.log4j.Logger;
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
9 import org.apache.log4j.PropertyConfigurator;
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
10
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
11 import java.net.MalformedURLException;
24
c0060abb7457 Added source directory and an initial entry class for a MXD converter tool.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
12
c0060abb7457 Added source directory and an initial entry class for a MXD converter tool.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
13 /**
c0060abb7457 Added source directory and an initial entry class for a MXD converter tool.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
14 * The entry point of the MXD converter tool.
c0060abb7457 Added source directory and an initial entry class for a MXD converter tool.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
15 *
c0060abb7457 Added source directory and an initial entry class for a MXD converter tool.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
16 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
c0060abb7457 Added source directory and an initial entry class for a MXD converter tool.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
17 */
c0060abb7457 Added source directory and an initial entry class for a MXD converter tool.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
18 public class Converter {
c0060abb7457 Added source directory and an initial entry class for a MXD converter tool.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
19
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
20 /**
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
21 * The logging is done via Log4j. To configure the logging
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
22 * a file 'log4j.properties' is search in the configuration
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
23 * directory.
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
24 */
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
25 public static final String LOG4J_PROPERTIES = "log4j.properties";
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
26
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
27 /**
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
28 *
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
29 * The path of the configuration directory.
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
30 */
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
31 public static final String CONFIG_PATH = System.getProperty("config.dir",
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
32 "conf");
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
33
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
34
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
35 /**
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
36 * The logger used in this class.
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
37 */
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
38 private static Logger logger;
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
39
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
40 static {
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
41 configureLogging();
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
42 logger = Logger.getLogger(Converter.class);
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
43 }
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
44
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
45
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
46 /**
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
47 * Trys to load the Log4j configuration
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
48 * from ${config.dir}/log4j.properties.
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
49 */
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
50 public static final void configureLogging() {
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
51 File configDir = new File(CONFIG_PATH);
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
52 File propFile = new File(configDir, LOG4J_PROPERTIES);
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
53 if (propFile.isFile() && propFile.canRead()) {
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
54 try {
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
55 PropertyConfigurator.configure(propFile.toURI().toURL());
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
56 }
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
57 catch (MalformedURLException mue) {
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
58 mue.printStackTrace(System.err);
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
59 }
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
60 }
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
61 }
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
62
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
63 /**
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
64 * Entrypoint for the application.
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
65 */
24
c0060abb7457 Added source directory and an initial entry class for a MXD converter tool.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
66 public static void main(String[] args) {
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
67 try{
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
68 IReader reader = new MXDReader();
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
69 reader.init();
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
70 // reader.setFilename("testdata/SubsurfaceSediments-Internet.mxd");
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
71 // reader.setFilename("testdata/p_single_4pt_c255-0-0.mxd");
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
72 // reader.setFilename("testdata/Facilities-Internet.mxd");
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
73 // reader.setFilename("testdata/fernerkundung_albedo.mxd");
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
74 reader.setFilename("testdata/gevu.mxd");
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
75
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
76 reader.read();
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
77 reader.shutdown();
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
78 }
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
79 catch(IOException e){
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
80 e.printStackTrace();
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
81 }
24
c0060abb7457 Added source directory and an initial entry class for a MXD converter tool.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
82 }
c0060abb7457 Added source directory and an initial entry class for a MXD converter tool.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
83 }
c0060abb7457 Added source directory and an initial entry class for a MXD converter tool.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
84 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)