Search in sources :

Example 1 with OptionProcessor

use of uk.me.parabola.mkgmap.OptionProcessor in project mkgmap by openstreetmap.

the class StyleImpl method readOptions.

/**
 * If there is an options file, then read it and keep options that
 * we are interested in.
 *
 * Only specific options can be set.
 */
private void readOptions() {
    try {
        Reader r = fileLoader.open(FILE_OPTIONS);
        Options opts = new Options(new OptionProcessor() {

            public void processOption(Option opt) {
                String key = opt.getOption();
                String val = opt.getValue();
                if (key.equals("name-tag-list")) {
                    if ("name".equals(val) == false) {
                        System.err.println("Warning: option name-tag-list used in the style options is ignored. " + "Please use only the command line option to specify this value.");
                    }
                } else if (OPTION_LIST.contains(key)) {
                    // Simple options that have string value.  Perhaps we should allow
                    // anything here?
                    generalOptions.put(key, val);
                }
            }
        });
        opts.readOptionFile(r, FILE_OPTIONS);
    } catch (FileNotFoundException e) {
        // the file is optional, so ignore if not present, or causes error
        log.debug("no options file");
    }
}
Also used : Options(uk.me.parabola.mkgmap.Options) FileNotFoundException(java.io.FileNotFoundException) Reader(java.io.Reader) InputStreamReader(java.io.InputStreamReader) BufferedReader(java.io.BufferedReader) Option(uk.me.parabola.mkgmap.Option) OptionProcessor(uk.me.parabola.mkgmap.OptionProcessor)

Example 2 with OptionProcessor

use of uk.me.parabola.mkgmap.OptionProcessor in project mkgmap by openstreetmap.

the class StyleImpl method readInfo.

/**
 * Read the info file.  This is just information about the style.
 */
private void readInfo() {
    try {
        Reader br = new BufferedReader(fileLoader.open(FILE_INFO));
        info = new StyleInfo();
        Options opts = new Options(new OptionProcessor() {

            public void processOption(Option opt) {
                String word = opt.getOption();
                String value = opt.getValue();
                if (word.equals("summary"))
                    info.setSummary(value);
                else if (word.equals("version")) {
                    info.setVersion(value);
                } else if (word.equals("base-style")) {
                    info.addBaseStyleName(value);
                } else if (word.equals("description")) {
                    info.setLongDescription(value);
                }
            }
        });
        opts.readOptionFile(br, FILE_INFO);
    } catch (FileNotFoundException e) {
        // optional file..
        log.debug("no info file");
    }
}
Also used : Options(uk.me.parabola.mkgmap.Options) BufferedReader(java.io.BufferedReader) StyleInfo(uk.me.parabola.mkgmap.reader.osm.StyleInfo) FileNotFoundException(java.io.FileNotFoundException) Reader(java.io.Reader) InputStreamReader(java.io.InputStreamReader) BufferedReader(java.io.BufferedReader) Option(uk.me.parabola.mkgmap.Option) OptionProcessor(uk.me.parabola.mkgmap.OptionProcessor)

Aggregations

BufferedReader (java.io.BufferedReader)2 FileNotFoundException (java.io.FileNotFoundException)2 InputStreamReader (java.io.InputStreamReader)2 Reader (java.io.Reader)2 Option (uk.me.parabola.mkgmap.Option)2 OptionProcessor (uk.me.parabola.mkgmap.OptionProcessor)2 Options (uk.me.parabola.mkgmap.Options)2 StyleInfo (uk.me.parabola.mkgmap.reader.osm.StyleInfo)1