/** * Parse the given input source and return the dataset. * * @param source the source input stream. Must not be null. * @param progressMonitor the progress monitor. If null, {@see NullProgressMonitor#INSTANCE} is * assumed * @return the dataset with the parsed data * @throws IllegalDataException thrown if the an error was found while parsing the data from the * source * @throws IllegalArgumentException thrown if source is null */ public static DataSet parseDataSet(InputStream source, ProgressMonitor progressMonitor) throws IllegalDataException { ProgressMonitor monitor = progressMonitor == null ? NullProgressMonitor.INSTANCE : progressMonitor; CheckParameterUtil.ensureParameterNotNull(source, "source"); PbfReader reader = new PbfReader(); try { monitor.beginTask(tr("Prepare OSM data...", 2)); monitor.indeterminateSubTask(tr("Reading OSM data...")); reader.parse(source); monitor.worked(1); monitor.indeterminateSubTask(tr("Preparing data set...")); reader.prepareDataSet(); monitor.worked(1); return reader.getDataSet(); } catch (IllegalDataException e) { throw e; } catch (Exception e) { throw new IllegalDataException(e); } finally { monitor.finishTask(); } }
/* (non-Javadoc) * @see org.openstreetmap.josm.io.OsmImporter#parseDataSet(java.io.InputStream, org.openstreetmap.josm.gui.progress.ProgressMonitor) */ @Override protected DataSet parseDataSet(InputStream in, ProgressMonitor progressMonitor) throws IllegalDataException { return PbfReader.parseDataSet(in, progressMonitor); }