Skip to content

Commit

Permalink
Seperate line sections instead of clipping linestring
Browse files Browse the repository at this point in the history
  • Loading branch information
kleunen committed May 1, 2021
1 parent 244614b commit b9ce0c7
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/output_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,27 @@ Geometry buildWayGeometry(OSMStore &osmStore, OutputObject const &oo, const Tile

case OutputGeometryType::LINESTRING:
{
auto const &ls = osmStore.retrieve<mmap::linestring_t>(oo.handle);

MultiLinestring out;
geom::intersection(osmStore.retrieve<mmap::linestring_t>(oo.handle), bbox.clippingBox, out);
if(ls.empty())
return out;

Linestring current_ls;
geom::append(current_ls, ls[0]);

for(size_t i = 1; i < ls.size(); ++i) {
if(!geom::intersects(Linestring({ ls[i-1], ls[i] }), bbox.clippingBox)) {
if(current_ls.size() > 1)
out.push_back(std::move(current_ls));
current_ls.clear();
}
geom::append(current_ls, ls[i]);
}

if(current_ls.size() > 1)
out.push_back(std::move(current_ls));

return out;
}

Expand Down

0 comments on commit b9ce0c7

Please sign in to comment.