Merge commit '95ceee84fac2cd9dffad0931889522a87c723537' into harfbuzz
Conflicts: src/cairo_renderer.cpp
This commit is contained in:
commit
90f0287a21
20 changed files with 164 additions and 21 deletions
|
@ -8,6 +8,8 @@ For a complete change history, see the git log.
|
|||
|
||||
## Future
|
||||
|
||||
- Added support for DBF `Logical` type: #1614
|
||||
|
||||
- Added serialization of `line-offset` to save_map (#1562)
|
||||
|
||||
- Enabled default input plugin directory and fonts path to be set inherited from environment settings in
|
||||
|
|
|
@ -78,11 +78,17 @@ struct raster_markers_rasterizer_dispatch_grid
|
|||
{
|
||||
marker_placement_e placement_method = sym_.get_marker_placement();
|
||||
box2d<double> bbox_(0,0, src_.width(),src_.height());
|
||||
if (placement_method != MARKER_LINE_PLACEMENT)
|
||||
if (placement_method != MARKER_LINE_PLACEMENT ||
|
||||
path.type() == Point)
|
||||
{
|
||||
double x = 0;
|
||||
double y = 0;
|
||||
if (placement_method == MARKER_INTERIOR_PLACEMENT)
|
||||
if (path.type() == LineString)
|
||||
{
|
||||
if (!label::middle_point(path, x, y))
|
||||
return;
|
||||
}
|
||||
else if (placement_method == MARKER_INTERIOR_PLACEMENT)
|
||||
{
|
||||
if (!label::interior_position(path, x, y))
|
||||
return;
|
||||
|
@ -209,11 +215,17 @@ struct vector_markers_rasterizer_dispatch_grid
|
|||
void add_path(T & path)
|
||||
{
|
||||
marker_placement_e placement_method = sym_.get_marker_placement();
|
||||
if (placement_method != MARKER_LINE_PLACEMENT)
|
||||
if (placement_method != MARKER_LINE_PLACEMENT ||
|
||||
path.type() == Point)
|
||||
{
|
||||
double x = 0;
|
||||
double y = 0;
|
||||
if (placement_method == MARKER_INTERIOR_PLACEMENT)
|
||||
if (path.type() == LineString)
|
||||
{
|
||||
if (!label::middle_point(path, x, y))
|
||||
return;
|
||||
}
|
||||
else if (placement_method == MARKER_INTERIOR_PLACEMENT)
|
||||
{
|
||||
if (!label::interior_position(path, x, y))
|
||||
return;
|
||||
|
|
|
@ -87,7 +87,8 @@ struct vector_markers_rasterizer_dispatch
|
|||
{
|
||||
marker_placement_e placement_method = sym_.get_marker_placement();
|
||||
|
||||
if (placement_method != MARKER_LINE_PLACEMENT)
|
||||
if (placement_method != MARKER_LINE_PLACEMENT ||
|
||||
path.type() == Point)
|
||||
{
|
||||
double x = 0;
|
||||
double y = 0;
|
||||
|
@ -188,7 +189,8 @@ struct raster_markers_rasterizer_dispatch
|
|||
marker_placement_e placement_method = sym_.get_marker_placement();
|
||||
box2d<double> bbox_(0,0, src_.width(),src_.height());
|
||||
|
||||
if (placement_method != MARKER_LINE_PLACEMENT)
|
||||
if (placement_method != MARKER_LINE_PLACEMENT ||
|
||||
path.type() == Point)
|
||||
{
|
||||
double x = 0;
|
||||
double y = 0;
|
||||
|
|
|
@ -134,8 +134,7 @@ void dbf_file::add_attribute(int col, mapnik::transcoder const& tr, Feature & f)
|
|||
switch (fields_[col].type_)
|
||||
{
|
||||
case 'C':
|
||||
case 'D'://todo handle date?
|
||||
case 'M':
|
||||
case 'D':
|
||||
{
|
||||
// FIXME - avoid constructing std::string on stack
|
||||
std::string str(record_+fields_[col].offset_,fields_[col].length_);
|
||||
|
@ -152,6 +151,7 @@ void dbf_file::add_attribute(int col, mapnik::transcoder const& tr, Feature & f)
|
|||
}
|
||||
else
|
||||
{
|
||||
// NOTE: null logical fields use '?'
|
||||
f.put(name,false);
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -50,6 +50,7 @@ DATASOURCE_PLUGIN(shape_datasource)
|
|||
using mapnik::String;
|
||||
using mapnik::Double;
|
||||
using mapnik::Integer;
|
||||
using mapnik::Boolean;
|
||||
using mapnik::datasource_exception;
|
||||
using mapnik::filter_in_box;
|
||||
using mapnik::filter_at_point;
|
||||
|
@ -121,10 +122,12 @@ void shape_datasource::bind() const
|
|||
case 'C': // character
|
||||
case 'D': // Date
|
||||
case 'M': // Memo, a string
|
||||
case 'L': // logical
|
||||
case '@': // timestamp
|
||||
desc_.add_descriptor(attribute_descriptor(fld_name, String));
|
||||
break;
|
||||
case 'L': // logical
|
||||
desc_.add_descriptor(attribute_descriptor(fld_name, Boolean));
|
||||
break;
|
||||
case 'N':
|
||||
case 'O': // double
|
||||
case 'F': // float
|
||||
|
@ -153,7 +156,7 @@ void shape_datasource::bind() const
|
|||
}
|
||||
|
||||
}
|
||||
catch (const datasource_exception& ex)
|
||||
catch (datasource_exception const& ex)
|
||||
{
|
||||
MAPNIK_LOG_ERROR(shape) << "Shape Plugin: error processing field attributes, " << ex.what();
|
||||
throw;
|
||||
|
|
|
@ -272,8 +272,11 @@ void agg_renderer<T>::end_style_processing(feature_type_style const& st)
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void agg_renderer<T>::render_marker(pixel_position const& pos, marker const& marker, agg::trans_affine const& tr,
|
||||
double opacity, composite_mode_e comp_op)
|
||||
void agg_renderer<T>::render_marker(pixel_position const& pos,
|
||||
marker const& marker,
|
||||
agg::trans_affine const& tr,
|
||||
double opacity,
|
||||
composite_mode_e comp_op)
|
||||
{
|
||||
typedef agg::rgba8 color_type;
|
||||
typedef agg::order_rgba order_type;
|
||||
|
|
|
@ -399,5 +399,13 @@ else:
|
|||
env['create_uninstall_target'](env, target1)
|
||||
env['create_uninstall_target'](env, target)
|
||||
|
||||
# to enable local testing
|
||||
lib_major_minor = "%s.%d.%d" % (os.path.basename(env.subst(env['MAPNIK_LIB_NAME'])), int(major), int(minor))
|
||||
local_lib = os.path.basename(env.subst(env['MAPNIK_LIB_NAME']))
|
||||
if os.path.islink(lib_major_minor) or os.path.exists(lib_major_minor):
|
||||
os.remove(lib_major_minor)
|
||||
os.symlink(local_lib,lib_major_minor)
|
||||
Clean(mapnik,lib_major_minor);
|
||||
|
||||
if not env['RUNTIME_LINK'] == 'static':
|
||||
Depends(mapnik, env.subst('../deps/agg/libagg.a'))
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
// boost
|
||||
#include <boost/utility.hpp>
|
||||
#include <boost/make_shared.hpp>
|
||||
#include <boost/math/special_functions/round.hpp>
|
||||
|
||||
// agg
|
||||
#include "agg_conv_clip_polyline.h"
|
||||
|
@ -1197,7 +1198,13 @@ void cairo_renderer_base::render_marker(pixel_position const& pos, marker const&
|
|||
else if (marker.is_bitmap())
|
||||
{
|
||||
agg::trans_affine matrix = tr;
|
||||
matrix *= agg::trans_affine_translation(pos.x, pos.y);
|
||||
double width = (*marker.get_bitmap_data())->width();
|
||||
double height = (*marker.get_bitmap_data())->height();
|
||||
double cx = 0.5 * width;
|
||||
double cy = 0.5 * height;
|
||||
matrix *= agg::trans_affine_translation(
|
||||
boost::math::iround(pos.x - cx),
|
||||
boost::math::iround(pos.y - cy));
|
||||
context.add_image(matrix, **marker.get_bitmap_data(), opacity);
|
||||
}
|
||||
}
|
||||
|
@ -1279,8 +1286,7 @@ void cairo_renderer_base::process(shield_symbolizer const& sym,
|
|||
{
|
||||
if (glyphs->marker())
|
||||
{
|
||||
// Position is handled differently by cairo renderer
|
||||
pixel_position pos = glyphs->marker_pos() - 0.5 *
|
||||
pixel_position pos = glyphs->marker_pos() + 0.5 *
|
||||
pixel_position(glyphs->marker()->marker->width(),
|
||||
glyphs->marker()->marker->height());
|
||||
|
||||
|
@ -1538,11 +1544,17 @@ struct markers_dispatch
|
|||
{
|
||||
marker_placement_e placement_method = sym_.get_marker_placement();
|
||||
|
||||
if (placement_method != MARKER_LINE_PLACEMENT)
|
||||
if (placement_method != MARKER_LINE_PLACEMENT ||
|
||||
path.type() == Point)
|
||||
{
|
||||
double x = 0;
|
||||
double y = 0;
|
||||
if (placement_method == MARKER_INTERIOR_PLACEMENT)
|
||||
if (path.type() == LineString)
|
||||
{
|
||||
if (!label::middle_point(path, x, y))
|
||||
return;
|
||||
}
|
||||
else if (placement_method == MARKER_INTERIOR_PLACEMENT)
|
||||
{
|
||||
if (!label::interior_position(path, x, y))
|
||||
return;
|
||||
|
@ -1621,11 +1633,17 @@ struct markers_dispatch_2
|
|||
{
|
||||
marker_placement_e placement_method = sym_.get_marker_placement();
|
||||
|
||||
if (placement_method != MARKER_LINE_PLACEMENT)
|
||||
if (placement_method != MARKER_LINE_PLACEMENT ||
|
||||
path.type() == Point)
|
||||
{
|
||||
double x = 0;
|
||||
double y = 0;
|
||||
if (placement_method == MARKER_INTERIOR_PLACEMENT)
|
||||
if (path.type() == LineString)
|
||||
{
|
||||
if (!label::middle_point(path, x, y))
|
||||
return;
|
||||
}
|
||||
else if (placement_method == MARKER_INTERIOR_PLACEMENT)
|
||||
{
|
||||
if (!label::interior_position(path, x, y))
|
||||
return;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<OGRVRTDataSource>
|
||||
<OGRVRTLayer name="long_lat">
|
||||
<SrcDataSource>long_lat.csv</SrcDataSource>
|
||||
<SrcDataSource relativeToVRT="1">long_lat.csv</SrcDataSource>
|
||||
<GeometryType>wkbPoint</GeometryType>
|
||||
<LayerSRS>WGS84</LayerSRS>
|
||||
<GeometryField encoding="PointFromColumns" x="long" y="lat"/>
|
||||
|
|
BIN
tests/data/shp/long_lat.dbf
Normal file
BIN
tests/data/shp/long_lat.dbf
Normal file
Binary file not shown.
BIN
tests/data/shp/long_lat.dbt
Normal file
BIN
tests/data/shp/long_lat.dbt
Normal file
Binary file not shown.
1
tests/data/shp/long_lat.prj
Normal file
1
tests/data/shp/long_lat.prj
Normal file
|
@ -0,0 +1 @@
|
|||
GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]
|
BIN
tests/data/shp/long_lat.shp
Normal file
BIN
tests/data/shp/long_lat.shp
Normal file
Binary file not shown.
BIN
tests/data/shp/long_lat.shx
Normal file
BIN
tests/data/shp/long_lat.shx
Normal file
Binary file not shown.
|
@ -52,6 +52,23 @@ if 'shape' in mapnik.DatasourceCache.plugin_names():
|
|||
query.add_property_name('bogus')
|
||||
fs = ds.features(query)
|
||||
|
||||
def test_dbf_logical_field_is_boolean():
|
||||
ds = mapnik.Shapefile(file='../data/shp/long_lat')
|
||||
eq_(len(ds.fields()),7)
|
||||
eq_(ds.fields(),['LONG', 'LAT', 'LOGICAL_TR', 'LOGICAL_FA', 'CHARACTER', 'NUMERIC', 'DATE'])
|
||||
eq_(ds.field_types(),['str', 'str', 'bool', 'bool', 'str', 'float', 'str'])
|
||||
query = mapnik.Query(ds.envelope())
|
||||
for fld in ds.fields():
|
||||
query.add_property_name(fld)
|
||||
feat = ds.all_features()[0]
|
||||
eq_(feat.id(),1)
|
||||
eq_(feat['LONG'],'0')
|
||||
eq_(feat['LAT'],'0')
|
||||
eq_(feat['LOGICAL_TR'],True)
|
||||
eq_(feat['LOGICAL_FA'],False)
|
||||
eq_(feat['CHARACTER'],'254')
|
||||
eq_(feat['NUMERIC'],32)
|
||||
eq_(feat['DATE'],'20121202')
|
||||
|
||||
if __name__ == "__main__":
|
||||
setup()
|
||||
|
|
|
@ -85,7 +85,7 @@ def summary(generate=False):
|
|||
global passed
|
||||
|
||||
if len(errors) != 0:
|
||||
msg = "Visual text rendering: %s failures" % len(errors)
|
||||
msg = "Visual text rendering: %s failed / %s passed" % (len(errors),passed)
|
||||
print "-"*len(msg)
|
||||
print msg
|
||||
print "-"*len(msg)
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
{
|
||||
"keys": [
|
||||
"",
|
||||
"4",
|
||||
"3",
|
||||
"6",
|
||||
"5",
|
||||
"7",
|
||||
"1",
|
||||
"2"
|
||||
],
|
||||
"data": {},
|
||||
"grid": [
|
||||
" !!!!!! ###### ",
|
||||
" !!!!! ##### ",
|
||||
" !! ## ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" $$$$ ",
|
||||
" $$$$$$ ",
|
||||
" $$$$$$$ ",
|
||||
" $$$$$$ ",
|
||||
" %%%$$%% ",
|
||||
" %%&&&&% ",
|
||||
" &&&&&& ",
|
||||
" &&&&&&& ",
|
||||
" &&&&&& ",
|
||||
" && ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ''' ((( ",
|
||||
" ''''' ((((( "
|
||||
]
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 2.3 KiB |
|
@ -0,0 +1,36 @@
|
|||
<!DOCTYPE Map>
|
||||
<Map background-color="white" srs="+init=epsg:4326" minimum-version="0.7.2">
|
||||
|
||||
<Style name="1">
|
||||
<Rule>
|
||||
<Filter>[id]=1</Filter>
|
||||
<MarkersSymbolizer fill="darkgreen" opacity=".7" width="15" height="10" stroke="green" stroke-width="7" stroke-opacity=".2" placement="line" marker-type="ellipse"/>
|
||||
</Rule>
|
||||
<Rule>
|
||||
<Filter>[id]=2</Filter>
|
||||
<MarkersSymbolizer fill="darkorange" opacity=".7" width="20" height="10" stroke="orange" stroke-width="7" stroke-opacity=".2" placement="line" marker-type="ellipse"/>
|
||||
</Rule>
|
||||
<Rule>
|
||||
<Filter>[id]=3</Filter>
|
||||
<MarkersSymbolizer fill="darkred" opacity=".7" width="20" height="10" stroke="orange" stroke-width="7" stroke-opacity=".2" placement="line" marker-type="ellipse"/>
|
||||
</Rule>
|
||||
</Style>
|
||||
<Layer name="point" srs="+init=epsg:4326">
|
||||
<StyleName>1</StyleName>
|
||||
<Datasource>
|
||||
<Parameter name="type">csv</Parameter>
|
||||
<Parameter name="inline">
|
||||
x,y,id
|
||||
0,0,1
|
||||
5,0,1
|
||||
5,5,1
|
||||
0,5,1
|
||||
2.5,2.5,2
|
||||
2.5,3,3
|
||||
2.5,2,3
|
||||
3,2.5,3
|
||||
2,2.5,3
|
||||
</Parameter>
|
||||
</Datasource>
|
||||
</Layer>
|
||||
</Map>
|
|
@ -41,6 +41,7 @@ files = [
|
|||
{'name': "lines-6", 'sizes': sizes_few_square},
|
||||
{'name': "lines-shield", 'sizes': sizes_few_square,'bbox':default_text_box},
|
||||
{'name': "marker-multi-policy", 'sizes':[(600,400)]},
|
||||
{'name': "marker_line_placement_on_points"},
|
||||
{'name': "whole-centroid", 'sizes':[(600,400)],
|
||||
'bbox': mapnik.Box2d(736908, 4390316, 2060771, 5942346)},
|
||||
{'name': "simple-E", 'bbox':mapnik.Box2d(-0.05, -0.01, 0.95, 0.01)},
|
||||
|
|
Loading…
Reference in a new issue