Permalink
Browse files

adapt to mapnik 2.2.0-pre code upstream as per mapnik/mapnik#1451

  • Loading branch information...
1 parent d306473 commit a344edcf3210e92313a63f0b176eb661dadec6d7 Dane Springmeyer committed Sep 5, 2012
Showing with 21 additions and 5 deletions.
  1. +5 −1 src/mapnik_datasource.cpp
  2. +16 −4 src/mapnik_plugins.hpp
@@ -1,4 +1,4 @@
-
+#include <mapnik/version.hpp>
#include <mapnik/datasource_cache.hpp>
#include "mapnik_datasource.hpp"
@@ -104,7 +104,11 @@ Handle<Value> Datasource::New(const Arguments& args)
mapnik::datasource_ptr ds;
try
{
+#if MAPNIK_VERSION >= 200200
+ ds = mapnik::datasource_cache::instance()->create(params, bind);
+#else
ds = mapnik::datasource_cache::create(params, bind);
+#endif
}
catch (std::exception const& ex)
{
View
@@ -10,6 +10,7 @@
// mapnik
#include <mapnik/datasource_cache.hpp>
+#include <mapnik/version.hpp>
// stl
#include <vector>
@@ -25,7 +26,11 @@ namespace node_mapnik {
static inline Handle<Value> available_input_plugins(const Arguments& args)
{
HandleScope scope;
- std::vector<std::string> const& names = mapnik::datasource_cache::plugin_names();
+#if MAPNIK_VERSION >= 200200
+ std::vector<std::string> names = mapnik::datasource_cache::instance()->plugin_names();
+#else
+ std::vector<std::string> names = mapnik::datasource_cache::plugin_names();
+#endif
Local<Array> a = Array::New(names.size());
for (unsigned i = 0; i < names.size(); ++i)
{
@@ -41,11 +46,18 @@ static inline Handle<Value> register_datasources(const Arguments& args)
if (args.Length() != 1 || !args[0]->IsString())
return ThrowException(Exception::TypeError(
String::New("first argument must be a path to a directory of mapnik input plugins")));
-
- std::vector<std::string> const names_before = mapnik::datasource_cache::plugin_names();
+#if MAPNIK_VERSION >= 200200
+ std::vector<std::string> names_before = mapnik::datasource_cache::instance()->plugin_names();
+#else
+ std::vector<std::string> names_before = mapnik::datasource_cache::plugin_names();
+#endif
std::string path = TOSTR(args[0]);
mapnik::datasource_cache::instance()->register_datasources(path);
- std::vector<std::string> const& names_after = mapnik::datasource_cache::plugin_names();
+#if MAPNIK_VERSION >= 200200
+ std::vector<std::string> names_after = mapnik::datasource_cache::instance()->plugin_names();
+#else
+ std::vector<std::string> names_after = mapnik::datasource_cache::plugin_names();
+#endif
if (names_after.size() > names_before.size())
return scope.Close(True());
return scope.Close(False());

0 comments on commit a344edc

Please sign in to comment.