#! /bin/sh /usr/share/dpatch/dpatch-run ## 98-mapnik-exception.dpatch by Andreas Putzo ## ## DP: Add exception handling for mapnik config file loading. @DPATCH@ diff -urNad gpsdrive-2.10~pre4~/src/mapnik.cpp gpsdrive-2.10~pre4/src/mapnik.cpp --- gpsdrive-2.10~pre4~/src/mapnik.cpp 2008-02-28 23:37:07.000000000 +0000 +++ gpsdrive-2.10~pre4/src/mapnik.cpp 2008-02-28 23:37:46.000000000 +0000 @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -37,6 +38,7 @@ using mapnik::feature_ptr; using mapnik::geometry_ptr; using mapnik::CoordTransform; +using mapnik::config_error; extern int mydebug; extern int borderlimit; @@ -131,11 +133,22 @@ MapnikMap.BorderlimitInt = borderlimit; MapnikMap.ScaleInt = -1; // <-- force creation of map if a map is set MapnikMap.MapPtr = new mapnik::Map(MapnikMap.WidthInt, MapnikMap.HeightInt); + //load map - std::string mapnik_config_file (ConfigXML); - mapnik::load_map(*MapnikMap.MapPtr, mapnik_config_file); - MapnikInitYsn = -1; + try { + std::string mapnik_config_file (ConfigXML); + mapnik::load_map(*MapnikMap.MapPtr, mapnik_config_file); + MapnikInitYsn = -1; + } + catch(const mapnik::config_error &ex) { + cerr << "Cannot init mapnik. Mapnik support DISABLED: " << ex.what() << "\n" << endl; + cerr << "Mapnik now raises exceptions on syntax errors in the map file,\n" << + "failed db connections, missing files, etc.\n" << + "Please fix or remove ~/.gpsdrive/osm.xml.\n" << + "See also NEWS.Debian." << endl; + MapnikInitYsn = 0; + } } /*