Skip to content

Commit af67552

Browse files
committed
Assert our addiction to GDAL and PROJ, and make them required dependencies
Because: - this was already the case. branch-7-4 does not even compile without them. - the sheer number of places where they were needed is an evidence that MapServer is not MapServer without them - it makes the code easier to comprehend.
1 parent 008b38c commit af67552

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+117
-1296
lines changed

Diff for: CMakeLists.txt

+27-106
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ int main(int argc, char **argv) {
119119
include_directories(${CMAKE_CURRENT_BINARY_DIR})
120120

121121
#options suported by the cmake builder
122-
option(WITH_PROJ "Choose if reprojection support should be built in" ON)
123122
option(WITH_PROTOBUFC "Choose if protocol buffers support should be built in (required for vector tiles)" ON)
124123
option(WITH_KML "Enable native KML output support (requires libxml2 support)" OFF)
125124
option(WITH_SOS "Enable SOS Server support (requires PROJ and libxml2 support)" OFF)
@@ -134,8 +133,6 @@ option(WITH_MYSQL "Choose if MYSQL joining support should be built in" OFF)
134133
option(WITH_FCGI "Choose if FastCGI support should be built in" ON)
135134
option(WITH_GEOS "Choose if GEOS geometry operations support should be built in" ON)
136135
option(WITH_POSTGIS "Choose if Postgis input support should be built in" ON)
137-
option(WITH_GDAL "Choose if GDAL input raster support should be built in" ON)
138-
option(WITH_OGR "Choose if OGR/GDAL input vector support should be built in" ON)
139136
option(WITH_CLIENT_WMS "Enable Client WMS Layer support (requires CURL and GDAL support)" OFF)
140137
option(WITH_CLIENT_WFS "Enable Client WMS Layer support (requires CURL and OGR support)" OFF)
141138
option(WITH_CURL "Enable Curl HTTP support (required for wms/wfs client, and remote SLD)" OFF)
@@ -388,17 +385,14 @@ ms_link_libraries( ${FREETYPE_LIBRARY})
388385
list(APPEND ALL_INCLUDE_DIRS ${FREETYPE_INCLUDE_DIR})
389386

390387

391-
if(WITH_PROJ)
392-
find_package(Proj)
393-
if(NOT PROJ_FOUND)
394-
report_optional_not_found(PROJ)
395-
else(NOT PROJ_FOUND)
396-
include_directories(${PROJ_INCLUDE_DIR})
397-
ms_link_libraries( ${PROJ_LIBRARY})
398-
list(APPEND ALL_INCLUDE_DIRS ${PROJ_INCLUDE_DIR})
399-
set (USE_PROJ 1)
400-
endif(NOT PROJ_FOUND)
401-
endif (WITH_PROJ)
388+
find_package(Proj)
389+
if(NOT PROJ_FOUND)
390+
report_mandatory_not_found(PROJ)
391+
endif(NOT PROJ_FOUND)
392+
393+
include_directories(${PROJ_INCLUDE_DIR})
394+
ms_link_libraries( ${PROJ_LIBRARY})
395+
list(APPEND ALL_INCLUDE_DIRS ${PROJ_INCLUDE_DIR})
402396

403397
if(USE_PBF)
404398
include_directories(${PROJECT_BINARY_DIR}/renderers/mvt)
@@ -419,11 +413,7 @@ if(WITH_PIXMAN)
419413
endif (WITH_PIXMAN)
420414

421415
if(WITH_WMS)
422-
if(USE_PROJ)
423-
set(USE_WMS_SVR 1)
424-
else(USE_PROJ)
425-
report_dependency_error(WMS PROJ)
426-
endif(USE_PROJ)
416+
set(USE_WMS_SVR 1)
427417
endif(WITH_WMS)
428418

429419
if(WITH_FRIBIDI)
@@ -591,17 +581,14 @@ if(WITH_POSTGIS)
591581
endif(POSTGRESQL_FOUND)
592582
endif (WITH_POSTGIS)
593583

594-
if(WITH_GDAL)
595-
find_package(GDAL)
596-
if(GDAL_FOUND)
597-
include_directories(${GDAL_INCLUDE_DIR})
598-
ms_link_libraries( ${GDAL_LIBRARY})
599-
list(APPEND ALL_INCLUDE_DIRS ${GDAL_INCLUDE_DIR})
600-
set (USE_GDAL 1)
601-
else(GDAL_FOUND)
602-
report_optional_not_found(GDAL)
603-
endif(GDAL_FOUND)
604-
endif (WITH_GDAL)
584+
find_package(GDAL)
585+
if(NOT GDAL_FOUND)
586+
report_mandatory_not_found(GDAL)
587+
endif(NOT GDAL_FOUND)
588+
589+
include_directories(${GDAL_INCLUDE_DIR})
590+
ms_link_libraries( ${GDAL_LIBRARY})
591+
list(APPEND ALL_INCLUDE_DIRS ${GDAL_INCLUDE_DIR})
605592

606593
if(WITH_SVGCAIRO)
607594
if(WITH_RSVG)
@@ -636,25 +623,6 @@ if(WITH_RSVG)
636623
endif(RSVG_FOUND AND GOBJECT_FOUND)
637624
endif (WITH_RSVG)
638625

639-
if(WITH_OGR)
640-
if(GDAL_FOUND)
641-
set (USE_OGR 1)
642-
else(GDAL_FOUND)
643-
find_package(GDAL)
644-
if(GDAL_FOUND)
645-
include_directories(${GDAL_INCLUDE_DIR})
646-
ms_link_libraries( ${GDAL_LIBRARY})
647-
list(APPEND ALL_INCLUDE_DIRS ${GDAL_INCLUDE_DIR})
648-
set (USE_OGR 1)
649-
else(GDAL_FOUND)
650-
message(SEND_ERROR "GDAL library could not be found and is needed for OGR support.
651-
HINTS:
652-
- disable OGR support by adding -DWITH_OGR=0
653-
- add the GDAL install directory to the CMAKE_PREFIX_PATH variable (-DCMAKE_PREFIX_PATH=\"/path/to/${component}-install-dir;/path/to/other/dirs\"")
654-
endif(GDAL_FOUND)
655-
endif(GDAL_FOUND)
656-
endif(WITH_OGR)
657-
658626
if(WITH_CLIENT_WMS OR WITH_CLIENT_WFS)
659627
set(WITH_CURL ON)
660628
endif(WITH_CLIENT_WMS OR WITH_CLIENT_WFS)
@@ -683,56 +651,19 @@ if(WITH_CLIENT_WMS OR WITH_CLIENT_WFS)
683651
endif(WITH_CLIENT_WMS OR WITH_CLIENT_WFS)
684652

685653
if(WITH_CLIENT_WMS)
686-
if(USE_GDAL AND USE_PROJ)
687-
set(USE_WMS_LYR 1)
688-
else(USE_GDAL AND USE_PROJ)
689-
if(NOT USE_GDAL)
690-
report_dependency_error(CLIENT_WMS GDAL)
691-
endif(NOT USE_GDAL)
692-
if( NOT USE_PROJ)
693-
report_dependency_error(CLIENT_WMS PROJ)
694-
endif(NOT USE_PROJ)
695-
endif(USE_GDAL AND USE_PROJ)
654+
set(USE_WMS_LYR 1)
696655
endif(WITH_CLIENT_WMS)
697656

698657
if(WITH_CLIENT_WFS)
699-
if(USE_OGR AND USE_PROJ)
700-
set(USE_WFS_LYR 1)
701-
else(USE_OGR AND USE_PROJ)
702-
if(NOT USE_OGR)
703-
report_dependency_error(CLIENT_WFS OGR)
704-
endif(NOT USE_OGR)
705-
if( NOT USE_PROJ)
706-
report_dependency_error(CLIENT_WFS PROJ)
707-
endif(NOT USE_PROJ)
708-
endif(USE_OGR AND USE_PROJ)
658+
set(USE_WFS_LYR 1)
709659
endif(WITH_CLIENT_WFS)
710660

711661
if(WITH_WFS)
712-
if(USE_PROJ AND USE_OGR)
713-
set(USE_WFS_SVR 1)
714-
#TODO: set WFS_USE_LIBXML2 ?
715-
else(USE_PROJ AND USE_OGR)
716-
if( NOT USE_OGR)
717-
report_dependency_error(WFS OGR)
718-
endif( NOT USE_OGR)
719-
if( NOT USE_PROJ)
720-
report_dependency_error(WFS PROJ)
721-
endif( NOT USE_PROJ)
722-
endif(USE_PROJ AND USE_OGR)
662+
set(USE_WFS_SVR 1)
723663
endif(WITH_WFS)
724664

725665
if(WITH_WCS)
726-
if(USE_PROJ AND USE_GDAL)
727-
set(USE_WCS_SVR 1)
728-
else(USE_PROJ AND USE_GDAL)
729-
if(NOT USE_GDAL)
730-
report_dependency_error(WCS GDAL)
731-
endif(NOT USE_GDAL)
732-
if(NOT USE_PROJ)
733-
report_dependency_error(WCS PROJ)
734-
endif(NOT USE_PROJ)
735-
endif(USE_PROJ AND USE_GDAL)
666+
set(USE_WCS_SVR 1)
736667
endif(WITH_WCS)
737668

738669
if(WITH_LIBXML2)
@@ -758,20 +689,11 @@ if( USE_WFS_SVR AND NOT USE_LIBXML2 )
758689
endif( USE_WFS_SVR AND NOT USE_LIBXML2 )
759690

760691
if(WITH_SOS)
761-
if(NOT USE_OGR)
762-
report_dependency_error(WITH_SOS OGR)
763-
endif(NOT USE_OGR)
764-
765-
if(USE_PROJ AND USE_LIBXML2)
692+
if(USE_LIBXML2)
766693
set(USE_SOS_SVR 1)
767-
else(USE_PROJ AND USE_LIBXML2)
768-
if(NOT USE_LIBXML2)
769-
report_dependency_error(SOS LIBXML2)
770-
endif(NOT USE_LIBXML2)
771-
if(NOT USE_PROJ)
772-
report_dependency_error(SOS PROJ)
773-
endif(NOT USE_PROJ)
774-
endif(USE_PROJ AND USE_LIBXML2)
694+
else(USE_LIBXML2)
695+
report_dependency_error(SOS LIBXML2)
696+
endif(USE_LIBXML2)
775697
endif(WITH_SOS)
776698

777699
if(WITH_POINT_Z_M)
@@ -944,12 +866,12 @@ endmacro()
944866

945867
message(STATUS "* Summary of configured options for this build")
946868
message(STATUS " * Mandatory components")
869+
message(STATUS " * GDAL: ${GDAL_LIBRARY}")
870+
message(STATUS " * PROJ: ${PROJ_LIBRARY}")
947871
message(STATUS " * png: ${PNG_LIBRARY}")
948872
message(STATUS " * jpeg: ${JPEG_LIBRARY}")
949873
message(STATUS " * freetype: ${FREETYPE_LIBRARY}")
950874
message(STATUS " * Optional components")
951-
status_optional_component("GDAL" "${USE_GDAL}" "${GDAL_LIBRARY}")
952-
status_optional_component("OGR" "${USE_OGR}" "${GDAL_LIBRARY}")
953875
status_optional_component("GIF" "${USE_GIF}" "${GIF_LIBRARY}")
954876
status_optional_component("MYSQL" "${USE_MYSQL}" "${MYSQL_LIBRARY}")
955877
status_optional_component("FRIBIDI" "${USE_FRIBIDI}" "${FRIBIDI_LIBRARY}")
@@ -959,7 +881,6 @@ status_optional_component("CAIRO" "${USE_CAIRO}" "${CAIRO_LIBRARY}")
959881
status_optional_component("SVGCAIRO" "${USE_SVG_CAIRO}" "${SVGCAIRO_LIBRARY}")
960882
status_optional_component("RSVG" "${USE_RSVG}" "${RSVG_LIBRARY}")
961883
status_optional_component("CURL" "${USE_CURL}" "${CURL_LIBRARY}")
962-
status_optional_component("PROJ" "${USE_PROJ}" "${PROJ_LIBRARY}")
963884
status_optional_component("PIXMAN" "${USE_PIXMAN}" "${PIXMAN_LIBRARY}")
964885
status_optional_component("LIBXML2" "${USE_LIBXML2}" "${LIBXML2_LIBRARY}")
965886
status_optional_component("POSTGIS" "${USE_POSTGIS}" "${POSTGRESQL_LIBRARY}")

Diff for: classobject.c

-6
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,6 @@
3131

3232
#include "mapserver.h"
3333

34-
#ifdef USE_GDAL
35-
# include "gdal.h"
36-
# include "cpl_conv.h"
37-
#endif
38-
39-
4034

4135
/*
4236
** Add a label to a classObj (order doesn't matter for labels like it does with styles)

Diff for: hittest.c

-2
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,8 @@ int msHitTestLayer(mapObj *map, layerObj *layer, layer_hittest *hittest) {
172172
/* identify target shapes */
173173
if(layer->transform == MS_TRUE) {
174174
searchrect = map->extent;
175-
#ifdef USE_PROJ
176175
if((map->projection.numargs > 0) && (layer->projection.numargs > 0))
177176
msProjectRect(&map->projection, &layer->projection, &searchrect); /* project the searchrect to source coords */
178-
#endif
179177
}
180178
else {
181179
searchrect.minx = searchrect.miny = 0;

Diff for: kerneldensity.c

+2-15
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828

2929
#include "mapserver.h"
3030
#include <float.h>
31-
#ifdef USE_GDAL
3231

3332
#include "gdal.h"
3433
#include "cpl_string.h"
@@ -180,11 +179,9 @@ int msComputeKernelDensityDataset(mapObj *map, imageObj *image, layerObj *kernel
180179
searchrect.maxy = map->height-1;
181180
}
182181

183-
#ifdef USE_PROJ
184182
layer->project = msProjectionsDiffer(&(layer->projection), &(map->projection));
185183
if(layer->project)
186184
msProjectRect(&map->projection, &layer->projection, &searchrect); /* project the searchrect to source coords */
187-
#endif
188185

189186
status = msLayerWhichShapes(layer, searchrect, MS_FALSE);
190187
/* nothing to do */
@@ -199,7 +196,7 @@ int msComputeKernelDensityDataset(mapObj *map, imageObj *image, layerObj *kernel
199196
double weight = 1.0;
200197
if(!values) /* defer allocation until we effectively have a feature */
201198
values = (float*) msSmallCalloc(im_width * im_height, sizeof(float));
202-
#ifdef USE_PROJ
199+
203200
if(layer->project)
204201
{
205202
if( layer->reprojectorLayerToMap == NULL )
@@ -215,8 +212,7 @@ int msComputeKernelDensityDataset(mapObj *map, imageObj *image, layerObj *kernel
215212
}
216213
msProjectShapeEx(layer->reprojectorLayerToMap, &shape);
217214
}
218-
#endif
219-
215+
220216
/* the weight for the sample is set to 1.0 by default. If the
221217
* layer has some classes defined, we will read the weight from
222218
* the class->style->size (which can be binded to an attribute)
@@ -345,15 +341,6 @@ int msComputeKernelDensityDataset(mapObj *map, imageObj *image, layerObj *kernel
345341
}
346342
return status;
347343
}
348-
#else
349-
350-
351-
int msComputeKernelDensityDataset(mapObj *map, imageObj *image, layerObj *layer, void **hDSvoid, void **cleanup_ptr) {
352-
msSetError(MS_MISCERR,"msComputeKernelDensityDataset()", "KernelDensity layers require GDAL support, however GDAL support is not compiled in this build");
353-
return MS_FAILURE;
354-
}
355-
356-
#endif
357344

358345
int msCleanupKernelDensityDataset(mapObj *map, imageObj *image, layerObj *layer, void *cleanup_ptr) {
359346
free(cleanup_ptr);

Diff for: layerobject.c

-6
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,6 @@
3131

3232
#include "mapserver.h"
3333

34-
#ifdef USE_GDAL
35-
# include "gdal.h"
36-
# include "cpl_conv.h"
37-
#endif
38-
39-
4034

4135
/* ===========================================================================
4236
msInsertClass

Diff for: mapcairo.c

-6
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,8 @@
5555
#endif
5656
#endif
5757

58-
#ifdef USE_GDAL
5958
#include <cpl_string.h>
6059
#include <gdal.h>
61-
#endif
6260

6361
#include "fontcache.h"
6462

@@ -537,9 +535,6 @@ imageObj* createImageCairo(int width, int height, outputFormatObj *format,colorO
537535

538536
static void msTransformToGeospatialPDF(imageObj *img, mapObj *map, cairo_renderer *r)
539537
{
540-
/* We need a GDAL 1.10 PDF driver at runtime, but as far as the C API is concerned, GDAL 1.9 is */
541-
/* largely sufficient. */
542-
#if defined(USE_GDAL) && defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 1900
543538
GDALDatasetH hDS = NULL;
544539
const char* pszGEO_ENCODING = NULL;
545540
GDALDriverH hPDFDriver = NULL;
@@ -646,7 +641,6 @@ static void msTransformToGeospatialPDF(imageObj *img, mapObj *map, cairo_rendere
646641
VSIUnlink(pszTmpFilename);
647642

648643
msFree(pszTmpFilename);
649-
#endif
650644
}
651645

652646
int saveImageCairo(imageObj *img, mapObj *map, FILE *fp, outputFormatObj *format)

Diff for: mapchart.c

+3-6
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ int getNextShape(mapObj *map, layerObj *layer, double *values, int *nvalues, sty
249249
int c;
250250
status = msLayerNextShape(layer, shape);
251251
if(status == MS_SUCCESS) {
252-
#ifdef USE_PROJ
252+
253253
if(layer->project)
254254
{
255255
if( layer->reprojectorLayerToMap == NULL )
@@ -263,7 +263,6 @@ int getNextShape(mapObj *map, layerObj *layer, double *values, int *nvalues, sty
263263
}
264264
msProjectShapeEx(layer->reprojectorLayerToMap, shape);
265265
}
266-
#endif
267266

268267
if(msBindLayerToShape(layer, shape, MS_DRAWMODE_FEATURES|MS_DRAWMODE_LABELS) != MS_SUCCESS)
269268
return MS_FAILURE; /* error message is set in msBindLayerToShape() */
@@ -372,9 +371,9 @@ int msDrawPieChartLayer(mapObj *map, layerObj *layer, imageObj *image)
372371
return MS_FAILURE;
373372
}
374373
}
375-
#ifdef USE_PROJ
374+
376375
layer->project = msProjectionsDiffer(&(layer->projection), &(map->projection));
377-
#endif
376+
378377
/* step through the target shapes */
379378
msInitShape(&shape);
380379

@@ -631,10 +630,8 @@ int msDrawChartLayer(mapObj *map, layerObj *layer, imageObj *image)
631630
searchrect.maxy = map->height-1;
632631
}
633632

634-
#ifdef USE_PROJ
635633
if((map->projection.numargs > 0) && (layer->projection.numargs > 0))
636634
msProjectRect(&map->projection, &layer->projection, &searchrect); /* project the searchrect to source coords */
637-
#endif
638635

639636
status = msLayerWhichShapes(layer, searchrect, MS_FALSE);
640637
if(status == MS_DONE) { /* no overlap */

0 commit comments

Comments
 (0)