Skip to content

Commit

Permalink
Merge pull request OSGeo#10914 from rouault/gml_plugin
Browse files Browse the repository at this point in the history
Build: enable -DOGR_ENABLE_DRIVER_GML_PLUGIN=ON, …
  • Loading branch information
rouault authored Oct 5, 2024
2 parents 9b44a75 + 579ffc7 commit 3b92680
Show file tree
Hide file tree
Showing 31 changed files with 590 additions and 513 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
25 changes: 21 additions & 4 deletions ogr/ogrsf_frmts/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,23 @@ 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
if (NOT(DEFINED OGR_ENABLE_DRIVER_GML AND NOT OGR_ENABLE_DRIVER_GML AND
((NOT GDAL_USE_CURL) OR
(DEFINED OGR_ENABLE_DRIVER_WFS AND NOT OGR_ENABLE_DRIVER_WFS AND
DEFINED OGR_ENABLE_DRIVER_OAPIF AND NOT OGR_ENABLE_DRIVER_OAPIF AND
DEFINED OGR_ENABLE_DRIVER_CSW AND NOT OGR_ENABLE_DRIVER_CSW))))
# Only build gmlutils if we have GML, WFS, OAPIF or CSW
add_subdirectory(gmlutils)
endif()

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 Expand Up @@ -85,21 +101,22 @@ ogr_dependent_driver(sdts SDTS "GDAL_ENABLE_DRIVER_SDTS")
ogr_dependent_driver(gpx "GPX - GPS Exchange Format" "GDAL_USE_EXPAT")
ogr_dependent_driver(gmlas GMLAS "GDAL_USE_XERCESC;OGR_ENABLE_DRIVER_PGDUMP")
ogr_dependent_driver(svg "Scalable Vector Graphics" "GDAL_USE_EXPAT")
ogr_dependent_driver(csw CSW "GDAL_USE_CURL;OGR_ENABLE_DRIVER_GML")
ogr_dependent_driver(csw CSW "GDAL_USE_CURL")
ogr_dependent_driver(dwg DWG "GDAL_USE_TEIGHA")
ogr_dependent_driver(filegdb FileGDB "GDAL_USE_FILEGDB")
ogr_dependent_driver(libkml LibKML "GDAL_USE_LIBKML")
ogr_dependent_driver(nas "NAS/ALKIS" "GDAL_USE_XERCESC;OGR_ENABLE_DRIVER_GML")
ogr_dependent_driver(plscenes PLSCENES "GDAL_USE_CURL")
ogr_dependent_driver(sosi "SOSI:Systematic Organization of Spatial Information" "GDAL_USE_FYBA")
ogr_dependent_driver(wfs "OGC WFS service" "GDAL_USE_CURL;OGR_ENABLE_DRIVER_GML")
ogr_dependent_driver(wfs "OGC WFS service" "GDAL_USE_CURL")
ogr_dependent_driver(oapif "OGC API Features service" "GDAL_USE_CURL")
ogr_dependent_driver(ngw "NextGIS Web" "GDAL_USE_CURL")
ogr_dependent_driver(elastic "ElasticSearch" "GDAL_USE_CURL")
ogr_dependent_driver(xodr OpenDRIVE "GDAL_USE_OPENDRIVE;GDAL_USE_GEOS")

ogr_dependent_driver(idrisi IDRISI "GDAL_ENABLE_DRIVER_IDRISI")

ogr_dependent_driver(pds "Planetary Data Systems TABLE" "GDAL_ENABLE_DRIVER_PDS;OGR_ENABLE_DRIVER_GML")
ogr_dependent_driver(pds "Planetary Data Systems TABLE" "GDAL_ENABLE_DRIVER_PDS")

# Caution: if modifying SQLite declaration here, also modify it in gdal.cmake
ogr_dependent_driver(sqlite "SQLite3 / Spatialite RDBMS" "GDAL_USE_SQLITE3")
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
2 changes: 2 additions & 0 deletions ogr/ogrsf_frmts/generic/ogrregisterall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ void OGRRegisterAllInternal()
#endif
#ifdef WFS_ENABLED
RegisterOGRWFS();
#endif
#ifdef OAPIF_ENABLED
RegisterOGROAPIF();
#endif
#ifdef SOSI_ENABLED
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 3b92680

Please sign in to comment.