Permalink
Browse files

Merge remote-tracking branch 'origin/master'

  • Loading branch information...
2 parents eaf6049 + 43280f1 commit 3072b3f5815c051432a3da8592dca5504ac7daa6 @artemp artemp committed Oct 4, 2012
Showing with 332 additions and 126 deletions.
  1. +13 −0 .travis.yml
  2. +6 −0 CHANGELOG.md
  3. +10 −8 README.md
  4. +1 −1 bindings/python/mapnik_datasource.cpp
  5. +109 −0 bindings/python/mapnik_python.cpp
  6. +1 −1 include/mapnik/agg_renderer.hpp
  7. +3 −1 include/mapnik/cairo_renderer.hpp
  8. +1 −1 include/mapnik/datasource.hpp
  9. +1 −1 include/mapnik/feature.hpp
  10. +1 −1 include/mapnik/memory_datasource.hpp
  11. +5 −7 include/mapnik/raster.hpp
  12. +1 −1 plugins/input/csv/csv_datasource.cpp
  13. +1 −1 plugins/input/csv/csv_datasource.hpp
  14. +1 −1 plugins/input/gdal/gdal_datasource.cpp
  15. +1 −1 plugins/input/gdal/gdal_datasource.hpp
  16. +3 −6 plugins/input/gdal/gdal_featureset.cpp
  17. +1 −1 plugins/input/geojson/geojson_datasource.cpp
  18. +1 −1 plugins/input/geojson/geojson_datasource.hpp
  19. +1 −1 plugins/input/geos/geos_datasource.cpp
  20. +1 −1 plugins/input/geos/geos_datasource.hpp
  21. +1 −1 plugins/input/kismet/kismet_datasource.cpp
  22. +1 −1 plugins/input/kismet/kismet_datasource.hpp
  23. +1 −1 plugins/input/occi/occi_datasource.cpp
  24. +1 −1 plugins/input/occi/occi_datasource.hpp
  25. +1 −1 plugins/input/ogr/ogr_datasource.cpp
  26. +1 −1 plugins/input/ogr/ogr_datasource.hpp
  27. +1 −1 plugins/input/osm/osm_datasource.cpp
  28. +1 −1 plugins/input/osm/osm_datasource.hpp
  29. +2 −2 plugins/input/postgis/postgis_datasource.cpp
  30. +1 −1 plugins/input/postgis/postgis_datasource.hpp
  31. +1 −1 plugins/input/python/python_datasource.cpp
  32. +1 −1 plugins/input/python/python_datasource.hpp
  33. +1 −1 plugins/input/raster/raster_datasource.cpp
  34. +1 −1 plugins/input/raster/raster_datasource.hpp
  35. +4 −3 plugins/input/raster/raster_featureset.cpp
  36. +1 −1 plugins/input/rasterlite/rasterlite_datasource.cpp
  37. +1 −1 plugins/input/rasterlite/rasterlite_datasource.hpp
  38. +1 −1 plugins/input/shape/shape_datasource.cpp
  39. +1 −1 plugins/input/shape/shape_datasource.hpp
  40. +1 −1 plugins/input/sqlite/sqlite_datasource.cpp
  41. +1 −1 plugins/input/sqlite/sqlite_datasource.hpp
  42. +1 −1 plugins/input/templates/helloworld/hello_datasource.cpp
  43. +1 −1 plugins/input/templates/helloworld/hello_datasource.hpp
  44. +3 −28 src/agg/agg_renderer.cpp
  45. +35 −2 src/agg/process_line_pattern_symbolizer.cpp
  46. +0 −3 src/agg/process_shield_symbolizer.cpp
  47. +41 −9 src/cairo_renderer.cpp
  48. +0 −3 src/grid/process_shield_symbolizer.cpp
  49. +16 −16 src/map.cpp
  50. +1 −1 src/memory_datasource.cpp
  51. +43 −0 tests/python_tests/query_tolerance_test.py
  52. +1 −1 tests/python_tests/raster_symbolizer_test.py
  53. +3 −2 utils/svg2png/svg2png.cpp
View
@@ -0,0 +1,13 @@
+language: cpp
+
+matrix:
+ include:
+ - compiler: clang
+ env: CXX_SCONS="-Qunused-arguments -fcolor-diagnostics" WARNING_CXXFLAGS="-Wno-unused-function -Wno-uninitialized -Wno-array-bounds -Wno-parentheses -Wno-char-subscripts -Wno-internal-linkage-in-inline"
+
+before_install:
+ - echo 'yes' | sudo add-apt-repository ppa:mapnik/boost
+ - sudo apt-get update -qq
+ - sudo apt-get install -qq libboost-dev libboost-filesystem-dev libboost-program-options-dev libboost-python-dev libboost-regex-dev libboost-system-dev libboost-thread-dev python-nose libicu-dev libpng-dev libjpeg-dev libtiff-dev libz-dev libfreetype6-dev libxml2-dev libproj-dev libpq-dev libgdal-dev libcairomm-1.0-dev python-cairo-dev libsqlite3-dev
+
+script: scons configure JOBS=2 FAST=True CXX="$CXX $CXX_SCONS" WARNING_CXXFLAGS=$WARNING_CXXFLAGS && sudo make install
View
@@ -8,6 +8,12 @@ For a complete change history, see the git log.
## Future
+- Faster rendering of rasters by reducing memory allocation of temporary buffers (#1516)
+
+- Added ability to pass a pre-created collision detector to the cairo renderer (#1444)
+
+- Tolerance parameter is now supported for querying datasources at a given point (#503/#1499)
+
- Improved detection of newlines in CSV files - now more robust in the face of mixed newline types (#1497)
- Allow style level compositing operations to work outside of featureset extents across tiled requests (#1477)
View
@@ -1,12 +1,14 @@
-```
- _/ _/ _/ _/
- _/_/ _/_/ _/_/_/ _/_/_/ _/_/_/ _/ _/
- _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/_/
- _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/
-_/ _/ _/_/_/ _/_/_/ _/ _/ _/ _/ _/
- _/
- _/
```
+ _/ _/ _/ _/
+ _/_/ _/_/ _/_/_/ _/_/_/ _/_/_/ _/ _/
+ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/_/
+ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/
+_/ _/ _/_/_/ _/_/_/ _/ _/ _/ _/ _/
+ _/
+ _/
+```
+
+[![Build Status](https://secure.travis-ci.org/mapnik/mapnik.png)](http://travis-ci.org/mapnik/mapnik)
# What is Mapnik?
@@ -172,7 +172,7 @@ void export_datasource()
.def("bind",&datasource::bind)
.def("fields",&fields)
.def("field_types",&field_types)
- .def("features_at_point",&datasource::features_at_point)
+ .def("features_at_point",&datasource::features_at_point, (arg("coord"),arg("tolerance")=0))
.def("params",&datasource::params,return_value_policy<copy_const_reference>(),
"The configuration parameters of the data source. "
"These vary depending on the type of data source.")
@@ -199,6 +199,56 @@ void render6(const mapnik::Map& map, PycairoContext* context)
ren.apply();
}
+void render_with_detector2(
+ const mapnik::Map& map,
+ PycairoContext* context,
+ boost::shared_ptr<mapnik::label_collision_detector4> detector)
+{
+ python_unblock_auto_block b;
+ Cairo::RefPtr<Cairo::Context> c(new Cairo::Context(context->ctx));
+ mapnik::cairo_renderer<Cairo::Context> ren(map,c,detector);
+ ren.apply();
+}
+
+void render_with_detector3(
+ const mapnik::Map& map,
+ PycairoContext* context,
+ boost::shared_ptr<mapnik::label_collision_detector4> detector,
+ double scale_factor = 1.0,
+ unsigned offset_x = 0u,
+ unsigned offset_y = 0u)
+{
+ python_unblock_auto_block b;
+ Cairo::RefPtr<Cairo::Context> c(new Cairo::Context(context->ctx));
+ mapnik::cairo_renderer<Cairo::Context> ren(map,c,detector,scale_factor,offset_x,offset_y);
+ ren.apply();
+}
+
+void render_with_detector4(
+ const mapnik::Map& map,
+ PycairoSurface* surface,
+ boost::shared_ptr<mapnik::label_collision_detector4> detector)
+{
+ python_unblock_auto_block b;
+ Cairo::RefPtr<Cairo::Surface> s(new Cairo::Surface(surface->surface));
+ mapnik::cairo_renderer<Cairo::Surface> ren(map,s,detector);
+ ren.apply();
+}
+
+void render_with_detector5(
+ const mapnik::Map& map,
+ PycairoSurface* surface,
+ boost::shared_ptr<mapnik::label_collision_detector4> detector,
+ double scale_factor = 1.0,
+ unsigned offset_x = 0u,
+ unsigned offset_y = 0u)
+{
+ python_unblock_auto_block b;
+ Cairo::RefPtr<Cairo::Surface> s(new Cairo::Surface(surface->surface));
+ mapnik::cairo_renderer<Cairo::Surface> ren(map,s,detector,scale_factor,offset_x,offset_y);
+ ren.apply();
+}
+
#endif
@@ -572,6 +622,65 @@ BOOST_PYTHON_MODULE(_mapnik)
">>> render(m,context)\n"
"\n"
);
+
+ def("render_with_detector", &render_with_detector2,
+ "\n"
+ "Render Map to Cairo Context using a pre-constructed detector.\n"
+ "\n"
+ "Usage:\n"
+ ">>> from mapnik import Map, LabelCollisionDetector, render_with_detector, load_map\n"
+ ">>> from cairo import SVGSurface, Context\n"
+ ">>> surface = SVGSurface('image.svg', m.width, m.height)\n"
+ ">>> ctx = Context(surface)\n"
+ ">>> m = Map(256,256)\n"
+ ">>> load_map(m,'mapfile.xml')\n"
+ ">>> detector = LabelCollisionDetector(m)\n"
+ ">>> render_with_detector(m, ctx, detector)\n"
+ );
+
+ def("render_with_detector", &render_with_detector3,
+ "\n"
+ "Render Map to Cairo Context using a pre-constructed detector, scale and offsets.\n"
+ "\n"
+ "Usage:\n"
+ ">>> from mapnik import Map, LabelCollisionDetector, render_with_detector, load_map\n"
+ ">>> from cairo import SVGSurface, Context\n"
+ ">>> surface = SVGSurface('image.svg', m.width, m.height)\n"
+ ">>> ctx = Context(surface)\n"
+ ">>> m = Map(256,256)\n"
+ ">>> load_map(m,'mapfile.xml')\n"
+ ">>> detector = LabelCollisionDetector(m)\n"
+ ">>> render_with_detector(m, ctx, detector, 1, 1, 1)\n"
+ );
+
+ def("render_with_detector", &render_with_detector4,
+ "\n"
+ "Render Map to Cairo Surface using a pre-constructed detector.\n"
+ "\n"
+ "Usage:\n"
+ ">>> from mapnik import Map, LabelCollisionDetector, render_with_detector, load_map\n"
+ ">>> from cairo import SVGSurface, Context\n"
+ ">>> surface = SVGSurface('image.svg', m.width, m.height)\n"
+ ">>> m = Map(256,256)\n"
+ ">>> load_map(m,'mapfile.xml')\n"
+ ">>> detector = LabelCollisionDetector(m)\n"
+ ">>> render_with_detector(m, surface, detector)\n"
+ );
+
+ def("render_with_detector", &render_with_detector5,
+ "\n"
+ "Render Map to Cairo Surface using a pre-constructed detector, scale and offsets.\n"
+ "\n"
+ "Usage:\n"
+ ">>> from mapnik import Map, LabelCollisionDetector, render_with_detector, load_map\n"
+ ">>> from cairo import SVGSurface, Context\n"
+ ">>> surface = SVGSurface('image.svg', m.width, m.height)\n"
+ ">>> m = Map(256,256)\n"
+ ">>> load_map(m,'mapfile.xml')\n"
+ ">>> detector = LabelCollisionDetector(m)\n"
+ ">>> render_with_detector(m, surface, detector, 1, 1, 1)\n"
+ );
+
#endif
def("scale_denominator", &scale_denominator,
@@ -142,7 +142,7 @@ class MAPNIK_DECL agg_renderer : public feature_style_processor<agg_renderer<T>
boost::shared_ptr<label_collision_detector4> detector_;
boost::scoped_ptr<rasterizer> ras_ptr;
box2d<double> query_extent_;
- void setup(Map const &m);
+ void setup(Map const& m);
};
}
@@ -73,6 +73,7 @@ class MAPNIK_DECL cairo_renderer_base : private boost::noncopyable
{
protected:
cairo_renderer_base(Map const& m, Cairo::RefPtr<Cairo::Context> const& context, double scale_factor=1.0, unsigned offset_x=0, unsigned offset_y=0);
+ cairo_renderer_base(Map const& m, Cairo::RefPtr<Cairo::Context> const& context, boost::shared_ptr<label_collision_detector4> detector, double scale_factor=1.0, unsigned offset_x=0, unsigned offset_y=0);
public:
~cairo_renderer_base();
void start_map_processing(Map const& map);
@@ -136,7 +137,7 @@ class MAPNIK_DECL cairo_renderer_base : private boost::noncopyable
boost::shared_ptr<freetype_engine> font_engine_;
face_manager<freetype_engine> font_manager_;
cairo_face_manager face_manager_;
- label_collision_detector4 detector_;
+ boost::shared_ptr<label_collision_detector4> detector_;
box2d<double> query_extent_;
};
@@ -147,6 +148,7 @@ class MAPNIK_DECL cairo_renderer : public feature_style_processor<cairo_renderer
public:
typedef cairo_renderer_base processor_impl_type;
cairo_renderer(Map const& m, Cairo::RefPtr<T> const& surface, double scale_factor=1.0, unsigned offset_x=0, unsigned offset_y=0);
+ cairo_renderer(Map const& m, Cairo::RefPtr<T> const& surface, boost::shared_ptr<label_collision_detector4> detector, double scale_factor=1.0, unsigned offset_x=0, unsigned offset_y=0);
void end_map_processing(Map const& map);
};
}
@@ -115,7 +115,7 @@ class MAPNIK_DECL datasource : private boost::noncopyable
virtual void bind() const {}
virtual featureset_ptr features(query const& q) const = 0;
- virtual featureset_ptr features_at_point(coord2d const& pt) const = 0;
+ virtual featureset_ptr features_at_point(coord2d const& pt, double tol = 0) const = 0;
virtual box2d<double> envelope() const = 0;
virtual boost::optional<geometry_t> get_geometry_type() const = 0;
virtual layer_descriptor get_descriptor() const = 0;
@@ -257,7 +257,7 @@ class MAPNIK_DECL feature_impl : private boost::noncopyable
return result;
}
- const raster_ptr& get_raster() const
+ raster_ptr const& get_raster() const
{
return raster_;
}
@@ -41,7 +41,7 @@ class MAPNIK_DECL memory_datasource : public datasource
void push(feature_ptr feature);
datasource::datasource_t type() const;
featureset_ptr features(const query& q) const;
- featureset_ptr features_at_point(coord2d const& pt) const;
+ featureset_ptr features_at_point(coord2d const& pt, double tol = 0) const;
box2d<double> envelope() const;
boost::optional<geometry_t> get_geometry_type() const;
layer_descriptor get_descriptor() const;
View
@@ -27,9 +27,13 @@
#include <mapnik/box2d.hpp>
#include <mapnik/image_data.hpp>
+// boost
+#include <boost/utility.hpp>
+
namespace mapnik {
-struct raster
+class raster : private boost::noncopyable
{
+public:
box2d<double> ext_;
image_data_32 data_;
bool premultiplied_alpha_;
@@ -38,12 +42,6 @@ struct raster
data_(width,height),
premultiplied_alpha_(premultiplied_alpha)
{}
- raster(box2d<double> const& ext,image_data_32 const& data, bool premultiplied_alpha = false)
- : ext_(ext),
- data_(data),
- premultiplied_alpha_(premultiplied_alpha)
- {}
-
};
}
@@ -959,7 +959,7 @@ mapnik::featureset_ptr csv_datasource::features(mapnik::query const& q) const
return boost::make_shared<mapnik::memory_featureset>(q.get_bbox(),features_);
}
-mapnik::featureset_ptr csv_datasource::features_at_point(mapnik::coord2d const& pt) const
+mapnik::featureset_ptr csv_datasource::features_at_point(mapnik::coord2d const& pt, double tol) const
{
if (!is_bound_) bind();
@@ -47,7 +47,7 @@ class csv_datasource : public mapnik::datasource
mapnik::datasource::datasource_t type() const;
static const char * name();
mapnik::featureset_ptr features(mapnik::query const& q) const;
- mapnik::featureset_ptr features_at_point(mapnik::coord2d const& pt) const;
+ mapnik::featureset_ptr features_at_point(mapnik::coord2d const& pt, double tol = 0) const;
mapnik::box2d<double> envelope() const;
boost::optional<mapnik::datasource::geometry_t> get_geometry_type() const;
mapnik::layer_descriptor get_descriptor() const;
@@ -246,7 +246,7 @@ featureset_ptr gdal_datasource::features(query const& q) const
nodata_value_));
}
-featureset_ptr gdal_datasource::features_at_point(coord2d const& pt) const
+featureset_ptr gdal_datasource::features_at_point(coord2d const& pt, double tol) const
{
if (! is_bound_) bind();
@@ -50,7 +50,7 @@ class gdal_datasource : public mapnik::datasource
mapnik::datasource::datasource_t type() const;
static const char * name();
mapnik::featureset_ptr features(mapnik::query const& q) const;
- mapnik::featureset_ptr features_at_point(mapnik::coord2d const& pt) const;
+ mapnik::featureset_ptr features_at_point(mapnik::coord2d const& pt, double tol = 0) const;
mapnik::box2d<double> envelope() const;
boost::optional<mapnik::datasource::geometry_t> get_geometry_type() const;
mapnik::layer_descriptor get_descriptor() const;
@@ -223,14 +223,14 @@ feature_ptr gdal_featureset::get_feature(mapnik::query const& q)
if (im_width > 0 && im_height > 0)
{
- mapnik::image_data_32 image(im_width, im_height);
+ mapnik::raster_ptr raster = boost::make_shared<mapnik::raster>(intersect, im_width, im_height);
+ feature->set_raster(raster);
+ mapnik::image_data_32 & image = raster->data_;
image.set(0xffffffff);
MAPNIK_LOG_DEBUG(gdal) << "gdal_featureset: Image Size=(" << im_width << "," << im_height << ")";
MAPNIK_LOG_DEBUG(gdal) << "gdal_featureset: Reading band=" << band_;
- typedef std::vector<int,int> pallete;
-
if (band_ > 0) // we are querying a single band
{
if (band_ > nbands_)
@@ -255,7 +255,6 @@ feature_ptr gdal_featureset::get_feature(mapnik::query const& q)
imageData, image.width(), image.height(),
GDT_Float32, 0, 0);
- feature->set_raster(boost::make_shared<mapnik::raster>(intersect,image));
if (hasNoData)
{
feature->put("NODATA",nodata);
@@ -488,8 +487,6 @@ feature_ptr gdal_featureset::get_feature(mapnik::query const& q)
alpha->RasterIO(GF_Read, x_off, y_off, width, height, image.getBytes() + 3,
image.width(), image.height(), GDT_Byte, 4, 4 * image.width());
}
-
- feature->set_raster(boost::make_shared<mapnik::raster>(intersect, image));
}
return feature;
}
@@ -217,7 +217,7 @@ mapnik::featureset_ptr geojson_datasource::features(mapnik::query const& q) cons
}
// FIXME
-mapnik::featureset_ptr geojson_datasource::features_at_point(mapnik::coord2d const& pt) const
+mapnik::featureset_ptr geojson_datasource::features_at_point(mapnik::coord2d const& pt, double tol) const
{
if (!is_bound_) bind();
throw mapnik::datasource_exception("GeoJSON Plugin: features_at_point is not supported yet");
@@ -60,7 +60,7 @@ class geojson_datasource : public mapnik::datasource
mapnik::datasource::datasource_t type() const;
static const char * name();
mapnik::featureset_ptr features(mapnik::query const& q) const;
- mapnik::featureset_ptr features_at_point(mapnik::coord2d const& pt) const;
+ mapnik::featureset_ptr features_at_point(mapnik::coord2d const& pt, double tol = 0) const;
mapnik::box2d<double> envelope() const;
mapnik::layer_descriptor get_descriptor() const;
boost::optional<mapnik::datasource::geometry_t> get_geometry_type() const;
@@ -315,7 +315,7 @@ featureset_ptr geos_datasource::features(query const& q) const
desc_.get_encoding());
}
-featureset_ptr geos_datasource::features_at_point(coord2d const& pt) const
+featureset_ptr geos_datasource::features_at_point(coord2d const& pt, double tol) const
{
if (! is_bound_) bind();
@@ -50,7 +50,7 @@ class geos_datasource : public mapnik::datasource
mapnik::datasource::datasource_t type() const;
static const char * name();
mapnik::featureset_ptr features(mapnik::query const& q) const;
- mapnik::featureset_ptr features_at_point(mapnik::coord2d const& pt) const;
+ mapnik::featureset_ptr features_at_point(mapnik::coord2d const& pt, double tol = 0) const;
mapnik::box2d<double> envelope() const;
boost::optional<mapnik::datasource::geometry_t> get_geometry_type() const;
mapnik::layer_descriptor get_descriptor() const;
@@ -166,7 +166,7 @@ featureset_ptr kismet_datasource::features(query const& q) const
// return featureset_ptr();
}
-featureset_ptr kismet_datasource::features_at_point(coord2d const& pt) const
+featureset_ptr kismet_datasource::features_at_point(coord2d const& pt, double tol) const
{
if (! is_bound_) bind();
@@ -52,7 +52,7 @@ class kismet_datasource : public mapnik::datasource
datasource::datasource_t type() const;
static const char * name();
mapnik::featureset_ptr features(mapnik::query const& q) const;
- mapnik::featureset_ptr features_at_point(mapnik::coord2d const& pt) const;
+ mapnik::featureset_ptr features_at_point(mapnik::coord2d const& pt, double tol = 0) const;
mapnik::box2d<double> envelope() const;
boost::optional<mapnik::datasource::geometry_t> get_geometry_type() const;
mapnik::layer_descriptor get_descriptor() const;
Oops, something went wrong.

0 comments on commit 3072b3f

Please sign in to comment.