Skip to content

Commit

Permalink
not ready
Browse files Browse the repository at this point in the history
  • Loading branch information
zhixiong-tang committed Nov 13, 2023
1 parent 6d3d435 commit 980430d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ project(geobuf)

set(CUBAO_INCLUDE ${PROJECT_SOURCE_DIR}/headers/include)
include(${CUBAO_INCLUDE}/utils.cmake)
# set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_BUILD_TYPE Debug)

activate_common_configuration()
auto_build_type_and_compile_flags()
Expand Down
6 changes: 5 additions & 1 deletion src/geobuf/geobuf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -677,11 +677,15 @@ void Decoder::decode_header(const uint8_t *data, std::size_t size)
mapbox::geojson::feature Decoder::decode_feature(const uint8_t *data,
std::size_t size)
{
dbg("here");
std::cout << std::endl;
auto pbf =
protozero::pbf_reader{reinterpret_cast<const char *>(data), size};
if (!pbf.next() || pbf.tag() != 1) {
dbg("not ready");
if (dbg(pbf.tag()) != 1) {
return {};
}
dbg("??");
protozero::pbf_reader pbf_f = pbf.get_message();
return readFeature(pbf_f);
}
Expand Down
6 changes: 4 additions & 2 deletions src/geobuf/geobuf_plus.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ struct GeobufPlus
sizeof(offsets[0]) * num_offsets);
cursor += sizeof(offsets[0]) * num_offsets;
spdlog::info("offsets: [{}, ..., {}]", offsets.front(), offsets.back());
dbg(offsets);

padding = *reinterpret_cast<const int *>(data + cursor);
cursor += sizeof(padding);
Expand Down Expand Up @@ -114,12 +115,13 @@ struct GeobufPlus

mapbox::geojson::feature decode_feature(int index)
{
return decode_feature(mmap.data() + offsets[index],
offsets[index + 1] - offsets[index]);
return decode_feature(mmap.data() + dbg(offsets[index]),
dbg(offsets[index + 1] - offsets[index]));
}

mapbox::geojson::feature decode_feature(const uint8_t *data, size_t size)
{
dbg(size);
return decoder.decode_feature(data, size);
}

Expand Down
1 change: 1 addition & 0 deletions tests/test_geobuf.py
Original file line number Diff line number Diff line change
Expand Up @@ -1898,6 +1898,7 @@ def test_query():
print(GeobufPlus.encode(ipath, opath_idx, opath_pbf))
gbp = GeobufPlus()
print(gbp.mmap_init(opath_idx, opath_pbf))
f = gbp.decode_feature(0)

np.set_printoptions(suppress=True)
pwd = os.path.abspath(os.path.dirname(__file__))
Expand Down

0 comments on commit 980430d

Please sign in to comment.