annotate src/java/de/intevation/mxd/Converter.java @ 248:191b7d18c79e

Minor fixes for metadata information.
author raimund renkert <raimund.renkert@intevation.de>
date Wed, 10 Aug 2011 14:39:31 +0200
parents df4e0946ef02
children 5c80058c08f6
rev   line source
243
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 180
diff changeset
1 /*
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 180
diff changeset
2 * Copyright (c) 2011 by Intevation GmbH, Germany <info@intevation.de>
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 180
diff changeset
3 *
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 180
diff changeset
4 * This file is part of MXD2map.
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 180
diff changeset
5 *
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 180
diff changeset
6 * This program is free software under the LGPL (>=v2.1)
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 180
diff changeset
7 * Read the file LICENCE.txt coming with the software for details
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 180
diff changeset
8 * or visit http://www.gnu.org/licenses/ if it does not exist.
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 180
diff changeset
9 *
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 180
diff changeset
10 * MXD2map has been developed on behalf of the
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 180
diff changeset
11 * Bundesamt fuer Seeschifffahrt und Hydrographie (BSH) in Hamburg
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 180
diff changeset
12 * by Intevation GmbH.
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 180
diff changeset
13 *
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 180
diff changeset
14 * Authors:
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 180
diff changeset
15 * Raimund Renkert <raimund.renkert@intevation.de>
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 180
diff changeset
16 * Bjoern Schilberg <bjoern.schilberg@intevation.de>
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 180
diff changeset
17 * Stephan Holl <stephan.holl@intevation.de>
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 180
diff changeset
18 */
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 180
diff changeset
19
33
c51376f8e24c Separated converter components into packages.
Raimund Renkert <rrenkert@intevation.de>
parents: 28
diff changeset
20 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
21
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
22 import java.io.File;
55
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
23 import java.io.FileInputStream;
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
24 import java.io.BufferedInputStream;
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
25 import java.util.Properties;
25
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 import org.apache.log4j.Logger;
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
28 import org.apache.log4j.PropertyConfigurator;
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
29
174
707f13cfba74 Improved the commandline arguments and save the mapfile in the correct directory.
raimund.renkert@intevation.de
parents: 118
diff changeset
30 import jargs.gnu.CmdLineParser;
707f13cfba74 Improved the commandline arguments and save the mapfile in the correct directory.
raimund.renkert@intevation.de
parents: 118
diff changeset
31
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
32 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
33
33
c51376f8e24c Separated converter components into packages.
Raimund Renkert <rrenkert@intevation.de>
parents: 28
diff changeset
34 import de.intevation.mxd.reader.IReader;
c51376f8e24c Separated converter components into packages.
Raimund Renkert <rrenkert@intevation.de>
parents: 28
diff changeset
35 import de.intevation.mxd.reader.MXDReader;
41
60ed2164035a Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents: 34
diff changeset
36 import de.intevation.mxd.writer.IWriter;
60ed2164035a Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents: 34
diff changeset
37 import de.intevation.mxd.writer.MapScriptWriter;
24
c0060abb7457 Added source directory and an initial entry class for a MXD converter tool.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
38 /**
c0060abb7457 Added source directory and an initial entry class for a MXD converter tool.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
39 * 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
40 *
180
f4eb506499f5 Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents: 174
diff changeset
41 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
24
c0060abb7457 Added source directory and an initial entry class for a MXD converter tool.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
42 */
c0060abb7457 Added source directory and an initial entry class for a MXD converter tool.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
43 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
44
25
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 * 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
47 * 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
48 * directory.
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 String LOG4J_PROPERTIES = "log4j.properties";
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
51
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
52 /**
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
53 *
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
54 * The path of the configuration directory.
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
55 */
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
56 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
57 "conf");
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
58
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 * The logger used in this class.
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 private static Logger logger;
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
64
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
65 static {
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
66 configureLogging();
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
67 logger = Logger.getLogger(Converter.class);
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
68 }
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
69
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
70
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
71 /**
55
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
72 * Entrypoint for the application.
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
73 */
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
74 public static void main(String[] args) {
174
707f13cfba74 Improved the commandline arguments and save the mapfile in the correct directory.
raimund.renkert@intevation.de
parents: 118
diff changeset
75 CmdLineParser parser = new CmdLineParser();
707f13cfba74 Improved the commandline arguments and save the mapfile in the correct directory.
raimund.renkert@intevation.de
parents: 118
diff changeset
76 CmdLineParser.Option mxd = parser.addStringOption('m', "mxd");
707f13cfba74 Improved the commandline arguments and save the mapfile in the correct directory.
raimund.renkert@intevation.de
parents: 118
diff changeset
77 CmdLineParser.Option map = parser.addStringOption('a', "map");
707f13cfba74 Improved the commandline arguments and save the mapfile in the correct directory.
raimund.renkert@intevation.de
parents: 118
diff changeset
78 CmdLineParser.Option temp = parser.addStringOption('t', "template");
707f13cfba74 Improved the commandline arguments and save the mapfile in the correct directory.
raimund.renkert@intevation.de
parents: 118
diff changeset
79
707f13cfba74 Improved the commandline arguments and save the mapfile in the correct directory.
raimund.renkert@intevation.de
parents: 118
diff changeset
80 try{
707f13cfba74 Improved the commandline arguments and save the mapfile in the correct directory.
raimund.renkert@intevation.de
parents: 118
diff changeset
81 parser.parse(args);
707f13cfba74 Improved the commandline arguments and save the mapfile in the correct directory.
raimund.renkert@intevation.de
parents: 118
diff changeset
82 }
707f13cfba74 Improved the commandline arguments and save the mapfile in the correct directory.
raimund.renkert@intevation.de
parents: 118
diff changeset
83 catch(CmdLineParser.OptionException oe) {
707f13cfba74 Improved the commandline arguments and save the mapfile in the correct directory.
raimund.renkert@intevation.de
parents: 118
diff changeset
84 logger.warn("Invalid options.");
707f13cfba74 Improved the commandline arguments and save the mapfile in the correct directory.
raimund.renkert@intevation.de
parents: 118
diff changeset
85 printUsage();
707f13cfba74 Improved the commandline arguments and save the mapfile in the correct directory.
raimund.renkert@intevation.de
parents: 118
diff changeset
86 System.exit(1);
707f13cfba74 Improved the commandline arguments and save the mapfile in the correct directory.
raimund.renkert@intevation.de
parents: 118
diff changeset
87 }
707f13cfba74 Improved the commandline arguments and save the mapfile in the correct directory.
raimund.renkert@intevation.de
parents: 118
diff changeset
88
55
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
89 try{
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
90 String mxdfile = "";
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
91 String mapfile = "";
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
92 String maptemplate = "";
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
93
174
707f13cfba74 Improved the commandline arguments and save the mapfile in the correct directory.
raimund.renkert@intevation.de
parents: 118
diff changeset
94 mxdfile = (String)parser.getOptionValue(mxd);
707f13cfba74 Improved the commandline arguments and save the mapfile in the correct directory.
raimund.renkert@intevation.de
parents: 118
diff changeset
95 mapfile = (String)parser.getOptionValue(map);
707f13cfba74 Improved the commandline arguments and save the mapfile in the correct directory.
raimund.renkert@intevation.de
parents: 118
diff changeset
96 maptemplate = (String)parser.getOptionValue(temp);
707f13cfba74 Improved the commandline arguments and save the mapfile in the correct directory.
raimund.renkert@intevation.de
parents: 118
diff changeset
97
707f13cfba74 Improved the commandline arguments and save the mapfile in the correct directory.
raimund.renkert@intevation.de
parents: 118
diff changeset
98 if(mxdfile == null) {
55
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
99 try {
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
100 mxdfile = readProperty("mxd");
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
101 }
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
102 catch(Exception e) {
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
103 e.printStackTrace ();
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
104 }
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
105 }
174
707f13cfba74 Improved the commandline arguments and save the mapfile in the correct directory.
raimund.renkert@intevation.de
parents: 118
diff changeset
106 if(mapfile == null) {
55
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
107 try {
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
108 mapfile = readProperty("map");
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
109 }
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
110 catch(Exception e) {
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
111 e.printStackTrace ();
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
112 }
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
113 }
174
707f13cfba74 Improved the commandline arguments and save the mapfile in the correct directory.
raimund.renkert@intevation.de
parents: 118
diff changeset
114 if(maptemplate == null) {
55
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
115 try {
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
116 maptemplate = readProperty("map-template");
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
117 }
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
118 catch(Exception e) {
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
119 e.printStackTrace ();
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
120 }
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
121 }
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
122
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
123 IReader reader = new MXDReader();
86
e19c5eb43099 Instantiate the mapscript writer before loading the MXD file.
Raimund Renkert <rrenkert@intevation.de>
parents: 55
diff changeset
124 IWriter writer = new MapScriptWriter(maptemplate, mapfile);
e19c5eb43099 Instantiate the mapscript writer before loading the MXD file.
Raimund Renkert <rrenkert@intevation.de>
parents: 55
diff changeset
125
55
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
126 reader.init();
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
127 reader.setFilename(mxdfile);
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
128 reader.read();
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
129
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
130 writer.write(reader.getMapDocument());
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
131 reader.shutdown();
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
132 }
86
e19c5eb43099 Instantiate the mapscript writer before loading the MXD file.
Raimund Renkert <rrenkert@intevation.de>
parents: 55
diff changeset
133 catch(Exception e) {
118
39957898c694 Improved top level exception handling and logging.
Raimund Renkert <rrenkert@intevation.de>
parents: 96
diff changeset
134 logger.error(e.getMessage());
174
707f13cfba74 Improved the commandline arguments and save the mapfile in the correct directory.
raimund.renkert@intevation.de
parents: 118
diff changeset
135 e.printStackTrace();
55
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
136 }
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
137 }
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
138
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
139 private static String readProperty (String key)
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
140 throws Exception {
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
141 Properties properties = new Properties();
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
142 BufferedInputStream stream =
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
143 new BufferedInputStream(
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
144 new FileInputStream("converter.properties")
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
145 );
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
146 properties.load(stream);
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
147 stream.close();
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
148 return properties.getProperty(key);
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
149 }
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
150 /**
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
151 * Trys to load the Log4j configuration
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
152 * from ${config.dir}/log4j.properties.
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
153 */
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
154 public static final void configureLogging() {
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
155 File configDir = new File(CONFIG_PATH);
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
156 File propFile = new File(configDir, LOG4J_PROPERTIES);
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
157 if (propFile.isFile() && propFile.canRead()) {
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
158 try {
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
159 PropertyConfigurator.configure(propFile.toURI().toURL());
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
160 }
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
161 catch (MalformedURLException mue) {
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
162 mue.printStackTrace(System.err);
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
163 }
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
164 }
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
165 }
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
166
180
f4eb506499f5 Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents: 174
diff changeset
167
174
707f13cfba74 Improved the commandline arguments and save the mapfile in the correct directory.
raimund.renkert@intevation.de
parents: 118
diff changeset
168 private static void printUsage() {
707f13cfba74 Improved the commandline arguments and save the mapfile in the correct directory.
raimund.renkert@intevation.de
parents: 118
diff changeset
169 System.out.println("Available parameters:[{-m,--mxd} path/to/mxd]\n" +
707f13cfba74 Improved the commandline arguments and save the mapfile in the correct directory.
raimund.renkert@intevation.de
parents: 118
diff changeset
170 "\t\t[{-a,--map} path/to/mapfile]\n" +
707f13cfba74 Improved the commandline arguments and save the mapfile in the correct directory.
raimund.renkert@intevation.de
parents: 118
diff changeset
171 "\t\t[{-t,--template} path/to/template]");
707f13cfba74 Improved the commandline arguments and save the mapfile in the correct directory.
raimund.renkert@intevation.de
parents: 118
diff changeset
172 }
24
c0060abb7457 Added source directory and an initial entry class for a MXD converter tool.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
173 }
c0060abb7457 Added source directory and an initial entry class for a MXD converter tool.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
174 // 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)