Skip to content
Permalink
Browse files
Assert our addiction to GDAL and PROJ, and make them required depende…
…ncies

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.
  • Loading branch information
rouault committed Nov 29, 2019
1 parent 008b38c commit af67552cbeb00242d20e345818caf4cf682ae7f8
Show file tree
Hide file tree
Showing 54 changed files with 117 additions and 1,296 deletions.
@@ -119,7 +119,6 @@ int main(int argc, char **argv) {
include_directories(${CMAKE_CURRENT_BINARY_DIR})

#options suported by the cmake builder
option(WITH_PROJ "Choose if reprojection support should be built in" ON)
option(WITH_PROTOBUFC "Choose if protocol buffers support should be built in (required for vector tiles)" ON)
option(WITH_KML "Enable native KML output support (requires libxml2 support)" OFF)
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)
option(WITH_FCGI "Choose if FastCGI support should be built in" ON)
option(WITH_GEOS "Choose if GEOS geometry operations support should be built in" ON)
option(WITH_POSTGIS "Choose if Postgis input support should be built in" ON)
option(WITH_GDAL "Choose if GDAL input raster support should be built in" ON)
option(WITH_OGR "Choose if OGR/GDAL input vector support should be built in" ON)
option(WITH_CLIENT_WMS "Enable Client WMS Layer support (requires CURL and GDAL support)" OFF)
option(WITH_CLIENT_WFS "Enable Client WMS Layer support (requires CURL and OGR support)" OFF)
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})
list(APPEND ALL_INCLUDE_DIRS ${FREETYPE_INCLUDE_DIR})


if(WITH_PROJ)
find_package(Proj)
if(NOT PROJ_FOUND)
report_optional_not_found(PROJ)
else(NOT PROJ_FOUND)
include_directories(${PROJ_INCLUDE_DIR})
ms_link_libraries( ${PROJ_LIBRARY})
list(APPEND ALL_INCLUDE_DIRS ${PROJ_INCLUDE_DIR})
set (USE_PROJ 1)
endif(NOT PROJ_FOUND)
endif (WITH_PROJ)
find_package(Proj)
if(NOT PROJ_FOUND)
report_mandatory_not_found(PROJ)
endif(NOT PROJ_FOUND)

include_directories(${PROJ_INCLUDE_DIR})
ms_link_libraries( ${PROJ_LIBRARY})
list(APPEND ALL_INCLUDE_DIRS ${PROJ_INCLUDE_DIR})

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

if(WITH_WMS)
if(USE_PROJ)
set(USE_WMS_SVR 1)
else(USE_PROJ)
report_dependency_error(WMS PROJ)
endif(USE_PROJ)
set(USE_WMS_SVR 1)
endif(WITH_WMS)

if(WITH_FRIBIDI)
@@ -591,17 +581,14 @@ if(WITH_POSTGIS)
endif(POSTGRESQL_FOUND)
endif (WITH_POSTGIS)

if(WITH_GDAL)
find_package(GDAL)
if(GDAL_FOUND)
include_directories(${GDAL_INCLUDE_DIR})
ms_link_libraries( ${GDAL_LIBRARY})
list(APPEND ALL_INCLUDE_DIRS ${GDAL_INCLUDE_DIR})
set (USE_GDAL 1)
else(GDAL_FOUND)
report_optional_not_found(GDAL)
endif(GDAL_FOUND)
endif (WITH_GDAL)
find_package(GDAL)
if(NOT GDAL_FOUND)
report_mandatory_not_found(GDAL)
endif(NOT GDAL_FOUND)

include_directories(${GDAL_INCLUDE_DIR})
ms_link_libraries( ${GDAL_LIBRARY})
list(APPEND ALL_INCLUDE_DIRS ${GDAL_INCLUDE_DIR})

if(WITH_SVGCAIRO)
if(WITH_RSVG)
@@ -636,25 +623,6 @@ if(WITH_RSVG)
endif(RSVG_FOUND AND GOBJECT_FOUND)
endif (WITH_RSVG)

if(WITH_OGR)
if(GDAL_FOUND)
set (USE_OGR 1)
else(GDAL_FOUND)
find_package(GDAL)
if(GDAL_FOUND)
include_directories(${GDAL_INCLUDE_DIR})
ms_link_libraries( ${GDAL_LIBRARY})
list(APPEND ALL_INCLUDE_DIRS ${GDAL_INCLUDE_DIR})
set (USE_OGR 1)
else(GDAL_FOUND)
message(SEND_ERROR "GDAL library could not be found and is needed for OGR support.
HINTS:
- disable OGR support by adding -DWITH_OGR=0
- add the GDAL install directory to the CMAKE_PREFIX_PATH variable (-DCMAKE_PREFIX_PATH=\"/path/to/${component}-install-dir;/path/to/other/dirs\"")
endif(GDAL_FOUND)
endif(GDAL_FOUND)
endif(WITH_OGR)

if(WITH_CLIENT_WMS OR WITH_CLIENT_WFS)
set(WITH_CURL ON)
endif(WITH_CLIENT_WMS OR WITH_CLIENT_WFS)
@@ -683,56 +651,19 @@ if(WITH_CLIENT_WMS OR WITH_CLIENT_WFS)
endif(WITH_CLIENT_WMS OR WITH_CLIENT_WFS)

if(WITH_CLIENT_WMS)
if(USE_GDAL AND USE_PROJ)
set(USE_WMS_LYR 1)
else(USE_GDAL AND USE_PROJ)
if(NOT USE_GDAL)
report_dependency_error(CLIENT_WMS GDAL)
endif(NOT USE_GDAL)
if( NOT USE_PROJ)
report_dependency_error(CLIENT_WMS PROJ)
endif(NOT USE_PROJ)
endif(USE_GDAL AND USE_PROJ)
set(USE_WMS_LYR 1)
endif(WITH_CLIENT_WMS)

if(WITH_CLIENT_WFS)
if(USE_OGR AND USE_PROJ)
set(USE_WFS_LYR 1)
else(USE_OGR AND USE_PROJ)
if(NOT USE_OGR)
report_dependency_error(CLIENT_WFS OGR)
endif(NOT USE_OGR)
if( NOT USE_PROJ)
report_dependency_error(CLIENT_WFS PROJ)
endif(NOT USE_PROJ)
endif(USE_OGR AND USE_PROJ)
set(USE_WFS_LYR 1)
endif(WITH_CLIENT_WFS)

if(WITH_WFS)
if(USE_PROJ AND USE_OGR)
set(USE_WFS_SVR 1)
#TODO: set WFS_USE_LIBXML2 ?
else(USE_PROJ AND USE_OGR)
if( NOT USE_OGR)
report_dependency_error(WFS OGR)
endif( NOT USE_OGR)
if( NOT USE_PROJ)
report_dependency_error(WFS PROJ)
endif( NOT USE_PROJ)
endif(USE_PROJ AND USE_OGR)
set(USE_WFS_SVR 1)
endif(WITH_WFS)

if(WITH_WCS)
if(USE_PROJ AND USE_GDAL)
set(USE_WCS_SVR 1)
else(USE_PROJ AND USE_GDAL)
if(NOT USE_GDAL)
report_dependency_error(WCS GDAL)
endif(NOT USE_GDAL)
if(NOT USE_PROJ)
report_dependency_error(WCS PROJ)
endif(NOT USE_PROJ)
endif(USE_PROJ AND USE_GDAL)
set(USE_WCS_SVR 1)
endif(WITH_WCS)

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

if(WITH_SOS)
if(NOT USE_OGR)
report_dependency_error(WITH_SOS OGR)
endif(NOT USE_OGR)

if(USE_PROJ AND USE_LIBXML2)
if(USE_LIBXML2)
set(USE_SOS_SVR 1)
else(USE_PROJ AND USE_LIBXML2)
if(NOT USE_LIBXML2)
report_dependency_error(SOS LIBXML2)
endif(NOT USE_LIBXML2)
if(NOT USE_PROJ)
report_dependency_error(SOS PROJ)
endif(NOT USE_PROJ)
endif(USE_PROJ AND USE_LIBXML2)
else(USE_LIBXML2)
report_dependency_error(SOS LIBXML2)
endif(USE_LIBXML2)
endif(WITH_SOS)

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

message(STATUS "* Summary of configured options for this build")
message(STATUS " * Mandatory components")
message(STATUS " * GDAL: ${GDAL_LIBRARY}")
message(STATUS " * PROJ: ${PROJ_LIBRARY}")
message(STATUS " * png: ${PNG_LIBRARY}")
message(STATUS " * jpeg: ${JPEG_LIBRARY}")
message(STATUS " * freetype: ${FREETYPE_LIBRARY}")
message(STATUS " * Optional components")
status_optional_component("GDAL" "${USE_GDAL}" "${GDAL_LIBRARY}")
status_optional_component("OGR" "${USE_OGR}" "${GDAL_LIBRARY}")
status_optional_component("GIF" "${USE_GIF}" "${GIF_LIBRARY}")
status_optional_component("MYSQL" "${USE_MYSQL}" "${MYSQL_LIBRARY}")
status_optional_component("FRIBIDI" "${USE_FRIBIDI}" "${FRIBIDI_LIBRARY}")
@@ -959,7 +881,6 @@ status_optional_component("CAIRO" "${USE_CAIRO}" "${CAIRO_LIBRARY}")
status_optional_component("SVGCAIRO" "${USE_SVG_CAIRO}" "${SVGCAIRO_LIBRARY}")
status_optional_component("RSVG" "${USE_RSVG}" "${RSVG_LIBRARY}")
status_optional_component("CURL" "${USE_CURL}" "${CURL_LIBRARY}")
status_optional_component("PROJ" "${USE_PROJ}" "${PROJ_LIBRARY}")
status_optional_component("PIXMAN" "${USE_PIXMAN}" "${PIXMAN_LIBRARY}")
status_optional_component("LIBXML2" "${USE_LIBXML2}" "${LIBXML2_LIBRARY}")
status_optional_component("POSTGIS" "${USE_POSTGIS}" "${POSTGRESQL_LIBRARY}")
@@ -31,12 +31,6 @@

#include "mapserver.h"

#ifdef USE_GDAL
# include "gdal.h"
# include "cpl_conv.h"
#endif



/*
** Add a label to a classObj (order doesn't matter for labels like it does with styles)
@@ -172,10 +172,8 @@ int msHitTestLayer(mapObj *map, layerObj *layer, layer_hittest *hittest) {
/* identify target shapes */
if(layer->transform == MS_TRUE) {
searchrect = map->extent;
#ifdef USE_PROJ
if((map->projection.numargs > 0) && (layer->projection.numargs > 0))
msProjectRect(&map->projection, &layer->projection, &searchrect); /* project the searchrect to source coords */
#endif
}
else {
searchrect.minx = searchrect.miny = 0;
@@ -28,7 +28,6 @@

#include "mapserver.h"
#include <float.h>
#ifdef USE_GDAL

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

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

status = msLayerWhichShapes(layer, searchrect, MS_FALSE);
/* nothing to do */
@@ -199,7 +196,7 @@ int msComputeKernelDensityDataset(mapObj *map, imageObj *image, layerObj *kernel
double weight = 1.0;
if(!values) /* defer allocation until we effectively have a feature */
values = (float*) msSmallCalloc(im_width * im_height, sizeof(float));
#ifdef USE_PROJ

if(layer->project)
{
if( layer->reprojectorLayerToMap == NULL )
@@ -215,8 +212,7 @@ int msComputeKernelDensityDataset(mapObj *map, imageObj *image, layerObj *kernel
}
msProjectShapeEx(layer->reprojectorLayerToMap, &shape);
}
#endif


/* the weight for the sample is set to 1.0 by default. If the
* layer has some classes defined, we will read the weight from
* the class->style->size (which can be binded to an attribute)
@@ -345,15 +341,6 @@ int msComputeKernelDensityDataset(mapObj *map, imageObj *image, layerObj *kernel
}
return status;
}
#else


int msComputeKernelDensityDataset(mapObj *map, imageObj *image, layerObj *layer, void **hDSvoid, void **cleanup_ptr) {
msSetError(MS_MISCERR,"msComputeKernelDensityDataset()", "KernelDensity layers require GDAL support, however GDAL support is not compiled in this build");
return MS_FAILURE;
}

#endif

int msCleanupKernelDensityDataset(mapObj *map, imageObj *image, layerObj *layer, void *cleanup_ptr) {
free(cleanup_ptr);
@@ -31,12 +31,6 @@

#include "mapserver.h"

#ifdef USE_GDAL
# include "gdal.h"
# include "cpl_conv.h"
#endif



/* ===========================================================================
msInsertClass
@@ -55,10 +55,8 @@
#endif
#endif

#ifdef USE_GDAL
#include <cpl_string.h>
#include <gdal.h>
#endif

#include "fontcache.h"

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

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

msFree(pszTmpFilename);
#endif
}

int saveImageCairo(imageObj *img, mapObj *map, FILE *fp, outputFormatObj *format)
@@ -249,7 +249,7 @@ int getNextShape(mapObj *map, layerObj *layer, double *values, int *nvalues, sty
int c;
status = msLayerNextShape(layer, shape);
if(status == MS_SUCCESS) {
#ifdef USE_PROJ

if(layer->project)
{
if( layer->reprojectorLayerToMap == NULL )
@@ -263,7 +263,6 @@ int getNextShape(mapObj *map, layerObj *layer, double *values, int *nvalues, sty
}
msProjectShapeEx(layer->reprojectorLayerToMap, shape);
}
#endif

if(msBindLayerToShape(layer, shape, MS_DRAWMODE_FEATURES|MS_DRAWMODE_LABELS) != MS_SUCCESS)
return MS_FAILURE; /* error message is set in msBindLayerToShape() */
@@ -372,9 +371,9 @@ int msDrawPieChartLayer(mapObj *map, layerObj *layer, imageObj *image)
return MS_FAILURE;
}
}
#ifdef USE_PROJ

layer->project = msProjectionsDiffer(&(layer->projection), &(map->projection));
#endif

/* step through the target shapes */
msInitShape(&shape);

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

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

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

0 comments on commit af67552

Please sign in to comment.