annotate src/java/de/intevation/mxd/Converter.java @ 289:cdf8e75dc2e1

Fixed anchor-links, added FOSSGIS-video to news-section
author Stephan Holl <stephan.holl@intevation.de>
date Tue, 03 Apr 2012 09:55:58 +0200
parents 10e0aa283217
children dbfcb0b69a63
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) {
255
5c80058c08f6 Replaced error outputs with logging messages.
raimund renkert <raimund.renkert@intevation.de>
parents: 243
diff changeset
103 logger.warn(
5c80058c08f6 Replaced error outputs with logging messages.
raimund renkert <raimund.renkert@intevation.de>
parents: 243
diff changeset
104 "No property file found. " +
5c80058c08f6 Replaced error outputs with logging messages.
raimund renkert <raimund.renkert@intevation.de>
parents: 243
diff changeset
105 "Please provide a valid property file or append " +
5c80058c08f6 Replaced error outputs with logging messages.
raimund renkert <raimund.renkert@intevation.de>
parents: 243
diff changeset
106 "parameters for mxd file, map file and template.");
55
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
107 }
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
108 }
174
707f13cfba74 Improved the commandline arguments and save the mapfile in the correct directory.
raimund.renkert@intevation.de
parents: 118
diff changeset
109 if(mapfile == null) {
55
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
110 try {
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
111 mapfile = readProperty("map");
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 catch(Exception e) {
255
5c80058c08f6 Replaced error outputs with logging messages.
raimund renkert <raimund.renkert@intevation.de>
parents: 243
diff changeset
114 logger.warn(
5c80058c08f6 Replaced error outputs with logging messages.
raimund renkert <raimund.renkert@intevation.de>
parents: 243
diff changeset
115 "No property file found. " +
5c80058c08f6 Replaced error outputs with logging messages.
raimund renkert <raimund.renkert@intevation.de>
parents: 243
diff changeset
116 "Please provide a valid property file or append " +
5c80058c08f6 Replaced error outputs with logging messages.
raimund renkert <raimund.renkert@intevation.de>
parents: 243
diff changeset
117 "parameters for mxd file, map file and template.");
55
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
118 }
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
119 }
174
707f13cfba74 Improved the commandline arguments and save the mapfile in the correct directory.
raimund.renkert@intevation.de
parents: 118
diff changeset
120 if(maptemplate == null) {
55
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
121 try {
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
122 maptemplate = readProperty("map-template");
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
123 }
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
124 catch(Exception e) {
255
5c80058c08f6 Replaced error outputs with logging messages.
raimund renkert <raimund.renkert@intevation.de>
parents: 243
diff changeset
125 logger.warn(
5c80058c08f6 Replaced error outputs with logging messages.
raimund renkert <raimund.renkert@intevation.de>
parents: 243
diff changeset
126 "No property file found. " +
5c80058c08f6 Replaced error outputs with logging messages.
raimund renkert <raimund.renkert@intevation.de>
parents: 243
diff changeset
127 "Please provide a valid property file or append " +
5c80058c08f6 Replaced error outputs with logging messages.
raimund renkert <raimund.renkert@intevation.de>
parents: 243
diff changeset
128 "parameters for mxd file, map file and template.");
55
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 }
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
131
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
132 IReader reader = new MXDReader();
86
e19c5eb43099 Instantiate the mapscript writer before loading the MXD file.
Raimund Renkert <rrenkert@intevation.de>
parents: 55
diff changeset
133 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
134
55
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
135 reader.init();
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
136 reader.setFilename(mxdfile);
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
137 reader.read();
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 writer.write(reader.getMapDocument());
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
140 reader.shutdown();
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
141 }
86
e19c5eb43099 Instantiate the mapscript writer before loading the MXD file.
Raimund Renkert <rrenkert@intevation.de>
parents: 55
diff changeset
142 catch(Exception e) {
255
5c80058c08f6 Replaced error outputs with logging messages.
raimund renkert <raimund.renkert@intevation.de>
parents: 243
diff changeset
143 logger.debug(e.getMessage());
5c80058c08f6 Replaced error outputs with logging messages.
raimund renkert <raimund.renkert@intevation.de>
parents: 243
diff changeset
144 logger.error(
5c80058c08f6 Replaced error outputs with logging messages.
raimund renkert <raimund.renkert@intevation.de>
parents: 243
diff changeset
145 "General error." +
5c80058c08f6 Replaced error outputs with logging messages.
raimund renkert <raimund.renkert@intevation.de>
parents: 243
diff changeset
146 " See logging file for more information.");
55
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
147 }
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
148 }
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
149
260
10e0aa283217 Updated documentation and added ant task for javadoc generation.
raimund renkert <raimund.renkert@intevation.de>
parents: 255
diff changeset
150
10e0aa283217 Updated documentation and added ant task for javadoc generation.
raimund renkert <raimund.renkert@intevation.de>
parents: 255
diff changeset
151 /**
10e0aa283217 Updated documentation and added ant task for javadoc generation.
raimund renkert <raimund.renkert@intevation.de>
parents: 255
diff changeset
152 * Reads a property value from the converter.properties file.
10e0aa283217 Updated documentation and added ant task for javadoc generation.
raimund renkert <raimund.renkert@intevation.de>
parents: 255
diff changeset
153 *
10e0aa283217 Updated documentation and added ant task for javadoc generation.
raimund renkert <raimund.renkert@intevation.de>
parents: 255
diff changeset
154 * @param key The property key.
10e0aa283217 Updated documentation and added ant task for javadoc generation.
raimund renkert <raimund.renkert@intevation.de>
parents: 255
diff changeset
155 *
10e0aa283217 Updated documentation and added ant task for javadoc generation.
raimund renkert <raimund.renkert@intevation.de>
parents: 255
diff changeset
156 * @return The value.
10e0aa283217 Updated documentation and added ant task for javadoc generation.
raimund renkert <raimund.renkert@intevation.de>
parents: 255
diff changeset
157 */
55
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
158 private static String readProperty (String key)
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
159 throws Exception {
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
160 Properties properties = new Properties();
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
161 BufferedInputStream stream =
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
162 new BufferedInputStream(
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
163 new FileInputStream("converter.properties")
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
164 );
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
165 properties.load(stream);
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
166 stream.close();
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
167 return properties.getProperty(key);
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
168 }
260
10e0aa283217 Updated documentation and added ant task for javadoc generation.
raimund renkert <raimund.renkert@intevation.de>
parents: 255
diff changeset
169
10e0aa283217 Updated documentation and added ant task for javadoc generation.
raimund renkert <raimund.renkert@intevation.de>
parents: 255
diff changeset
170
55
f0c02ff120d6 Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
171 /**
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
172 * Trys to load the Log4j configuration
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
173 * from ${config.dir}/log4j.properties.
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
174 */
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
175 public static final void configureLogging() {
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
176 File configDir = new File(CONFIG_PATH);
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
177 File propFile = new File(configDir, LOG4J_PROPERTIES);
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
178 if (propFile.isFile() && propFile.canRead()) {
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
179 try {
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
180 PropertyConfigurator.configure(propFile.toURI().toURL());
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
181 }
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
182 catch (MalformedURLException mue) {
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
183 mue.printStackTrace(System.err);
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
184 }
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
185 }
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
186 }
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents: 24
diff changeset
187
180
f4eb506499f5 Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents: 174
diff changeset
188
260
10e0aa283217 Updated documentation and added ant task for javadoc generation.
raimund renkert <raimund.renkert@intevation.de>
parents: 255
diff changeset
189 /**
10e0aa283217 Updated documentation and added ant task for javadoc generation.
raimund renkert <raimund.renkert@intevation.de>
parents: 255
diff changeset
190 * Print out usage informations.
10e0aa283217 Updated documentation and added ant task for javadoc generation.
raimund renkert <raimund.renkert@intevation.de>
parents: 255
diff changeset
191 */
174
707f13cfba74 Improved the commandline arguments and save the mapfile in the correct directory.
raimund.renkert@intevation.de
parents: 118
diff changeset
192 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
193 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
194 "\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
195 "\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
196 }
24
c0060abb7457 Added source directory and an initial entry class for a MXD converter tool.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
197 }
c0060abb7457 Added source directory and an initial entry class for a MXD converter tool.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
198 // 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)