Merge commit 'bda0375f9728f3b8b2cc74d9338f9a84f527ba2f' into harfbuzz

Conflicts:
	include/mapnik/font_engine_freetype.hpp
This commit is contained in:
Hermann Kraus 2013-03-16 17:47:17 +01:00
commit 87395157c6
9 changed files with 194 additions and 89 deletions

View file

@ -5,16 +5,28 @@ ifeq ($(UNAME), Darwin)
else
endif
OS:=$(shell uname -s)
ifeq ($(NPROCS),)
NPROCS:=1
ifeq ($(OS),Linux)
NPROCS:=$(shell grep -c ^processor /proc/cpuinfo)
endif
ifeq ($(OS),Darwin)
NPROCS:=$(shell sysctl -n hw.ncpu)
endif
endif
all: mapnik
install:
@python scons/scons.py --config=cache --implicit-cache --max-drift=1 install
@python scons/scons.py -j$(NPROCS) --config=cache --implicit-cache --max-drift=1 install
mapnik:
@python scons/scons.py --config=cache --implicit-cache --max-drift=1
@python scons/scons.py -j$(NPROCS) --config=cache --implicit-cache --max-drift=1
clean:
@python scons/scons.py -c --config=cache --implicit-cache --max-drift=1
@python scons/scons.py -j$(NPROCS) -c --config=cache --implicit-cache --max-drift=1
@if test -e ".sconsign.dblite"; then rm ".sconsign.dblite"; fi
@if test -e "config.log"; then rm "config.log"; fi
@if test -e ".sconf_temp/"; then rm -r ".sconf_temp/"; fi
@ -34,7 +46,7 @@ rebuild:
make uninstall && make clean && time make && make install
uninstall:
@python scons/scons.py --config=cache --implicit-cache --max-drift=1 uninstall
@python scons/scons.py -j$(NPROCS) --config=cache --implicit-cache --max-drift=1 uninstall
test:
@ ./run_tests

View file

@ -0,0 +1,48 @@
//-----------------------------------------------------------------------------
// boost variant/detail/hash_variant.hpp header file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// Copyright (c) 2011
// Antony Polukhin
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// TODO: Remove this file once the minimum Boost version is bumped to 1.50
#ifndef BOOST_HASH_VARIANT_FUNCTION_HPP
#define BOOST_HASH_VARIANT_FUNCTION_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
#include <boost/variant/variant_fwd.hpp>
#include <boost/variant/static_visitor.hpp>
#include <boost/variant/apply_visitor.hpp>
#include <boost/functional/hash_fwd.hpp>
namespace boost {
namespace detail { namespace variant {
struct variant_hasher: public boost::static_visitor<std::size_t> {
template <class T>
std::size_t operator()(T const& val) const {
using namespace boost;
hash<T> hasher;
return hasher(val);
}
};
}}
template < BOOST_VARIANT_ENUM_PARAMS(typename T) >
std::size_t hash_value(variant< BOOST_VARIANT_ENUM_PARAMS(T) > const& val) {
std::size_t seed = boost::apply_visitor(detail::variant::variant_hasher(), val);
hash_combine(seed, val.which());
return seed;
}
}
#endif

View file

@ -113,14 +113,14 @@ public:
*
* @param rhs Map to copy from.
*/
Map(const Map& rhs);
Map(Map const& rhs);
/*! \brief Assignment operator
*
* TODO: to be documented
*
*/
Map& operator=(const Map& rhs);
Map& operator=(Map const& rhs);
/*! \brief Get all styles
* @return Const reference to styles
@ -202,13 +202,13 @@ public:
/*! \brief Add a layer to the map.
* @param l The layer to add.
*/
void addLayer(const layer& l);
void addLayer(layer const& l);
/*! \brief Get a layer.
* @param index layer number.
* @return Constant layer.
*/
const layer& getLayer(size_t index) const;
layer const& getLayer(size_t index) const;
/*! \brief Get a layer.
* @param index layer number.
@ -268,7 +268,7 @@ public:
/*! \brief Set the map background color.
* @param c Background color.
*/
void set_background(const color& c);
void set_background(color const& c);
/*! \brief Get the map background color
* @return Background color as boost::optional
@ -328,7 +328,7 @@ public:
* Aspect is handled automatic if not fitting to width/height.
* @param box The bounding box where to zoom.
*/
void zoom_to_box(const box2d<double>& box);
void zoom_to_box(box2d<double> const& box);
/*! \brief Zoom the map to show all data.
*/
@ -341,7 +341,7 @@ public:
/*! \brief Get current bounding box.
* @return The current bounding box.
*/
const box2d<double>& get_current_extent() const;
box2d<double> const& get_current_extent() const;
/*! \brief Get current buffered bounding box.
* @return The current buffered bounding box.

View file

@ -51,4 +51,10 @@ private:
};
}
namespace U_ICU_NAMESPACE {
inline std::size_t hash_value(const UnicodeString& val) {
return val.hashCode();
}
}
#endif // MAPNIK_UNICODE_HPP

View file

@ -36,6 +36,8 @@
#include <boost/variant/variant.hpp>
#include <boost/scoped_array.hpp>
#include <boost/concept_check.hpp>
#include <boost/functional/hash.hpp>
#include "hash_variant.hpp"
// stl
#include <iostream>
@ -905,6 +907,10 @@ operator << (std::basic_ostream<charT,traits>& out,
return out;
}
inline std::size_t hash_value(const value& val) {
return hash_value(val.base());
}
} // namespace value_adl_barrier
using value_adl_barrier::value;

View file

@ -78,6 +78,10 @@ struct value_null
}
};
inline std::size_t hash_value(const value_null& val) {
return 0;
}
inline std::ostream& operator<< (std::ostream & out,value_null const& v)
{
return out;

View file

@ -61,6 +61,7 @@ using oracle::occi::SQLException;
using oracle::occi::Type;
using oracle::occi::StatelessConnectionPool;
const double occi_datasource::FMAX = std::numeric_limits<double>::max();
const std::string occi_datasource::METADATA_TABLE = "USER_SDO_GEOM_METADATA";
DATASOURCE_PLUGIN(occi_datasource)
@ -72,6 +73,10 @@ occi_datasource::occi_datasource(parameters const& params)
geometry_field_(*params.get<std::string>("geometry_field", "")),
srid_initialized_(false),
extent_initialized_(false),
bbox_token_("!bbox!"),
scale_denom_token_("!scale_denominator!"),
pixel_width_token_("!pixel_width!"),
pixel_height_token_("!pixel_height!"),
desc_(*params.get<std::string>("type"), *params.get<std::string>("encoding", "utf-8")),
use_wkb_(*params.get<mapnik::boolean>("use_wkb", false)),
row_limit_(*params.get<mapnik::value_integer>("row_limit", 0)),
@ -203,7 +208,7 @@ occi_datasource::occi_datasource(parameters const& params)
#endif
std::ostringstream s;
s << "SELECT " << fields_ << " FROM (" << table_name_ << ") WHERE rownum < 1";
s << "SELECT " << fields_ << " FROM (" << table_name_ << ") WHERE ROWNUM < 1";
MAPNIK_LOG_DEBUG(occi) << "occi_datasource: " << s.str();
@ -263,12 +268,12 @@ occi_datasource::occi_datasource(parameters const& params)
case oracle::occi::OCCI_SQLT_VNU:
case oracle::occi::OCCI_SQLT_VBI:
case oracle::occi::OCCI_SQLT_VST:
case oracle::occi::OCCIDATE:
case oracle::occi::OCCI_SQLT_DAT:
case oracle::occi::OCCI_SQLT_DATE:
case oracle::occi::OCCIROWID:
case oracle::occi::OCCI_SQLT_RDD:
case oracle::occi::OCCI_SQLT_RID:
case oracle::occi::OCCIDATE:
case oracle::occi::OCCI_SQLT_DAT:
case oracle::occi::OCCI_SQLT_DATE:
case oracle::occi::OCCI_SQLT_TIME:
case oracle::occi::OCCI_SQLT_TIME_TZ:
case oracle::occi::OCCITIMESTAMP:
@ -458,6 +463,51 @@ layer_descriptor occi_datasource::get_descriptor() const
return desc_;
}
std::string occi_datasource::sql_bbox(box2d<double> const& env) const
{
std::ostringstream b;
b << std::setprecision(16);
b << "MDSYS.SDO_GEOMETRY(" << SDO_GTYPE_2DPOLYGON << "," << srid_ << ",NULL,";
b << " MDSYS.SDO_ELEM_INFO_ARRAY(1," << SDO_ETYPE_POLYGON << "," << SDO_INTERPRETATION_RECTANGLE << "),";
b << " MDSYS.SDO_ORDINATE_ARRAY(";
b << env.minx() << "," << env.miny() << ", ";
b << env.maxx() << "," << env.maxy() << "))";
return b.str();
}
std::string occi_datasource::populate_tokens(std::string const& sql, double scale_denom, box2d<double> const& env, double pixel_width, double pixel_height) const
{
std::string populated_sql = sql;
if (boost::algorithm::icontains(populated_sql, scale_denom_token_))
{
std::ostringstream ss;
ss << scale_denom;
boost::algorithm::replace_all(populated_sql, scale_denom_token_, ss.str());
}
if (boost::algorithm::icontains(sql, pixel_width_token_))
{
std::ostringstream ss;
ss << pixel_width;
boost::algorithm::replace_all(populated_sql, pixel_width_token_, ss.str());
}
if (boost::algorithm::icontains(sql, pixel_height_token_))
{
std::ostringstream ss;
ss << pixel_height;
boost::algorithm::replace_all(populated_sql, pixel_height_token_, ss.str());
}
if (boost::algorithm::icontains(populated_sql, bbox_token_))
{
boost::algorithm::replace_all(populated_sql, bbox_token_, sql_bbox(env));
}
return populated_sql;
}
featureset_ptr occi_datasource::features(query const& q) const
{
#ifdef MAPNIK_STATS
@ -465,6 +515,9 @@ featureset_ptr occi_datasource::features(query const& q) const
#endif
box2d<double> const& box = q.get_bbox();
const double px_gw = 1.0 / boost::get<0>(q.resolution());
const double px_gh = 1.0 / boost::get<1>(q.resolution());
const double scale_denom = q.scale_denominator();
std::ostringstream s;
s << "SELECT ";
@ -486,20 +539,14 @@ featureset_ptr occi_datasource::features(query const& q) const
ctx->push(*pos);
}
s << " FROM ";
std::string query(table_);
std::string query = populate_tokens(table_, scale_denom, box, px_gw, px_gh);
if (use_spatial_index_)
{
std::ostringstream spatial_sql;
spatial_sql << std::setprecision(16);
spatial_sql << " WHERE SDO_FILTER(" << geometry_field_ << ",";
spatial_sql << " MDSYS.SDO_GEOMETRY(" << SDO_GTYPE_2DPOLYGON << "," << srid_ << ",NULL,";
spatial_sql << " MDSYS.SDO_ELEM_INFO_ARRAY(1," << SDO_ETYPE_POLYGON << "," << SDO_INTERPRETATION_RECTANGLE << "),";
spatial_sql << " MDSYS.SDO_ORDINATE_ARRAY(";
spatial_sql << box.minx() << "," << box.miny() << ", ";
spatial_sql << box.maxx() << "," << box.maxy() << ")), 'querytype=WINDOW') = 'TRUE'";
spatial_sql << " WHERE SDO_FILTER(";
spatial_sql << geometry_field_ << "," << sql_bbox(box);
spatial_sql << ", 'querytype = WINDOW') = 'TRUE'";
if (boost::algorithm::ifind_first(query, "WHERE"))
{
@ -515,36 +562,23 @@ featureset_ptr occi_datasource::features(query const& q) const
}
}
s << " FROM " << query;
if (row_limit_ > 0)
{
std::ostringstream row_limit_string;
row_limit_string << "rownum < " << row_limit_;
if (boost::algorithm::ifind_first(query, "WHERE"))
{
boost::algorithm::ireplace_first(query, "WHERE", row_limit_string.str() + " AND ");
}
else if (boost::algorithm::ifind_first(query, table_name_))
{
boost::algorithm::ireplace_first(query, table_name_, table_name_ + " " + row_limit_string.str());
}
else
{
MAPNIK_LOG_WARN(occi) << "occi_datasource: Cannot determine where to add the row limit declaration";
}
s << " WHERE ROWNUM < " << row_limit_;
}
s << query;
MAPNIK_LOG_DEBUG(occi) << "occi_datasource: " << s.str();
return boost::make_shared<occi_featureset>(pool_,
conn_,
ctx,
s.str(),
desc_.get_encoding(),
use_connection_pool_,
use_wkb_,
row_prefetch_);
conn_,
ctx,
s.str(),
desc_.get_encoding(),
use_connection_pool_,
use_wkb_,
row_prefetch_);
}
featureset_ptr occi_datasource::features_at_point(coord2d const& pt, double tol) const
@ -573,19 +607,15 @@ featureset_ptr occi_datasource::features_at_point(coord2d const& pt, double tol)
++itr;
}
s << " FROM ";
std::string query(table_);
box2d<double> box(pt.x - tol, pt.y - tol, pt.x + tol, pt.y + tol);
std::string query = populate_tokens(table_, FMAX, box, 0, 0);
if (use_spatial_index_)
{
std::ostringstream spatial_sql;
spatial_sql << std::setprecision(16);
spatial_sql << " WHERE SDO_FILTER(" << geometry_field_ << ",";
spatial_sql << " MDSYS.SDO_GEOMETRY(" << SDO_GTYPE_2DPOINT << "," << srid_ << ",NULL,";
spatial_sql << " MDSYS.SDO_ELEM_INFO_ARRAY(1," << SDO_ETYPE_POINT << "," << SDO_INTERPRETATION_POINT << "),";
spatial_sql << " MDSYS.SDO_ORDINATE_ARRAY(";
spatial_sql << pt.x << "," << pt.y << ")), 'querytype=WINDOW') = 'TRUE'";
spatial_sql << " WHERE SDO_FILTER(";
spatial_sql << geometry_field_ << "," << sql_bbox(box);
spatial_sql << ", 'querytype = WINDOW') = 'TRUE'";
if (boost::algorithm::ifind_first(query, "WHERE"))
{
@ -601,34 +631,21 @@ featureset_ptr occi_datasource::features_at_point(coord2d const& pt, double tol)
}
}
s << " FROM " << query;
if (row_limit_ > 0)
{
std::ostringstream row_limit_string;
row_limit_string << "rownum < " << row_limit_;
if (boost::algorithm::ifind_first(query, "WHERE"))
{
boost::algorithm::ireplace_first(query, "WHERE", row_limit_string.str() + " AND ");
}
else if (boost::algorithm::ifind_first(query, table_name_))
{
boost::algorithm::ireplace_first(query, table_name_, table_name_ + " " + row_limit_string.str());
}
else
{
MAPNIK_LOG_WARN(occi) << "occi_datasource: Cannot determine where to add the row limit declaration";
}
s << " WHERE ROWNUM < " << row_limit_;
}
s << query;
MAPNIK_LOG_DEBUG(occi) << "occi_datasource: " << s.str();
return boost::make_shared<occi_featureset>(pool_,
conn_,
ctx,
s.str(),
desc_.get_encoding(),
use_connection_pool_,
use_wkb_,
row_prefetch_);
conn_,
ctx,
s.str(),
desc_.get_encoding(),
use_connection_pool_,
use_wkb_,
row_prefetch_);
}

View file

@ -58,7 +58,15 @@ public:
mapnik::layer_descriptor get_descriptor() const;
private:
std::string sql_bbox(mapnik::box2d<double> const& env) const;
std::string populate_tokens(std::string const& sql,
double scale_denom,
mapnik::box2d<double> const& env,
double pixel_width,
double pixel_height) const;
static const std::string METADATA_TABLE;
static const double FMAX;
mapnik::datasource::datasource_t type_;
std::string table_;
@ -69,6 +77,10 @@ private:
bool srid_initialized_;
mutable bool extent_initialized_;
mutable mapnik::box2d<double> extent_;
const std::string bbox_token_;
const std::string scale_denom_token_;
const std::string pixel_width_token_;
const std::string pixel_height_token_;
mapnik::layer_descriptor desc_;
bool use_wkb_;
mapnik::value_integer row_limit_;

View file

@ -75,7 +75,7 @@ Map::Map(int width,int height, std::string const& srs)
aspectFixMode_(GROW_BBOX),
base_path_("") {}
Map::Map(const Map& rhs)
Map::Map(Map const& rhs)
: width_(rhs.width_),
height_(rhs.height_),
srs_(rhs.srs_),
@ -93,7 +93,7 @@ Map::Map(const Map& rhs)
Map::~Map() {}
Map& Map::operator=(const Map& rhs)
Map& Map::operator=(Map const& rhs)
{
if (this==&rhs) return *this;
width_=rhs.width_;
@ -132,12 +132,12 @@ Map::style_iterator Map::end_styles()
return styles_.end();
}
Map::const_style_iterator Map::begin_styles() const
Map::const_style_iterator Map::begin_styles() const
{
return styles_.begin();
}
Map::const_style_iterator Map::end_styles() const
Map::const_style_iterator Map::end_styles() const
{
return styles_.end();
}
@ -194,7 +194,7 @@ size_t Map::layer_count() const
return layers_.size();
}
void Map::addLayer(const layer& l)
void Map::addLayer(layer const& l)
{
layers_.push_back(l);
}
@ -210,7 +210,7 @@ void Map::remove_all()
styles_.clear();
}
const layer& Map::getLayer(size_t index) const
layer const& Map::getLayer(size_t index) const
{
return layers_[index];
}
@ -302,7 +302,7 @@ boost::optional<color> const& Map::background() const
return background_;
}
void Map::set_background(const color& c)
void Map::set_background(color const& c)
{
background_ = c;
}
@ -426,7 +426,7 @@ void Map::zoom_all()
}
}
void Map::zoom_to_box(const box2d<double> &box)
void Map::zoom_to_box(box2d<double> const& box)
{
current_extent_=box;
fixAspectRatio();
@ -488,7 +488,7 @@ void Map::fixAspectRatio()
}
}
const box2d<double>& Map::get_current_extent() const
box2d<double> const& Map::get_current_extent() const
{
return current_extent_;
}