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);
}
}
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());
}
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);
}
}
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));
}
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;
}
Aggregations