diff --git a/CHANGELOG b/CHANGELOG index 9a06d91d5..26cf180f5 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -81,6 +81,10 @@ Mapnik 0.7.0 Release - PNG: Added support for semitransparency in png256 outpuy (#477,#202) +- PolygonSymbolizer: Added 'gamma' attribute to allow for dilation of polygon edges - a solution + to gap artifacts or "ghost lines" between adjacent polygons and allows for slight sharpening of + the edges of non overlapping polygons. Accepts any values but 0-1 is the recommended range. + - TextSymbolizer: Large set of new attributes: 'text_convert', 'line_spacing', 'character_spacing', 'wrap_character', 'wrap_before', 'horizontal_alignment', 'justify_alignment', and 'opacity'. diff --git a/bindings/python/mapnik_polygon_symbolizer.cpp b/bindings/python/mapnik_polygon_symbolizer.cpp index 2758f04ef..b5fec8637 100644 --- a/bindings/python/mapnik_polygon_symbolizer.cpp +++ b/bindings/python/mapnik_polygon_symbolizer.cpp @@ -38,23 +38,24 @@ struct polygon_symbolizer_pickle_suite : boost::python::pickle_suite static boost::python::tuple getstate(const polygon_symbolizer& p) { - return boost::python::make_tuple(p.get_opacity()); + return boost::python::make_tuple(p.get_opacity(),p.get_gamma()); } static void setstate (polygon_symbolizer& p, boost::python::tuple state) { using namespace boost::python; - if (len(state) != 1) + if (len(state) != 2) { PyErr_SetObject(PyExc_ValueError, - ("expected 1-item tuple in call to __setstate__; got %s" + ("expected 2-item tuple in call to __setstate__; got %s" % state).ptr() ); throw_error_already_set(); } p.set_opacity(extract(state[0])); + p.set_gamma(extract(state[1])); } }; @@ -74,6 +75,9 @@ void export_polygon_symbolizer() .add_property("fill_opacity", &polygon_symbolizer::get_opacity, &polygon_symbolizer::set_opacity) + .add_property("gamma", + &polygon_symbolizer::get_gamma, + &polygon_symbolizer::set_gamma) ; } diff --git a/include/mapnik/polygon_symbolizer.hpp b/include/mapnik/polygon_symbolizer.hpp index 96de5c838..809c806f3 100644 --- a/include/mapnik/polygon_symbolizer.hpp +++ b/include/mapnik/polygon_symbolizer.hpp @@ -33,11 +33,13 @@ namespace mapnik { explicit polygon_symbolizer() : fill_(color(128,128,128)), - opacity_(1.0) {} + opacity_(1.0), + gamma_(1.0) {} polygon_symbolizer(color const& fill) : fill_(fill), - opacity_(1.0) {} + opacity_(1.0), + gamma_(1.0) {} color const& get_fill() const { @@ -55,9 +57,19 @@ namespace mapnik { return opacity_; } + void set_gamma(float gamma) + { + gamma_ = gamma; + } + float get_gamma() const + { + return gamma_; + } + private: color fill_; float opacity_; + float gamma_; }; struct MAPNIK_DECL building_symbolizer diff --git a/src/agg_renderer.cpp b/src/agg_renderer.cpp index 56777524c..09af83eaf 100644 --- a/src/agg_renderer.cpp +++ b/src/agg_renderer.cpp @@ -188,6 +188,8 @@ namespace mapnik renderer ren(renb); ras_ptr->reset(); + + ras_ptr->gamma(agg::gamma_linear(0.0, sym.get_gamma())); for (unsigned i=0;i(css, css_name); poly_sym.set_opacity(opacity); } + else if (css_name == "gamma") + { + float gamma = get_css(css, css_name); + poly_sym.set_gamma(gamma); + } else { throw config_error(std::string("Failed to parse unknown CSS ") + diff --git a/src/save_map.cpp b/src/save_map.cpp index 3031858ef..998d8b9bc 100644 --- a/src/save_map.cpp +++ b/src/save_map.cpp @@ -128,6 +128,10 @@ namespace mapnik { set_css( sym_node, "fill-opacity", sym.get_opacity() ); } + if ( sym.get_gamma() != dfl.get_gamma() || explicit_defaults_ ) + { + set_css( sym_node, "gamma", sym.get_gamma() ); + } } void operator () ( const polygon_pattern_symbolizer & sym ) diff --git a/tests/data/good_maps/agg_poly_gamma_map.xml b/tests/data/good_maps/agg_poly_gamma_map.xml new file mode 100644 index 000000000..447101905 --- /dev/null +++ b/tests/data/good_maps/agg_poly_gamma_map.xml @@ -0,0 +1,61 @@ + + + + + world_merc20090930161252883_style + + ../../data/shp/world_merc + shape + + + diff --git a/tests/data/shp/world_merc.dbf b/tests/data/shp/world_merc.dbf new file mode 100644 index 000000000..2de17d74e Binary files /dev/null and b/tests/data/shp/world_merc.dbf differ diff --git a/tests/data/shp/world_merc.prj b/tests/data/shp/world_merc.prj new file mode 100644 index 000000000..16b8e1eef --- /dev/null +++ b/tests/data/shp/world_merc.prj @@ -0,0 +1 @@ +PROJCS["Google Maps Global Mercator",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Mercator_2SP"],PARAMETER["standard_parallel_1",0],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",0],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["Meter",1]] \ No newline at end of file diff --git a/tests/data/shp/world_merc.shp b/tests/data/shp/world_merc.shp new file mode 100644 index 000000000..eaf627d86 Binary files /dev/null and b/tests/data/shp/world_merc.shp differ diff --git a/tests/data/shp/world_merc.shx b/tests/data/shp/world_merc.shx new file mode 100644 index 000000000..c2eeb54b0 Binary files /dev/null and b/tests/data/shp/world_merc.shx differ diff --git a/tests/data/shp/world_merc_license.txt b/tests/data/shp/world_merc_license.txt new file mode 100644 index 000000000..b32fcc9aa --- /dev/null +++ b/tests/data/shp/world_merc_license.txt @@ -0,0 +1,85 @@ +world_merc +========== + +'world_merc.shp' is a version of TM_WORLD_BORDERS_SIMPL-0.3.shp +downloaded from http://thematicmapping.org/downloads/world_borders.php. + +Coodinates near 180 degress longitude were clipped to faciliate reprojection +to Google mercator (EPSG:900913). + +Details from original readme are below: + +------------- + +TM_WORLD_BORDERS-0.1.ZIP + +Provided by Bjorn Sandvik, thematicmapping.org + +Use this dataset with care, as several of the borders are disputed. + +The original shapefile (world_borders.zip, 3.2 MB) was downloaded from the Mapping Hacks website: +http://www.mappinghacks.com/data/ + +The dataset was derived by Schuyler Erle from public domain sources. +Sean Gilles did some clean up and made some enhancements. + + +COLUMN TYPE DESCRIPTION + +Shape Polygon Country/area border as polygon(s) +FIPS String(2) FIPS 10-4 Country Code +ISO2 String(2) ISO 3166-1 Alpha-2 Country Code +ISO3 String(3) ISO 3166-1 Alpha-3 Country Code +UN Short Integer(3) ISO 3166-1 Numeric-3 Country Code +NAME String(50) Name of country/area +AREA Long Integer(7) Land area, FAO Statistics (2002) +POP2005 Double(10,0) Population, World Polulation Prospects (2005) +REGION Short Integer(3) Macro geographical (continental region), UN Statistics +SUBREGION Short Integer(3) Geogrpahical sub-region, UN Statistics +LON FLOAT (7,3) Longitude +LAT FLOAT (6,3) Latitude + + +CHANGELOG VERSION 0.3 - 30 July 2008 + +- Corrected spelling mistake (United Arab Emirates) +- Corrected population number for Japan +- Adjusted long/lat values for India, Italy and United Kingdom + + +CHANGELOG VERSION 0.2 - 1 April 2008 + +- Made new ZIP archieves. No change in dataset. + + +CHANGELOG VERSION 0.1 - 13 March 2008 + +- Polygons representing each country were merged into one feature +- ≈land Islands was extracted from Finland +- Hong Kong was extracted from China +- Holy See (Vatican City) was added +- Gaza Strip and West Bank was merged into "Occupied Palestinean Territory" +- Saint-Barthelemy was extracted from Netherlands Antilles +- Saint-Martin (Frensh part) was extracted from Guadeloupe +- Svalbard and Jan Mayen was merged into "Svalbard and Jan Mayen Islands" +- Timor-Leste was extracted from Indonesia +- Juan De Nova Island was merged with "French Southern & Antarctic Land" +- Baker Island, Howland Island, Jarvis Island, Johnston Atoll, Midway Islands + and Wake Island was merged into "United States Minor Outlying Islands" +- Glorioso Islands, Parcel Islands, Spartly Islands was removed + (almost uninhabited and missing ISO-3611-1 code) + +- Added ISO-3166-1 codes (alpha-2, alpha-3, numeric-3). Source: + https://www.cia.gov/library/publications/the-world-factbook/appendix/appendix-d.html + http://unstats.un.org/unsd/methods/m49/m49alpha.htm + http://www.fysh.org/~katie/development/geography.txt +- AREA column has been replaced with data from UNdata: + Land area, 1000 hectares, 2002, FAO Statistics +- POPULATION column (POP2005) has been replaced with data from UNdata: + Population, 2005, Medium variant, World Population Prospects: The 2006 Revision +- Added region and sub-region codes from UN Statistics Division. Source: + http://unstats.un.org/unsd/methods/m49/m49regin.htm +- Added LAT, LONG values for each country + + +