svg2png: better error output
This commit is contained in:
parent
19972fb87e
commit
9fe698e409
1 changed files with 72 additions and 59 deletions
|
@ -26,6 +26,7 @@
|
|||
#include <string>
|
||||
|
||||
#include <mapnik/version.hpp>
|
||||
#include <mapnik/debug.hpp>
|
||||
#include <mapnik/marker.hpp>
|
||||
#include <mapnik/marker_cache.hpp>
|
||||
#include <mapnik/image_util.hpp>
|
||||
|
@ -52,10 +53,12 @@ int main (int argc,char** argv)
|
|||
{
|
||||
namespace po = boost::program_options;
|
||||
|
||||
bool verbose=false;
|
||||
bool auto_open=false;
|
||||
bool verbose = false;
|
||||
bool auto_open = false;
|
||||
bool error = false;
|
||||
std::vector<std::string> svg_files;
|
||||
xmlInitParser();
|
||||
mapnik::logger logger;
|
||||
logger.set_severity(mapnik::logger::error);
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -112,6 +115,9 @@ int main (int argc,char** argv)
|
|||
std::clog << "no svg files to render" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
xmlInitParser();
|
||||
|
||||
while (itr != svg_files.end())
|
||||
{
|
||||
std::string svg_name (*itr++);
|
||||
|
@ -122,11 +128,19 @@ int main (int argc,char** argv)
|
|||
|
||||
boost::optional<mapnik::marker_ptr> marker_ptr =
|
||||
mapnik::marker_cache::instance()->find(svg_name, false);
|
||||
if (marker_ptr)
|
||||
if (!marker_ptr)
|
||||
{
|
||||
std::clog << "svg2png error: could not open: '" << svg_name << "'\n";
|
||||
error = true;
|
||||
continue;
|
||||
}
|
||||
mapnik::marker marker = **marker_ptr;
|
||||
if (marker.is_vector())
|
||||
if (!marker.is_vector())
|
||||
{
|
||||
std::clog << "svg2png error: '" << svg_name << "' is not a valid vector!\n";
|
||||
error = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
typedef agg::pixfmt_rgba32_plain pixfmt;
|
||||
typedef agg::renderer_base<pixfmt> renderer_base;
|
||||
|
@ -179,8 +193,6 @@ int main (int argc,char** argv)
|
|||
std::clog << "rendered to: " << svg_name << "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
std::clog << "Exception of unknown type!" << std::endl;
|
||||
|
@ -192,7 +204,8 @@ int main (int argc,char** argv)
|
|||
// to make sure valgrind output is clean
|
||||
// http://xmlsoft.org/xmlmem.html
|
||||
xmlCleanupParser();
|
||||
|
||||
if (error)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue