+ don't fail if load_map throws config error

This commit is contained in:
Artem Pavlenko 2010-03-10 17:08:28 +00:00
parent 1cd9c3257d
commit 556df8a751

View file

@ -140,13 +140,14 @@ void MainWindow::open(QString const& path)
void MainWindow::reload()
{
if (!filename_.isEmpty())
{
mapnik::box2d<double> bbox = mapWidget_->getMap()->getCurrentExtent();
load_map_file(filename_);
mapWidget_->zoomToBox(bbox);
setWindowTitle(tr("%1 - *Reloaded*").arg(filename_));
}
if (!filename_.isEmpty())
{
mapnik::box2d<double> bbox = mapWidget_->getMap()->getCurrentExtent();
load_map_file(filename_);
mapWidget_->zoomToBox(bbox);
setWindowTitle(tr("%1 - *Reloaded*").arg(filename_));
}
}
void MainWindow::save()
@ -166,24 +167,23 @@ void MainWindow::save()
void MainWindow::load_map_file(QString const& filename)
{
std::cout<<"loading "<< filename.toStdString() << std::endl;
unsigned width = mapWidget_->width();
unsigned height = mapWidget_->height();
boost::shared_ptr<mapnik::Map> map(new mapnik::Map(width,height));
mapWidget_->setMap(map);
try
{
unsigned width = mapWidget_->width();
unsigned height = mapWidget_->height();
boost::shared_ptr<mapnik::Map> map(new mapnik::Map(width,height));
mapnik::load_map(*map,filename.toStdString());
mapWidget_->setMap(map);
map->zoom_all();
mapnik::box2d<double> const& ext = map->getCurrentExtent();
mapWidget_->zoomToBox(ext);
layerTab_->setModel(new LayerListModel(map,this));
styleTab_->setModel(new StyleModel(map,this));
}
catch (mapnik::config_error & ex)
{
std::cout << ex.what() << "\n";
}
map->zoom_all();
mapnik::box2d<double> const& ext = map->getCurrentExtent();
mapWidget_->zoomToBox(ext);
layerTab_->setModel(new LayerListModel(map,this));
styleTab_->setModel(new StyleModel(map,this));
}
void MainWindow::zoom_all()