]> git.street.me.uk Git - andy/viking.git/commitdiff
Mapnik3 support.
authorRob Norris <rw_norris@hotmail.com>
Fri, 10 Jul 2015 23:51:49 +0000 (00:51 +0100)
committerRob Norris <rw_norris@hotmail.com>
Fri, 10 Jul 2015 23:51:49 +0000 (00:51 +0100)
C++ standard required is now C++11.
New location for plugins.
Revised code for accessing Mapnik parameters and some types/functions have been renamed.

configure.ac
src/mapnik_interface.cpp
src/vikmapniklayer.c

index 8c0b4d4e9b19f3be39b32e40580293e7021a2194..feef828791793d1e54de0b381683d332db9ef9ad 100644 (file)
@@ -340,12 +340,17 @@ case $ac_cv_enable_mapnik in
     AC_LANG_CPLUSPLUS
     AC_LANG_SAVE
     AC_PROG_CXX
+    # Mapnik3 requires C++11. Viking will use C++11 as well.
+    CXXFLAGS="$CXXFLAGS -std=c++11"
     # Too difficult to get check working under Windows (extra dependencies needed probably Boost)- so just skip it
     if test "x$ac_cv_enable_windows" = "xno"; then
       AC_CHECK_HEADER([mapnik/map.hpp],[],[AC_MSG_ERROR([mapnik/map.hpp is needed but not found - you will need to install package 'libmapnik-dev' or similar. The feature can be disabled with --disable-mapnik])])
     fi
     AC_CHECK_LIB([mapnik], [main], [], [AC_MSG_ERROR([libmapnik is needed but not found.])])
     AC_CHECK_LIB([stdc++], [main], [], [AC_MSG_ERROR([libstdc++ is needed but not found.])])
+    # Required for Mapnik3 build (it's also in Mapnik2 but does not need to be specified for some reason)
+    #  it's part of libmapnik install dependencies
+    AC_CHECK_LIB([icuuc], [main], [], [AC_MSG_ERROR([libicuuc is needed but not found.])])
     AC_LANG_RESTORE
     ;;
 esac
index 087e01389b53ec16f42b6d7a529a3a4990ad92b3..211ec8e43317d5608eea27defd66180873a7b279 100644 (file)
 #include <mapnik/datasource_cache.hpp>
 #include <mapnik/agg_renderer.hpp>
 #include <mapnik/load_map.hpp>
+#include <mapnik/projection.hpp>
+#if MAPNIK_VERSION < 300000
 #include <mapnik/graphics.hpp>
+#else
+#include <mapnik/value.hpp>
+#endif
 #include <mapnik/image_util.hpp>
 
 #include <exception>
 #define zoom_to_box zoomToBox
 #else
 #include <mapnik/box2d.hpp>
+#if MAPNIK_VERSION >= 300000
+// In Mapnik3 'image_32' has changed names once again
+#define image_32 image_rgba8
+#define raw_data data
+#endif
 #endif
 
 #define MAPNIK_INTERFACE_TYPE            (mapnik_interface_get_type ())
@@ -130,18 +140,28 @@ void mapnik_interface_initialize (const char *plugins_dir, const char* font_dir,
  */
 static void set_copyright ( MapnikInterface* mi )
 {
-       if ( mi->copyright )
-               g_free ( mi->copyright );
+       g_free ( mi->copyright );
+       mi->copyright = NULL;
 
        mapnik::parameters pmts = mi->myMap->get_extra_parameters();
+#if MAPNIK_VERSION < 300000
        for (mapnik::parameters::const_iterator ii = pmts.begin(); ii != pmts.end(); ii++) {
                if ( ii->first == "attribution" || ii->first == "copyright" ) {
                        std::stringstream ss;
                        ss << ii->second;
                        // Copy it
                        mi->copyright = g_strdup ( (gchar*)ss.str().c_str() );
+                       break;
                }
        }
+#else
+       if ( pmts.get<std::string>("attribution") )
+               mi->copyright = g_strdup ( (*pmts.get<std::string>("attribution")).c_str() );
+
+       if ( !mi->copyright )
+               if ( pmts.get<std::string>("copyright") )
+                       mi->copyright = g_strdup ( (*pmts.get<std::string>("copyright")).c_str() );
+#endif
 }
 
 #define VIK_SETTINGS_MAPNIK_BUFFER_SIZE "mapnik_buffer_size"
@@ -264,11 +284,16 @@ GArray* mapnik_interface_get_parameters ( MapnikInterface* mi )
        GArray *array = g_array_new (FALSE, TRUE, sizeof(gchar*));
 
        mapnik::parameters pmts = mi->myMap->get_extra_parameters();
-       for (mapnik::parameters::const_iterator ii = pmts.begin(); ii != pmts.end(); ii++) {
-               // Dodgy hacking to avoid using boost or mapnik::utils visitor stuff (not available in mapnik 2.2)
-               // Simply want the strings of each parameter so we can display something...
+       // Simply want the strings of each parameter so we can display something...
+#if MAPNIK_VERSION < 300000
+       for (mapnik::parameters::const_iterator pmt = pmts.begin(); pmt != pmts.end(); pmt++) {
                std::stringstream ss;
-               ss << ii->first << ": " << ii->second;
+               ss << pmt->first << ": " << pmt->second;
+#else
+       for (auto const& pmt : pmts) {
+               std::stringstream ss;
+               ss << pmt.first << ": " << *(pmts.get<std::string>(pmt.first,"empty"));
+#endif
                // Copy - otherwise ss goes output scope and junk memory would be referenced.
                gchar *str2 = g_strdup ( (gchar*)ss.str().c_str() );
                g_array_append_val ( array, str2 );
index 486125eeefe97804a963a7abda6c95d69144b3ff..61518a1d26076a5e8e8d6bb94354fd001371cb18 100644 (file)
@@ -231,8 +231,10 @@ static VikLayerParamData plugins_default ( void )
 #else
        if ( g_file_test ( "/usr/lib/mapnik/input", G_FILE_TEST_EXISTS ) )
                data.s = g_strdup ( "/usr/lib/mapnik/input" );
+               // Current Debian locations
+       else if ( g_file_test ( "/usr/lib/mapnik/3.0/input", G_FILE_TEST_EXISTS ) )
+               data.s = g_strdup ( "/usr/lib/mapnik/3.0/input" );
        else if ( g_file_test ( "/usr/lib/mapnik/2.2/input", G_FILE_TEST_EXISTS ) )
-               // Current Debian location
                data.s = g_strdup ( "/usr/lib/mapnik/2.2/input" );
        else
                data.s = g_strdup ( "" );