Skip to content

Commit

Permalink
pure expand to 3d and serialize with protobuf
Browse files Browse the repository at this point in the history
  • Loading branch information
Change72 committed May 18, 2023
1 parent b4563dc commit ccf1745
Show file tree
Hide file tree
Showing 8 changed files with 105 additions and 343 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "third_party/protobuf"]
path = third_party/protobuf
url = https://github.com/protocolbuffers/protobuf.git
17 changes: 10 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ include(CMakeDependentOption)

## CMake global variables
option(BUILD_SHARED_LIBS "Build GEOS with shared libraries" ON)
set(CMAKE_CXX_STANDARD 11 CACHE STRING "C++ standard version to use (default is 11)")
set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard version to use (default is 11)")

## GEOS custom variables
option(BUILD_BENCHMARKS "Build GEOS benchmarks" OFF)
Expand Down Expand Up @@ -161,14 +161,16 @@ message(STATUS "GEOS: Archives output: ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")

include(GNUInstallDirs)
include(CMakePackageConfigHelpers)

include_directories(BEFORE third_party/protobuf)
add_subdirectory(third_party/protobuf)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
#-----------------------------------------------------------------------------
# C++ language version and compilation flags
#-----------------------------------------------------------------------------
message(STATUS "GEOS: Require C++${CMAKE_CXX_STANDARD}")
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

set(ENV{LD_LIBRARY_PATH} "/usr/local/lib:$ENV{LD_LIBRARY_PATH}")
#-----------------------------------------------------------------------------
# Target geos_cxx_flags: common compilation flags
#-----------------------------------------------------------------------------
Expand Down Expand Up @@ -235,14 +237,15 @@ target_compile_definitions(geos_developer_cxx_flags
target_compile_options(geos_developer_cxx_flags
INTERFACE
$<$<CXX_COMPILER_ID:MSVC>:-W4>
$<$<OR:$<CXX_COMPILER_ID:GNU>,$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:-Werror -pedantic -Wall -Wextra -Wno-long-long -Wcast-align -Wconversion -Wsign-conversion -Wchar-subscripts -Wdouble-promotion -Wpointer-arith -Wformat -Wformat-security -Wshadow -Wuninitialized -Wunused-parameter -fno-common>
# $<$<OR:$<CXX_COMPILER_ID:GNU>,$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:-Werror -pedantic -Wall -Wextra -Wno-long-long -Wcast-align -Wconversion -Wsign-conversion -Wchar-subscripts -Wdouble-promotion -Wpointer-arith -Wformat -Wformat-security -Wshadow -Wuninitialized -Wunused-parameter -fno-common>
$<$<CXX_COMPILER_ID:GNU>:-fno-implicit-inline-templates -Wno-psabi>
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:-Wno-unknown-warning-option>
)

#-----------------------------------------------------------------------------
# Define a coverage build
#-----------------------------------------------------------------------------
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error")
set(CMAKE_CXX_FLAGS_COVERAGE "-fprofile-arcs -ftest-coverage")

#-----------------------------------------------------------------------------
Expand All @@ -254,9 +257,9 @@ check_library_exists(m pow "" HAVE_LIBM)
#-----------------------------------------------------------------------------
# Target geos: C++ API library
#-----------------------------------------------------------------------------
add_library(geos "" test.cpp)
add_library(geos "")
add_library(GEOS::geos ALIAS geos)
target_link_libraries(geos PUBLIC geos_cxx_flags PRIVATE $<BUILD_INTERFACE:ryu>)
target_link_libraries(geos PUBLIC geos_cxx_flags pthread PRIVATE $<BUILD_INTERFACE:ryu>)
# ryu is an object library, nothing is actually being linked here. The BUILD_INTERFACE
# switch was necessary to build on AppVeyor (CMake 3.16.2) but not locally (CMake 3.16.3)
add_subdirectory(include)
Expand Down Expand Up @@ -457,7 +460,7 @@ endif() # PROJECT_IS_TOP_LEVEL
#-----------------------------------------------------------------------------

if(PROJECT_IS_TOP_LEVEL)
add_custom_target(check COMMAND ${CMAKE_BUILD_TOOL} test)
add_custom_target(checkgeos COMMAND ${CMAKE_BUILD_TOOL} test)
endif()

#-----------------------------------------------------------------------------
Expand Down
26 changes: 22 additions & 4 deletions include/geos/geom/Envelope3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class GEOS_DLL Envelope3d {
, maxy(DoubleNotANumber)
, minz(DoubleNotANumber)
, maxz(DoubleNotANumber)
, slice_id_(-1)
{};

/** \brief
Expand All @@ -85,9 +86,9 @@ class GEOS_DLL Envelope3d {
* @param z1 the first y-value
* @param z2 the second y-value
*/
Envelope3d(double x1, double x2, double y1, double y2, double z1, double z2)
Envelope3d(double x1, double x2, double y1, double y2, double z1, double z2, int slice_id = -1)
{
init(x1, x2, y1, y2, z1, z2);
init(x1, x2, y1, y2, z1, z2, slice_id);
}

/** \brief
Expand Down Expand Up @@ -205,7 +206,7 @@ class GEOS_DLL Envelope3d {
* @param z1 the first y-value
* @param z2 the second y-value
*/
void init(double x1, double x2, double y1, double y2, double z1, double z2)
void init(double x1, double x2, double y1, double y2, double z1, double z2, int slice_id = -1)
{
if(x1 < x2) {
minx = x1;
Expand All @@ -231,6 +232,7 @@ class GEOS_DLL Envelope3d {
minz = z2;
maxz = z1;
}
slice_id_ = slice_id;
};

/** \brief
Expand Down Expand Up @@ -261,6 +263,7 @@ class GEOS_DLL Envelope3d {
void setToNull()
{
minx = maxx = miny = maxy = minz = maxz = DoubleNotANumber;
slice_id_ = -1;
};

/** \brief
Expand All @@ -272,7 +275,7 @@ class GEOS_DLL Envelope3d {
bool isNull(void) const
{
return std::isnan(maxx) && std::isnan(maxy) && std::isnan(maxz) &&
std::isnan(minx) && std::isnan(miny) && std::isnan(minz);
std::isnan(minx) && std::isnan(miny) && std::isnan(minz) && slice_id_ == -1;
};

/** \brief
Expand Down Expand Up @@ -959,6 +962,18 @@ class GEOS_DLL Envelope3d {
GEOS_DLL friend bool
operator< (const Envelope3d& a, const Envelope3d& b);

// get the slice_id
int getSliceId() const
{
return slice_id_;
}

// set the slice_id
void setSliceId(int id)
{
slice_id_ = id;
}

private:

/** \brief
Expand Down Expand Up @@ -1007,6 +1022,9 @@ class GEOS_DLL Envelope3d {

/// the maximum z-coordinate
double maxz;

/// slice id for each block
int slice_id_;
};


Expand Down
17 changes: 17 additions & 0 deletions proto/treeNode.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
syntax = "proto3";

message TreeNode {
int32 level = 1;
int32 childSize = 2;
double minx = 3;
double maxx = 4;
double miny = 5;
double maxy = 6;
double minz = 7;
double maxz = 8;
int32 slice_id = 9;
}

message Tree {
repeated TreeNode treeNodes = 1;
}
2 changes: 1 addition & 1 deletion src/index/strtree/SimpleSTRtree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ SimpleSTRtree::addParentNodesFromDepthSlice3d(
int newLevel,
std::vector<SimpleSTRnode3d*>& parentNodes)
{
sortNodesY3d(depthSlice);
sortNodesZ3d(depthSlice);

SimpleSTRnode3d* parent = nullptr;
for (auto* node: depthSlice) {
Expand Down
Loading

0 comments on commit ccf1745

Please sign in to comment.