Search in sources :

Example 1 with StyleFileLoader

use of uk.me.parabola.mkgmap.osmstyle.StyleFileLoader in project mkgmap by openstreetmap.

the class Main method listStyles.

private void listStyles() {
    String[] names;
    try {
        StyleFileLoader loader = StyleFileLoader.createStyleLoader(styleFile, null);
        names = loader.list();
        loader.close();
    } catch (FileNotFoundException e) {
        log.debug("didn't find style file", e);
        throw new ExitException("Could not list style file " + styleFile);
    }
    Arrays.sort(names);
    System.out.println("The following styles are available:");
    for (String name : names) {
        Style style = readOneStyle(name, false);
        if (style == null)
            continue;
        StyleInfo info = style.getInfo();
        System.out.format("%-15s %6s: %s\n", searchedStyleName, info.getVersion(), info.getSummary());
        if (verbose) {
            for (String s : info.getLongDescription().split("\n")) System.out.printf("\t%s\n", s.trim());
        }
    }
}
Also used : StyleFileLoader(uk.me.parabola.mkgmap.osmstyle.StyleFileLoader) FileNotFoundException(java.io.FileNotFoundException) StyleInfo(uk.me.parabola.mkgmap.reader.osm.StyleInfo) Style(uk.me.parabola.mkgmap.reader.osm.Style) ExitException(uk.me.parabola.imgfmt.ExitException)

Example 2 with StyleFileLoader

use of uk.me.parabola.mkgmap.osmstyle.StyleFileLoader in project mkgmap by openstreetmap.

the class Main method checkStyles.

/**
 * Check one or all styles in the path given in styleFile.
 */
private void checkStyles() {
    String[] names;
    try {
        StyleFileLoader loader = StyleFileLoader.createStyleLoader(styleFile, null);
        names = loader.list();
        loader.close();
    } catch (FileNotFoundException e) {
        log.debug("didn't find style file", e);
        throw new ExitException("Could not check style file " + styleFile);
    }
    Arrays.sort(names);
    if (styleOption == null) {
        if (names.length > 1)
            System.out.println("The following styles are available:");
        else
            System.out.println("Found one style in " + styleFile);
    }
    int checked = 0;
    for (String name : names) {
        if (styleOption != null && !Objects.equals(name, styleOption))
            continue;
        if (names.length > 1) {
            System.out.println("checking style: " + name);
        }
        ++checked;
        boolean performChecks = true;
        if (Objects.equals("classpath:styles", styleFile) && !Objects.equals("default", name)) {
            performChecks = false;
        }
        Style style = readOneStyle(name, performChecks);
        if (style == null) {
            System.out.println("could not open style " + name);
        }
    }
    if (checked == 0)
        System.out.println("could not open style " + styleOption + " in " + styleFile);
    System.out.println("finished check-styles");
}
Also used : StyleFileLoader(uk.me.parabola.mkgmap.osmstyle.StyleFileLoader) FileNotFoundException(java.io.FileNotFoundException) Style(uk.me.parabola.mkgmap.reader.osm.Style) ExitException(uk.me.parabola.imgfmt.ExitException)

Example 3 with StyleFileLoader

use of uk.me.parabola.mkgmap.osmstyle.StyleFileLoader in project mkgmap by openstreetmap.

the class StyleTester method readGivenResults.

private static List<String> readGivenResults() {
    List<String> givenResults = new ArrayList<>();
    // BufferedReader br = null;
    try (StyleFileLoader fileLoader = StyleFileLoader.createStyleLoader(STYLETESTER_STYLE, null);
        Reader reader = fileLoader.open("results");
        BufferedReader br = new BufferedReader(reader)) {
        String line;
        while ((line = br.readLine()) != null) {
            line = line.trim();
            if (line.isEmpty())
                continue;
            givenResults.add(line);
        }
    } catch (IOException e) {
    // there are no known good results given, that is OK
    }
    return givenResults;
}
Also used : StyleFileLoader(uk.me.parabola.mkgmap.osmstyle.StyleFileLoader) ArrayList(java.util.ArrayList) BufferedReader(java.io.BufferedReader) TypeReader(uk.me.parabola.mkgmap.osmstyle.TypeReader) Reader(java.io.Reader) ActionReader(uk.me.parabola.mkgmap.osmstyle.actions.ActionReader) ExpressionReader(uk.me.parabola.mkgmap.osmstyle.eval.ExpressionReader) BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader) IOException(java.io.IOException)

Aggregations

StyleFileLoader (uk.me.parabola.mkgmap.osmstyle.StyleFileLoader)3 FileNotFoundException (java.io.FileNotFoundException)2 ExitException (uk.me.parabola.imgfmt.ExitException)2 Style (uk.me.parabola.mkgmap.reader.osm.Style)2 BufferedReader (java.io.BufferedReader)1 FileReader (java.io.FileReader)1 IOException (java.io.IOException)1 Reader (java.io.Reader)1 ArrayList (java.util.ArrayList)1 TypeReader (uk.me.parabola.mkgmap.osmstyle.TypeReader)1 ActionReader (uk.me.parabola.mkgmap.osmstyle.actions.ActionReader)1 ExpressionReader (uk.me.parabola.mkgmap.osmstyle.eval.ExpressionReader)1 StyleInfo (uk.me.parabola.mkgmap.reader.osm.StyleInfo)1