Skip to content
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
4 changes: 4 additions & 0 deletions include/append_vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ namespace AppendVectorNS {
return el;
}

const T& operator [](int idx) const {
return vecs[idx / APPEND_VECTOR_SIZE][idx % APPEND_VECTOR_SIZE];
}

Iterator begin() {
return Iterator(*this, 0, 0);
}
Expand Down
6 changes: 3 additions & 3 deletions include/tile_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ template<typename OO> void collectObjectsForTileTemplate(
class TileDataSource {
public:
// Store for generated geometries
using point_store_t = std::vector<Point>;
using point_store_t = AppendVectorNS::AppendVector<Point>;

using linestring_t = boost::geometry::model::linestring<Point, std::vector, mmap_allocator>;
using linestring_store_t = std::vector<linestring_t>;
Expand Down Expand Up @@ -391,8 +391,8 @@ class TileDataSource {
const auto& shardId = getShard(id);
const auto& shard = pointStores[shardId];
const auto offset = getId(id);
if (offset > shard.size()) throw std::out_of_range("Could not find generated node with id " + std::to_string(id) + ", shard " + std::to_string(shardId) + ", offset=" + std::to_string(offset));
return shard.at(offset);
if (offset >= shard.size()) throw std::out_of_range("Could not find generated node with id " + std::to_string(id) + ", shard " + std::to_string(shardId) + ", offset=" + std::to_string(offset));
return shard[offset];
}

NodeID storeLinestring(const Linestring& src);
Expand Down
2 changes: 1 addition & 1 deletion src/tile_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ NodeID TileDataSource::storePoint(const Point& input) {
const auto& store = pointStore.get(this);

NodeID offset = store.second->size();
store.second->emplace_back(input);
store.second->push_back(input);
NodeID rv = (store.first << (TILE_DATA_ID_SIZE - shardBits)) + offset;
return rv;
}
Expand Down
6 changes: 6 additions & 0 deletions test/append_vector.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ MU_TEST(test_append_vector) {

mu_check(vec[25] == 25);

const AppendVector<int32_t>& constVec = vec;
mu_check(constVec[25] == 25);
mu_check(constVec[8191] == 8191);
mu_check(constVec[8192] == 8192);
mu_check(constVec[9999] == 9999);

const AppendVector<int32_t>::Iterator& it = vec.begin();
mu_check(*it == 0);
mu_check(*(it + 1) == 1);
Expand Down
Loading