Skip to content

Commit 265ccce

Browse files
authored
Append multilinestrings rather than merging them (#387)
1 parent a06d0aa commit 265ccce

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

src/tile_worker.cpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,21 @@ using namespace std;
99
extern bool verbose;
1010

1111
typedef std::pair<double,double> xy_pair;
12+
namespace std {
13+
template<>
14+
struct hash<xy_pair> {
15+
size_t operator()(const xy_pair &xy) const {
16+
return std::hash<double>()(xy.first) ^ std::hash<double>()(xy.second);
17+
}
18+
};
19+
}
1220

1321
// Connect disconnected linestrings within a MultiLinestring
1422
void ReorderMultiLinestring(MultiLinestring &input, MultiLinestring &output) {
1523
// create a map of the start/end points of each linestring
1624
// (we should be able to do std::map<Point,unsigned>, but that errors)
17-
std::map<xy_pair,unsigned> startPoints;
18-
std::map<xy_pair,unsigned> endPoints;
25+
std::unordered_map<xy_pair,unsigned> startPoints;
26+
std::unordered_map<xy_pair,unsigned> endPoints;
1927
for (unsigned i=0; i<input.size(); i++) {
2028
startPoints[xy_pair(input[i][0].x(),input[i][0].y())] = i;
2129
endPoints[xy_pair(input[i][input[i].size()-1].x(),input[i][input[i].size()-1].y())] = i;
@@ -61,11 +69,10 @@ void ReorderMultiLinestring(MultiLinestring &input, MultiLinestring &output) {
6169
}
6270
}
6371

64-
// Merge two multilinestrings (just a wrapper around boost::geometry::union_)
72+
// Merge two multilinestrings by simply appending
73+
// (the constituent parts will be matched up in subsequent call to ReorderMultiLinestring)
6574
void MergeIntersecting(MultiLinestring &input, MultiLinestring &to_merge) {
66-
MultiLinestring output;
67-
geom::union_(input, to_merge, output);
68-
input = move(output);
75+
for (auto ls : to_merge) input.emplace_back(ls);
6976
}
7077

7178
// Merge two multipolygons by doing intersection checks for each constituent polygon

0 commit comments

Comments
 (0)