diff --git a/BUILDING.md b/BUILDING.md
index acf7e37ace9..e46aabfee1f 100644
--- a/BUILDING.md
+++ b/BUILDING.md
@@ -26,13 +26,13 @@ To build GMT, you have to install:
- [CMake](https://cmake.org/) (>=2.8.12)
- [netCDF](https://www.unidata.ucar.edu/software/netcdf/) (>=4.0, netCDF-4/HDF5 support mandatory)
- [curl](https://curl.haxx.se/)
+- [GDAL](https://www.gdal.org/) (Ability to read and write numerous grid and image formats)
### Optional dependencies
Optionally install these for more capabilities within GMT:
- [Ghostscript](https://www.ghostscript.com/) (Ability to convert PostScript plots to PDF and rasters)
-- [GDAL](https://www.gdal.org/) (Ability to read and write numerous grid and image formats)
- [GEOS](https://trac.osgeo.org/geos/) (Ability to buffer lines and polygons)
- [PCRE](https://www.pcre.org/) or PCRE2 (Regular expression support)
- [FFTW](http://www.fftw.org/) single-precision (Fast FFTs, >=3.3 [not needed under macOS])
diff --git a/cmake/ConfigUserAdvancedTemplate.cmake b/cmake/ConfigUserAdvancedTemplate.cmake
index e7150bb2765..8896ee70f42 100644
--- a/cmake/ConfigUserAdvancedTemplate.cmake
+++ b/cmake/ConfigUserAdvancedTemplate.cmake
@@ -46,8 +46,7 @@
# Make executables relocatable on supported platforms (relative RPATH) [FALSE]:
#set (GMT_INSTALL_RELOCATABLE TRUE)
-# Exclude optional GDAL, GEOS ,PCRE, PCRE2, FFTW3, LAPACK, BLAS, ZLIB dependencies even if you have them installed [FALSE]
-#set (GMT_EXCLUDE_GDAL TRUE)
+# Exclude optional GEOS, PCRE, PCRE2, FFTW3, LAPACK, BLAS, ZLIB dependencies even if you have them installed [FALSE]
#set (GMT_EXCLUDE_GEOS TRUE)
#set (GMT_EXCLUDE_PCRE TRUE)
#set (GMT_EXCLUDE_PCRE2 TRUE)
diff --git a/doc/examples/ex32/ex32.bat b/doc/examples/ex32/ex32.bat
index 34eab0e33c9..1a36f5db181 100644
--- a/doc/examples/ex32/ex32.bat
+++ b/doc/examples/ex32/ex32.bat
@@ -10,8 +10,7 @@ gmt begin ex32
REM Here we get and convert the flag of Europe directly from the web through grdconvert using
REM GDAL support. We take into account the dimension of the flag (1000x667 pixels)
REM for a ratio of 3x2.
- REM Because GDAL support will not be standard for most users, we have stored
- REM the result, @euflag.nc in this directory.
+ REM To simplify the example, we have stored the result, @euflag.nc in this directory.
set Rflag=-R3/9/50/54
REM gmt grdconvert \
diff --git a/doc/examples/ex32/ex32.sh b/doc/examples/ex32/ex32.sh
index 30db2ee77f6..970bfe159f6 100755
--- a/doc/examples/ex32/ex32.sh
+++ b/doc/examples/ex32/ex32.sh
@@ -11,8 +11,7 @@ gmt begin ex32
# Here we get and convert the flag of Europe directly from the web through grdconvert using
# GDAL support. We take into account the dimension of the flag (1000x667 pixels)
# for a ratio of 3x2.
- # Because GDAL support will not be standard for most users, we have stored
- # the result, @euflag.nc in this directory.
+ # So simplify this example, we have stored the result, @euflag.nc in this directory.
Rflag=-R3/9/50/54
# gmt grdconvert \
diff --git a/doc/rst/source/cookbook/features.rst b/doc/rst/source/cookbook/features.rst
index 45f4cca7f5c..e0d596acca9 100644
--- a/doc/rst/source/cookbook/features.rst
+++ b/doc/rst/source/cookbook/features.rst
@@ -1028,8 +1028,8 @@ use **-G** for this task and some have several options specifying different fill
Due to PostScript implementation limitations the raster images used
with **-G** must be less than 146 x 146 pixels in size; for larger
images see :doc:`/image`. The format of Sun raster files [18]_ is
-outlined in Chapter :doc:`file-formats`. However, if you built GMT
-with GDAL then other image formats can be used as well. Note that under
+outlined in Chapter :doc:`file-formats`; other image formats can be
+used as well. Note that under
PostScript Level 1 the patterns are filled by using the polygon as a
*clip path*. Complex clip paths may require more memory than the
PostScript interpreter has been assigned. There is therefore the
@@ -2391,7 +2391,7 @@ approach should contact the GMT team for guidance.
+----------+---------------------------------------------------------------+
| ef | ESRI Arc/Info ASCII Grid Interchange format (ASCII float) |
+----------+---------------------------------------------------------------+
-| gd | Import/export via GDAL [19]_ |
+| gd | Import/export via GDAL |
+----------+---------------------------------------------------------------+
Because some formats have limitations on the range of values they can
@@ -2685,8 +2685,7 @@ unit of the z-coordinate. The default is simply "z".
Modifiers to read and write grids and images via GDAL
-----------------------------------------------------
-If the support has been configured during installation, then GMT can
-read and write a variety of grid and image formats via GDAL. This
+GMT can read and write a variety of grid and image formats via GDAL. This
extends the capability of GMT to handle data sets from a variety of
sources.
@@ -2958,6 +2957,3 @@ Footnotes
.. [18]
Convert other graphics formats to Sun ras format using GraphicsMagick's or ImageMagick's **convert** program.
-
-.. [19]
- Requires building GMT with GDAL.
diff --git a/doc/rst/source/cookbook/file-formats.rst b/doc/rst/source/cookbook/file-formats.rst
index 46b252bf520..209b94f0bbe 100644
--- a/doc/rst/source/cookbook/file-formats.rst
+++ b/doc/rst/source/cookbook/file-formats.rst
@@ -97,9 +97,9 @@ reads, but does not write, netCDF tabular data.
Shapefiles
~~~~~~~~~~
-GMT programs that read tables also support ESRI shapefiles, provided GMT was compiled
-with GDAL support. By default, only the geographic coordinates are read. To select
-some or all aspatial fields, see the :ref:`-a option <-aspatial_full>`.
+GMT programs that read tables also support ESRI shapefiles. By default,
+only the geographic coordinates are read. To select some or all aspatial
+fields, see the :ref:`-a option <-aspatial_full>`.
Grid files
----------
diff --git a/doc/rst/source/cookbook/introduction.rst b/doc/rst/source/cookbook/introduction.rst
index b81641f4d13..7db083af487 100644
--- a/doc/rst/source/cookbook/introduction.rst
+++ b/doc/rst/source/cookbook/introduction.rst
@@ -117,7 +117,7 @@ grid files. One such program, :doc:`/surface`,
includes new modifications to the gridding algorithm developed by *Smith
and Wessel* [1990] using continuous splines in tension. Optionally, GMT
can also read various binary and netCDF tables, as well as a variety of
-grid formats, especially if built with GDAL support.
+grid formats via GDAL.
Most of the programs will produce some form of output, which falls into
four categories. Several of the programs may produce more than one of
diff --git a/doc/rst/source/datasets/remote-data.rst b/doc/rst/source/datasets/remote-data.rst
index 0cc4e061046..b08ab68b398 100644
--- a/doc/rst/source/datasets/remote-data.rst
+++ b/doc/rst/source/datasets/remote-data.rst
@@ -103,8 +103,8 @@ Single grids are provided as netCDF-4 maximum-lossless compressed short int grid
much smaller than their original source files without any loss of precision. To minimize download
speed, the dataset tiles are all stored as JPEG2000 images on the GMT server due to superior compression,
but once downloaded to your server directory they are converted to the same short int compressed netCDF4
-format for easier access. This step uses our GDAL bridge and thus requires that you have built GMT with
-GDAL support *and* that your GDAL distribution was built with *openjpeg* support.
+format for easier access. This step uses our GDAL bridge and requires that your GDAL distribution was
+built with *openjpeg* support.
.. _jp2_compression:
diff --git a/doc/rst/source/explain_-Jproj_full.rst_ b/doc/rst/source/explain_-Jproj_full.rst_
index 1f2178f3b9c..12d7ca98047 100644
--- a/doc/rst/source/explain_-Jproj_full.rst_
+++ b/doc/rst/source/explain_-Jproj_full.rst_
@@ -1,6 +1,6 @@
**-J**\ *proj*\|\ **EPSG:n**
Starting at GMT6 it is possible to use the `PROJ `_ library to do coordinate and datum transforms.
- This is achieved via GDAL so it requires that GMT build is linked to that library. It is, however,
+ This is achieved via the GDAL library. It is, however,
beyond the scope of this manual to document the **PROJ** syntax (that is the syntax of the **proj**
and **cs2cs** programs) so users are referred to `PROJ Applications `_ for the details.
diff --git a/doc/rst/source/gallery/ex32.rst b/doc/rst/source/gallery/ex32.rst
index 39dcaf26f76..ed71b0e6d78 100644
--- a/doc/rst/source/gallery/ex32.rst
+++ b/doc/rst/source/gallery/ex32.rst
@@ -16,9 +16,8 @@ Bonn. Obviously, the flag of the European Union came to mind as a good
To avoid adding large files to this example, some steps have been
already done. First we get the EU flag directly from the web and convert
it to a grid with values ranging from 0 to 255, where the higher values
-will become yellow and the lower values blue. This use of
-:doc:`grdconvert ` requires GDAL support.
-:doc:`grdedit ` then adds the right grid dimension.
+will become yellow and the lower values blue. Then,
+:doc:`grdedit ` adds the right grid dimension.
The second step is to reformat the GTOPO30 DEM file to a netCDF grid as
well and then subsample it at the same pixels as the EU flag. We then
@@ -37,8 +36,7 @@ symbols and names for cities.
The script produces the plot in the Figure `fig_ex32`. Note
that the PNG image of the flag can be downloaded directly in the call
the :doc:`grdconvert `, but we have
-commented that out in the example because it requires compilation with
-GDAL support. You will also see the
+commented that out in the example. You will also see the
:doc:`grdcut ` command commented out because we
did not want to store the 58 MB DEM file, whose location is mentioned in the script.
diff --git a/doc/rst/source/gallery/ex51.rst b/doc/rst/source/gallery/ex51.rst
index 088739266ad..a834640a224 100644
--- a/doc/rst/source/gallery/ex51.rst
+++ b/doc/rst/source/gallery/ex51.rst
@@ -8,8 +8,8 @@ project `_ in GMT. When working with the high
resolution SRTM :doc:`/datasets` provided by GMT, the GSHHG coastlines might
not be precise enough on small scales. Here comes the OSM project to the rescue
as it provides high resolution coastlines in the WGS84 datum. Not as convenient
-and fast as GSHHG but easy enough to give it a try – as long as you have GDAL
-installed, space on your hard drive and some processor cycles to spare.
+and fast as GSHHG but easy enough to give it a try – as long as you have space
+on your hard drive and some processor cycles to spare.
.. note::
This example makes use of data provided by third parties outside the GMT
@@ -26,8 +26,7 @@ in the *Large polygons not split* version with WGS84 datum from their `download
page `_. It’s a
~630 MB download.
-If your GMT installation comes with GDAL support then you are able to make use
-of this file right away as GMT converts it under the hood to something more
+You may use this file right away as GMT converts it under the hood to something more
useful on the fly. Neither very fast nor very efficient if you want to use the
file multiple times and have to deal with large file sizes as we do here. So we
use `GDAL's `_ *ogr2ogr* and convert the shape file to a native GMT format.
diff --git a/doc/rst/source/gmt-config.rst b/doc/rst/source/gmt-config.rst
index 0e94208412a..2f39a4ca89d 100644
--- a/doc/rst/source/gmt-config.rst
+++ b/doc/rst/source/gmt-config.rst
@@ -18,7 +18,7 @@ Description
**gmt-config** is used by developers who need to know technical information
about the current GMT installation, such as what include files to supply,
-the path to the library, or if it was built with GDAL support, and more.
+the path to the library, and more.
Required Arguments
------------------
@@ -61,9 +61,6 @@ Optional Arguments
**--has-fftw**
Whether FFTW is used in build.
-**--has-gdal**
- Whether GDAL is used in build.
-
**--has-pcre**
Whether PCRE is used in build.
diff --git a/doc/rst/source/grdimage-classic.rst b/doc/rst/source/grdimage-classic.rst
index 74923551fd0..61c0e3808e6 100644
--- a/doc/rst/source/grdimage-classic.rst
+++ b/doc/rst/source/grdimage-classic.rst
@@ -82,8 +82,7 @@ tickmarks every 5 units:
gmt grdimage red.nc green.nc blue.nc -Jx10i -B5 -P > rgbimage.ps
-When GDAL support is built in: To create a sinusoidal projection of a
-remotely located Jessica Rabbit
+To create a sinusoidal projection of a remotely located Jessica Rabbit
::
diff --git a/doc/rst/source/grdimage.rst b/doc/rst/source/grdimage.rst
index e1d7a817929..0ea4f928fd7 100644
--- a/doc/rst/source/grdimage.rst
+++ b/doc/rst/source/grdimage.rst
@@ -49,8 +49,8 @@ intensities in the (-1,+1) range or instructions to derive intensities
from the input data grid. Values outside this range will be
clipped. Such intensity files can be created from the grid using
:doc:`grdgradient` and, optionally, modified by :doc:`grdmath` or
-:doc:`grdhisteq`. A third alternative is available when GMT is built
-with GDAL support. Pass *image* which can be an image file (geo-referenced or not).
+:doc:`grdhisteq`. Alternatively , pass *image* which can be an image
+file (geo-referenced or not).
In this case the image can optionally be illuminated with the
file provided via the **-I** option. Here, if image has no coordinates
then those of the intensity file will be used.
@@ -87,9 +87,7 @@ Optional Arguments
.. _-A:
**-A**\ *out_img*\ [**=**\ *driver*]
- Save an image in a raster format instead of PostScript. Use extension .ppm for a Portable
- Pixel Map format which is the only raster format GMT can natively write. For GMT installations
- configured with GDAL support there are more choices: Append *out_img* to select
+ Save an image in a raster format instead of PostScript. Append *out_img* to select
the image file name and extension. If the extension is one of .bmp, .gif, .jpg, .png, or .tif
then no driver information is required. For other output formats you must append the required
GDAL driver. The *driver* is the driver code name used by GDAL; see your GDAL installation's
@@ -290,8 +288,7 @@ tickmarks every 5 units::
gmt grdimage red.nc green.nc blue.nc -Jx10i -B5 -pdf rgbimage
-When GDAL support is built in: To create a sinusoidal projection of a
-remotely located Jessica Rabbit::
+To create a sinusoidal projection of a remotely located Jessica Rabbit::
gmt grdimage -JI15c -Rd http://larryfire.files.wordpress.com/2009/07/untooned_jessicarabbit.jpg -pdf jess
diff --git a/doc/rst/source/image.rst b/doc/rst/source/image.rst
index 3493f0d7e90..f7806e99d27 100644
--- a/doc/rst/source/image.rst
+++ b/doc/rst/source/image.rst
@@ -57,8 +57,6 @@ Required Arguments
This must be an Encapsulated PostScript (EPS) file or a raster
image. An EPS file must contain an appropriate BoundingBox. A raster
file can have a depth of 1, 8, 24, or 32 bits and is read via GDAL.
- **Note**: If GDAL was not configured during GMT installation then only
- EPS files are supported.
Optional Arguments
------------------
diff --git a/doc/rst/source/psconvert.rst b/doc/rst/source/psconvert.rst
index 3cfe03ad2be..6446bc699a2 100644
--- a/doc/rst/source/psconvert.rst
+++ b/doc/rst/source/psconvert.rst
@@ -272,7 +272,7 @@ Optional Arguments
**psconvert** can create a georeferenced raster image with a world
file OR uses GDAL to convert the GMT PostScript file to geotiff.
GDAL uses `PROJ `_ for its projection library. To provide with the
- information it needs to do the georeferencing, GMT 4.5 embeds a
+ information it needs to do the georeferencing, GMT embeds a
comment near the start of the PostScript file defining the
projection using **PROJ** syntax. Users with pre-GMT v4.5 PostScript
files, or even non-GMT ps files, can provide the information
diff --git a/doc/rst/source/surface.rst b/doc/rst/source/surface.rst
index 4069d6edb78..08d6b790844 100644
--- a/doc/rst/source/surface.rst
+++ b/doc/rst/source/surface.rst
@@ -121,7 +121,7 @@ Optional Arguments
.. |Add_-J| replace::
Select the data map projection. This projection is only used to add a referencing info
- to the grid formats that support it. E.g. netCDF, GeoTIFF, and others supported by GDAL.
+ to the grid formats that support it. E.g., netCDF, GeoTIFF, and others supported by GDAL.
.. include:: explain_-J.rst_
:start-after: **Syntax**
:end-before: **Description**
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 71eb17f771a..9acc139a86e 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -145,14 +145,9 @@ include_directories (${CURL_INCLUDE_DIRS})
list (APPEND GMT_OPTIONAL_LIBRARIES ${CURL_LIBRARIES})
set (CURL_LIBRARY ${CURL_LIBRARIES} CACHE INTERNAL "")
-if (NOT DEFINED GMT_EXCLUDE_GDAL)
- find_package (GDAL)
-endif (NOT DEFINED GMT_EXCLUDE_GDAL)
-if (GDAL_FOUND)
- set (HAVE_GDAL TRUE CACHE INTERNAL "System has GDAL")
- include_directories (${GDAL_INCLUDE_DIR})
- list (APPEND GMT_OPTIONAL_LIBRARIES ${GDAL_LIBRARIES})
-endif (GDAL_FOUND)
+find_package (GDAL REQUIRED)
+include_directories (${GDAL_INCLUDE_DIR})
+list (APPEND GMT_OPTIONAL_LIBRARIES ${GDAL_LIBRARIES})
if (NOT DEFINED GMT_EXCLUDE_GEOS)
find_package (GEOS)
diff --git a/src/gmt-config.in b/src/gmt-config.in
index d58490d096f..12443b863ed 100755
--- a/src/gmt-config.in
+++ b/src/gmt-config.in
@@ -50,12 +50,6 @@ else
CONFIG_FFTW_ENABLED=no
fi
-if [ "@HAVE_GDAL@" == "TRUE" ]; then
- CONFIG_GDAL_ENABLED=yes
-else
- CONFIG_GDAL_ENABLED=no
-fi
-
if [ "@HAVE_PCRE@" == "TRUE" ] || [ "@HAVE_PCRE2@" == "TRUE" ]; then
CONFIG_PCRE_ENABLED=yes
else
@@ -98,7 +92,6 @@ Available values for OPTIONS include:
--dep-libs dependent libraries
--gshhg location of used GSHHG
--has-fftw whether FFTW is used in build
- --has-gdal whether GDAL is used in build
--has-pcre whether PCRE is used in build
--has-lapack whether LAPACK is used in build
--has-openmp whether GMT was built with OpenMP support
@@ -129,7 +122,6 @@ This GMT $CONFIG_VERSION has been built with the following features:
--dep-libs -> ${CONFIG_DEP_LIBS//;/ }
--gshhg -> $CONFIG_GSHHG
--has-fftw -> $CONFIG_FFTW_ENABLED
- --has-gdal -> $CONFIG_GDAL_ENABLED
--has-pcre -> $CONFIG_PCRE_ENABLED
--has-lapack -> $CONFIG_LAPACK_ENABLED
--has-openmp -> $CONFIG_OPENMP_ENABLED
@@ -187,10 +179,6 @@ for arg in "$@"; do
echo $CONFIG_FFTW_ENABLED
;;
- --has-gdal)
- echo $CONFIG_GDAL_ENABLED
- ;;
-
--has-pcre)
echo $CONFIG_PCRE_ENABLED
;;
diff --git a/src/gmt.c b/src/gmt.c
index 04ff8136ee7..5a5390c331a 100644
--- a/src/gmt.c
+++ b/src/gmt.c
@@ -326,10 +326,7 @@ int main (int argc, char *argv[]) {
fprintf (stderr, "Shared libraries must be in standard system paths or set via environmental parameter %s.\n\n", LIB_PATH);
}
else {
- char libraries[GMT_LEN128] = {"netCDF"}; /* Always linked with netCDF */
-#ifdef HAVE_GDAL
- strcat (libraries, ", GDAL");
-#endif
+ char libraries[GMT_LEN128] = {"netCDF, GDAL"}; /* Always linked with netCDF and GDAL */
#ifdef HAVE_PCRE
strcat (libraries, ", PCRE");
#endif
diff --git a/src/gmt_api.c b/src/gmt_api.c
index 0faa5c054c2..67973a50f01 100644
--- a/src/gmt_api.c
+++ b/src/gmt_api.c
@@ -4505,7 +4505,6 @@ GMT_LOCAL int gmtapi_import_ppm (struct GMT_CTRL *GMT, char *fname, struct GMT_I
return GMT_NOERROR;
}
-#ifdef HAVE_GDAL
GMT_LOCAL bool gmtapi_expand_index_image (struct GMT_CTRL *GMT, struct GMT_IMAGE *I_in, struct GMT_IMAGE **I_out) {
/* In most situations we can use an input image given to a module as the dataset to
* plot. However, if the image is indexed then we must expand it to rgb since we may
@@ -4603,7 +4602,6 @@ void gmtlib_GDALDestroyDriverManager (struct GMTAPI_CTRL *API) {
/* Cannot close connection to GDAL if calling environment expect it to be open */
if (API->external < 2) GDALDestroyDriverManager();
}
-#endif
/*! . */
GMT_LOCAL struct GMT_IMAGE *gmtapi_import_image (struct GMTAPI_CTRL *API, int object_ID, unsigned int mode, struct GMT_IMAGE *image) {
@@ -4618,10 +4616,11 @@ GMT_LOCAL struct GMT_IMAGE *gmtapi_import_image (struct GMTAPI_CTRL *API, int ob
*/
int item, new_item, new_ID;
- bool done = true, via = false, must_be_image = true, no_index = false, bc_not_set = true;
+ bool done = true, via = false, must_be_image = true, no_index = false, bc_not_set = true, new = false;
uint64_t ij, ij_orig;
openmp_int row, col, i0, i1, j0, j1;
unsigned int both_set = (GMT_CONTAINER_ONLY | GMT_DATA_ONLY);
+ size_t size;
double dx, dy, d;
p_func_uint64_t GMT_2D_to_index = NULL;
GMT_getfunction api_get_val = NULL;
@@ -4632,11 +4631,7 @@ GMT_LOCAL struct GMT_IMAGE *gmtapi_import_image (struct GMTAPI_CTRL *API, int ob
struct GMT_GRID_HEADER_HIDDEN *HH = NULL;
struct GMTAPI_DATA_OBJECT *S_obj = NULL;
struct GMT_CTRL *GMT = API->GMT;
-#ifdef HAVE_GDAL
- bool new = false;
- size_t size;
struct GMT_IMAGE *Irgb = NULL;
-#endif
GMT_Report (API, GMT_MSG_DEBUG, "gmtapi_import_image: Passed ID = %d and mode = %d\n", object_ID, mode);
@@ -4658,7 +4653,6 @@ GMT_LOCAL struct GMT_IMAGE *gmtapi_import_image (struct GMTAPI_CTRL *API, int ob
switch (S_obj->method) {
case GMT_IS_FILE: /* Name of an image file on disk */
-#ifdef HAVE_GDAL
if (image == NULL) { /* Only allocate image struct when not already allocated */
if (mode & GMT_DATA_ONLY) return_null (API, GMT_NO_GRDHEADER); /* For mode & GMT_DATA_ONLY image must already be allocated */
I_obj = gmtlib_create_image (GMT);
@@ -4718,9 +4712,6 @@ GMT_LOCAL struct GMT_IMAGE *gmtapi_import_image (struct GMTAPI_CTRL *API, int ob
}
IH = gmt_get_I_hidden (I_obj);
IH->alloc_mode = GMT_ALLOC_INTERNALLY;
-#else
- GMT_Report (API, GMT_MSG_ERROR, "GDAL required to read image from file %s\n", S_obj->filename);
-#endif
break;
case GMT_IS_DUPLICATE: /* GMT image and header in a GMT_IMAGE container object. */
@@ -4896,7 +4887,6 @@ GMT_LOCAL struct GMT_IMAGE *gmtapi_import_image (struct GMTAPI_CTRL *API, int ob
if (done) S_obj->status = GMT_IS_USED; /* Mark as read (unless we just got the header) */
-#ifdef HAVE_GDAL
if (no_index) { /* true if we have an indexed image and we had to allocate a new one */
if (gmtapi_expand_index_image (API->GMT, I_obj, &Irgb)) { /* true if we have a read-only indexed image and we had to allocate a new one */
if (GMT_Destroy_Data (API, &I_obj) != GMT_NOERROR) {
@@ -4908,7 +4898,6 @@ GMT_LOCAL struct GMT_IMAGE *gmtapi_import_image (struct GMTAPI_CTRL *API, int ob
if (bc_not_set && gmt_M_err_pass (GMT, gmtlib_image_BC_set (GMT, I_obj), S_obj->filename))
return_null (API, GMT_IMAGE_BC_ERROR); /* Failed to set boundary conditions */
}
-#endif
if (!via) S_obj->resource = I_obj; /* Retain pointer to the allocated data so we use garbage collection later */
@@ -5003,13 +4992,8 @@ GMT_LOCAL int gmtapi_export_image (struct GMTAPI_CTRL *API, int object_ID, unsig
GMT_Report (API, GMT_MSG_ERROR, "Unable to export image\n");
return (gmtlib_report_error (API, GMT_ERROR_ON_FOPEN));
}
-#ifdef HAVE_GDAL
else if (gmt_M_err_pass (API->GMT, gmt_export_image (API->GMT, S_obj->filename, I_obj), S_obj->filename))
return (gmtlib_report_error (API, GMT_IMAGE_WRITE_ERROR));
-#else
- else
- GMT_Report (API, GMT_MSG_ERROR, "GDAL required to write image to file %s\n", S_obj->filename);
-#endif
break;
case GMT_IS_DUPLICATE: /* Duplicate GMT image to a new GMT_IMAGE container object */
@@ -13534,13 +13518,7 @@ int GMT_Get_Default (void *V_API, const char *keyword, char *value) {
else if (!strncmp (keyword, "API_CORES", 9U)) /* Report number of cores */
sprintf (value, "%d", API->n_cores);
else if (!strncmp (keyword, "API_IMAGE_LAYOUT", 16U)) { /* Report image/band layout */
-#ifdef HAVE_GDAL
gmt_M_memcpy (value, API->GMT->current.gdal_read_in.O.mem_layout, 4, char);
-#else
- GMT_Report (API, GMT_MSG_ERROR, "API_IMAGE_LAYOUT only available when GMT is linked with GDAL; request ignored");
- value[0] = '\0';
- error = GMT_NOT_A_VALID_ARG;
-#endif
}
else if (!strncmp (keyword, "API_GRID_LAYOUT", 15U)) { /* Report grid layout */
if (API->shape == GMT_IS_COL_FORMAT)
@@ -13583,7 +13561,6 @@ int GMT_Set_Default (void *V_API, const char *keyword, const char *txt_val) {
API->pad = pad;
}
}
-#ifdef HAVE_GDAL
else if (!strncmp (keyword, "API_IMAGE_LAYOUT", 16U)) { /* Change image/band layout */
if (strlen (value) != 4U) {
error = 1;
@@ -13592,7 +13569,6 @@ int GMT_Set_Default (void *V_API, const char *keyword, const char *txt_val) {
else
gmt_M_memcpy (API->GMT->current.gdal_read_in.O.mem_layout, value, 4, char);
}
-#endif
else if (!strncmp (keyword, "API_GRID_LAYOUT", 15U)) { /* Change grid layout */
if (!strncmp (value, "columns", 7U) || (strlen(value) >= 2 && value[1] == 'C')) /* Accept also TC, though ignore 1st and 3-end chars. Accept this to be consistent with the "API_IMAGE_LAYOUT" case */
API->shape = GMT_IS_COL_FORMAT; /* Switch to column-major format */
diff --git a/src/gmt_config.h.in b/src/gmt_config.h.in
index 8ff05285390..a68a67a152e 100644
--- a/src/gmt_config.h.in
+++ b/src/gmt_config.h.in
@@ -44,9 +44,6 @@
#cmakedefine HAVE_PCRE2
#cmakedefine HAVE_POSIX_ERE
-/* compile with GDAL support */
-#cmakedefine HAVE_GDAL
-
/* compile with GEOS support */
#cmakedefine HAVE_GEOS
diff --git a/src/gmt_customio.c b/src/gmt_customio.c
index e031230b5c3..5769b0f90c1 100644
--- a/src/gmt_customio.c
+++ b/src/gmt_customio.c
@@ -1623,13 +1623,8 @@ int gmt_srf_write_grd (struct GMT_CTRL *GMT, struct GMT_GRID_HEADER *header, gmt
struct GMT_GRID_HEADER_HIDDEN *HH = gmt_get_H_hidden (header);
if (GMT->session.grdformat[header->type][1] == 'd') {
-#ifdef HAVE_GDAL
GMT_Report(GMT->parent, GMT_MSG_INFORMATION,
"Surfer 7 format in GMT is read-only but you can do it via GDAL by appending '=gd:GS7BG' to the file name\n");
-#else
- GMT_Report(GMT->parent, GMT_MSG_INFORMATION,
- "As mentioned in the manual, Surfer 7 format in GMT is read-only\n");
-#endif
return (GMT_NOERROR);
}
@@ -1719,7 +1714,6 @@ int gmt_srf_write_grd (struct GMT_CTRL *GMT, struct GMT_GRID_HEADER *header, gmt
return (GMT_NOERROR);
}
-#ifdef HAVE_GDAL
#include "gmt_gdalread.c"
#include "gmt_gdalwrite.c"
#include "gmt_ogrproj.c" /* For coordinate conversions but can "enter" here too */
@@ -2173,8 +2167,6 @@ int gmt_gdal_write_grd (struct GMT_CTRL *GMT, struct GMT_GRID_HEADER *header, gm
return (GMT_NOERROR);
}
-#endif
-
/* Add custom code here */
/* 12: NOAA NGDC MGG Format */
@@ -2432,21 +2424,12 @@ void gmtlib_grdio_init (struct GMT_CTRL *GMT) {
/* FORMAT: Import via the GDAL interface */
id = GMT_GRID_IS_GD;
-#ifdef HAVE_GDAL
GMT->session.grdformat[id] = "gd = Import/export through GDAL";
GMT->session.readinfo[id] = &gmt_gdal_read_grd_info;
GMT->session.updateinfo[id] = &gmt_gdal_write_grd_info;
GMT->session.writeinfo[id] = &gmt_gdal_write_grd_info;
GMT->session.readgrd[id] = &gmt_gdal_read_grd;
GMT->session.writegrd[id] = &gmt_gdal_write_grd;
-#else
- GMT->session.grdformat[id] = "gd = Import/export through GDAL (not supported)";
- GMT->session.readinfo[id] = &gmt_dummy_grd_info;
- GMT->session.updateinfo[id] = &gmt_dummy_grd_info;
- GMT->session.writeinfo[id] = &gmt_dummy_grd_info;
- GMT->session.readgrd[id] = &gmt_dummy_grd_read;
- GMT->session.writegrd[id] = &gmt_dummy_grd_read;
-#endif
/* ----------------------------------------------
* ADD CUSTOM FORMATS BELOW AS THEY ARE NEEDED */
diff --git a/src/gmt_dev.h b/src/gmt_dev.h
index 3d7d011f218..d31127b7381 100644
--- a/src/gmt_dev.h
+++ b/src/gmt_dev.h
@@ -145,9 +145,7 @@ struct GMT_CTRL; /* forward declaration of GMT_CTRL */
#include "gmt_psl.h" /* Declarations of structure for GMT PostScript settings */
#include "gmt_hash.h" /* Declarations of structure for GMT hashing */
-#ifdef HAVE_GDAL
-# include "gmt_gdalread.h" /* GDAL support */
-#endif
+#include "gmt_gdalread.h" /* GDAL support */
#include "gmt_common.h" /* For holding the GMT common option settings */
#include "gmt_fft.h" /* Structures and enums used by programs needing FFTs */
diff --git a/src/gmt_esri_io.c b/src/gmt_esri_io.c
index 750f071b2cb..986ec5a96c9 100644
--- a/src/gmt_esri_io.c
+++ b/src/gmt_esri_io.c
@@ -355,7 +355,7 @@ int gmtlib_is_esri_grid (struct GMT_CTRL *GMT, struct GMT_GRID_HEADER *header) {
if (!strcmp (HH->name, "="))
return (GMT_GRDIO_PIPE_CODECHECK); /* Cannot check on pipes */
- if ((e = gmt_get_ext (HH->name)) && !strcmp (e, GMT_TILE_EXTENSION_REMOTE)) return (-1); /* Watch out for .jp2 tiles since they may contain W|E|S|N codes as well and the ESRI check comes before GDAL check*/
+ if ((e = gmt_get_ext (HH->name)) && !strcmp (e, GMT_TILE_EXTENSION_REMOTE)) return (-1); /* Watch out for .jp2 tiles since they may contain W|E|S|N codes as well and the ESRI check comes before GDAL check */
if ((fp = gmt_fopen (GMT, HH->name, "r")) == NULL)
return (GMT_GRDIO_OPEN_FAILED);
if (fgets (record, GMT_BUFSIZ, fp) == NULL) { /* Just get first line. Not using gmt_fgets since we may be reading a binary file */
diff --git a/src/gmt_gdalcall.c b/src/gmt_gdalcall.c
index 3e599cc6cba..fe1f213ca63 100644
--- a/src/gmt_gdalcall.c
+++ b/src/gmt_gdalcall.c
@@ -18,7 +18,7 @@
#include "gmt_dev.h"
#include "gmt_internals.h"
-#if defined(HAVE_GDAL) && ((GDAL_VERSION_MAJOR >= 2) && (GDAL_VERSION_MINOR >= 1)) || (GDAL_VERSION_MAJOR >= 3)
+#if ((GDAL_VERSION_MAJOR >= 2) && (GDAL_VERSION_MINOR >= 1)) || (GDAL_VERSION_MAJOR >= 3)
#include
@@ -511,4 +511,4 @@ int gmt_gdal_warp (struct GMT_CTRL *GMT, struct GMT_GDALLIBRARIFIED_CTRL *GDLL)
if (hDstDS == NULL) return bUsageError;
return error;
}
-#endif //defined(HAVE_GDAL) && ...
+#endif /* ((GDAL_VERSION_MAJOR >= 2) && (GDAL_VERSION_MINOR >= 1)) || (GDAL_VERSION_MAJOR >= 3) */
diff --git a/src/gmt_grdio.c b/src/gmt_grdio.c
index 4b26890cfbb..2163ccd06b4 100644
--- a/src/gmt_grdio.c
+++ b/src/gmt_grdio.c
@@ -77,7 +77,7 @@
* gmt_grd_flip_vertical : Flips the grid in vertical direction
* gmtgrdio_pack_grid : Packs or unpacks a grid by calling gmt_scale_and_offset_f()
*
- * Reading images via GDAL (if enabled):
+ * Reading images via GDAL:
* gmtlib_read_image : Read [subset of] an image via GDAL
* gmtlib_read_image_info : Get information for an image via GDAL
*
@@ -1133,14 +1133,12 @@ int gmt_grd_get_format (struct GMT_CTRL *GMT, char *file, struct GMT_GRID_HEADER
else if (magic) { /* Reading: determine file format automatically based on grid content */
int choice = 0;
sscanf (HH->name, "%[^?]?%s", tmp, HH->varname); /* Strip off variable name */
-#ifdef HAVE_GDAL
/* Check if file is an URL */
if (gmtlib_found_url_for_gdal(HH->name)) {
/* Then check for GDAL grid */
if (gmtlib_is_gdal_grid (GMT, header) == GMT_NOERROR)
return (GMT_NOERROR);
}
-#endif
if (!gmt_getdatapath (GMT, tmp, HH->name, R_OK))
return (GMT_GRDIO_FILE_NOT_FOUND); /* Possibly prepended a path from GMT_[GRID|DATA|IMG]DIR */
/* First check if we have a netCDF grid. This MUST be first, because ?var needs to be stripped off. */
@@ -1173,11 +1171,9 @@ int gmt_grd_get_format (struct GMT_CTRL *GMT, char *file, struct GMT_GRID_HEADER
ext = gmt_get_ext (file);
if (ext && (!strcmp (ext, "txt") || !strcmp (ext, "lis")))
return (GMT_GRDIO_UNKNOWN_FORMAT);
-#ifdef HAVE_GDAL
/* Then check for GDAL grid */
if (gmtlib_is_gdal_grid (GMT, header) == GMT_NOERROR)
return (GMT_NOERROR);
-#endif
return (GMT_GRDIO_UNKNOWN_FORMAT); /* No supported format found */
}
else { /* Writing: get format type, scale, offset and missing value from GMT->current.setting.io_gridfile_format */
@@ -3632,7 +3628,6 @@ uint64_t gmt_get_active_layers (struct GMT_CTRL *GMT, struct GMT_CUBE *U, double
return (n_layers_used);
}
-#ifdef HAVE_GDAL
GMT_LOCAL void gmtgrdio_gdal_free_from (struct GMT_CTRL *GMT, struct GMT_GDALREAD_OUT_CTRL *from_gdalread) {
int i;
if (from_gdalread->band_field_names) {
@@ -3840,4 +3835,3 @@ int gmtlib_read_image (struct GMT_CTRL *GMT, char *file, struct GMT_IMAGE *I, do
return (GMT_NOERROR);
}
-#endif
diff --git a/src/gmt_init.c b/src/gmt_init.c
index 48cf39f7899..5297282a288 100644
--- a/src/gmt_init.c
+++ b/src/gmt_init.c
@@ -15741,14 +15741,12 @@ void gmt_end_module (struct GMT_CTRL *GMT, struct GMT_CTRL *Ccopy) {
gmt_M_memcpy (spacing, GMT->current.plot.gridline_spacing, 2U, double); /* Remember these so they can survive the end of the module */
-#ifdef HAVE_GDAL
- /* If that's the case, clean up anu GDAL CT object */
+ /* If that's the case, clean up any GDAL CT object */
if (GMT->current.gdal_read_in.hCT_fwd)
OCTDestroyCoordinateTransformation(GMT->current.gdal_read_in.hCT_fwd);
if (GMT->current.gdal_read_in.hCT_inv)
OCTDestroyCoordinateTransformation(GMT->current.gdal_read_in.hCT_inv);
GMT->current.gdal_read_in.hCT_fwd = GMT->current.gdal_read_in.hCT_inv = NULL;
-#endif
if (GMT->hidden.func_level == GMT_TOP_MODULE && GMT->current.ps.oneliner && GMT->current.ps.active) {
char *setting = getenv ("GMT_END_SHOW");
@@ -15893,12 +15891,10 @@ void gmt_end_module (struct GMT_CTRL *GMT, struct GMT_CTRL *Ccopy) {
*/
GMT->current.setting.io_lonlat_toggle[GMT_IN] = GMT->current.setting.io_lonlat_toggle[GMT_OUT] = false;
-#ifdef HAVE_GDAL
/* Reset these GDAL in/out stuff */
gmt_M_memset (&GMT->current.gdal_read_in, 1, struct GMT_GDALREAD_IN_CTRL);
gmt_M_memset (&GMT->current.gdal_read_out, 1, struct GMT_GDALREAD_OUT_CTRL);
gmt_M_memset (&GMT->current.gdal_write, 1, struct GMT_GDALWRITE_CTRL);
-#endif
GMT->parent->cache = false; /* Otherwise gdalread from externals on Windows would mingle CACHEDIR in fnames */
@@ -17406,7 +17402,6 @@ unsigned int gmt_parse_inc_option (struct GMT_CTRL *GMT, char option, char *item
return GMT_NOERROR;
}
-#ifdef HAVE_GDAL
GMT_LOCAL int gmtinit_parse_proj4 (struct GMT_CTRL *GMT, char *item, char *dest) {
/* Deal with proj.4 or EPSGs passed in -J option */
char *item_t1 = NULL, *item_t2 = NULL, wktext[32] = {""}, *pch;
@@ -17565,7 +17560,6 @@ GMT_LOCAL int gmtinit_parse_proj4 (struct GMT_CTRL *GMT, char *item, char *dest)
return error;
}
-#endif
/*! gmt_parse_common_options interprets the command line for the common, unique options
* -B, -J, -K, -O, -P, -R, -U, -V, -X, -Y, -a, -b, -c, -d, -e, -f, -g, -h, -i, -j, -l, -n, -o, -p, -q, -r, -s, -t, -w, -:, -- and -^.
@@ -17636,7 +17630,6 @@ int gmt_parse_common_options (struct GMT_CTRL *GMT, char *list, char option, cha
GMT->common.J.zactive = true;
}
else if (item && (item[0] == '+' || isdigit(item[0]) || !strncmp(item, "EPSG:", 5) || !strncmp(item, "epsg:", 5))) {
-#ifdef HAVE_GDAL
char source[GMT_LEN1024] = {""}, dest[GMT_LEN1024] = {""}, *pch;
bool two = false;
@@ -17692,11 +17685,6 @@ int gmt_parse_common_options (struct GMT_CTRL *GMT, char *list, char option, cha
if (GMT->current.gdal_read_in.hCT_fwd == NULL || GMT->current.gdal_read_in.hCT_inv == NULL)
error = 1;
}
-#else
- GMT_Report (GMT->parent, GMT_MSG_ERROR, "PROJ.4 can only be used with GDAL linked GMT.\n");
- error = 1;
- }
-#endif
else { /* Horizontal map projection */
error += (gmt_M_check_condition (GMT, GMT->common.J.active, "Option -J given more than once\n") ||
gmtinit_parse_J_option (GMT, item));
@@ -18151,7 +18139,7 @@ struct GMT_CTRL *gmt_begin (struct GMTAPI_CTRL *API, const char *session, unsign
struct GMT_CTRL *GMT = NULL;
char version[GMT_LEN8] = {""};
-#if defined(HAVE_GDAL) && (GDAL_VERSION_MAJOR >= 3)
+#if (GDAL_VERSION_MAJOR >= 3)
char *path1 = NULL, *path2 = NULL, *paths[2] = {NULL, NULL};
int local_count = 0;
#endif
@@ -18208,7 +18196,7 @@ struct GMT_CTRL *gmt_begin (struct GMTAPI_CTRL *API, const char *session, unsign
API->GMT = GMT;
-#if defined(HAVE_GDAL) && (GDAL_VERSION_MAJOR >= 3)
+#if (GDAL_VERSION_MAJOR >= 3)
/* Here we allow users to declare a different location for the GDAL's GDAL_DATA and
PROJ4 PROJ_LIB directories. The later may be particularly useful in these days of
transition to GDAL3.0, which imply PROJ4 V6 but many (different) PROJ_LIB from PROJ4 < 6
diff --git a/src/gmt_internals.h b/src/gmt_internals.h
index dc345e624fd..2da7d97d19f 100644
--- a/src/gmt_internals.h
+++ b/src/gmt_internals.h
@@ -291,13 +291,11 @@ EXTERN_MSC const char *gmtlib_module_group (void *API, struct GMT_MODULEINFO M[]
EXTERN_MSC int gmtlib_ind2rgb (struct GMT_CTRL *GMT, struct GMT_IMAGE **I_in);
-#ifdef HAVE_GDAL
EXTERN_MSC int gmtlib_read_image (struct GMT_CTRL *GMT, char *file, struct GMT_IMAGE *I, double *wesn,
unsigned int *pad, unsigned int complex_mode); /* Function to read true images via GDAL */
int gmtlib_read_image_info (struct GMT_CTRL *GMT, char *file, bool must_be_image, struct GMT_IMAGE *I);
EXTERN_MSC int gmtlib_is_gdal_grid (struct GMT_CTRL *GMT, struct GMT_GRID_HEADER *header);
EXTERN_MSC void gmtlib_GDALDestroyDriverManager (struct GMTAPI_CTRL *API);
-#endif
/* LOCAL MACROS USED BY GMT_*.C ONLY - NOT PART OF GMT_DEV.H DISTRIBUTION */
diff --git a/src/gmt_io.c b/src/gmt_io.c
index 968bb646ddc..084bf733c6d 100644
--- a/src/gmt_io.c
+++ b/src/gmt_io.c
@@ -4501,14 +4501,12 @@ int gmt_fclose (struct GMT_CTRL *GMT, FILE *stream) {
}
/* Regular file */
err = fclose (stream);
-#ifdef HAVE_GDAL
if (GMT->current.io.tempfile[0] && !access (GMT->current.io.tempfile, F_OK)) {
/* Converted a shapefile to a temporary GMT/OGR file. Now delete that file */
GMT_Report (GMT->parent, GMT_MSG_DEBUG, "Remove temporary GMT/OGR file %s\n", GMT->current.io.tempfile);
gmt_remove_file (GMT, GMT->current.io.tempfile);
GMT->current.io.tempfile[0] = '\0'; /* Flag as no longer active */
}
-#endif
return (err);
}
@@ -5046,7 +5044,6 @@ FILE * gmt_fopen (struct GMT_CTRL *GMT, const char *filename, const char *mode)
fd = gmtio_nc_fopen (GMT, &filename[first], mode);
if (!fd) { /* No, was not a netCDF file */
if ((c = gmt_getdatapath (GMT, &filename[first], path, R_OK)) != NULL) { /* Got the file path */
-#ifdef HAVE_GDAL
char *ext = gmt_get_ext (c); /* Get pointer to extension (or NULL if no extension) */
if (ext && mode[0] == 'r' && !strncmp (ext, "shp", 3U)) { /* Got a shapefile for reading */
/* We will do a system call to ogr2ogr in order to read the shapefile */
@@ -5070,8 +5067,7 @@ FILE * gmt_fopen (struct GMT_CTRL *GMT, const char *filename, const char *mode)
sprintf (GMT->current.io.filename[GMT_IN], "%s ", GMT->current.io.tempfile, c);
c = GMT->current.io.tempfile; /* Open this temporary instead */
}
-#endif
- fd = fopen (c, mode);
+ fd = fopen (c, mode);
}
}
return (fd);
@@ -5351,14 +5347,10 @@ char *gmt_getdatapath (struct GMT_CTRL *GMT, const char *stem, char *path, int m
/* If we got here and a full path is given, we give up ... unless it is one of those /vsi.../ files */
if (stem[0] == '/') {
-#ifdef HAVE_GDAL
if (gmtlib_found_url_for_gdal ((char *)stem))
return ((char *)stem); /* With GDAL all the /vsi-stuff is given existence credit */
else
return (NULL);
-#else
- return (NULL);
-#endif
}
#ifdef WIN32
@@ -8728,11 +8720,9 @@ struct GMT_IMAGE *gmtlib_create_image (struct GMT_CTRL *GMT) {
IH->alloc_level = GMT->hidden.func_level; /* Must be freed at this level. */
IH->id = GMT->parent->unique_var_ID++; /* Give unique identifier */
gmt_grd_init (GMT, I->header, NULL, false); /* Set default values */
-#ifdef HAVE_GDAL
if (GMT->current.gdal_read_in.O.mem_layout[0])
gmt_strncpy (I->header->mem_layout, GMT->current.gdal_read_in.O.mem_layout, 4); /* Set the current memory layout */
else
-#endif
gmt_strncpy (I->header->mem_layout, GMT_IMAGE_LAYOUT, 4); /* Set the default array memory layout */
GMT_Set_Index (GMT->parent, I->header, GMT_IMAGE_LAYOUT);
return (I);
diff --git a/src/gmt_io.h b/src/gmt_io.h
index 15e98a74d90..d168bc0c3a5 100644
--- a/src/gmt_io.h
+++ b/src/gmt_io.h
@@ -288,9 +288,7 @@ struct GMT_IO { /* Used to process input data records */
char curr_trailing_text[GMT_BUFSIZ]; /* Current text portion of current record (or NULL) */
char segment_header[GMT_BUFSIZ]; /* Current ASCII segment header */
char filename[2][PATH_MAX]; /* Current filenames (or /) */
-#ifdef HAVE_GDAL
char tempfile[PATH_MAX]; /* Temporary file used to read - should be removed when closed */
-#endif
char col_set[2][GMT_MAX_COLUMNS]; /* Keeps track of which columns have had their type set */
char *o_format[GMT_MAX_COLUMNS]; /* Custom output ASCII format to overrule format_float_out */
int ncid; /* NetCDF file ID (when opening netCDF file) */
diff --git a/src/gmt_map.c b/src/gmt_map.c
index e5f7ce6e592..41cce07d6a4 100644
--- a/src/gmt_map.c
+++ b/src/gmt_map.c
@@ -5065,7 +5065,6 @@ GMT_LOCAL int gmtmap_init_polyconic (struct GMT_CTRL *GMT, bool *search) {
return (GMT_NOERROR);
}
-#ifdef HAVE_GDAL
/*!
* TRANSFORMATION ROUTINES FOR PROJ4 TRANSFORMATIONS (GMT_PROJ4_PROJS)
*/
@@ -5143,7 +5142,6 @@ GMT_LOCAL int gmtmap_init_polyconic (struct GMT_CTRL *GMT, bool *search) {
GMT->current.proj.inv = &gmt_proj4_inv;
return error;
}
-#endif
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*
@@ -9631,11 +9629,9 @@ int gmt_proj_setup (struct GMT_CTRL *GMT, double wesn[]) {
error = gmtmap_init_polyconic (GMT, &search);
break;
-#ifdef HAVE_GDAL
case GMT_PROJ4_PROJS: /* All proj.4 projections */
error = map_init_proj4 (GMT, &search);
break;
-#endif
default: /* No projection selected, return to a horrible death */
Error_and_return (GMT_MAP_NO_PROJECTION, GMT_PROJECTION_ERROR);
diff --git a/src/gmt_nc.c b/src/gmt_nc.c
index 3ccf7400f2e..9bcc49235b0 100644
--- a/src/gmt_nc.c
+++ b/src/gmt_nc.c
@@ -971,7 +971,6 @@ GMT_LOCAL int gmtnc_grd_info (struct GMT_CTRL *GMT, struct GMT_GRID_HEADER *head
else
nc_del_att (ncid, NC_GLOBAL, "node_offset");
-#ifdef HAVE_GDAL
/* If we have projection information create a container variable named "grid_mapping" with an attribute
"spatial_ref" that will hold the projection info in WKT format. GDAL and Mirone know use this info */
if ((header->ProjRefWKT != NULL) || (header->ProjRefPROJ4 != NULL)) {
@@ -1010,7 +1009,6 @@ GMT_LOCAL int gmtnc_grd_info (struct GMT_CTRL *GMT, struct GMT_GRID_HEADER *head
}
}
L100:
-#endif
/* Avoid NaN increments */
if (gmt_M_is_dnan(header->inc[GMT_X])) header->inc[GMT_X] = 1.0;
diff --git a/src/gmt_plot.c b/src/gmt_plot.c
index c620deb8d48..2fa8302e94e 100644
--- a/src/gmt_plot.c
+++ b/src/gmt_plot.c
@@ -7722,7 +7722,6 @@ GMT_LOCAL void gmtplot_wipe_substr(char *str1, char *str2) {
}
#endif
-#ifdef HAVE_GDAL
char *gmt_importproj4 (struct GMT_CTRL *GMT, char *pStr, int *scale_pos) {
/* Take a PROJ.4 projection string or EPSG code and try to find the equivalent -J syntax
scale_pos is position on the return string where starts the scale sub-string.
@@ -8200,7 +8199,6 @@ char *gmt_importproj4 (struct GMT_CTRL *GMT, char *pStr, int *scale_pos) {
pStrOut = strdup(opt_J);
return pStrOut;
}
-#endif
char *gmt_export2proj4 (struct GMT_CTRL *GMT) {
char *pStrOut = NULL;
diff --git a/src/gmt_prototypes.h b/src/gmt_prototypes.h
index a6deaa18195..236cdbb5ac5 100644
--- a/src/gmt_prototypes.h
+++ b/src/gmt_prototypes.h
@@ -155,7 +155,6 @@ EXTERN_MSC int gmt_parse_j_option (struct GMT_CTRL *GMT, char *arg);
/* gmt_customio.c: */
-#ifdef HAVE_GDAL
/* Format # 22 */
EXTERN_MSC int gmt_gdalread (struct GMT_CTRL *GMT, char *gdal_filename, struct GMT_GDALREAD_IN_CTRL *prhs, struct GMT_GDALREAD_OUT_CTRL *Ctrl);
EXTERN_MSC int gmt_gdalwrite (struct GMT_CTRL *GMT, char *filename, struct GMT_GDALWRITE_CTRL *prhs);
@@ -176,7 +175,6 @@ void gmt_proj4_inv (struct GMT_CTRL *GMT, double *xi, double *yi, double xo, dou
EXTERN_MSC int gmt_gdal_translate (struct GMT_CTRL *GMT, struct GMT_GDALLIBRARIFIED_CTRL *GDLL);
EXTERN_MSC int gmt_gdal_warp (struct GMT_CTRL *GMT, struct GMT_GDALLIBRARIFIED_CTRL *GDLL);
# endif
-#endif
/* gmt_fft.c: */
@@ -261,9 +259,7 @@ EXTERN_MSC void gmt_map_title (struct GMT_CTRL *GMT, double x, double y);
EXTERN_MSC void gmt_linearx_grid (struct GMT_CTRL *GMT, struct PSL_CTRL *P, double w, double e, double s, double n, double dval);
EXTERN_MSC int gmt_ps_append (struct GMT_CTRL *GMT, char *source, unsigned int mode, FILE *dest);
EXTERN_MSC char * gmt_export2proj4 (struct GMT_CTRL *GMT);
-#ifdef HAVE_GDAL
EXTERN_MSC char * gmt_importproj4 (struct GMT_CTRL *GMT, char *szProj4, int *scale_pos);
-#endif
EXTERN_MSC int gmt_strip_layer (struct GMTAPI_CTRL *API, int nlayers);
EXTERN_MSC void gmt_textpath_init (struct GMT_CTRL *GMT, struct GMT_PEN *BP, double Brgb[]);
EXTERN_MSC void gmt_draw_map_rose (struct GMT_CTRL *GMT, struct GMT_MAP_ROSE *mr);
diff --git a/src/gmt_types.h b/src/gmt_types.h
index 9c6b5958068..e69edc52064 100644
--- a/src/gmt_types.h
+++ b/src/gmt_types.h
@@ -383,11 +383,9 @@ struct GMT_CURRENT {
struct GMT_PSL ps; /* Hold parameters related to PSL setup */
struct GMT_OPTION *options; /* Pointer to current program's options */
struct GMT_FFT_HIDDEN fft; /* Structure with info that must survive between FFT calls */
-#ifdef HAVE_GDAL
struct GMT_GDALREAD_IN_CTRL gdal_read_in; /* Hold parameters related to options transmitted to gdalread */
struct GMT_GDALREAD_OUT_CTRL gdal_read_out; /* Hold parameters related to options transmitted from gdalread */
struct GMT_GDALWRITE_CTRL gdal_write; /* Hold parameters related to options transmitted to gdalwrite */
-#endif
};
struct GMT_INTERNAL {
diff --git a/src/grd2kml.c b/src/grd2kml.c
index 942b4d3235e..901a01c1e79 100644
--- a/src/grd2kml.c
+++ b/src/grd2kml.c
@@ -885,7 +885,7 @@ EXTERN_MSC int GMT_grd2kml (void *V_API, int mode, void *args) {
}
/* Will pass -W so grdimage will notify us if there was no valid image data imaged */
if (!Ctrl->W.active) {
- /* Build the grdimage command to write an image directly via GDAL - no need to go via PostSCript */
+ /* Build the grdimage command to write an image directly via GDAL - no need to go via PostScript */
char imagefile[PATH_MAX] = {""};
if (Ctrl->D.single)
sprintf (imagefile, "%s/L%2.2dR%3.3dC%3.3d.%s", Ctrl->N.prefix, level, row, col, ext[im_type]);
diff --git a/src/grdblend.c b/src/grdblend.c
index de121d3ae6a..778ef366343 100644
--- a/src/grdblend.c
+++ b/src/grdblend.c
@@ -103,20 +103,12 @@ struct GRDBLEND_INFO { /* Structure with info about each input grid file */
gmt_grdfloat *z; /* Row vector holding the current row from this file */
};
-#ifdef HAVE_GDAL
#define N_NOT_SUPPORTED 8
-#else
-#define N_NOT_SUPPORTED 7
-#endif
GMT_LOCAL int grdblend_found_unsupported_format (struct GMT_CTRL *GMT, struct GMT_GRID_HEADER *h, char *file) {
/* Check that grid files are not among the unsupported formats that has no row-by-row io yet */
unsigned int i, type;
-#ifdef HAVE_GDAL
static char *not_supported[N_NOT_SUPPORTED] = {"rb", "rf", "sf", "sd", "af", "ei", "ef", "gd"};
-#else
- static char *not_supported[N_NOT_SUPPORTED] = {"rb", "rf", "sf", "sd", "af", "ei", "ef"};
-#endif
for (i = 0; i < N_NOT_SUPPORTED; i++) { /* Only allow netcdf (both v3 and new) and native binary output */
if (gmt_grd_format_decoder (GMT, not_supported[i], &type) != GMT_NOERROR) {
/* no valid type id - which should not happen unless typo in not_supported array */
diff --git a/src/grdconvert.c b/src/grdconvert.c
index 5d6b6218e12..eac7fb1908f 100644
--- a/src/grdconvert.c
+++ b/src/grdconvert.c
@@ -106,12 +106,10 @@ static int usage (struct GMTAPI_CTRL *API, int level) {
if (!strstr (grdformats[i], "not supported"))
GMT_Usage (API, -2, grdformats[i]);
}
-#ifdef HAVE_GDAL
GMT_Usage (API, -1, "When =gd on output, the grid will be saved using the GDAL library. Specify and "
"optionally . Driver names are as in GDAL (e.g., netCDF, GTiFF, etc.) is "
"u8|u16|i16|u32|i32|float32; i|u denote signed|unsigned integer. Default type is float32. Both driver "
"names and data types are case insensitive.");
-#endif
return (GMT_MODULE_USAGE);
}
diff --git a/src/grdgdal.c b/src/grdgdal.c
index e7bf13122ef..4a7a43529c9 100644
--- a/src/grdgdal.c
+++ b/src/grdgdal.c
@@ -231,7 +231,7 @@ EXTERN_MSC int GMT_grdgdal (void *V_API, int mode, void *args) {
if ((error = parse (GMT, Ctrl, options)) != 0) Return (error);
/*---------------------------- This is the grdgdal main code ----------------------------*/
-#if defined(HAVE_GDAL) && ((GDAL_VERSION_MAJOR >= 2) && (GDAL_VERSION_MINOR >= 1)) || (GDAL_VERSION_MAJOR >= 3)
+#if ((GDAL_VERSION_MAJOR >= 2) && (GDAL_VERSION_MINOR >= 1)) || (GDAL_VERSION_MAJOR >= 3)
if ((st = gmt_M_memory (GMT, NULL, 1, struct GMT_GDALLIBRARIFIED_CTRL)) == NULL) {
GMT_Report (API, GMT_MSG_ERROR, "Memory allocation failure\n");
diff --git a/src/grdimage.c b/src/grdimage.c
index 570f027a9f3..1b22296fb8c 100644
--- a/src/grdimage.c
+++ b/src/grdimage.c
@@ -35,11 +35,9 @@
#define THIS_MODULE_NEEDS "Jg"
#define THIS_MODULE_OPTIONS "->BJKOPRUVXYfnptxy" GMT_OPT("Sc") GMT_ADD_x_OPT
-#ifdef HAVE_GDAL
-/* These are images that GDAL knows how to read for us. Otherwise we can only deal with ppm */
+/* These are images that GDAL knows how to read for us. */
#define N_IMG_EXTENSIONS 6
static char *gdal_ext[N_IMG_EXTENSIONS] = {"tiff", "tif", "gif", "png", "jpg", "bmp"};
-#endif
#define GRDIMAGE_NAN_INDEX (GMT_NAN - 3)
@@ -149,11 +147,7 @@ static void Free_Ctrl (struct GMT_CTRL *GMT, struct GRDIMAGE_CTRL *C) { /* Deall
}
static int usage (struct GMTAPI_CTRL *API, int level) {
-#ifdef HAVE_GDAL
const char *A = " [-A[=]]";
-#else
- const char *A = " [-A]";
-#endif
const char *name = gmt_show_name_and_purpose (API, THIS_MODULE_LIB, THIS_MODULE_CLASSIC_NAME, THIS_MODULE_PURPOSE);
const char *extra[2] = {A, " [-A]"};
if (level == GMT_MODULE_PURPOSE) return (GMT_NOERROR);
@@ -177,15 +171,11 @@ static int usage (struct GMTAPI_CTRL *API, int level) {
if (API->external) /* External interface */
GMT_Usage (API, 1, "\n-A Return a GMT raster image instead of a PostScript plot.");
else {
-#ifdef HAVE_GDAL
GMT_Usage (API, 1, "\n-A[=]");
GMT_Usage (API, -2, "Save image in a raster format (.bmp, .gif, .jpg, .png, .tif) instead of PostScript. "
"If filename does not have any of these extensions then append = to select "
"the desired image format. The 'driver' is the driver code name used by GDAL. "
"See GDAL documentation for available drivers. Note: any vector elements are lost.");
-#else
- GMT_Usage (API, 1, "\n-A Save image in a PPM format (give .ppm extension) instead of PostScript.");
-#endif
}
GMT_Option (API, "B-");
GMT_Usage (API, 1, "\n-C");
@@ -197,12 +187,10 @@ static int usage (struct GMTAPI_CTRL *API, int level) {
GMT_Usage (API, 1, "\n-D[r]");
if (API->external) /* External interface */
GMT_Usage (API, -2, "Input is an image instead of a grid. Append r to equate image region to -R region.");
-#ifdef HAVE_GDAL
else {
GMT_Usage (API, -2, "GMT automatically detects standard image formats. For non-standard formats you must "
"use -D to force it to be seen as an image. Append r to equate image region with -R region.");
}
-#endif
GMT_Usage (API, 1, "\n-Ei|");
GMT_Usage (API, -2, "Set dpi for the projected grid which must be constructed [100] "
"if -J implies a nonlinear graticule [Default gives same size as input grid]. "
@@ -295,8 +283,7 @@ static int parse (struct GMT_CTRL *GMT, struct GRDIMAGE_CTRL *Ctrl, struct GMT_O
Ctrl->A.file = strdup (opt->arg);
Ctrl->A.way = 1; /* Building image directly, use TRP layout, no call to GDAL, writing a PPM file */
}
-#ifdef HAVE_GDAL
- else { /* Must give file and GDAL driver and this requires GDAL support */
+ else { /* Must give file and GDAL driver */
Ctrl->A.file = strdup (opt->arg);
while (Ctrl->A.file[n] != '=' && n > 0) n--;
if (n == 0) { /* Gave no driver, see if we requested one of the standard image formats */
@@ -322,10 +309,6 @@ static int parse (struct GMT_CTRL *GMT, struct GRDIMAGE_CTRL *Ctrl, struct GMT_O
}
}
}
-#else
- else
- GMT_Report (API, GMT_MSG_ERROR, "Option -A: Your selection requires building GMT with GDAL support.\n");
-#endif
break;
case 'C': /* CPT */
@@ -335,7 +318,6 @@ static int parse (struct GMT_CTRL *GMT, struct GRDIMAGE_CTRL *Ctrl, struct GMT_O
if (opt->arg[0]) Ctrl->C.file = strdup (opt->arg);
gmt_cpt_interval_modifier (GMT, &(Ctrl->C.file), &(Ctrl->C.dz));
break;
-#ifdef HAVE_GDAL
case 'D': /* Get an image via GDAL */
n_errors += gmt_M_repeated_module_option (API, Ctrl->D.active);
if (!API->external) /* For externals we actually still need the -D */
@@ -344,7 +326,6 @@ static int parse (struct GMT_CTRL *GMT, struct GRDIMAGE_CTRL *Ctrl, struct GMT_O
Ctrl->D.active = true;
Ctrl->D.mode = (opt->arg[0] == 'r');
break;
-#endif
case 'E': /* Sets dpi */
n_errors += gmt_M_repeated_module_option (API, Ctrl->E.active);
Ctrl->E.active = true;
@@ -490,14 +471,6 @@ static int parse (struct GMT_CTRL *GMT, struct GRDIMAGE_CTRL *Ctrl, struct GMT_O
/* Unless user selected -n we want the default not to exceed data range on projection when we are auto-scaling a master table */
n_errors += gmtinit_parse_n_option (GMT, "b+c");
- if (Ctrl->D.active) { /* Only OK with memory input or GDAL support */
- if (!gmt_M_file_is_memory (Ctrl->In.file)) {
-#ifndef HAVE_GDAL
- GMT_Report (API, GMT_MSG_ERROR, "Option -D: Requires building GMT with GDAL support.\n");
- n_errors++;
-#endif
- }
- }
if (!API->external) { /* I.e, not an External interface */
n_errors += gmt_M_check_condition (GMT, !(n_files == 1 || n_files == 3),
"Must specify one (or three [deprecated]) input file(s)\n");
@@ -1199,7 +1172,7 @@ EXTERN_MSC int GMT_grdimage (void *V_API, int mode, void *args) {
struct GMT_GRID_HEADER *header_work = NULL; /* Pointer to a GMT header for the image or grid */
struct GMT_GRID_HEADER *header_D = NULL, *header_I = NULL, *header_G = NULL;
struct GMTAPI_CTRL *API = gmt_get_api_ptr (V_API); /* Cast from void to GMTAPI_CTRL pointer */
- struct GMT_IMAGE *I = NULL, *Img_proj = NULL; /* A GMT image datatype, if GDAL is used */
+ struct GMT_IMAGE *I = NULL, *Img_proj = NULL; /* A GMT image datatype */
struct GMT_IMAGE *Out = NULL; /* A GMT image datatype, if external interface is used with -A */
struct GMT_GRID *G2 = NULL;
struct GRDIMAGE_CONF *Conf = NULL;
@@ -1274,7 +1247,6 @@ EXTERN_MSC int GMT_grdimage (void *V_API, int mode, void *args) {
}
}
-#ifdef HAVE_GDAL
if (!Ctrl->D.active && (ftype = gmt_raster_type (GMT, Ctrl->In.file, false)) == GMT_IS_IMAGE) {
/* The input file is an ordinary image instead of a grid and -R may be required to use it */
Ctrl->D.active = true;
@@ -1293,7 +1265,6 @@ EXTERN_MSC int GMT_grdimage (void *V_API, int mode, void *args) {
}
}
}
-#endif
gmt_detect_oblique_region (GMT, Ctrl->In.file); /* Ensure a proper and smaller -R for oblique projections */
@@ -1364,12 +1335,10 @@ EXTERN_MSC int GMT_grdimage (void *V_API, int mode, void *args) {
I->y = gmt_grd_coord (GMT, I->header, GMT_Y);
}
-#ifdef HAVE_GDAL
if (!Ctrl->A.active && gmtlib_ind2rgb(GMT, &I)) {
GMT_Report (API, GMT_MSG_ERROR, "Error converting from indexed to RGB\n");
Return (API->error);
}
-#endif
gray_only = (I->header->n_bands == 1 && I->n_indexed_colors == 0); /* Got a grayscale image */
got_z_grid = false; /* Flag that we are using a GMT_IMAGE instead of a GMT_GRID as main input */
@@ -1781,11 +1750,9 @@ EXTERN_MSC int GMT_grdimage (void *V_API, int mode, void *args) {
img_wesn[YLO] -= 0.5 * img_inc[1]; img_wesn[YHI] += 0.5 * img_inc[1];
}
if (Ctrl->Q.active) dim[GMT_Z]++; /* Flag to remind us that we need to allocate a transparency array in GMT_Create_Data */
-#ifdef HAVE_GDAL
if (GMT->current.gdal_read_in.O.mem_layout[0])
strcpy (mem_layout, GMT->current.gdal_read_in.O.mem_layout); /* Backup current layout */
else
-#endif
gmt_strncpy (mem_layout, "TRPa", 4); /* Don't let it be empty (maybe it will screw?) */
GMT_Set_Default (API, "API_IMAGE_LAYOUT", "TRPa"); /* Set grdimage's default image memory layout */
diff --git a/src/nearneighbor.c b/src/nearneighbor.c
index 6dc240c03c3..ce232ee98fb 100644
--- a/src/nearneighbor.c
+++ b/src/nearneighbor.c
@@ -329,7 +329,6 @@ EXTERN_MSC int GMT_nearneighbor (void *V_API, int mode, void *args) {
/*---------------------------- This is the nearneighbor main code ----------------------------*/
-#if defined(HAVE_GDAL) && ((GDAL_VERSION_MAJOR >= 2) && (GDAL_VERSION_MINOR >= 1)) || (GDAL_VERSION_MAJOR >= 3)
if (Ctrl->N.mode) { /* Pass over to GDAL */
char buf[GMT_LEN128] = {""};
struct GMT_OPTION *opt = NULL;
@@ -348,7 +347,6 @@ EXTERN_MSC int GMT_nearneighbor (void *V_API, int mode, void *args) {
gmt_M_free (GMT, st);
Return (error);
}
-#endif
/* Regular nearest neighbor moving average operation */
diff --git a/src/psconvert.c b/src/psconvert.c
index 0145eb78f00..60a3ca074ad 100644
--- a/src/psconvert.c
+++ b/src/psconvert.c
@@ -1630,10 +1630,8 @@ EXTERN_MSC int GMT_psconvert (void *V_API, int mode, void *args) {
static char *gs_params_rasnew = "-q -dNOPAUSE -dBATCH -dNOSAFER -dSCANCONVERTERTYPE=2";
static char *gs_params_rasold = "-q -dNOPAUSE -dBATCH -dNOSAFER";
static char *gs_params = NULL;
-#ifdef HAVE_GDAL
struct GMT_GDALREAD_IN_CTRL *to_gdalread = NULL;
struct GMT_GDALREAD_OUT_CTRL *from_gdalread = NULL;
-#endif
FILE *fp = NULL, *fpo = NULL, *fpb = NULL, *fp2 = NULL, *fpw = NULL;
@@ -1707,10 +1705,6 @@ EXTERN_MSC int GMT_psconvert (void *V_API, int mode, void *args) {
Return (GMT_RUNTIME_ERROR);
}
return_image = true;
-#ifndef HAVE_GDAL
- GMT_Report (API, GMT_MSG_WARNING, "Selecting ppmraw device since GDAL not available.\n");
- Ctrl->T.device = GS_DEV_PPM;
-#endif
}
if (Ctrl->D.active && (error = psconvert_make_dir_if_needed (API, Ctrl->D.dir))) { /* Specified output directory; create if it does not exists */
@@ -2408,7 +2402,6 @@ EXTERN_MSC int GMT_psconvert (void *V_API, int mode, void *args) {
fprintf (fpo, "V clippath %s %g %g /Normal PSL_transp F N U\n", ptr, Ctrl->N.fade_level, Ctrl->N.fade_level);
transparency = true;
}
-#ifdef HAVE_GDAL
else if (Ctrl->A.crop && found_proj && !strncmp (line, "%%PageTrailer", 13)) {
psconvert_file_line_reader (GMT, &line, &line_size, fp, PS->data, &pos);
fprintf (fpo, "%%%%PageTrailer\n");
@@ -2467,7 +2460,6 @@ EXTERN_MSC int GMT_psconvert (void *V_API, int mode, void *args) {
}
continue;
}
-#endif
fprintf (fpo, "%s\n", line);
}
if (add_grestore)
@@ -2635,7 +2627,6 @@ EXTERN_MSC int GMT_psconvert (void *V_API, int mode, void *args) {
if (return_image) { /* Must read in the saved raster image and return via Ctrl->F.file pointer */
struct GMT_IMAGE *I = NULL;
-#ifdef HAVE_GDAL /* Since GMT_Read_Data with GMT_IS_IMAGE, GMT_IS_FILE means a call to GDAL */
gmt_set_pad (GMT, 0U); /* Temporary turn off padding (and thus BC setting) since we will use image exactly as is */
/* State how we wish to receive images from GDAL */
if (GMT->current.gdal_read_in.O.mem_layout[0]) /* At one point this should never be allowed to be empty */
@@ -2646,44 +2637,6 @@ EXTERN_MSC int GMT_psconvert (void *V_API, int mode, void *args) {
if ((I = GMT_Read_Data (API, GMT_IS_IMAGE, GMT_IS_FILE, GMT_IS_SURFACE, GMT_CONTAINER_AND_DATA, NULL, out_file, NULL)) == NULL) {
Return (API->error);
}
-#else /* Here we have already set device to PPM which we can read ourselves. */
- uint64_t dim[GMT_DIM_SIZE] = {0U, 0U, 3U, 0U}; /* 3 bands. This might change if we do monochrome at some point */
- uint64_t row, col, band, nCols, nRows, nBands, nXY;
- FILE *fp_raw = NULL;
- unsigned char *tmp;
- if ((fp_raw = fopen (out_file, "rb")) == NULL) {
- GMT_Report (API, GMT_MSG_ERROR, "Unable to open image file %s\n", out_file);
- Return (GMT_ERROR_ON_FOPEN);
- }
- gmt_fgets (GMT, line, GMT_LEN128, fp_raw); /* Skip 1st line */
- gmt_fgets (GMT, line, GMT_LEN128, fp_raw); /* Skip 2nd line */
- gmt_fgets (GMT, line, GMT_LEN128, fp_raw); /* Get 3rd line */
- if (sscanf (line, "%" PRIu64 " %" PRIu64, &dim[GMT_X], &dim[GMT_Y]) != 2) {
- GMT_Report (API, GMT_MSG_ERROR, "Unable to decipher size of image in file %s\n", out_file);
- fclose (fp_raw);
- Return (GMT_PARSE_ERROR);
- }
- gmt_fgets (GMT, line, GMT_LEN128, fp_raw); /* Skip 4th line */
- gmt_set_pad (GMT, 0U); /* Temporary turn off padding (and thus BC setting) since we will use image exactly as is */
- if ((I = GMT_Create_Data (API, GMT_IS_IMAGE, GMT_IS_SURFACE, GMT_CONTAINER_AND_DATA, dim, NULL, NULL, 0, 0, NULL)) == NULL) {
- GMT_Report (API, GMT_MSG_ERROR, "Unable to create image structure\n");
- fclose (fp_raw);
- Return (API->error);
- }
-
- nCols = dim[GMT_X]; nRows = dim[GMT_Y]; nBands = dim[2]; nXY = nRows * nCols;
- tmp = gmt_M_memory(GMT, NULL, nCols * nBands, char);
- for (row = 0; row < nRows; row++) {
- fread(tmp, sizeof (unsigned char), nCols * nBands, fp_raw); /* Read a row of nCols by nBands bytes of data */
- for (col = 0; col < nCols; col++) {
- for (band = 0; band < nBands; band++) {
- I->data[row + col*nRows + band*nXY] = tmp[band + col*nBands];
- }
- }
- }
- gmt_M_free (GMT, tmp);
- fclose (fp_raw); fp_raw = NULL;
-#endif
if (GMT_Write_Data (API, GMT_IS_IMAGE, GMT_IS_FILE, GMT_IS_SURFACE, GMT_CONTAINER_AND_DATA, NULL, Ctrl->F.file, I) != GMT_NOERROR)
Return (API->error);
gmt_set_pad (GMT, API->pad); /* Reset padding to GMT default */
diff --git a/src/psimage.c b/src/psimage.c
index 705777b692b..c4f2b9900e5 100644
--- a/src/psimage.c
+++ b/src/psimage.c
@@ -16,7 +16,6 @@
*--------------------------------------------------------------------*/
/*
* Brief synopsis: psimage reads an EPS file or a 1, 8, 24, or 32 bit image and plots it on the page
- * Images are only supported if GMT was built with GDAL support.
*
* Author: Paul Wessel
* Date: 1-JAN-2010
@@ -346,7 +345,6 @@ GMT_LOCAL int file_is_eps (struct GMT_CTRL *GMT, char **file) { /* Returns 1 if
#define Return(code) {gmt_M_free (GMT, table); return (code);}
-#ifdef HAVE_GDAL
GMT_LOCAL int psimage_find_unique_color (struct GMT_CTRL *GMT, unsigned char *rgba, size_t n, int *r, int *g, int *b) {
size_t i, j;
int idx;
@@ -384,7 +382,6 @@ GMT_LOCAL int psimage_find_unique_color (struct GMT_CTRL *GMT, unsigned char *rg
}
Return (3);
}
-#endif
#undef Return
@@ -394,7 +391,9 @@ EXTERN_MSC unsigned char *psl_gray_encode (struct PSL_CTRL *PSL, size_t *nbytes,
EXTERN_MSC int GMT_psimage (void *V_API, int mode, void *args) {
int i, j, PS_interpolate = 1, PS_transparent = 1, is_eps = 0, error = 0, is_gdal = 0;
+ int k, r = 0, g = 0, b = 0, has_trans = 0;
unsigned int row, col;
+ unsigned char colormap[4*256];
size_t n;
bool free_GMT = false, did_gray = false;
@@ -410,11 +409,7 @@ EXTERN_MSC int GMT_psimage (void *V_API, int mode, void *args) {
struct GMT_CTRL *GMT = NULL, *GMT_cpy = NULL; /* General GMT internal parameters */
struct GMT_OPTION *options = NULL;
struct PSL_CTRL *PSL = NULL; /* General PSL internal parameters */
-#ifdef HAVE_GDAL
- int k, r = 0, g = 0, b = 0, has_trans = 0;
- unsigned char colormap[4*256];
- struct GMT_IMAGE *I = NULL; /* A GMT image datatype, if GDAL is used */
-#endif
+ struct GMT_IMAGE *I = NULL; /* A GMT image datatype */
struct GMTAPI_CTRL *API = gmt_get_api_ptr (V_API); /* Cast from void to GMTAPI_CTRL pointer */
/*----------------------- Standard module initialization and parsing ----------------------*/
@@ -462,7 +457,6 @@ EXTERN_MSC int GMT_psimage (void *V_API, int mode, void *args) {
Return (GMT_IMAGE_READ_ERROR);
}
}
-#ifdef HAVE_GDAL
else { /* Read a raster image */
bool R_save = GMT->common.R.active[RSET];
GMT->common.R.active[RSET] = false; /* Temporarily unset any active -R since we do not want it to be used for a subset of this image! */
@@ -533,13 +527,6 @@ EXTERN_MSC int GMT_psimage (void *V_API, int mode, void *args) {
header.height = I->header->n_rows;
header.depth = (int)I->header->n_bands * 8;
}
-#else
- else { /* Without GDAL we can only read EPS files */
- GMT_Report (API, GMT_MSG_ERROR, "Unsupported file format for file %s!\n", file);
- gmt_M_str_free (file);
- Return (GMT_RUNTIME_ERROR);
- }
-#endif
if (Ctrl->M.active && header.depth == 24) { /* Downgrade to grayshade image */
did_gray = true;
@@ -547,14 +534,12 @@ EXTERN_MSC int GMT_psimage (void *V_API, int mode, void *args) {
buffer = psl_gray_encode (PSL, &n, picture);
header.depth = 8;
if (is_eps) PSL_free (picture); /* EPS ile */
-#ifdef HAVE_GDAL
else { /* Got it via GMT_Read_Data */
if (GMT_Destroy_Data (API, &I) != GMT_NOERROR) {
gmt_M_str_free (file);
Return (API->error);
}
}
-#endif
picture = buffer;
}
@@ -568,14 +553,10 @@ EXTERN_MSC int GMT_psimage (void *V_API, int mode, void *args) {
buffer = gmt_M_memory (GMT, NULL, n, unsigned char);
for (i = 0; i < j; i++) buffer[i] = (unsigned char)rint(255 * Ctrl->G.rgb[PSIMAGE_TRA][i]);
gmt_M_memcpy (&(buffer[j]), picture, n - j, unsigned char);
-#ifdef HAVE_GDAL
if (GMT_Destroy_Data (API, &I) != GMT_NOERROR) { /* If I is NULL then nothing is done */
gmt_M_str_free (file);
Return (API->error);
}
-#else
- PSL_free (picture);
-#endif
picture = buffer;
free_GMT = true;
}
@@ -700,11 +681,9 @@ EXTERN_MSC int GMT_psimage (void *V_API, int mode, void *args) {
gmt_plotend (GMT);
gmt_M_str_free (file);
-#ifdef HAVE_GDAL
if (I && GMT_Destroy_Data (API, &I) != GMT_NOERROR) {
Return (API->error); /* If I is NULL then nothing is done */
}
-#endif
if (free_GMT) {
gmt_M_free (GMT, picture);
}
diff --git a/src/surface.c b/src/surface.c
index ce426a1e943..bf3edd4d98a 100644
--- a/src/surface.c
+++ b/src/surface.c
@@ -1664,7 +1664,7 @@ static int usage (struct GMTAPI_CTRL *API, int level) {
GMT_Usage (API, -2, "Use xyz data in the file as a 'soft breakline'. Optional modifier:");
GMT_Usage (API, 3, "+z Override any z from the file with the appended [0].");
GMT_Usage (API, 1, "\n%s", GMT_J_OPT);
- GMT_Usage (API, -2, "Select the data map projection. This projection is only used to add a CRS info to the "
+ GMT_Usage (API, -2, "Select the data map projection. This projection is only used to add CRS info to the "
"grid formats that support it, i.e., netCDF, GeoTIFF, and others supported by GDAL.");
GMT_Usage (API, 1, "\n-Ll|u");
GMT_Usage (API, -2, "Constrain the range of output values; append directive and value, repeatable:");
diff --git a/src/xyz2grd.c b/src/xyz2grd.c
index 241195025db..8099d6e21f1 100644
--- a/src/xyz2grd.c
+++ b/src/xyz2grd.c
@@ -303,15 +303,10 @@ static int parse (struct GMT_CTRL *GMT, struct XYZ2GRD_CTRL *Ctrl, struct GMT_Z_
#define bailout(code) {gmt_M_free_options (mode); return (code);}
#define Return(code) {Free_Ctrl (GMT, Ctrl); gmt_end_module (GMT, GMT_cpy); bailout (code);}
-GMT_LOCAL void xyz2grd_protect_J(struct GMTAPI_CTRL *API, struct GMT_OPTION *options) {
+GMT_LOCAL void xyz2grd_protect_J (struct GMTAPI_CTRL *API, struct GMT_OPTION *options) {
if (GMT_Find_Option (API, 'J', options) != NULL) {
-#ifdef HAVE_GDAL
struct GMT_OPTION *opt = GMT_Make_Option (API, 'f', "0f,1f");
(void)GMT_Append_Option(API, opt, options);
-#else
- GMT_Report(API, GMT_MSG_ERROR,
- "-J option to set grid's referencing system is only available when GMT was build with GDAL\n");
-#endif
}
}
diff --git a/test/grdimage/readwrite_withgdal.sh b/test/grdimage/readwrite_withgdal.sh
index e9a5f292656..4a7b12de5e0 100755
--- a/test/grdimage/readwrite_withgdal.sh
+++ b/test/grdimage/readwrite_withgdal.sh
@@ -1,9 +1,6 @@
#!/usr/bin/env bash
#
-GDAL=$(gmt grdconvert 2>&1 | grep -c gd)
-if [ $GDAL -eq 0 ]; then exit; fi
-
ps=readwrite_withgdal.ps
# RGB image. The +b0,1,2 also tests the bands request option
diff --git a/test/psimage/transparent_gif.sh b/test/psimage/transparent_gif.sh
index a9bab283bdc..372945ccacf 100755
--- a/test/psimage/transparent_gif.sh
+++ b/test/psimage/transparent_gif.sh
@@ -1,9 +1,6 @@
#!/usr/bin/env bash
#
-GDAL=`gmt grdconvert 2>&1 | grep -c gd`
-if [ $GDAL -eq 0 ]; then exit; fi
-
ps=transparent_gif.ps
# Make several plots to test transparency
diff --git a/test/psimage/transparent_png.sh b/test/psimage/transparent_png.sh
index 165ca3b2f6e..9251e5356bc 100755
--- a/test/psimage/transparent_png.sh
+++ b/test/psimage/transparent_png.sh
@@ -1,8 +1,5 @@
#!/usr/bin/env bash
-GDAL=`gmt grdconvert 2>&1 | grep -c gd`
-if [ $GDAL -eq 0 ]; then exit; fi
-
ps=transparent_png.ps
# Make several plots to test transparency
diff --git a/test/psimage/withgdal.sh b/test/psimage/withgdal.sh
index 9e90ce1a1f9..f87ffffc63a 100755
--- a/test/psimage/withgdal.sh
+++ b/test/psimage/withgdal.sh
@@ -1,9 +1,5 @@
#!/usr/bin/env bash
#
-
-GDAL=`gmt grdconvert 2>&1 | grep -c gd`
-if [ $GDAL -eq 0 ]; then exit; fi
-
ps=withgdal.ps
# RGB image. The +b2,1,0 also tests the bands request option