+ make width,height and type optinal in following
symbolizers: * point_symbolizer * shield_symbolizer * line_pattern_symbolizer * polygon_pattern_symbolizer
This commit is contained in:
parent
cf4c94a44b
commit
8cd7645561
1 changed files with 1467 additions and 1371 deletions
144
src/load_map.cpp
144
src/load_map.cpp
|
@ -24,6 +24,7 @@
|
|||
|
||||
#include <mapnik/version.hpp>
|
||||
#include <mapnik/image_reader.hpp>
|
||||
#include <mapnik/image_util.hpp>
|
||||
#include <mapnik/color.hpp>
|
||||
#include <mapnik/color_factory.hpp>
|
||||
#include <mapnik/filter_factory.hpp>
|
||||
|
@ -652,6 +653,7 @@ namespace mapnik
|
|||
optional<std::string> file = get_opt_attr<string>(sym, "file");
|
||||
optional<std::string> base = get_opt_attr<string>(sym, "base");
|
||||
optional<std::string> type = get_opt_attr<string>(sym, "type");
|
||||
|
||||
optional<boolean> allow_overlap =
|
||||
get_opt_attr<boolean>(sym, "allow_overlap");
|
||||
optional<float> opacity =
|
||||
|
@ -660,8 +662,32 @@ namespace mapnik
|
|||
optional<unsigned> width = get_opt_attr<unsigned>(sym, "width");
|
||||
optional<unsigned> height = get_opt_attr<unsigned>(sym, "height");
|
||||
|
||||
if (file && type && width && height)
|
||||
//
|
||||
if (file)
|
||||
{
|
||||
if (!type)
|
||||
{
|
||||
type = type_from_filename(*file);
|
||||
}
|
||||
|
||||
if (!width || !height)
|
||||
{
|
||||
try
|
||||
{
|
||||
std::auto_ptr<ImageReader> reader(get_image_reader(*file));
|
||||
if (reader.get())
|
||||
{
|
||||
if (!width) width = reader->width();
|
||||
if (!height) height = reader->height();
|
||||
BOOST_ASSERT(*width > 0 && *height > 0);
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
std::cerr << "Exception caught while loading image:" << *file << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if( base )
|
||||
|
@ -678,7 +704,8 @@ namespace mapnik
|
|||
*file = ensure_relative_to_xml(file);
|
||||
}
|
||||
#ifdef MAPNIK_DEBUG
|
||||
else {
|
||||
else
|
||||
{
|
||||
std::clog << "\nFound relative paths in xml, leaving unchanged...\n";
|
||||
}
|
||||
#endif
|
||||
|
@ -709,16 +736,16 @@ namespace mapnik
|
|||
}
|
||||
|
||||
}
|
||||
else if (file || type || width || height)
|
||||
{
|
||||
std::ostringstream os;
|
||||
os << "Missing required attributes: ";
|
||||
if ( ! file ) os << "file ";
|
||||
if ( ! type ) os << "type ";
|
||||
if ( ! width ) os << "width ";
|
||||
if ( ! height ) os << "height ";
|
||||
throw config_error( os.str() );
|
||||
}
|
||||
//else if (file || type || width || height)
|
||||
//{
|
||||
// std::ostringstream os;
|
||||
// os << "Missing required attributes: ";
|
||||
// if ( ! file ) os << "file ";
|
||||
// if ( ! type ) os << "type ";
|
||||
// if ( ! width ) os << "width ";
|
||||
// if ( ! height ) os << "height ";
|
||||
// throw config_error( os.str() );
|
||||
//}
|
||||
else
|
||||
{
|
||||
rule.append(point_symbolizer());
|
||||
|
@ -737,9 +764,32 @@ namespace mapnik
|
|||
{
|
||||
std::string file = get_attr<string>(sym, "file");
|
||||
optional<std::string> base = get_opt_attr<string>(sym, "base");
|
||||
std::string type = get_attr<string>(sym, "type");
|
||||
unsigned width = get_attr<unsigned>(sym, "width");
|
||||
unsigned height = get_attr<unsigned>(sym, "height");
|
||||
optional<std::string> type = get_attr<string>(sym, "type");
|
||||
optional<unsigned> width = get_attr<unsigned>(sym, "width");
|
||||
optional<unsigned> height = get_attr<unsigned>(sym, "height");
|
||||
|
||||
if (!type)
|
||||
{
|
||||
type = type_from_filename(file);
|
||||
}
|
||||
|
||||
if (!width || !height)
|
||||
{
|
||||
try
|
||||
{
|
||||
std::auto_ptr<ImageReader> reader(get_image_reader(file));
|
||||
if (reader.get())
|
||||
{
|
||||
if (!width) width = reader->width();
|
||||
if (!height) height = reader->height();
|
||||
BOOST_ASSERT(*width > 0 && *height > 0);
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
std::cerr << "Exception caught while loading image:" << file << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -762,7 +812,7 @@ namespace mapnik
|
|||
#endif
|
||||
|
||||
|
||||
line_pattern_symbolizer symbol(file,type,width,height);
|
||||
line_pattern_symbolizer symbol(file,*type,*width,*height);
|
||||
rule.append(symbol);
|
||||
}
|
||||
catch (ImageReaderException const & ex )
|
||||
|
@ -793,9 +843,32 @@ namespace mapnik
|
|||
{
|
||||
std::string file = get_attr<string>(sym, "file");
|
||||
optional<std::string> base = get_opt_attr<string>(sym, "base");
|
||||
std::string type = get_attr<string>(sym, "type");
|
||||
unsigned width = get_attr<unsigned>(sym, "width");
|
||||
unsigned height = get_attr<unsigned>(sym, "height");
|
||||
optional<std::string> type = get_attr<string>(sym, "type");
|
||||
optional<unsigned> width = get_attr<unsigned>(sym, "width");
|
||||
optional<unsigned> height = get_attr<unsigned>(sym, "height");
|
||||
|
||||
if (!type)
|
||||
{
|
||||
type = type_from_filename(file);
|
||||
}
|
||||
|
||||
if (!width || !height)
|
||||
{
|
||||
try
|
||||
{
|
||||
std::auto_ptr<ImageReader> reader(get_image_reader(file));
|
||||
if (reader.get())
|
||||
{
|
||||
if (!width) width = reader->width();
|
||||
if (!height) height = reader->height();
|
||||
BOOST_ASSERT(*width > 0 && *height > 0);
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
std::cerr << "Exception caught while loading image:" << file << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -817,7 +890,7 @@ namespace mapnik
|
|||
}
|
||||
#endif
|
||||
|
||||
polygon_pattern_symbolizer symbol(file,type,width,height);
|
||||
polygon_pattern_symbolizer symbol(file,*type,*width,*height);
|
||||
rule.append(symbol);
|
||||
}
|
||||
catch (ImageReaderException const & ex )
|
||||
|
@ -1053,9 +1126,32 @@ namespace mapnik
|
|||
|
||||
std::string image_file = get_attr<string>(sym, "file");
|
||||
optional<std::string> base = get_opt_attr<string>(sym, "base");
|
||||
std::string type = get_attr<string>(sym, "type");
|
||||
unsigned width = get_attr<unsigned>(sym, "width");
|
||||
unsigned height = get_attr<unsigned>(sym, "height");
|
||||
optional<std::string> type = get_opt_attr<string>(sym, "type");
|
||||
optional<unsigned> width = get_opt_attr<unsigned>(sym, "width");
|
||||
optional<unsigned> height = get_opt_attr<unsigned>(sym, "height");
|
||||
|
||||
if (!type)
|
||||
{
|
||||
type = type_from_filename(image_file);
|
||||
}
|
||||
|
||||
if (!width || !height)
|
||||
{
|
||||
try
|
||||
{
|
||||
std::auto_ptr<ImageReader> reader(get_image_reader(image_file));
|
||||
if (reader.get())
|
||||
{
|
||||
if (!width) width = reader->width();
|
||||
if (!height) height = reader->height();
|
||||
BOOST_ASSERT(*width > 0 && *height > 0);
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
std::cerr << "Exception caught while loading image:" << image_file << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -1079,7 +1175,7 @@ namespace mapnik
|
|||
#endif
|
||||
|
||||
shield_symbolizer shield_symbol(name,size,fill,
|
||||
image_file,type,width,height);
|
||||
image_file,*type,*width,*height);
|
||||
|
||||
if (fontset_name && face_name)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue