Search in sources :

Example 1 with EnhancedProperties

use of uk.me.parabola.util.EnhancedProperties in project mkgmap by openstreetmap.

the class StyleTester method runTest.

private static void runTest(String stylefile, String mapfile) {
    PrintingMapCollector collector = new PrintingMapCollector();
    OsmConverter normal;
    try {
        normal = new StyleTester(stylefile, collector, reference);
    } catch (FileNotFoundException e) {
        System.err.println("Could not open style file " + stylefile);
        return;
    }
    try {
        InputStream is = Utils.openFile(mapfile);
        SAXParserFactory parserFactory = SAXParserFactory.newInstance();
        parserFactory.setXIncludeAware(true);
        parserFactory.setNamespaceAware(true);
        SAXParser parser = parserFactory.newSAXParser();
        try {
            EnhancedProperties props = new EnhancedProperties();
            props.put("preserve-element-order", "1");
            ElementSaver saver = new ElementSaver(props);
            OsmXmlHandler handler = new OsmXmlHandler();
            SaxHandler saxHandler = handler.new SaxHandler();
            handler.setElementSaver(saver);
            parser.parse(is, saxHandler);
            saver.finishLoading();
            saver.convert(normal);
            System.err.println("Conversion time " + (System.currentTimeMillis() - collector.getStart()) + "ms");
        } catch (IOException e) {
            throw new FormatException("Error reading file", e);
        }
    } catch (SAXException e) {
        throw new FormatException("Error parsing file", e);
    } catch (ParserConfigurationException e) {
        throw new FormatException("Internal error configuring xml parser", e);
    } catch (FileNotFoundException e) {
        System.err.println("Cannot open file " + mapfile);
    }
}
Also used : InputStream(java.io.InputStream) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) SaxHandler(uk.me.parabola.mkgmap.reader.osm.xml.OsmXmlHandler.SaxHandler) FormatException(uk.me.parabola.imgfmt.FormatException) SAXException(org.xml.sax.SAXException) EnhancedProperties(uk.me.parabola.util.EnhancedProperties) ElementSaver(uk.me.parabola.mkgmap.reader.osm.ElementSaver) SAXParser(javax.xml.parsers.SAXParser) OsmConverter(uk.me.parabola.mkgmap.reader.osm.OsmConverter) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) OsmXmlHandler(uk.me.parabola.mkgmap.reader.osm.xml.OsmXmlHandler) SAXParserFactory(javax.xml.parsers.SAXParserFactory)

Example 2 with EnhancedProperties

use of uk.me.parabola.util.EnhancedProperties in project mkgmap by openstreetmap.

the class StyledConverterTest method makeConverter.

private StyledConverter makeConverter(String name) throws FileNotFoundException {
    Style style = new StyleImpl(LOC, name);
    MapCollector coll = new MapCollector() {

        public void addToBounds(Coord p) {
        }

        // could save points in the same way as lines to test them
        public void addPoint(MapPoint point) {
        }

        public void addLine(MapLine line) {
            // Save line so that it can be examined in the tests.
            assertNotNull("points are not null", line.getPoints());
            lines.add(line);
        }

        public void addShape(MapShape shape) {
        }

        public void addRoad(MapRoad road) {
            lines.add(road);
        }

        public int addRestriction(GeneralRouteRestriction grr) {
            return 0;
        }

        public void addThroughRoute(int junctionNodeId, long roadIdA, long roadIdB) {
        }
    };
    return new StyledConverter(style, coll, new EnhancedProperties());
}
Also used : Coord(uk.me.parabola.imgfmt.app.Coord) EnhancedProperties(uk.me.parabola.util.EnhancedProperties) MapLine(uk.me.parabola.mkgmap.general.MapLine) MapPoint(uk.me.parabola.mkgmap.general.MapPoint) GeneralRouteRestriction(uk.me.parabola.imgfmt.app.net.GeneralRouteRestriction) Style(uk.me.parabola.mkgmap.reader.osm.Style) MapRoad(uk.me.parabola.mkgmap.general.MapRoad) MapCollector(uk.me.parabola.mkgmap.general.MapCollector) MapShape(uk.me.parabola.mkgmap.general.MapShape)

Example 3 with EnhancedProperties

use of uk.me.parabola.util.EnhancedProperties in project mkgmap by openstreetmap.

the class OverviewBuilder method init.

public void init(CommandArgs args) {
    areaName = args.get("area-name", "Overview Map");
    overviewMapname = args.get("overview-mapname", "osmmap");
    overviewMapnumber = args.get("overview-mapnumber", "63240000");
    outputDir = args.getOutputDir();
    String demDist = args.getProperties().getProperty("overview-dem-dist");
    String hgtPath = args.getProperties().getProperty("dem");
    if (hgtPath != null && demDist != null && "0".equals(demDist.trim()) == false) {
        demProps = new EnhancedProperties(args.getProperties());
        demProps.setProperty("dem-dists", demDist);
    }
}
Also used : EnhancedProperties(uk.me.parabola.util.EnhancedProperties)

Example 4 with EnhancedProperties

use of uk.me.parabola.util.EnhancedProperties in project mkgmap by openstreetmap.

the class StyleImpl method main.

public static void main(String[] args) throws FileNotFoundException {
    String file = args[0];
    String name = null;
    if (args.length > 1)
        name = args[1];
    StyleImpl style = new StyleImpl(file, name, new EnhancedProperties(), WITH_CHECKS);
    style.dumpToFile(new OutputStreamWriter(System.out));
}
Also used : EnhancedProperties(uk.me.parabola.util.EnhancedProperties) OutputStreamWriter(java.io.OutputStreamWriter)

Example 5 with EnhancedProperties

use of uk.me.parabola.util.EnhancedProperties in project mkgmap by openstreetmap.

the class Main method readOneStyle.

/**
 * Try to read a style from styleFile directory
 * @param name name of the style
 * @param performChecks perform checks?
 * @return the style or null in case of errors
 */
private Style readOneStyle(String name, boolean performChecks) {
    searchedStyleName = name;
    Style style = null;
    try {
        style = new StyleImpl(styleFile, name, new EnhancedProperties(), performChecks);
    } catch (SyntaxException e) {
        System.err.println("Error in style: " + e.getMessage());
    } catch (FileNotFoundException e) {
        log.debug("could not find style", name);
        try {
            searchedStyleName = new File(styleFile).getName();
            style = new StyleImpl(styleFile, null, new EnhancedProperties(), performChecks);
        } catch (SyntaxException e1) {
            System.err.println("Error in style: " + e1.getMessage());
        } catch (FileNotFoundException e1) {
            log.debug("could not find style", styleFile);
        }
    }
    return style;
}
Also used : EnhancedProperties(uk.me.parabola.util.EnhancedProperties) StyleImpl(uk.me.parabola.mkgmap.osmstyle.StyleImpl) SyntaxException(uk.me.parabola.mkgmap.scan.SyntaxException) FileNotFoundException(java.io.FileNotFoundException) Style(uk.me.parabola.mkgmap.reader.osm.Style) File(java.io.File)

Aggregations

EnhancedProperties (uk.me.parabola.util.EnhancedProperties)7 FileNotFoundException (java.io.FileNotFoundException)2 FormatException (uk.me.parabola.imgfmt.FormatException)2 Style (uk.me.parabola.mkgmap.reader.osm.Style)2 File (java.io.File)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 OutputStreamWriter (java.io.OutputStreamWriter)1 FormatStyle (java.time.format.FormatStyle)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 SAXParser (javax.xml.parsers.SAXParser)1 SAXParserFactory (javax.xml.parsers.SAXParserFactory)1 SAXException (org.xml.sax.SAXException)1 Coord (uk.me.parabola.imgfmt.app.Coord)1 GeneralRouteRestriction (uk.me.parabola.imgfmt.app.net.GeneralRouteRestriction)1 MapCollector (uk.me.parabola.mkgmap.general.MapCollector)1 MapLine (uk.me.parabola.mkgmap.general.MapLine)1 MapPoint (uk.me.parabola.mkgmap.general.MapPoint)1 MapRoad (uk.me.parabola.mkgmap.general.MapRoad)1 MapShape (uk.me.parabola.mkgmap.general.MapShape)1