Skip to content

Commit

Permalink
Make v3.x.x the minimum required Mapnik version (openstreetmap#365)
Browse files Browse the repository at this point in the history
Remove support for Mapnik versions < [3.0.0](https://mapnik.org/news/release-3.0.0), which have been around since 2015
  • Loading branch information
hummeltech authored Jan 5, 2024
1 parent ff06794 commit 6c1d890
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 49 deletions.
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ find_package(CAIRO REQUIRED)
find_package(GLIB REQUIRED)
find_package(HTTPD REQUIRED)
find_package(INIPARSER REQUIRED)
find_package(LIBMAPNIK REQUIRED)
find_package(LIBMAPNIK 3 REQUIRED)
find_package(LIBMEMCACHED)
find_package(LIBRADOS)

if(LIBMAPNIK_VERSION STRGREATER_EQUAL "4")
if(LIBMAPNIK_VERSION VERSION_GREATER_EQUAL 4)
set(CMAKE_CXX_STANDARD 14)
endif()

Expand Down Expand Up @@ -111,7 +111,7 @@ execute_process(COMMAND ${APXS_EXECUTABLE} -q sysconfdir
OUTPUT_STRIP_TRAILING_WHITESPACE
)

if(LIBMAPNIK_VERSION STRLESS "4")
if(LIBMAPNIK_VERSION VERSION_LESS 4)
find_program(MAPNIK_CONFIG_EXECUTABLE NAMES mapnik-config REQUIRED)
execute_process(COMMAND ${MAPNIK_CONFIG_EXECUTABLE} --fonts
OUTPUT_STRIP_TRAILING_WHITESPACE
Expand All @@ -121,7 +121,7 @@ if(LIBMAPNIK_VERSION STRLESS "4")
OUTPUT_STRIP_TRAILING_WHITESPACE
OUTPUT_VARIABLE MAPNIK_PLUGINS_DIR
)
elseif(LIBMAPNIK_VERSION STRGREATER_EQUAL "4")
elseif(LIBMAPNIK_VERSION VERSION_GREATER_EQUAL 4)
pkg_get_variable(MAPNIK_FONTS_DIR libmapnik fonts_dir)
pkg_get_variable(MAPNIK_PLUGINS_DIR libmapnik plugins_dir)
endif()
Expand Down
29 changes: 0 additions & 29 deletions src/gen_tile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,27 +53,15 @@
#include <netdb.h>
#endif

#if MAPNIK_VERSION >= 300000
#define image_data_32 image_rgba8
#define image_32 image_rgba8
#include <mapnik/image.hpp>
#include <mapnik/image_view_any.hpp>
#else
#include <mapnik/graphics.hpp>
#if MAPNIK_VERSION < 200000
#include <mapnik/envelope.hpp>
#define image_32 Image32
#define image_data_32 ImageData32
#define box2d Envelope
#define zoom_to_box zoomToBox
#else
#if MAPNIK_VERSION >= 400000
#include <mapnik/geometry/box2d.hpp>
#else
#include <mapnik/box2d.hpp>
#endif
#endif
#endif


using namespace mapnik;
Expand Down Expand Up @@ -222,23 +210,15 @@ static void parameterize_map_max_connections(Map &m, int num_threads)
char * tmp = (char *)malloc(20);

for (i = 0; i < m.layer_count(); i++) {
#if MAPNIK_VERSION >= 300000
layer& l = m.get_layer(i);
#else
layer& l = m.getLayer(i);
#endif
parameters params = l.datasource()->params();

if (params.find("max_size") == params.end()) {
sprintf(tmp, "%i", num_threads + 2);
params["max_size"] = std::string(tmp);
}

#if MAPNIK_VERSION >= 200200
l.set_datasource(datasource_cache::instance().create(params));
#else
l.set_datasource(datasource_cache::instance()->create(params));
#endif
}

free(tmp);
Expand Down Expand Up @@ -324,12 +304,8 @@ static enum protoCmd render(struct xmlmapconfig * map, int x, int y, int z, char

for (yy = 0; yy < render_size_ty; yy++) {
for (xx = 0; xx < render_size_tx; xx++) {
#if MAPNIK_VERSION >= 300000
mapnik::image_view<mapnik::image<mapnik::rgba8_t>> vw1(xx * map->tilesize, yy * map->tilesize, map->tilesize, map->tilesize, buf);
struct mapnik::image_view_any vw(vw1);
#else
mapnik::image_view<mapnik::image_data_32> vw(xx * map->tilesize, yy * map->tilesize, map->tilesize, map->tilesize, buf.data());
#endif
tiles.set(xx, yy, save_to_string(vw, map->output_format));
}
}
Expand Down Expand Up @@ -386,12 +362,7 @@ static enum protoCmd render(Map &m, const char *tile_dir, char *xmlname, project
void render_init(const char *plugins_dir, const char* font_dir, int font_dir_recurse)
{
g_logger(G_LOG_LEVEL_INFO, "Renderd is using mapnik version %i.%i.%i", ((MAPNIK_VERSION) / 100000), (((MAPNIK_VERSION) / 100) % 1000), ((MAPNIK_VERSION) % 100));

#if MAPNIK_VERSION >= 200200
mapnik::datasource_cache::instance().register_datasources(plugins_dir);
#else
mapnik::datasource_cache::instance()->register_datasources(plugins_dir);
#endif
load_fonts(font_dir, font_dir_recurse);
}

Expand Down
9 changes: 1 addition & 8 deletions src/gen_tile_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,12 @@
#endif

#include <mapnik/version.hpp>
#if MAPNIK_VERSION < 200000
#include <mapnik/envelope.hpp>
#define image_32 Image32
#define image_data_32 ImageData32
#define box2d Envelope
#define zoom_to_box zoomToBox
#else

#if MAPNIK_VERSION >= 400000
#include <mapnik/geometry/box2d.hpp>
#else
#include <mapnik/box2d.hpp>
#endif
#endif


#define NO_QUEUE_REQUESTS 9
Expand Down
8 changes: 0 additions & 8 deletions src/parameterize_style.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,7 @@ static void parameterize_map_language(mapnik::Map &m, char * parameter)
strncat(name_replace, ") as name", 255);

for (i = 0; i < m.layer_count(); i++) {
#if MAPNIK_VERSION >= 300000
mapnik::layer& l = m.get_layer(i);
#else
mapnik::layer& l = m.getLayer(i);
#endif
mapnik::parameters params = l.datasource()->params();

if (params.find("table") != params.end()) {
Expand All @@ -79,11 +75,7 @@ static void parameterize_map_language(mapnik::Map &m, char * parameter)
size_t pos = str.find(",name");
str.replace(pos, 5, name_replace);
params["table"] = str;
#if MAPNIK_VERSION >= 200200
l.set_datasource(mapnik::datasource_cache::instance().create(params));
#else
l.set_datasource(mapnik::datasource_cache::instance()->create(params));
#endif
}
}

Expand Down

0 comments on commit 6c1d890

Please sign in to comment.