Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use libspatialjoin for geometric relations, drop Boost dependency #92

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@
[submodule "vendor/google/benchmark"]
path = vendor/google/benchmark
url = https://github.com/google/benchmark.git
[submodule "vendor/spatialjoin"]
path = vendor/spatialjoin
url = https://github.com/ad-freiburg/spatialjoin.git
9 changes: 4 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,6 @@ find_program(
# ----------------------------------------------------------------------------
# Configure dependencies
# ----------------------------------------------------------------------------
set(Boost_USE_STATIC_LIBS OFF)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
find_package(Boost REQUIRED serialization)
find_package(EXPAT REQUIRED)
find_package(BZip2 REQUIRED)
find_package(ZLIB REQUIRED)
Expand Down Expand Up @@ -216,7 +212,7 @@ configure_file(

if (CLANG_TIDY_EXE)
message(STATUS "Found CLANG_TIDY_EXE at ${CLANG_TIDY_EXE}, enabling checks")
set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_EXE};-checks=-*,readability-*")
# set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_EXE};-checks=-*,readability-*")
else()
message(STATUS "CLANG_TIDY_EXE not found")
endif ()
Expand All @@ -230,6 +226,9 @@ endif ()
# The compiled library code is here
add_subdirectory(src)

# libspatialjoin
add_subdirectory(vendor/spatialjoin)

# The executable code is here
add_subdirectory(apps)

Expand Down
151 changes: 151 additions & 0 deletions cmake/GetGitRevisionDescription.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
# - Returns a version string from Git
#
# These functions force a re-configure on each git commit so that you can
# trust the values of the variables in your build system.
#
# get_git_head_revision(<refspecvar> <hashvar> [<additional arguments to git describe> ...])
#
# Returns the refspec and sha hash of the current head revision
#
# git_describe(<var> [<additional arguments to git describe> ...])
#
# Returns the results of git describe on the source tree, and adjusting
# the output so that it tests false if an error occurs.
#
# git_get_exact_tag(<var> [<additional arguments to git describe> ...])
#
# Returns the results of git describe --exact-match on the source tree,
# and adjusting the output so that it tests false if there was no exact
# matching tag.
#
# Requires CMake 2.6 or newer (uses the 'function' command)
#
# Original Author:
# 2009-2010 Ryan Pavlik <[email protected]> <[email protected]>
# http://academic.cleardefinition.com
# Iowa State University HCI Graduate Program/VRAC
#
# Copyright Iowa State University 2009-2010.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)

if(__get_git_revision_description)
return()
endif()
set(__get_git_revision_description YES)

# We must run the following at "include" time, not at function call time,
# to find the path to this module rather than the path to a calling list file
get_filename_component(_gitdescmoddir ${CMAKE_CURRENT_LIST_FILE} PATH)

function(get_git_head_revision _refspecvar _hashvar)
set(GIT_PARENT_DIR "${CMAKE_SOURCE_DIR}")
set(GIT_DIR "${GIT_PARENT_DIR}/.git")
while(NOT EXISTS "${GIT_DIR}") # .git dir not found, search parent directories
set(GIT_PREVIOUS_PARENT "${GIT_PARENT_DIR}")
get_filename_component(GIT_PARENT_DIR ${GIT_PARENT_DIR} PATH)
if(GIT_PARENT_DIR STREQUAL GIT_PREVIOUS_PARENT)
# We have reached the root directory, we are not in git
set(${_refspecvar} "GITDIR-NOTFOUND" PARENT_SCOPE)
set(${_hashvar} "GITDIR-NOTFOUND" PARENT_SCOPE)
return()
endif()
set(GIT_DIR "${GIT_PARENT_DIR}/.git")
endwhile()
set(GIT_DATA "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/git-data")
if(NOT EXISTS "${GIT_DATA}")
file(MAKE_DIRECTORY "${GIT_DATA}")
endif()

if(NOT EXISTS "${GIT_DIR}/HEAD")
return()
endif()
set(HEAD_FILE "${GIT_DATA}/HEAD")
configure_file("${GIT_DIR}/HEAD" "${HEAD_FILE}" COPYONLY)

configure_file("${_gitdescmoddir}/GetGitRevisionDescription.cmake.in"
"${GIT_DATA}/grabRef.cmake"
@ONLY)
include("${GIT_DATA}/grabRef.cmake")

set(${_refspecvar} "${HEAD_REF}" PARENT_SCOPE)
set(${_hashvar} "${HEAD_HASH}" PARENT_SCOPE)
endfunction()

function(get_git_is_dirty _var)
if(NOT GIT_FOUND)
find_package(Git QUIET)
endif()

execute_process(COMMAND
"${GIT_EXECUTABLE}"
diff-index --name-only HEAD --
WORKING_DIRECTORY
"${CMAKE_SOURCE_DIR}"
RESULT_VARIABLE
res
OUTPUT_VARIABLE
out
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT res EQUAL 0)
set(out "${out}-${res}-NOTFOUND")
endif()

if (NOT "${out}" STREQUAL "")
set(IS_DIRTY "dirty")
else()
set(IS_DIRTY "")
endif()
set(${_var} "${IS_DIRTY}" PARENT_SCOPE)
endfunction()

function(git_describe _var)
if(NOT GIT_FOUND)
find_package(Git QUIET)
endif()
get_git_head_revision(refspec hash)
if(NOT GIT_FOUND)
set(${_var} "GIT-NOTFOUND" PARENT_SCOPE)
return()
endif()
if(NOT hash)
set(${_var} "HEAD-HASH-NOTFOUND" PARENT_SCOPE)
return()
endif()

# TODO sanitize
#if((${ARGN}" MATCHES "&&") OR
# (ARGN MATCHES "||") OR
# (ARGN MATCHES "\\;"))
# message("Please report the following error to the project!")
# message(FATAL_ERROR "Looks like someone's doing something nefarious with git_describe! Passed arguments ${ARGN}")
#endif()

#message(STATUS "Arguments to execute_process: ${ARGN}")

execute_process(COMMAND
"${GIT_EXECUTABLE}"
describe
${hash}
${ARGN}
WORKING_DIRECTORY
"${CMAKE_SOURCE_DIR}"
RESULT_VARIABLE
res
OUTPUT_VARIABLE
out
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT res EQUAL 0)
set(out "${out}-${res}-NOTFOUND")
endif()

set(${_var} "${out}" PARENT_SCOPE)
endfunction()

function(git_get_tag _var)
git_describe(out --tags ${ARGN})
set(${_var} "${out}" PARENT_SCOPE)
endfunction()
38 changes: 38 additions & 0 deletions cmake/GetGitRevisionDescription.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#
# Internal file for GetGitRevisionDescription.cmake
#
# Requires CMake 2.6 or newer (uses the 'function' command)
#
# Original Author:
# 2009-2010 Ryan Pavlik <[email protected]> <[email protected]>
# http://academic.cleardefinition.com
# Iowa State University HCI Graduate Program/VRAC
#
# Copyright Iowa State University 2009-2010.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)

set(HEAD_HASH)

file(READ "@HEAD_FILE@" HEAD_CONTENTS LIMIT 1024)

string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS)
if(HEAD_CONTENTS MATCHES "ref")
# named branch
string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}")
if(EXISTS "@GIT_DIR@/${HEAD_REF}")
configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY)
elseif(EXISTS "@GIT_DIR@/logs/${HEAD_REF}")
configure_file("@GIT_DIR@/logs/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY)
set(HEAD_HASH "${HEAD_REF}")
endif()
else()
# detached HEAD
configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY)
endif()

if(NOT HEAD_HASH)
file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024)
string(STRIP "${HEAD_HASH}" HEAD_HASH)
endif()
20 changes: 2 additions & 18 deletions include/osm2rdf/config/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ namespace osm2rdf::config {

enum GeoTriplesMode {
none = 0,
reduced = 1,
full = 2
full = 1
};

enum SourceDataset {
Expand All @@ -60,17 +59,6 @@ struct Config {

SourceDataset sourceDataset = OSM;

// the epsilon for the inner/outer douglas-peucker is based on the
// circumference of a hypothetical circle. By dividing by ~pi, we base the
// epsilon on 1/n of the radius of this hypothetical circle (n = 20 in this
// case). Think of this is maximum portion of the radius that is
// "collapsed away" by the inner simplification, or added by the outer
// simplification
double simplifyGeometriesInnerOuter = 1 / (3.14 * 20);
double approxContainsSlack = 0.05;
bool dontUseInnerOuterGeoms = false;
bool approximateSpatialRels = false;

// Select amount to dump
bool addAreaWayLinestrings = false;
bool addWayMetadata = false;
Expand All @@ -82,20 +70,16 @@ struct Config {
// Default settings for data
std::unordered_set<std::string> semicolonTagKeys;

// Dot
bool writeDAGDotFiles = false;

// Statistics
bool writeRDFStatistics = false;
std::filesystem::path rdfStatisticsPath;

// Output modifiers
uint16_t simplifyWKT = 250;
uint16_t simplifyWKT = 0;
double wktDeviation = 5;
uint16_t wktPrecision = 7;

GeoTriplesMode ogcGeoTriplesMode = full;
GeoTriplesMode osm2rdfGeoTriplesMode = none;

// Output, empty for stdout
std::filesystem::path output;
Expand Down
28 changes: 1 addition & 27 deletions include/osm2rdf/config/Constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,21 +102,13 @@ const static inline std::string SOURCE_DATASET_OPTION_LONG =
const static inline std::string SOURCE_DATASET_OPTION_HELP =
"Source dataset, either 'OSM', or 'OHM'";

const static inline std::string OSM2RDF_GEO_TRIPLES_INFO =
"Writing mode of osm2rdf-style geometric triples";
const static inline std::string OSM2RDF_GEO_TRIPLES_OPTION_SHORT = "";
const static inline std::string OSM2RDF_GEO_TRIPLES_OPTION_LONG =
"write-osm2rdf-geo-triples";
const static inline std::string OSM2RDF_GEO_TRIPLES_OPTION_HELP =
"Writing of osm2rdf-style geometric triples, either 'full', 'reduced', or 'none'";

const static inline std::string OGC_GEO_TRIPLES_INFO =
"Writing mode of OGC-style geometric triples";
const static inline std::string OGC_GEO_TRIPLES_OPTION_SHORT = "";
const static inline std::string OGC_GEO_TRIPLES_OPTION_LONG =
"write-ogc-geo-triples";
const static inline std::string OGC_GEO_TRIPLES_OPTION_HELP =
"Writing of OGC-style geometric triples, either 'full', 'reduced', or 'none'";
"Writing of OGC-style geometric triples, either 'full', or 'none'";

const static inline std::string NO_AREA_OPTION_SHORT = "";
const static inline std::string NO_AREA_OPTION_LONG = "no-areas";
Expand Down Expand Up @@ -255,24 +247,6 @@ const static inline std::string DONT_USE_INNER_OUTER_GEOMETRIES_OPTION_HELP =
"Don't use inner/outer simplified geometries of areas for contains "
"relation.";

const static inline std::string APPROX_SPATIAL_REL_INFO =
"Approximate spatial relations using inner/outer simplified geometries.";
const static inline std::string APPROX_SPATIAL_REL_OPTION_SHORT =
"";
const static inline std::string APPROX_SPATIAL_REL_OPTION_LONG =
"approximate-spatial-relations";
const static inline std::string APPROX_SPATIAL_REL_OPTION_HELP = "Use "
"simplified inner/outer geometries for approximate calculation of spatial "
"relations";

const static inline std::string APPROX_CONTAINS_SLACK_INFO =
"Slack for approximate contains";
const static inline std::string APPROX_CONTAINS_SLACK_OPTION_SHORT =
"";
const static inline std::string APPROX_CONTAINS_SLACK_OPTION_LONG =
"approximate-contains-slack";
const static inline std::string APPROX_CONTAINS_SLACK_OPTION_HELP = "";

const static inline std::string SIMPLIFY_WKT_INFO = "Simplifying WKT";
const static inline std::string SIMPLIFY_WKT_OPTION_SHORT = "s";
const static inline std::string SIMPLIFY_WKT_OPTION_LONG = "simplify-wkt";
Expand Down
28 changes: 0 additions & 28 deletions include/osm2rdf/geometry/Area.h

This file was deleted.

Loading