Merge branch 'master' into boost_1_67
This commit is contained in:
commit
95d5fabad0
7 changed files with 176 additions and 40 deletions
19
SConstruct
19
SConstruct
|
@ -1401,6 +1401,7 @@ if not preconfigured:
|
|||
['harfbuzz', 'harfbuzz/hb.h',True,'C++']
|
||||
]
|
||||
|
||||
CHECK_PKG_CONFIG = conf.CheckPKGConfig('0.15.0')
|
||||
if env.get('FREETYPE_LIBS') or env.get('FREETYPE_INCLUDES'):
|
||||
REQUIRED_LIBSHEADERS.insert(0,['freetype','ft2build.h',True,'C'])
|
||||
if env.get('FREETYPE_INCLUDES'):
|
||||
|
@ -1409,6 +1410,21 @@ if not preconfigured:
|
|||
if env.get('FREETYPE_LIBS'):
|
||||
lib_path = env['FREETYPE_LIBS']
|
||||
env.AppendUnique(LIBPATH = fix_path(lib_path))
|
||||
elif CHECK_PKG_CONFIG and conf.CheckPKG('freetype2'):
|
||||
# Freetype 2.9+ doesn't use freetype-config and uses pkg-config instead
|
||||
cmd = 'pkg-config freetype2 --libs --cflags'
|
||||
if env['RUNTIME_LINK'] == 'static':
|
||||
cmd += ' --static'
|
||||
|
||||
temp_env = Environment(ENV=os.environ)
|
||||
try:
|
||||
temp_env.ParseConfig(cmd)
|
||||
for lib in temp_env['LIBS']:
|
||||
env.AppendUnique(LIBPATH = fix_path(lib))
|
||||
for inc in temp_env['CPPPATH']:
|
||||
env.AppendUnique(CPPPATH = fix_path(inc))
|
||||
except OSError as e:
|
||||
pass
|
||||
elif conf.parse_config('FREETYPE_CONFIG'):
|
||||
# check if freetype links to bz2
|
||||
if env['RUNTIME_LINK'] == 'static':
|
||||
|
@ -1642,9 +1658,6 @@ if not preconfigured:
|
|||
color_print(1,'%s not detected on your system' % env['QUERIED_ICU_DATA'] )
|
||||
env['MISSING_DEPS'].append('ICU_DATA')
|
||||
|
||||
|
||||
CHECK_PKG_CONFIG = conf.CheckPKGConfig('0.15.0')
|
||||
|
||||
if len(env['REQUESTED_PLUGINS']):
|
||||
if env['HOST']:
|
||||
for plugin in env['REQUESTED_PLUGINS']:
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
/*****************************************************************************
|
||||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2017 Artem Pavlenko
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef MAPNIK_ELLIPSOID_HPP
|
||||
#define MAPNIK_ELLIPSOID_HPP
|
||||
|
||||
namespace mapnik {
|
||||
struct ellipsoid
|
||||
{
|
||||
double a; // semi mayor axis
|
||||
double b; // semi minor axis
|
||||
};
|
||||
}
|
||||
|
||||
#endif // MAPNIK_ELLIPSOID_HPP
|
|
@ -314,6 +314,12 @@ bool middle_point(PathType & path, double & x, double & y, boost::optional<doubl
|
|||
path.rewind(0);
|
||||
unsigned command = path.vertex(&x0,&y0);
|
||||
if (command == SEG_END) return false;
|
||||
if (std::abs(mid_length) < std::numeric_limits<double>::epsilon())
|
||||
{
|
||||
x = x0;
|
||||
y = y0;
|
||||
return true;
|
||||
}
|
||||
double dist = 0.0;
|
||||
while (SEG_END != (command = path.vertex(&x1, &y1)))
|
||||
{
|
||||
|
|
|
@ -67,7 +67,7 @@ public:
|
|||
|
||||
inline std::string id() const
|
||||
{
|
||||
return connection_string();
|
||||
return connection_string_safe();
|
||||
}
|
||||
|
||||
inline std::string connection_string() const
|
||||
|
@ -115,6 +115,9 @@ public:
|
|||
|
||||
bool registerPool(ConnectionCreator<Connection> const& creator,unsigned initialSize,unsigned maxSize)
|
||||
{
|
||||
#ifdef MAPNIK_THREADSAFE
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
#endif
|
||||
ContType::const_iterator itr = pools_.find(creator.id());
|
||||
|
||||
if (itr != pools_.end())
|
||||
|
@ -134,6 +137,9 @@ public:
|
|||
|
||||
std::shared_ptr<PoolType> getPool(std::string const& key)
|
||||
{
|
||||
#ifdef MAPNIK_THREADSAFE
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
#endif
|
||||
ContType::const_iterator itr=pools_.find(key);
|
||||
if (itr!=pools_.end())
|
||||
{
|
||||
|
|
|
@ -23,17 +23,22 @@
|
|||
// mapnik
|
||||
#include <mapnik/scale_denominator.hpp>
|
||||
#include <mapnik/global.hpp>
|
||||
#include <mapnik/well_known_srs.hpp>
|
||||
|
||||
// stl
|
||||
#include <cmath>
|
||||
|
||||
namespace mapnik {
|
||||
|
||||
static const double meters_per_degree = 6378137 * 2 * M_PI / 360;
|
||||
static const double meters_per_degree = EARTH_CIRCUMFERENCE / 360;
|
||||
|
||||
double scale_denominator(double map_scale, bool geographic)
|
||||
{
|
||||
double denom = map_scale / 0.00028;
|
||||
// Pixel size in meters.
|
||||
// Corresponding approximate resolution is 90.71 DPI.
|
||||
constexpr double pixel_size = 0.00028;
|
||||
|
||||
double denom = map_scale / pixel_size;
|
||||
if (geographic) denom *= meters_per_degree;
|
||||
return denom;
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include <mapnik/geometry/geometry_type.hpp>
|
||||
#include <mapnik/unicode.hpp>
|
||||
#include <mapnik/util/fs.hpp>
|
||||
#include "../../../plugins/input/postgis/connection_manager.hpp"
|
||||
|
||||
/*
|
||||
Compile and run just this test:
|
||||
|
@ -406,3 +407,20 @@ TEST_CASE("postgis") {
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE("ConnectionCreator") {
|
||||
|
||||
SECTION("ConnectionCreator::id() should not expose password")
|
||||
{
|
||||
ConnectionCreator<Connection> creator(boost::optional<std::string>("host"),
|
||||
boost::optional<std::string>("12345"),
|
||||
boost::optional<std::string>("dbname"),
|
||||
boost::optional<std::string>("user"),
|
||||
boost::optional<std::string>("pass"),
|
||||
boost::optional<std::string>("111"));
|
||||
|
||||
CHECK(creator.id() == "host=host port=12345 dbname=dbname user=user connect_timeout=111");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
122
test/unit/symbolizer/markers_point_placement.cpp
Normal file
122
test/unit/symbolizer/markers_point_placement.cpp
Normal file
|
@ -0,0 +1,122 @@
|
|||
|
||||
#include "catch.hpp"
|
||||
|
||||
#include <mapnik/vertex_adapters.hpp>
|
||||
#include <mapnik/label_collision_detector.hpp>
|
||||
#include <mapnik/markers_placements/point.hpp>
|
||||
|
||||
using namespace mapnik;
|
||||
|
||||
TEST_CASE("marker placement point") {
|
||||
|
||||
SECTION("empty geometry") {
|
||||
|
||||
mapnik::geometry::line_string<double> g;
|
||||
using va_type = mapnik::geometry::line_string_vertex_adapter<double>;
|
||||
va_type va(g);
|
||||
|
||||
using detector_type = mapnik::label_collision_detector4;
|
||||
detector_type detector(mapnik::box2d<double>(0, 0, 100, 100));
|
||||
|
||||
using placement_type = mapnik::markers_point_placement<va_type, detector_type>;
|
||||
|
||||
mapnik::markers_placement_params params {
|
||||
mapnik::box2d<double>(0, 0, 10, 10),
|
||||
agg::trans_affine(),
|
||||
0, 0, false, false, DIRECTION_AUTO, 1.0 };
|
||||
|
||||
placement_type placement(va, detector, params);
|
||||
|
||||
double x, y, angle;
|
||||
CHECK( !placement.get_point(x, y, angle, true) );
|
||||
}
|
||||
|
||||
SECTION("point") {
|
||||
|
||||
mapnik::geometry::point<double> g(2.0, 3.0);
|
||||
using va_type = mapnik::geometry::point_vertex_adapter<double>;
|
||||
va_type va(g);
|
||||
|
||||
using detector_type = mapnik::label_collision_detector4;
|
||||
detector_type detector(mapnik::box2d<double>(0, 0, 100, 100));
|
||||
|
||||
using placement_type = mapnik::markers_point_placement<va_type, detector_type>;
|
||||
|
||||
mapnik::markers_placement_params params {
|
||||
mapnik::box2d<double>(0, 0, 10, 10),
|
||||
agg::trans_affine(),
|
||||
0, 0, false, false, DIRECTION_AUTO, 1.0 };
|
||||
|
||||
placement_type placement(va, detector, params);
|
||||
|
||||
double x, y, angle;
|
||||
|
||||
CHECK( placement.get_point(x, y, angle, true) );
|
||||
CHECK( x == Approx(2.0) );
|
||||
CHECK( y == Approx(3.0) );
|
||||
CHECK( angle == Approx(0.0) );
|
||||
|
||||
CHECK( !placement.get_point(x, y, angle, true) );
|
||||
}
|
||||
|
||||
SECTION("line string") {
|
||||
|
||||
mapnik::geometry::line_string<double> g;
|
||||
g.emplace_back(1.0, 1.0);
|
||||
g.emplace_back(2.0, 2.0);
|
||||
using va_type = mapnik::geometry::line_string_vertex_adapter<double>;
|
||||
va_type va(g);
|
||||
|
||||
using detector_type = mapnik::label_collision_detector4;
|
||||
detector_type detector(mapnik::box2d<double>(0, 0, 100, 100));
|
||||
|
||||
using placement_type = mapnik::markers_point_placement<va_type, detector_type>;
|
||||
|
||||
mapnik::markers_placement_params params {
|
||||
mapnik::box2d<double>(0, 0, 10, 10),
|
||||
agg::trans_affine(),
|
||||
0, 0, false, false, DIRECTION_AUTO, 1.0 };
|
||||
|
||||
placement_type placement(va, detector, params);
|
||||
|
||||
double x, y, angle;
|
||||
|
||||
CHECK( placement.get_point(x, y, angle, true) );
|
||||
CHECK( x == Approx(1.5) );
|
||||
CHECK( y == Approx(1.5) );
|
||||
CHECK( angle == Approx(0) );
|
||||
|
||||
CHECK( !placement.get_point(x, y, angle, true) );
|
||||
}
|
||||
|
||||
SECTION("line string zero length") {
|
||||
|
||||
mapnik::geometry::line_string<double> g;
|
||||
g.emplace_back(1.0, 1.0);
|
||||
g.emplace_back(1.0, 1.0);
|
||||
using va_type = mapnik::geometry::line_string_vertex_adapter<double>;
|
||||
va_type va(g);
|
||||
|
||||
using detector_type = mapnik::label_collision_detector4;
|
||||
detector_type detector(mapnik::box2d<double>(0, 0, 100, 100));
|
||||
|
||||
using placement_type = mapnik::markers_point_placement<va_type, detector_type>;
|
||||
|
||||
mapnik::markers_placement_params params {
|
||||
mapnik::box2d<double>(0, 0, 10, 10),
|
||||
agg::trans_affine(),
|
||||
0, 0, false, false, DIRECTION_AUTO, 1.0 };
|
||||
|
||||
placement_type placement(va, detector, params);
|
||||
|
||||
double x, y, angle;
|
||||
|
||||
CHECK( placement.get_point(x, y, angle, true) );
|
||||
CHECK( x == Approx(1.0) );
|
||||
CHECK( y == Approx(1.0) );
|
||||
CHECK( angle == Approx(0) );
|
||||
|
||||
CHECK( !placement.get_point(x, y, angle, true) );
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue