Skip to content

Commit

Permalink
use vtzero instead of libprotobuf (#625)
Browse files Browse the repository at this point in the history
  • Loading branch information
cldellow authored Dec 28, 2023
1 parent 12ed241 commit ae1981b
Show file tree
Hide file tree
Showing 29 changed files with 5,325 additions and 500 deletions.
17 changes: 1 addition & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ ENDIF ()

find_package(Boost 1.66 REQUIRED COMPONENTS system filesystem program_options iostreams)

set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON)
find_package(Protobuf REQUIRED)
set(CMAKE_FIND_PACKAGE_PREFER_CONFIG OFF)

find_package(libshp REQUIRED)

find_package(Rapidjson REQUIRED)
Expand Down Expand Up @@ -72,15 +68,6 @@ else()
set(THREAD_LIB pthread)
endif()

if(NOT PROTOBUF_PROTOC_EXECUTABLE)
set (PROTOBUF_PROTOC_EXECUTABLE "protobuf::protoc")
endif()


ADD_CUSTOM_COMMAND(OUTPUT vector_tile.pb.cc vector_tile.pb.h
COMMAND ${PROTOBUF_PROTOC_EXECUTABLE}
ARGS --cpp_out ${CMAKE_BINARY_DIR} -I ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/include/vector_tile.proto)

file(GLOB tilemaker_src_files
src/attribute_store.cpp
src/coordinates.cpp
Expand Down Expand Up @@ -113,15 +100,13 @@ file(GLOB tilemaker_src_files
src/tilemaker.cpp
src/tile_worker.cpp
src/way_stores.cpp
src/write_geometry.cpp
)
add_executable(tilemaker vector_tile.pb.cc ${tilemaker_src_files})
add_executable(tilemaker ${tilemaker_src_files})
target_include_directories(tilemaker PRIVATE include)
target_include_directories(tilemaker PRIVATE ${CMAKE_BINARY_DIR}) # for generated files
target_link_libraries(tilemaker
${THREAD_LIB} ${CMAKE_DL_LIBS}
${LUA_LIBRARIES}
protobuf::libprotobuf
shapelib::shp
SQLite::SQLite3
ZLIB::ZLIB
Expand Down
5 changes: 1 addition & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ RUN apt-get update && \
build-essential \
liblua5.1-0 \
liblua5.1-0-dev \
libprotobuf-dev \
libsqlite3-dev \
protobuf-compiler \
shapelib \
libshp-dev \
libboost-program-options-dev \
Expand All @@ -36,7 +34,6 @@ FROM debian:bullseye-slim
RUN apt-get update && \
apt-get install -y --no-install-recommends \
liblua5.1-0 \
libprotobuf-dev \
libshp-dev \
libsqlite3-dev \
libboost-filesystem-dev \
Expand All @@ -49,4 +46,4 @@ COPY process.lua .
COPY config.json .

# Entrypoint for docker, wrapped with /bin/sh to remove requirement for executable permissions on script
ENTRYPOINT ["/bin/sh", "/resources/docker-entrypoint.sh"]
ENTRYPOINT ["/bin/sh", "/resources/docker-entrypoint.sh"]
9 changes: 2 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ prefix = /usr/local
MANPREFIX := /usr/share/man
TM_VERSION ?= $(shell git describe --tags --abbrev=0)
CXXFLAGS ?= -O3 -Wall -Wno-unknown-pragmas -Wno-sign-compare -std=c++14 -pthread -fPIE -DTM_VERSION=$(TM_VERSION) $(CONFIG)
LIB := -L$(PLATFORM_PATH)/lib -lz $(LUA_LIBS) -lboost_program_options -lsqlite3 -lboost_filesystem -lboost_system -lboost_iostreams -lprotobuf -lshp -pthread
LIB := -L$(PLATFORM_PATH)/lib -lz $(LUA_LIBS) -lboost_program_options -lsqlite3 -lboost_filesystem -lboost_system -lboost_iostreams -lshp -pthread
INC := -I$(PLATFORM_PATH)/include -isystem ./include -I./src $(LUA_CFLAGS)

# Targets
Expand All @@ -93,7 +93,6 @@ INC := -I$(PLATFORM_PATH)/include -isystem ./include -I./src $(LUA_CFLAGS)
all: tilemaker

tilemaker: \
include/vector_tile.pb.o \
src/attribute_store.o \
src/coordinates_geom.o \
src/coordinates.o \
Expand Down Expand Up @@ -124,8 +123,7 @@ tilemaker: \
src/tile_data.o \
src/tilemaker.o \
src/tile_worker.o \
src/way_stores.o \
src/write_geometry.o
src/way_stores.o
$(CXX) $(CXXFLAGS) -o tilemaker $^ $(INC) $(LIB) $(LDFLAGS)

test: \
Expand Down Expand Up @@ -194,9 +192,6 @@ test_pbf_reader: \
%.o: %.cc
$(CXX) $(CXXFLAGS) -o $@ -c $< $(INC)

%.pb.cc: %.proto
protoc --proto_path=include --cpp_out=include $<

install:
install -m 0755 -d $(DESTDIR)$(prefix)/bin/
install -m 0755 tilemaker $(DESTDIR)$(prefix)/bin/
Expand Down
6 changes: 3 additions & 3 deletions docs/INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

Install all dependencies with Homebrew:

brew install protobuf boost lua51 shapelib rapidjson
brew install boost lua51 shapelib rapidjson

Then:

Expand All @@ -15,7 +15,7 @@ Then:

Start with:

sudo apt install build-essential libboost-dev libboost-filesystem-dev libboost-iostreams-dev libboost-program-options-dev libboost-system-dev liblua5.1-0-dev libprotobuf-dev libshp-dev libsqlite3-dev protobuf-compiler rapidjson-dev
sudo apt install build-essential libboost-dev libboost-filesystem-dev libboost-iostreams-dev libboost-program-options-dev libboost-system-dev liblua5.1-0-dev libshp-dev libsqlite3-dev rapidjson-dev

Once you've installed those, then `cd` back to your Tilemaker directory and simply:

Expand All @@ -28,7 +28,7 @@ If it fails, check that the LIB and INC lines in the Makefile correspond with yo

Start with:

dnf install lua-devel luajit-devel sqlite-devel protobuf-devel protobuf-compiler shapelib-devel rapidjson
dnf install lua-devel luajit-devel sqlite-devel shapelib-devel rapidjson

then build either with lua:

Expand Down
26 changes: 6 additions & 20 deletions include/output_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
#include "coordinates.h"
#include "attribute_store.h"
#include "osm_store.h"

// Protobuf
#include "vector_tile.pb.h"
#include <vtzero/builder.hpp>

enum OutputGeometryType : unsigned int { POINT_, LINESTRING_, MULTILINESTRING_, POLYGON_ };

Expand Down Expand Up @@ -73,18 +71,11 @@ class OutputObject {
this->attributes = attributes;
}

//\brief Write attribute key/value pairs (dictionary-encoded)
void writeAttributes(std::vector<std::string> *keyList,
std::vector<vector_tile::Tile_Value> *valueList,
AttributeStore const &attributeStore,
vector_tile::Tile_Feature *featurePtr, char zoom) const;

/**
* \brief Find a value in the value dictionary
* (we can't easily use find() because of the different value-type encoding -
* should be possible to improve this though)
*/
int findValue(const std::vector<vector_tile::Tile_Value>* valueList, const AttributePair& value) const;
void writeAttributes(
const AttributeStore& attributeStore,
vtzero::feature_builder& fbuilder,
char zoom
) const;
};
#pragma pack(pop)

Expand All @@ -97,9 +88,4 @@ struct OutputObjectID {
bool operator==(const OutputObject& x, const OutputObject& y);
bool operator==(const OutputObjectID& x, const OutputObjectID& y);

namespace vector_tile {
bool operator==(const vector_tile::Tile_Value &x, const vector_tile::Tile_Value &y);
bool operator<(const vector_tile::Tile_Value &x, const vector_tile::Tile_Value &y);
}

#endif //_OUTPUT_OBJECT_H
5 changes: 1 addition & 4 deletions include/pbf_processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,14 @@
#include "pbf_reader.h"
#include <protozero/data_view.hpp>

// Protobuf
#include "vector_tile.pb.h"

class OsmLuaProcessing;

extern const std::string OptionSortTypeThenID;
extern const std::string OptionLocationsOnWays;

struct BlockMetadata {
long int offset;
google::protobuf::int32 length;
int32_t length;
bool hasNodes;
bool hasWays;
bool hasRelations;
Expand Down
102 changes: 0 additions & 102 deletions include/vector_tile.proto

This file was deleted.

Loading

0 comments on commit ae1981b

Please sign in to comment.