osm plugin: report a decent error if the .osm file is not found

This commit is contained in:
Dane Springmeyer 2011-12-05 14:30:55 -08:00
parent dbce93669a
commit 71b281e1cc
3 changed files with 13 additions and 1 deletions

View file

@ -41,6 +41,8 @@ libraries = [ 'xml2' ]
libraries.append('curl') libraries.append('curl')
libraries.append('mapnik') libraries.append('mapnik')
libraries.append(env['ICU_LIB_NAME']) libraries.append(env['ICU_LIB_NAME'])
libraries.append('boost_system%s' % env['BOOST_APPEND'])
libraries.append('boost_filesystem%s' % env['BOOST_APPEND'])
input_plugin = plugin_env.SharedLibrary('../osm', source=osm_src, SHLIBPREFIX='', SHLIBSUFFIX='.input', LIBS=libraries, LINKFLAGS=env['CUSTOM_LDFLAGS']) input_plugin = plugin_env.SharedLibrary('../osm', source=osm_src, SHLIBPREFIX='', SHLIBSUFFIX='.input', LIBS=libraries, LINKFLAGS=env['CUSTOM_LDFLAGS'])

View file

@ -20,6 +20,8 @@
* *
*****************************************************************************/ *****************************************************************************/
#include <mapnik/datasource.hpp>
#include <boost/filesystem/operations.hpp>
#include "dataset_deliverer.h" #include "dataset_deliverer.h"
#include "basiccurl.h" #include "basiccurl.h"
#include <sstream> #include <sstream>
@ -33,6 +35,11 @@ osm_dataset* dataset_deliverer::load_from_file(const string& file, const string&
// Only actually load from file if we haven't done so already // Only actually load from file if we haven't done so already
if (dataset == NULL) if (dataset == NULL)
{ {
if (!boost::filesystem::exists(file))
{
throw mapnik::datasource_exception("OSM Plugin: '" + file + "' does not exist");
}
dataset = new osm_dataset; dataset = new osm_dataset;
if (dataset->load(file.c_str(), parser) == false) if (dataset->load(file.c_str(), parser) == false)
{ {

View file

@ -22,6 +22,7 @@
// stl // stl
#include <iostream> #include <iostream>
#include <sstream>
#include <fstream> #include <fstream>
#include <stdexcept> #include <stdexcept>
#include <set> #include <set>
@ -91,7 +92,9 @@ void osm_datasource::bind() const
{ {
if ((osm_data_= dataset_deliverer::load_from_file(osm_filename, parser)) == NULL) if ((osm_data_= dataset_deliverer::load_from_file(osm_filename, parser)) == NULL)
{ {
throw datasource_exception("Error loading from file"); std::ostringstream s;
s << "OSM Plugin: Error loading from file '" << osm_filename << "'";
throw datasource_exception(s.str());
} }
do_process = true; do_process = true;