view src/java/de/intevation/mxd/Converter.java @ 36:472aa36d0e01

Added a new layer reader and symbol reader.
author Raimund Renkert <rrenkert@intevation.de>
date Tue, 12 Apr 2011 14:43:58 +0200
parents 7a927921eb6c
children 60ed2164035a
line wrap: on
line source
package de.intevation.mxd;

import java.io.IOException;
import java.io.File;

import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;

import java.net.MalformedURLException;

import de.intevation.mxd.reader.IReader;
import de.intevation.mxd.reader.MXDReader;

/**
 * The entry point of the MXD converter tool.
 *
 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
 */
public class Converter {

    /**
     * The logging is done via Log4j. To configure the logging
     * a file 'log4j.properties' is search in the configuration
     * directory.
     */
    public static final String LOG4J_PROPERTIES = "log4j.properties";

    /**
     *
     * The path of the configuration directory.
     */
    public static final String CONFIG_PATH = System.getProperty("config.dir",
                                                                "conf");


    /**
     * The logger used in this class.
     */
    private static Logger logger;

    static {
        configureLogging();
        logger = Logger.getLogger(Converter.class);
    }


    /**
     * Trys to load the Log4j configuration
     * from ${config.dir}/log4j.properties.
     */
    public static final void configureLogging() {
        File configDir = new File(CONFIG_PATH);
        File propFile  = new File(configDir, LOG4J_PROPERTIES);
        if (propFile.isFile() && propFile.canRead()) {
            try {
                PropertyConfigurator.configure(propFile.toURI().toURL());
            }
            catch (MalformedURLException mue) {
                mue.printStackTrace(System.err);
            }
        }
    }

    /**
     * Entrypoint for the application.
     */
    public static void main(String[] args) {
        try{

            IReader reader = new MXDReader();
            reader.init();

            String path = System.getProperty("mxd.file");
            if (path.equals("${MXDFILE}")) {
                System.out.println("No valid MXD file. Use ant parameter" +
                                   " \"-DMXDFILE=path/to/file.mxd\".");
                System.exit(-1);
            }
            reader.setFilename(path);

            reader.read();
            reader.shutdown();
        }
        catch(IOException e){
            e.printStackTrace();
        }
    }
}
// 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)