Skip to content

Commit

Permalink
Build: enable -DOGR_ENABLE_DRIVER_GML_PLUGIN=ON, provided that -DOGR_…
Browse files Browse the repository at this point in the history
…ENABLE_DRIVER_NAS=OFF; make CSW and WFS drivers plugin capable too
  • Loading branch information
rouault committed Oct 2, 2024
1 parent 9660894 commit 256c413
Show file tree
Hide file tree
Showing 28 changed files with 575 additions and 508 deletions.
1 change: 1 addition & 0 deletions autotest/gdrivers/ogcapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ def init():


@pytest.mark.parametrize("remove_type_application_json", [False, True])
@pytest.mark.require_driver("OAPIF")
def test_ogr_ogcapi_features(remove_type_application_json):

global global_remove_type_application_json
Expand Down
8 changes: 1 addition & 7 deletions frmts/ogcapi/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
add_gdal_driver(TARGET gdal_OGCAPI SOURCES gdalogcapidataset.cpp PLUGIN_CAPABLE NO_DEPS)
gdal_standard_includes(gdal_OGCAPI)
if(NOT DEFINED OGR_ENABLE_DRIVER_GML)
message(FATAL_ERROR "OGR_ENABLE_DRIVER_GML is not defined")
endif()
if(OGR_ENABLE_DRIVER_GML)
target_include_directories(gdal_OGCAPI PRIVATE ${GDAL_VECTOR_FORMAT_SOURCE_DIR}/gml)
target_compile_definitions(gdal_OGCAPI PRIVATE -DOGR_ENABLE_DRIVER_GML)
endif()
target_include_directories(gdal_OGCAPI PRIVATE ${GDAL_VECTOR_FORMAT_SOURCE_DIR}/gmlutils)
8 changes: 0 additions & 8 deletions frmts/ogcapi/gdalogcapidataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@
#include "ogrsf_frmts.h"
#include "ogr_spatialref.h"

#ifdef OGR_ENABLE_DRIVER_GML
#include "parsexsd.h"
#endif

#include <algorithm>
#include <memory>
Expand Down Expand Up @@ -1649,7 +1647,6 @@ GDALColorInterp OGCAPIMapWrapperBand::GetColorInterpretation()
/* ParseXMLSchema() */
/************************************************************************/

#ifdef OGR_ENABLE_DRIVER_GML
static bool
ParseXMLSchema(const std::string &osURL,
std::vector<std::unique_ptr<OGRFieldDefn>> &apoFields,
Expand Down Expand Up @@ -1694,7 +1691,6 @@ ParseXMLSchema(const std::string &osURL,

return false;
}
#endif

/************************************************************************/
/* InitWithTilesAPI() */
Expand Down Expand Up @@ -1966,14 +1962,12 @@ bool OGCAPIDataset::InitWithTilesAPI(GDALOpenInfo *poOpenInfo,
}
}

#ifdef OGR_ENABLE_DRIVER_GML
std::vector<std::unique_ptr<OGRFieldDefn>> apoFields;
bool bGotSchema = false;
if (!osXMLSchemaURL.empty())
{
bGotSchema = ParseXMLSchema(osXMLSchemaURL, apoFields, eGeomType);
}
#endif

for (const auto &tileMatrix : tms->tileMatrixList())
{
Expand Down Expand Up @@ -2021,10 +2015,8 @@ bool OGCAPIDataset::InitWithTilesAPI(GDALOpenInfo *poOpenInfo,
tileMatrix, eGeomType));
poLayer->SetMinMaxXY(minCol, minRow, maxCol, maxRow);
poLayer->SetExtent(dfXMin, dfYMin, dfXMax, dfYMax);
#ifdef OGR_ENABLE_DRIVER_GML
if (bGotSchema)
poLayer->SetFields(apoFields);
#endif
m_apoLayers.emplace_back(std::move(poLayer));
}

Expand Down
2 changes: 1 addition & 1 deletion frmts/wcs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ if(NOT TARGET gdal_WCS)
endif()

gdal_standard_includes(gdal_WCS)
target_include_directories(gdal_WCS PRIVATE ${GDAL_VECTOR_FORMAT_SOURCE_DIR}/gml)
target_include_directories(gdal_WCS PRIVATE ${GDAL_VECTOR_FORMAT_SOURCE_DIR}/gmlutils)
10 changes: 4 additions & 6 deletions ogr/ogr_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,10 @@ OGRErr CPL_DLL OGRCheckPermutation(const int *panPermutation, int nSize);

/* GML related */

OGRGeometry *GML2OGRGeometry_XMLNode(const CPLXMLNode *psNode,
int nPseudoBoolGetSecondaryGeometryOption,
int nRecLevel = 0, int nSRSDimension = 0,
bool bIgnoreGSG = false,
bool bOrientation = true,
bool bFaceHoleNegative = false);
OGRGeometry CPL_DLL *GML2OGRGeometry_XMLNode(
const CPLXMLNode *psNode, int nPseudoBoolGetSecondaryGeometryOption,
int nRecLevel = 0, int nSRSDimension = 0, bool bIgnoreGSG = false,
bool bOrientation = true, bool bFaceHoleNegative = false);

/************************************************************************/
/* PostGIS EWKB encoding */
Expand Down
11 changes: 10 additions & 1 deletion ogr/ogrsf_frmts/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,16 @@ ogr_optional_driver(vrt "VRT - Virtual Format")
# Caution: if modifying AVC declaration here, also modify it in gdal.cmake
ogr_optional_driver(avc AVC)

ogr_optional_driver(gml GML) # when not found both EXPAT/XercesC, return error in driver, referenced by WCS
add_subdirectory(gmlutils)

if (GDAL_ENABLE_PLUGINS_NO_DEPS AND NOT DEFINED OGR_ENABLE_DRIVER_GML_PLUGIN)
option(OGR_ENABLE_DRIVER_GML_PLUGIN "Set ON to build GML driver as a plugin" OFF)
endif ()
ogr_optional_driver(gml GML)
if (OGR_ENABLE_DRIVER_GML_PLUGIN AND
((NOT DEFINED OGR_ENABLE_DRIVER_NAS OR OGR_ENABLE_DRIVER_NAS)))
message(FATAL_ERROR "When building the GML driver as a plugin, the NAS driver must be explicitly disabled with OGR_ENABLE_DRIVER_NAS=OFF")
endif()

# ######################################################################################################################
ogr_optional_driver(csv CSV)
Expand Down
5 changes: 3 additions & 2 deletions ogr/ogrsf_frmts/csw/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
add_gdal_driver(
TARGET ogr_CSW
SOURCES ogrcswdataset.cpp
BUILTIN) # BUILTIN because of GML and WFS dependency
PLUGIN_CAPABLE
NO_DEPS)
gdal_standard_includes(ogr_CSW)
target_include_directories(ogr_CSW PRIVATE $<TARGET_PROPERTY:ogr_GML,SOURCE_DIR> $<TARGET_PROPERTY:ogr_WFS,SOURCE_DIR>)
target_include_directories(ogr_CSW PRIVATE $<TARGET_PROPERTY:gmlutils,SOURCE_DIR>)
3 changes: 2 additions & 1 deletion ogr/ogrsf_frmts/csw/ogrcswdataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@
#include "ogrsf_frmts.h"
#include "cpl_conv.h"
#include "cpl_http.h"
#include "ogr_wfs.h"
#include "ogr_p.h"
#include "ogr_swq.h"
#include "ogrwfsfilter.h"
#include "gmlutils.h"

extern "C" void RegisterOGRCSW();
Expand Down
12 changes: 4 additions & 8 deletions ogr/ogrsf_frmts/gml/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,32 +1,28 @@
add_gdal_driver(
TARGET ogr_GML
SOURCES gfstemplate.cpp
gmlpropertydefn.cpp
gmlreadstate.cpp
gmlutils.h
ogrgmldriver.cpp
resolvexlinks.cpp
gmlfeature.cpp
gmlreader.cpp
gmlregistry.cpp
hugefileresolver.cpp
ogrgmllayer.cpp
xercesc_headers.h
gmlfeatureclass.cpp
gmlreader.h
gmlregistry.h
ogr_gml.h
parsexsd.cpp
gmlhandler.cpp
gmlreaderp.h
gmlutils.cpp
ogrgmldatasource.cpp
parsexsd.h
BUILTIN
PLUGIN_CAPABLE
NO_DEPS
STRONG_CXX_WFLAGS
)
gdal_standard_includes(ogr_GML)

target_include_directories(ogr_GML PRIVATE $<TARGET_PROPERTY:gmlutils,SOURCE_DIR>)

set(GDAL_DATA_FILES
${CMAKE_CURRENT_SOURCE_DIR}/data/gfs.xsd
${CMAKE_CURRENT_SOURCE_DIR}/data/gml_registry.xml
Expand Down
Loading

0 comments on commit 256c413

Please sign in to comment.