use of uk.me.parabola.mkgmap.reader.osm.xml.OsmXmlHandler.SaxHandler 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);
}
}
Aggregations