avoid muffling proj_init at render time and instead catch at load_map - closes #646
This commit is contained in:
parent
97fe52ac04
commit
b0f15bf5de
5 changed files with 63 additions and 50 deletions
|
@ -32,6 +32,10 @@ Summary: The 2.2.0 release is the fastest running and most stable release in the
|
||||||
|
|
||||||
- Fixed blurry rendering of image and SVG icons (#1316)
|
- Fixed blurry rendering of image and SVG icons (#1316)
|
||||||
|
|
||||||
|
- Added detection of invalid srs values when loading xml (#646)
|
||||||
|
|
||||||
|
- Removed muffling of projection errors while rendering (#646)
|
||||||
|
|
||||||
- Improved logging system (https://github.com/mapnik/mapnik/wiki/Logging)
|
- Improved logging system (https://github.com/mapnik/mapnik/wiki/Logging)
|
||||||
|
|
||||||
- Added support for reading images from in memory streams (#1805)
|
- Added support for reading images from in memory streams (#1805)
|
||||||
|
|
|
@ -160,8 +160,6 @@ void feature_style_processor<Processor>::apply(double scale_denom)
|
||||||
Processor & p = static_cast<Processor&>(*this);
|
Processor & p = static_cast<Processor&>(*this);
|
||||||
p.start_map_processing(m_);
|
p.start_map_processing(m_);
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
projection proj(m_.srs(),true);
|
projection proj(m_.srs(),true);
|
||||||
if (scale_denom <= 0.0)
|
if (scale_denom <= 0.0)
|
||||||
scale_denom = mapnik::scale_denominator(m_.scale(),proj.is_geographic());
|
scale_denom = mapnik::scale_denominator(m_.scale(),proj.is_geographic());
|
||||||
|
@ -185,11 +183,6 @@ void feature_style_processor<Processor>::apply(double scale_denom)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch (proj_init_error const& ex)
|
|
||||||
{
|
|
||||||
MAPNIK_LOG_ERROR(feature_style_processor) << "feature_style_processor: proj_init_error=" << ex.what();
|
|
||||||
}
|
|
||||||
|
|
||||||
p.end_map_processing(m_);
|
p.end_map_processing(m_);
|
||||||
|
|
||||||
|
@ -207,8 +200,6 @@ void feature_style_processor<Processor>::apply(mapnik::layer const& lyr,
|
||||||
{
|
{
|
||||||
Processor & p = static_cast<Processor&>(*this);
|
Processor & p = static_cast<Processor&>(*this);
|
||||||
p.start_map_processing(m_);
|
p.start_map_processing(m_);
|
||||||
try
|
|
||||||
{
|
|
||||||
projection proj(m_.srs(),true);
|
projection proj(m_.srs(),true);
|
||||||
if (scale_denom <= 0.0)
|
if (scale_denom <= 0.0)
|
||||||
scale_denom = mapnik::scale_denominator(m_.scale(),proj.is_geographic());
|
scale_denom = mapnik::scale_denominator(m_.scale(),proj.is_geographic());
|
||||||
|
@ -227,11 +218,6 @@ void feature_style_processor<Processor>::apply(mapnik::layer const& lyr,
|
||||||
m_.buffer_size(),
|
m_.buffer_size(),
|
||||||
names);
|
names);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch (proj_init_error const& ex)
|
|
||||||
{
|
|
||||||
MAPNIK_LOG_ERROR(feature_style_processor) << "feature_style_processor: proj_init_error=" << ex.what();
|
|
||||||
}
|
|
||||||
p.end_map_processing(m_);
|
p.end_map_processing(m_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -199,7 +199,17 @@ void map_parser::parse_map(Map & map, xml_node const& pt, std::string const& bas
|
||||||
map.set_background_image(ensure_relative_to_xml(image_filename));
|
map.set_background_image(ensure_relative_to_xml(image_filename));
|
||||||
}
|
}
|
||||||
|
|
||||||
map.set_srs(map_node.get_attr("srs", map.srs()));
|
std::string srs = map_node.get_attr("srs", map.srs());
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// create throwaway projection object here to ensure it is valid
|
||||||
|
projection proj(srs);
|
||||||
|
}
|
||||||
|
catch (proj_init_error const& ex)
|
||||||
|
{
|
||||||
|
throw mapnik::config_error(ex.what());
|
||||||
|
}
|
||||||
|
map.set_srs(srs);
|
||||||
|
|
||||||
optional<unsigned> buffer_size = map_node.get_opt_attr<unsigned>("buffer-size");
|
optional<unsigned> buffer_size = map_node.get_opt_attr<unsigned>("buffer-size");
|
||||||
if (buffer_size)
|
if (buffer_size)
|
||||||
|
@ -543,9 +553,17 @@ void map_parser::parse_layer(Map & map, xml_node const& node)
|
||||||
{
|
{
|
||||||
name = node.get_attr("name", std::string("Unnamed"));
|
name = node.get_attr("name", std::string("Unnamed"));
|
||||||
|
|
||||||
// XXX if no projection is given inherit from map? [DS]
|
// If no projection is given inherit from map
|
||||||
std::string srs = node.get_attr("srs", map.srs());
|
std::string srs = node.get_attr("srs", map.srs());
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// create throwaway projection object here to ensure it is valid
|
||||||
|
projection proj(srs);
|
||||||
|
}
|
||||||
|
catch (proj_init_error const& ex)
|
||||||
|
{
|
||||||
|
throw mapnik::config_error(ex.what());
|
||||||
|
}
|
||||||
layer lyr(name, srs);
|
layer lyr(name, srs);
|
||||||
|
|
||||||
optional<boolean> status = node.get_opt_attr<boolean>("status");
|
optional<boolean> status = node.get_opt_attr<boolean>("status");
|
||||||
|
|
3
tests/data/broken_maps/invalid_layer_srs.xml
Normal file
3
tests/data/broken_maps/invalid_layer_srs.xml
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
<Map>
|
||||||
|
<Layer srs="+init=invalid_srs_value" />
|
||||||
|
</Map>
|
2
tests/data/broken_maps/invalid_map_srs.xml
Normal file
2
tests/data/broken_maps/invalid_map_srs.xml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
<Map srs="+init=invalid_srs_value">
|
||||||
|
</Map>
|
Loading…
Reference in a new issue