Skip to content

Commit 6c1d890

Browse files
authored
Make v3.x.x the minimum required Mapnik version (#365)
Remove support for Mapnik versions < [3.0.0](https://mapnik.org/news/release-3.0.0), which have been around since 2015
1 parent ff06794 commit 6c1d890

4 files changed

Lines changed: 5 additions & 49 deletions

File tree

CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ find_package(CAIRO REQUIRED)
4343
find_package(GLIB REQUIRED)
4444
find_package(HTTPD REQUIRED)
4545
find_package(INIPARSER REQUIRED)
46-
find_package(LIBMAPNIK REQUIRED)
46+
find_package(LIBMAPNIK 3 REQUIRED)
4747
find_package(LIBMEMCACHED)
4848
find_package(LIBRADOS)
4949

50-
if(LIBMAPNIK_VERSION STRGREATER_EQUAL "4")
50+
if(LIBMAPNIK_VERSION VERSION_GREATER_EQUAL 4)
5151
set(CMAKE_CXX_STANDARD 14)
5252
endif()
5353

@@ -111,7 +111,7 @@ execute_process(COMMAND ${APXS_EXECUTABLE} -q sysconfdir
111111
OUTPUT_STRIP_TRAILING_WHITESPACE
112112
)
113113

114-
if(LIBMAPNIK_VERSION STRLESS "4")
114+
if(LIBMAPNIK_VERSION VERSION_LESS 4)
115115
find_program(MAPNIK_CONFIG_EXECUTABLE NAMES mapnik-config REQUIRED)
116116
execute_process(COMMAND ${MAPNIK_CONFIG_EXECUTABLE} --fonts
117117
OUTPUT_STRIP_TRAILING_WHITESPACE
@@ -121,7 +121,7 @@ if(LIBMAPNIK_VERSION STRLESS "4")
121121
OUTPUT_STRIP_TRAILING_WHITESPACE
122122
OUTPUT_VARIABLE MAPNIK_PLUGINS_DIR
123123
)
124-
elseif(LIBMAPNIK_VERSION STRGREATER_EQUAL "4")
124+
elseif(LIBMAPNIK_VERSION VERSION_GREATER_EQUAL 4)
125125
pkg_get_variable(MAPNIK_FONTS_DIR libmapnik fonts_dir)
126126
pkg_get_variable(MAPNIK_PLUGINS_DIR libmapnik plugins_dir)
127127
endif()

src/gen_tile.cpp

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -53,27 +53,15 @@
5353
#include <netdb.h>
5454
#endif
5555

56-
#if MAPNIK_VERSION >= 300000
5756
#define image_data_32 image_rgba8
5857
#define image_32 image_rgba8
5958
#include <mapnik/image.hpp>
6059
#include <mapnik/image_view_any.hpp>
61-
#else
62-
#include <mapnik/graphics.hpp>
63-
#if MAPNIK_VERSION < 200000
64-
#include <mapnik/envelope.hpp>
65-
#define image_32 Image32
66-
#define image_data_32 ImageData32
67-
#define box2d Envelope
68-
#define zoom_to_box zoomToBox
69-
#else
7060
#if MAPNIK_VERSION >= 400000
7161
#include <mapnik/geometry/box2d.hpp>
7262
#else
7363
#include <mapnik/box2d.hpp>
7464
#endif
75-
#endif
76-
#endif
7765

7866

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

224212
for (i = 0; i < m.layer_count(); i++) {
225-
#if MAPNIK_VERSION >= 300000
226213
layer& l = m.get_layer(i);
227-
#else
228-
layer& l = m.getLayer(i);
229-
#endif
230214
parameters params = l.datasource()->params();
231215

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

237-
#if MAPNIK_VERSION >= 200200
238221
l.set_datasource(datasource_cache::instance().create(params));
239-
#else
240-
l.set_datasource(datasource_cache::instance()->create(params));
241-
#endif
242222
}
243223

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

325305
for (yy = 0; yy < render_size_ty; yy++) {
326306
for (xx = 0; xx < render_size_tx; xx++) {
327-
#if MAPNIK_VERSION >= 300000
328307
mapnik::image_view<mapnik::image<mapnik::rgba8_t>> vw1(xx * map->tilesize, yy * map->tilesize, map->tilesize, map->tilesize, buf);
329308
struct mapnik::image_view_any vw(vw1);
330-
#else
331-
mapnik::image_view<mapnik::image_data_32> vw(xx * map->tilesize, yy * map->tilesize, map->tilesize, map->tilesize, buf.data());
332-
#endif
333309
tiles.set(xx, yy, save_to_string(vw, map->output_format));
334310
}
335311
}
@@ -386,12 +362,7 @@ static enum protoCmd render(Map &m, const char *tile_dir, char *xmlname, project
386362
void render_init(const char *plugins_dir, const char* font_dir, int font_dir_recurse)
387363
{
388364
g_logger(G_LOG_LEVEL_INFO, "Renderd is using mapnik version %i.%i.%i", ((MAPNIK_VERSION) / 100000), (((MAPNIK_VERSION) / 100) % 1000), ((MAPNIK_VERSION) % 100));
389-
390-
#if MAPNIK_VERSION >= 200200
391365
mapnik::datasource_cache::instance().register_datasources(plugins_dir);
392-
#else
393-
mapnik::datasource_cache::instance()->register_datasources(plugins_dir);
394-
#endif
395366
load_fonts(font_dir, font_dir_recurse);
396367
}
397368

src/gen_tile_test.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,12 @@
4747
#endif
4848

4949
#include <mapnik/version.hpp>
50-
#if MAPNIK_VERSION < 200000
51-
#include <mapnik/envelope.hpp>
52-
#define image_32 Image32
53-
#define image_data_32 ImageData32
54-
#define box2d Envelope
55-
#define zoom_to_box zoomToBox
56-
#else
50+
5751
#if MAPNIK_VERSION >= 400000
5852
#include <mapnik/geometry/box2d.hpp>
5953
#else
6054
#include <mapnik/box2d.hpp>
6155
#endif
62-
#endif
6356

6457

6558
#define NO_QUEUE_REQUESTS 9

src/parameterize_style.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,7 @@ static void parameterize_map_language(mapnik::Map &m, char * parameter)
6464
strncat(name_replace, ") as name", 255);
6565

6666
for (i = 0; i < m.layer_count(); i++) {
67-
#if MAPNIK_VERSION >= 300000
6867
mapnik::layer& l = m.get_layer(i);
69-
#else
70-
mapnik::layer& l = m.getLayer(i);
71-
#endif
7268
mapnik::parameters params = l.datasource()->params();
7369

7470
if (params.find("table") != params.end()) {
@@ -79,11 +75,7 @@ static void parameterize_map_language(mapnik::Map &m, char * parameter)
7975
size_t pos = str.find(",name");
8076
str.replace(pos, 5, name_replace);
8177
params["table"] = str;
82-
#if MAPNIK_VERSION >= 200200
8378
l.set_datasource(mapnik::datasource_cache::instance().create(params));
84-
#else
85-
l.set_datasource(mapnik::datasource_cache::instance()->create(params));
86-
#endif
8779
}
8880
}
8981

0 commit comments

Comments
 (0)