Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxxen committed Dec 3, 2024
1 parent f6815ce commit ca1a5dd
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 31 deletions.
41 changes: 20 additions & 21 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ add_definitions(-DDUCKDB_PATCH_VERSION=${DUCKDB_PATCH_VERSION})
# Enable network functionality (OpenSSL and GDAL's CURL based fs/drivers)
option(SPATIAL_USE_NETWORK "Enable network functionality" ON)

if (EMSCRIPTEN OR IOS OR ANDROID)
if(EMSCRIPTEN
OR IOS
OR ANDROID)
set(SPATIAL_USE_NETWORK OFF)
endif()

Expand All @@ -32,7 +34,6 @@ include_directories(spatial/third_party/protozero/include)
include_directories(spatial/third_party/shapelib)
add_subdirectory(spatial/third_party/shapelib)


add_library(${EXTENSION_NAME} STATIC ${EXTENSION_SOURCES})

# Build dependencies TODO: in the future we should allow users to dynamically
Expand All @@ -44,19 +45,17 @@ if(NOT EXISTS ${CMAKE_BINARY_DIR}/deps)
execute_process(
# Generate project
COMMAND
${CMAKE_COMMAND} -G ${CMAKE_GENERATOR}
-DDUCKDB_ENABLE_DEPRECATED_API=1
-DWASM_LOADABLE_EXTENSIONS=1
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
${CMAKE_COMMAND} -G ${CMAKE_GENERATOR} -DDUCKDB_ENABLE_DEPRECATED_API=1
-DWASM_LOADABLE_EXTENSIONS=1 -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DOSX_BUILD_ARCH=${OSX_BUILD_ARCH}
-DSPATIAL_USE_NETWORK=${SPATIAL_USE_NETWORK}
-DOPENSSL_ROOT_DIR=$ENV{OPENSSL_ROOT_DIR}
-DVCPKG_MANIFEST_DIR='${VCPKG_MANIFEST_DIR}'
-DVCPKG_INSTALLED_DIR='${CMAKE_BINARY_DIR}/vcpkg_installed'
-DCMAKE_TOOLCHAIN_FILE='${CMAKE_TOOLCHAIN_FILE}'
-DVCPKG_TARGET_TRIPLET='${VCPKG_TARGET_TRIPLET}'
-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE='${VCPKG_CHAINLOAD_TOOLCHAIN_FILE}'
-S ${CMAKE_CURRENT_SOURCE_DIR}/deps -B ${CMAKE_BINARY_DIR}/deps
-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE='${VCPKG_CHAINLOAD_TOOLCHAIN_FILE}' -S
${CMAKE_CURRENT_SOURCE_DIR}/deps -B ${CMAKE_BINARY_DIR}/deps
RESULT_VARIABLE DEPENDENCIES_GENERATE_RESULT)
if(NOT DEPENDENCIES_GENERATE_RESULT EQUAL 0)
message(FATAL_ERROR "Could not generate dependencies project")
Expand All @@ -83,7 +82,7 @@ message(STATUS "Find libraries path: '${CMAKE_PREFIX_PATH}'")
set(ZLIB_USE_STATIC_LIBS ON)
set(OPENSSL_USE_STATIC_LIBS ON)

if (EMSCRIPTEN)
if(EMSCRIPTEN)
set(OPENSSL_USE_STATIC_LIBS OFF)
endif()

Expand All @@ -97,16 +96,15 @@ find_package(EXPAT REQUIRED)
find_package(GeographicLib REQUIRED)

# Important: The link order matters, its the reverse order of dependency
set(EXTENSION_DEPENDENCIES
GDAL::GDAL
GEOS::geos_c
PROJ::proj
EXPAT::EXPAT
SQLite::SQLite3
ZLIB::ZLIB
${SQLITE3_MEMVFS}
${GeographicLib_LIBRARIES}
)
set(EXTENSION_DEPENDENCIES
GDAL::GDAL
GEOS::geos_c
PROJ::proj
EXPAT::EXPAT
SQLite::SQLite3
ZLIB::ZLIB
${SQLITE3_MEMVFS}
${GeographicLib_LIBRARIES})

if(SPATIAL_USE_NETWORK)
message(STATUS "Building with network functionality")
Expand All @@ -125,7 +123,7 @@ if((NOT EMSCRIPTEN) AND (NOT IOS))
find_library(CoreFoundation_Library CoreFoundation)
find_library(SystemConfiguration_Library SystemConfiguration)
list(APPEND EXTENSION_DEPENDENCIES ${CoreFoundation_Library}
${SystemConfiguration_Library})
${SystemConfiguration_Library})
endif()
endif()

Expand All @@ -139,7 +137,8 @@ target_link_libraries(${EXTENSION_NAME} PUBLIC ${EXTENSION_DEPENDENCIES})
set(PARAMETERS "-warnings")
build_loadable_extension(${TARGET_NAME} ${PARAMETERS} ${EXTENSION_SOURCES})

target_link_libraries(${TARGET_NAME}_loadable_extension ${EXTENSION_DEPENDENCIES})
target_link_libraries(${TARGET_NAME}_loadable_extension
${EXTENSION_DEPENDENCIES})

install(
TARGETS ${EXTENSION_NAME}
Expand Down
7 changes: 4 additions & 3 deletions spatial/include/spatial/doc_util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ struct DocTag {

struct DocUtil {
static void AddDocumentation(duckdb::DatabaseInstance &db, const char *function_name, const char *description,
const char *example,
const duckdb::unordered_map<duckdb::string, duckdb::string> &tags, duckdb::vector<duckdb::string> parameter_names = {});
const char *example, const duckdb::unordered_map<duckdb::string, duckdb::string> &tags,
duckdb::vector<duckdb::string> parameter_names = {});

// Abuse adding tags as a comment
template <size_t N>
static void AddDocumentation(duckdb::DatabaseInstance &db, const char *function_name, const char *description,
const char *example, const DocTag (&tags)[N], duckdb::vector<duckdb::string> parameter_names = {}) {
const char *example, const DocTag (&tags)[N],
duckdb::vector<duckdb::string> parameter_names = {}) {
duckdb::unordered_map<duckdb::string, duckdb::string> tag_map;
for (size_t i = 0; i < N; i++) {
tag_map[tags[i].key] = tags[i].value;
Expand Down
10 changes: 6 additions & 4 deletions spatial/src/spatial/geos/functions/aggregate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,17 +197,19 @@ void GeosAggregateFunctions::Register(DatabaseInstance &db) {

AggregateFunctionSet st_intersection_agg("ST_Intersection_Agg");
st_intersection_agg.AddFunction(
AggregateFunction::UnaryAggregateDestructor<GEOSAggState, geometry_t, geometry_t, IntersectionAggFunction, AggregateDestructorType::LEGACY>(
core::GeoTypes::GEOMETRY(), core::GeoTypes::GEOMETRY()));
AggregateFunction::UnaryAggregateDestructor<GEOSAggState, geometry_t, geometry_t, IntersectionAggFunction,
AggregateDestructorType::LEGACY>(core::GeoTypes::GEOMETRY(),
core::GeoTypes::GEOMETRY()));

ExtensionUtil::RegisterFunction(db, st_intersection_agg);
DocUtil::AddDocumentation(db, "ST_Intersection_Agg", INTERSECTION_DOC_DESCRIPTION, INTERSECTION_DOC_EXAMPLE,
DOC_TAGS);

AggregateFunctionSet st_union_agg("ST_Union_Agg");
st_union_agg.AddFunction(
AggregateFunction::UnaryAggregateDestructor<GEOSAggState, geometry_t, geometry_t, UnionAggFunction, AggregateDestructorType::LEGACY>(
core::GeoTypes::GEOMETRY(), core::GeoTypes::GEOMETRY()));
AggregateFunction::UnaryAggregateDestructor<GEOSAggState, geometry_t, geometry_t, UnionAggFunction,
AggregateDestructorType::LEGACY>(core::GeoTypes::GEOMETRY(),
core::GeoTypes::GEOMETRY()));

ExtensionUtil::RegisterFunction(db, st_union_agg);
DocUtil::AddDocumentation(db, "ST_Union_Agg", UNION_DOC_DESCRIPTION, UNION_DOC_EXAMPLE, DOC_TAGS);
Expand Down
3 changes: 2 additions & 1 deletion spatial/src/spatial/geos/functions/scalar/st_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ void GEOSScalarFunctions::RegisterStBuffer(DatabaseInstance &db) {
GEOSFunctionLocalState::Init));

ExtensionUtil::RegisterFunction(db, set);
DocUtil::AddDocumentation(db, "ST_Buffer", DOC_DESCRIPTION, DOC_EXAMPLE, DOC_TAGS, {"geom", "distance", "num_triangles", "join_style", "cap_style", "mitre_limit"});
DocUtil::AddDocumentation(db, "ST_Buffer", DOC_DESCRIPTION, DOC_EXAMPLE, DOC_TAGS,
{"geom", "distance", "num_triangles", "join_style", "cap_style", "mitre_limit"});
}

} // namespace geos
Expand Down
3 changes: 2 additions & 1 deletion spatial/src/spatial/proj/functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,8 @@ void ProjFunctions::Register(DatabaseInstance &db) {
GeometryTransformFunction, TransformBind, nullptr, nullptr, ProjFunctionLocalState::Init));

ExtensionUtil::RegisterFunction(db, set);
DocUtil::AddDocumentation(db, "ST_Transform", DOC_DESCRIPTION, DOC_EXAMPLE, DOC_TAGS, {"geom", "source_crs", "target_crs", "always_xy"});
DocUtil::AddDocumentation(db, "ST_Transform", DOC_DESCRIPTION, DOC_EXAMPLE, DOC_TAGS,
{"geom", "source_crs", "target_crs", "always_xy"});
GenerateSpatialRefSysTable::Register(db);
}

Expand Down
2 changes: 1 addition & 1 deletion spatial/src/spatial_extension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ static string RemoveIndentAndTrailingWhitespace(const char *text) {
void spatial::DocUtil::AddDocumentation(duckdb::DatabaseInstance &db, const char *function_name,
const char *description, const char *example,
const duckdb::unordered_map<duckdb::string, duckdb::string> &tags,
duckdb::vector<duckdb::string> parameter_names) {
duckdb::vector<duckdb::string> parameter_names) {

auto &system_catalog = Catalog::GetSystemCatalog(db);
auto data = CatalogTransaction::GetSystemTransaction(db);
Expand Down

0 comments on commit ca1a5dd

Please sign in to comment.