mirror of
https://github.com/mapnik/mapnik.git
synced 2025-12-08 20:13:09 +00:00
merge with master
This commit is contained in:
commit
48eb4abedb
@ -958,7 +958,6 @@ inline std::size_t hash_value(value const& val)
|
||||
} // namespace value_adl_barrier
|
||||
|
||||
using value_adl_barrier::value;
|
||||
using value_adl_barrier::operator<<;
|
||||
|
||||
namespace detail {
|
||||
|
||||
|
||||
@ -93,11 +93,27 @@ struct split_multi_geometries
|
||||
cont_.push_back(base_symbolizer_helper::geometry_cref(std::cref(pt)));
|
||||
}
|
||||
}
|
||||
void operator() (geometry::line_string<double> const& line) const
|
||||
{
|
||||
if (minimum_path_length_ > 0)
|
||||
{
|
||||
box2d<double> bbox = t_.forward(geometry::envelope(line), prj_trans_);
|
||||
if (bbox.width() >= minimum_path_length_)
|
||||
{
|
||||
cont_.push_back(base_symbolizer_helper::geometry_cref(std::cref(line)));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cont_.push_back(base_symbolizer_helper::geometry_cref(std::cref(line)));
|
||||
}
|
||||
}
|
||||
|
||||
void operator() (geometry::multi_line_string<double> const& multi_line) const
|
||||
{
|
||||
for ( auto const& line : multi_line )
|
||||
{
|
||||
cont_.push_back(base_symbolizer_helper::geometry_cref(std::cref(line)));
|
||||
(*this)(line);
|
||||
}
|
||||
}
|
||||
|
||||
@ -182,6 +198,7 @@ struct largest_bbox_first
|
||||
bool operator() (base_symbolizer_helper::geometry_cref const& g0,
|
||||
base_symbolizer_helper::geometry_cref const& g1) const
|
||||
{
|
||||
// TODO - this has got to be expensive! Can we cache bbox's if there are repeated calls to same geom?
|
||||
box2d<double> b0 = geometry::envelope(g0);
|
||||
box2d<double> b1 = geometry::envelope(g1);
|
||||
return b0.width() * b0.height() > b1.width() * b1.height();
|
||||
@ -190,18 +207,26 @@ struct largest_bbox_first
|
||||
|
||||
void base_symbolizer_helper::initialize_geometries() const
|
||||
{
|
||||
bool largest_box_only = text_props_->largest_bbox_only;
|
||||
double minimum_path_length = text_props_->minimum_path_length;
|
||||
auto const& geom = feature_.get_geometry();
|
||||
util::apply_visitor(detail::split_multi_geometries<geometry_container_type>
|
||||
(geometries_to_process_, t_, prj_trans_, minimum_path_length ), feature_.get_geometry());
|
||||
// FIXME: return early if geometries_to_process_.empty() ?
|
||||
if (largest_box_only)
|
||||
(geometries_to_process_, t_, prj_trans_, minimum_path_length ), geom);
|
||||
if (!geometries_to_process_.empty())
|
||||
{
|
||||
geometries_to_process_.sort(largest_bbox_first());
|
||||
auto type = geometry::geometry_type(geom);
|
||||
if (type == geometry::geometry_types::Polygon ||
|
||||
type == geometry::geometry_types::MultiPolygon)
|
||||
{
|
||||
bool largest_box_only = text_props_->largest_bbox_only;
|
||||
if (largest_box_only)
|
||||
{
|
||||
geometries_to_process_.sort(largest_bbox_first());
|
||||
geo_itr_ = geometries_to_process_.begin();
|
||||
geometries_to_process_.erase(++geo_itr_, geometries_to_process_.end());
|
||||
}
|
||||
}
|
||||
geo_itr_ = geometries_to_process_.begin();
|
||||
geometries_to_process_.erase(++geo_itr_, geometries_to_process_.end());
|
||||
}
|
||||
geo_itr_ = geometries_to_process_.begin();
|
||||
}
|
||||
|
||||
void base_symbolizer_helper::initialize_points() const
|
||||
@ -236,30 +261,30 @@ void base_symbolizer_helper::initialize_points() const
|
||||
// https://github.com/mapnik/mapnik/issues/1350
|
||||
auto type = geometry::geometry_type(geom);
|
||||
|
||||
// FIXME: how to handle MultiLineString?
|
||||
// note: split_multi_geometries is called above so the only likely types are:
|
||||
// Point, LineString, and Polygon.
|
||||
if (type == geometry::geometry_types::LineString)
|
||||
{
|
||||
auto const& line = mapnik::util::get<geometry::line_string<double> >(geom);
|
||||
geometry::line_string_vertex_adapter<double> va(line);
|
||||
success = label::middle_point(va, label_x,label_y);
|
||||
}
|
||||
else if (how_placed == POINT_PLACEMENT)
|
||||
else if (how_placed == POINT_PLACEMENT || type == geometry::geometry_types::Point)
|
||||
{
|
||||
geometry::point<double> pt;
|
||||
geometry::centroid(geom, pt);
|
||||
label_x = pt.x;
|
||||
label_y = pt.y;
|
||||
success = true;
|
||||
}
|
||||
else if (how_placed == INTERIOR_PLACEMENT) // polygon
|
||||
{
|
||||
if (type == geometry::geometry_types::Polygon)
|
||||
if (geometry::centroid(geom, pt))
|
||||
{
|
||||
auto const& poly = mapnik::util::get<geometry::polygon<double> >(geom);
|
||||
geometry::polygon_vertex_adapter<double> va(poly);
|
||||
success = label::interior_position(va, label_x, label_y);
|
||||
label_x = pt.x;
|
||||
label_y = pt.y;
|
||||
success = true;
|
||||
}
|
||||
}
|
||||
else if (how_placed == INTERIOR_PLACEMENT && type == geometry::geometry_types::Polygon)
|
||||
{
|
||||
auto const& poly = mapnik::util::get<geometry::polygon<double> >(geom);
|
||||
geometry::polygon_vertex_adapter<double> va(poly);
|
||||
success = label::interior_position(va, label_x, label_y);
|
||||
}
|
||||
else
|
||||
{
|
||||
MAPNIK_LOG_ERROR(symbolizer_helpers) << "ERROR: Unknown placement type in initialize_points()";
|
||||
|
||||
@ -1 +1 @@
|
||||
Subproject commit a6838f99a4c4be37989cea6718442cf4b53bd616
|
||||
Subproject commit 2823c6a0ba9e642869537d8e5c1a1ca5fd3de18a
|
||||
@ -1 +1 @@
|
||||
Subproject commit 1ff20dbb0550da6ab37374b0525f289150c79652
|
||||
Subproject commit 1c4c5bc2d77d86c466087d004fb37cf1bef2f9dd
|
||||
@ -2,11 +2,14 @@
|
||||
|
||||
#include <mapnik/value_types.hpp>
|
||||
#include <mapnik/value.hpp>
|
||||
#include <mapnik/unicode.hpp>
|
||||
#include <mapnik/util/conversions.hpp>
|
||||
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include <unordered_map>
|
||||
#include <sstream>
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1900
|
||||
#include <cstdio>
|
||||
@ -289,6 +292,14 @@ SECTION("to string") {
|
||||
vc[val2] = 1;
|
||||
REQUIRE( vc[1] == static_cast<int>(1) );
|
||||
|
||||
// mapnik::value << to ostream
|
||||
std::stringstream s;
|
||||
mapnik::transcoder tr("utf-8");
|
||||
mapnik::value_unicode_string ustr = tr.transcode("hello world!");
|
||||
mapnik::value streamable(ustr);
|
||||
s << streamable;
|
||||
CHECK( s.str() == std::string("hello world!") );
|
||||
|
||||
}
|
||||
catch (std::exception const & ex)
|
||||
{
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
#include "catch.hpp"
|
||||
|
||||
// mapnik
|
||||
#include <mapnik/value.hpp>
|
||||
#include <mapnik/image_any.hpp>
|
||||
#include <mapnik/color.hpp>
|
||||
#include <mapnik/image_view_any.hpp>
|
||||
|
||||
@ -31,6 +31,18 @@
|
||||
|
||||
#include "cleanup.hpp" // run_cleanup()
|
||||
|
||||
#ifdef MAPNIK_LOG
|
||||
using log_levels_map = std::map<std::string, mapnik::logger::severity_type>;
|
||||
|
||||
log_levels_map log_levels
|
||||
{
|
||||
{ "debug", mapnik::logger::severity_type::debug },
|
||||
{ "warn", mapnik::logger::severity_type::warn },
|
||||
{ "error", mapnik::logger::severity_type::error },
|
||||
{ "none", mapnik::logger::severity_type::none }
|
||||
};
|
||||
#endif
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
using namespace visual_tests;
|
||||
@ -49,6 +61,11 @@ int main(int argc, char** argv)
|
||||
("styles", po::value<std::vector<std::string>>(), "selected styles to test")
|
||||
("fonts", po::value<std::string>()->default_value("fonts"), "font search path")
|
||||
("plugins", po::value<std::string>()->default_value("plugins/input"), "input plugins search path")
|
||||
#ifdef MAPNIK_LOG
|
||||
("log", po::value<std::string>()->default_value(std::find_if(log_levels.begin(), log_levels.end(),
|
||||
[](log_levels_map::value_type const & level) { return level.second == mapnik::logger::get_severity(); } )->first),
|
||||
"log level (debug, warn, error, none)")
|
||||
#endif
|
||||
;
|
||||
|
||||
po::positional_options_description p;
|
||||
@ -63,6 +80,20 @@ int main(int argc, char** argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifdef MAPNIK_LOG
|
||||
std::string log_level(vm["log"].as<std::string>());
|
||||
log_levels_map::const_iterator level_iter = log_levels.find(log_level);
|
||||
if (level_iter == log_levels.end())
|
||||
{
|
||||
std::cerr << "Error: Unknown log level: " << log_level << std::endl;
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
mapnik::logger::set_severity(level_iter->second);
|
||||
}
|
||||
#endif
|
||||
|
||||
mapnik::freetype_engine::register_fonts(vm["fonts"].as<std::string>(), true);
|
||||
mapnik::datasource_cache::instance().register_datasources(vm["plugins"].as<std::string>());
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user