Merge commit '7cf4a00af9530ba2aa46ba1a4a5cb2cb41fe166a' into harfbuzz

This commit is contained in:
Hermann Kraus 2013-03-16 12:13:11 +01:00
commit 3ea335af66
10 changed files with 69 additions and 50 deletions

View file

@ -665,7 +665,9 @@ void csv_datasource::parse_csv(T & stream,
} }
} }
// now, add all values as attributes // now, add attributes, skipping any WKT or JSON fiels
if ((has_wkt_field) && (i == wkt_idx)) continue;
if ((has_json_field) && (i == json_idx)) continue;
/* First we detect likely strings, then try parsing likely numbers, /* First we detect likely strings, then try parsing likely numbers,
finally falling back to string type finally falling back to string type
* We intentionally do not try to detect boolean or null types * We intentionally do not try to detect boolean or null types

View file

@ -121,7 +121,7 @@ void gdal_datasource::bind() const
double tr[6]; double tr[6];
bool bbox_override = false; bool bbox_override = false;
boost::optional<std::string> bbox_s = params_.get<std::string>("bbox"); boost::optional<std::string> bbox_s = params_.get<std::string>("extent");
if (bbox_s) if (bbox_s)
{ {
MAPNIK_LOG_DEBUG(gdal) << "gdal_datasource: BBox Parameter=" << *bbox_s; MAPNIK_LOG_DEBUG(gdal) << "gdal_datasource: BBox Parameter=" << *bbox_s;

View file

@ -45,7 +45,7 @@ using mapnik::image_reader;
DATASOURCE_PLUGIN(raster_datasource) DATASOURCE_PLUGIN(raster_datasource)
raster_datasource::raster_datasource(const parameters& params, bool bind) raster_datasource::raster_datasource(parameters const& params, bool bind)
: datasource(params), : datasource(params),
desc_(*params.get<std::string>("type"), "utf-8"), desc_(*params.get<std::string>("type"), "utf-8"),
extent_initialized_(false) extent_initialized_(false)
@ -62,8 +62,8 @@ raster_datasource::raster_datasource(const parameters& params, bool bind)
filename_ = *file; filename_ = *file;
multi_tiles_ = *params_.get<bool>("multi", false); multi_tiles_ = *params_.get<bool>("multi", false);
tile_size_ = *params_.get<unsigned>("tile_size", 256); tile_size_ = *params_.get<unsigned>("tile-size", 256);
tile_stride_ = *params_.get<unsigned>("tile_stride", 1); tile_stride_ = *params_.get<unsigned>("tile-stride", 1);
format_ = *params_.get<std::string>("format","tiff"); format_ = *params_.get<std::string>("format","tiff");
@ -100,8 +100,8 @@ void raster_datasource::bind() const
if (multi_tiles_) if (multi_tiles_)
{ {
boost::optional<unsigned> x_width = params_.get<unsigned>("x_width"); boost::optional<unsigned> x_width = params_.get<unsigned>("x-width");
boost::optional<unsigned> y_width = params_.get<unsigned>("y_width"); boost::optional<unsigned> y_width = params_.get<unsigned>("y-width");
if (! x_width) if (! x_width)
{ {
@ -201,11 +201,11 @@ featureset_ptr raster_datasource::features(query const& q) const
return boost::make_shared<raster_featureset<tiled_multi_file_policy> >(policy, extent_, q); return boost::make_shared<raster_featureset<tiled_multi_file_policy> >(policy, extent_, q);
} }
else if (width * height > 512*512) else if (width * height > (tile_size_ * tile_size_ << 2))
{ {
MAPNIK_LOG_DEBUG(raster) << "raster_datasource: Tiled policy"; MAPNIK_LOG_DEBUG(raster) << "raster_datasource: Tiled policy";
tiled_file_policy policy(filename_, format_, 256, extent_, q.get_bbox(), width_, height_); tiled_file_policy policy(filename_, format_, tile_size_, extent_, q.get_bbox(), width_, height_);
return boost::make_shared<raster_featureset<tiled_file_policy> >(policy, extent_, q); return boost::make_shared<raster_featureset<tiled_file_policy> >(policy, extent_, q);
} }

View file

@ -83,7 +83,8 @@ void agg_renderer<T>::process(raster_symbolizer const& sym,
if (scaling_method == SCALING_BILINEAR8) if (scaling_method == SCALING_BILINEAR8)
{ {
scale_image_bilinear8<image_data_32>(target.data_,source->data_, 0.0, 0.0); scale_image_bilinear8<image_data_32>(target.data_,source->data_, 0.0, 0.0);
} else }
else
{ {
double scaling_ratio = ext.width() / source->data_.width(); double scaling_ratio = ext.width() / source->data_.width();
scale_image_agg<image_data_32>(target.data_, scale_image_agg<image_data_32>(target.data_,

View file

@ -31,15 +31,12 @@ namespace mapnik {
void evaluate_transform(agg::trans_affine& tr, Feature const& feature, void evaluate_transform(agg::trans_affine& tr, Feature const& feature,
transform_list_ptr const& trans_expr) transform_list_ptr const& trans_expr)
{ {
#ifdef MAPNIK_LOG
MAPNIK_LOG_DEBUG(transform) << "transform: evaluate "
<< (trans_expr
? transform_processor_type::to_string(*trans_expr)
: std::string("null"));
#endif
if (trans_expr) if (trans_expr)
{ {
#ifdef MAPNIK_LOG
MAPNIK_LOG_DEBUG(transform) << "transform: evaluate "
<< transform_processor_type::to_string(*trans_expr);
#endif
transform_processor_type::evaluate(tr, feature, *trans_expr); transform_processor_type::evaluate(tr, feature, *trans_expr);
} }
} }

View file

@ -23,6 +23,8 @@
// mapnik // mapnik
#include <mapnik/debug.hpp> #include <mapnik/debug.hpp>
#include <mapnik/image_reader.hpp> #include <mapnik/image_reader.hpp>
// boost
#include <boost/shared_ptr.hpp>
#include <boost/filesystem/operations.hpp> #include <boost/filesystem/operations.hpp>
// stl // stl
@ -41,6 +43,18 @@ using std::max;
class tiff_reader : public image_reader class tiff_reader : public image_reader
{ {
typedef boost::shared_ptr<TIFF> tiff_ptr;
struct tiff_closer
{
void operator() (TIFF * tif)
{
if (tif != 0)
{
TIFFClose(tif);
}
}
};
private: private:
std::string file_name_; std::string file_name_;
int read_method_; int read_method_;
@ -49,6 +63,8 @@ private:
int rows_per_strip_; int rows_per_strip_;
int tile_width_; int tile_width_;
int tile_height_; int tile_height_;
tiff_ptr tif_;
public: public:
enum TiffType { enum TiffType {
generic=1, generic=1,
@ -116,11 +132,9 @@ void tiff_reader::init()
{ {
read_method_=stripped; read_method_=stripped;
} }
TIFFClose(tif);
} }
else else
{ {
TIFFClose(tif);
throw image_reader_exception(msg); throw image_reader_exception(msg);
} }
} }
@ -128,7 +142,6 @@ void tiff_reader::init()
tiff_reader::~tiff_reader() tiff_reader::~tiff_reader()
{ {
//
} }
@ -167,8 +180,6 @@ void tiff_reader::read_generic(unsigned /*x*/,unsigned /*y*/,image_data_32& /*im
if (tif) if (tif)
{ {
MAPNIK_LOG_DEBUG(tiff_reader) << "tiff_reader: TODO - tiff is not stripped or tiled"; MAPNIK_LOG_DEBUG(tiff_reader) << "tiff_reader: TODO - tiff is not stripped or tiled";
TIFFClose(tif);
} }
} }
@ -213,7 +224,6 @@ void tiff_reader::read_tiled(unsigned x0,unsigned y0,image_data_32& image)
} }
} }
_TIFFfree(buf); _TIFFfree(buf);
TIFFClose(tif);
} }
} }
@ -254,21 +264,21 @@ void tiff_reader::read_stripped(unsigned x0,unsigned y0,image_data_32& image)
} }
} }
_TIFFfree(buf); _TIFFfree(buf);
TIFFClose(tif);
} }
} }
TIFF* tiff_reader::load_if_exists(std::string const& filename) TIFF* tiff_reader::load_if_exists(std::string const& filename)
{ {
TIFF * tif = 0; if (!tif_)
{
boost::filesystem::path path(file_name_); boost::filesystem::path path(file_name_);
if (exists(path)) // && is_regular(path)) { -- not supported in boost-1.33.* if (boost::filesystem::is_regular(path)) // exists and regular file
{ {
// File path is a full file path and does exist // File path is a full file path and does exist
tif = TIFFOpen(filename.c_str(), "rb"); tif_ = tiff_ptr(TIFFOpen(filename.c_str(), "rb"), tiff_closer());
} }
}
return tif; return tif_.get();
}
} }
} // namespace mapnik

View file

@ -160,10 +160,10 @@ void reproject_and_scale_raster(raster & target, raster const& source,
tt.forward(polygon+6, polygon+7); tt.forward(polygon+6, polygon+7);
rasterizer.reset(); rasterizer.reset();
rasterizer.move_to_d(polygon[0]-1, polygon[1]-1); rasterizer.move_to_d(std::floor(polygon[0]), std::floor(polygon[1]));
rasterizer.line_to_d(polygon[2]+1, polygon[3]-1); rasterizer.line_to_d(std::floor(polygon[2]), std::floor(polygon[3]));
rasterizer.line_to_d(polygon[4]+1, polygon[5]+1); rasterizer.line_to_d(std::floor(polygon[4]), std::floor(polygon[5]));
rasterizer.line_to_d(polygon[6]-1, polygon[7]+1); rasterizer.line_to_d(std::floor(polygon[6]), std::floor(polygon[7]));
unsigned x0 = i * mesh_size; unsigned x0 = i * mesh_size;
unsigned y0 = j * mesh_size; unsigned y0 = j * mesh_size;

View file

@ -137,9 +137,9 @@ if 'csv' in mapnik.DatasourceCache.plugin_names():
def test_wkt_field(**kwargs): def test_wkt_field(**kwargs):
ds = get_csv_ds('wkt.csv') ds = get_csv_ds('wkt.csv')
eq_(len(ds.fields()),2) eq_(len(ds.fields()),1)
eq_(ds.fields(),['type','WKT']) eq_(ds.fields(),['type'])
eq_(ds.field_types(),['str','str']) eq_(ds.field_types(),['str'])
fs = ds.all_features() fs = ds.all_features()
eq_(len(fs[0].geometries()),1) eq_(len(fs[0].geometries()),1)
eq_(fs[0].geometries()[0].type(),mapnik.DataGeometryType.Point) eq_(fs[0].geometries()[0].type(),mapnik.DataGeometryType.Point)
@ -396,9 +396,9 @@ if 'csv' in mapnik.DatasourceCache.plugin_names():
eq_(feat['Name'],u"Winthrop, WA") eq_(feat['Name'],u"Winthrop, WA")
def validate_geojson_datasource(ds): def validate_geojson_datasource(ds):
eq_(len(ds.fields()),2) eq_(len(ds.fields()),1)
eq_(ds.fields(),['type','GeoJSON']) eq_(ds.fields(),['type'])
eq_(ds.field_types(),['str','str']) eq_(ds.field_types(),['str'])
fs = ds.all_features() fs = ds.all_features()
eq_(len(fs[0].geometries()),1) eq_(len(fs[0].geometries()),1)
eq_(fs[0].geometries()[0].type(),mapnik.DataGeometryType.Point) eq_(fs[0].geometries()[0].type(),mapnik.DataGeometryType.Point)

View file

@ -3,7 +3,10 @@
from nose.tools import * from nose.tools import *
import os,sys import os,sys
import mapnik import mapnik
try:
import json import json
except ImportError:
import simplejson as json
chars = [ chars = [
{ {

View file

@ -49,7 +49,7 @@ def compare(actual, expected):
passed += 1 passed += 1
return diff return diff
def summary(): def summary(generate=False):
global errors global errors
global passed global passed
print "-"*80 print "-"*80
@ -57,6 +57,12 @@ def summary():
if len(errors) != 0: if len(errors) != 0:
for error in errors: for error in errors:
if (error[0] is None): if (error[0] is None):
if generate:
actual = open(error[1],'r').read()
open(error[2],'wb').write(actual)
print "Generating reference image: '%s'" % error[2]
continue
else:
print "Could not verify %s: No reference image found!" % error[1] print "Could not verify %s: No reference image found!" % error[1]
else: else:
print "Failed: %d different pixels:\n\t%s (actual)\n\t%s (expected)" % error print "Failed: %d different pixels:\n\t%s (actual)\n\t%s (expected)" % error