use of uk.me.parabola.imgfmt.FormatException in project mkgmap by openstreetmap.
the class OsmXmlHandler method parse.
@Override
public void parse(InputStream is) throws FormatException {
try {
SAXParserFactory parserFactory = SAXParserFactory.newInstance();
parserFactory.setXIncludeAware(true);
parserFactory.setNamespaceAware(true);
SAXParser parser = parserFactory.newSAXParser();
try {
SaxHandler saxHandler = new SaxHandler();
// parse the xml file
parser.parse(is, saxHandler);
} 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);
}
}
use of uk.me.parabola.imgfmt.FormatException in project mkgmap by openstreetmap.
the class SeaGenerator method loadPrecompTile.
/**
* Loads the precomp sea tile with the given filename.
* @param filename the filename of the precomp sea tile
* @return all ways of the tile
* @throws FileNotFoundException if the tile could not be found
*/
private Collection<Way> loadPrecompTile(InputStream is, String filename) {
OsmPrecompSeaDataSource src = new OsmPrecompSeaDataSource();
EnhancedProperties props = new EnhancedProperties();
props.setProperty("style", "empty");
src.config(props);
log.info("Started loading coastlines from", filename);
try {
src.parse(is, filename);
} catch (FormatException e) {
log.error("Failed to read " + filename);
log.error(e);
}
log.info("Finished loading coastlines from", filename);
return src.getElementSaver().getWays().values();
}
use of uk.me.parabola.imgfmt.FormatException in project mkgmap by openstreetmap.
the class OsmBinHandler method parse.
@Override
public void parse(InputStream is) {
try {
BinParser reader = new BinParser();
BlockInputStream stream = new BlockInputStream(is, reader);
stream.process();
} catch (NoClassDefFoundError e) {
throw new FormatException("Failed to read binary file, probably missing protobuf.jar");
} catch (IOException e) {
throw new FormatException("Failed to read binary file");
}
}
use of uk.me.parabola.imgfmt.FormatException in project mkgmap by openstreetmap.
the class BoundaryPreprocessor method createRawData.
/**
* Parse OSM data and create boundaries. Distribute the boundaries on a grid
* with a fixed raster.
* @return true if data was successfully written, else false
*/
private boolean createRawData() {
File boundsDirectory = new File(outDir);
BoundarySaver saver = new BoundarySaver(boundsDirectory, BoundarySaver.RAW_DATA_FORMAT);
OsmBoundaryDataSource dataSource = new OsmBoundaryDataSource();
dataSource.setBoundarySaver(saver);
log.info("Started loading", boundaryFilename);
try {
dataSource.load(boundaryFilename, false);
} catch (FileNotFoundException e) {
e.printStackTrace();
return false;
} catch (FormatException e) {
e.printStackTrace();
return false;
}
saver.setBbox(dataSource.getBounds());
log.info("Finished loading", boundaryFilename);
saver.end();
return true;
}
Aggregations