Skip to content

Commit ec36916

Browse files
authored
Merge pull request #1775 from joto/consistent-naming
Consistent naming of buffer paramater in create_*() calls
2 parents 87460ef + cdf38d6 commit ec36916

File tree

2 files changed

+40
-30
lines changed

2 files changed

+40
-30
lines changed

src/geom-from-osm.cpp

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,10 @@ geometry_t create_polygon(osmium::Way const &way)
9696
}
9797

9898
void create_multilinestring(geometry_t *geom,
99-
osmium::memory::Buffer const &ways_buffer,
99+
osmium::memory::Buffer const &buffer,
100100
bool force_multi)
101101
{
102-
auto ways = ways_buffer.select<osmium::Way>();
102+
auto ways = buffer.select<osmium::Way>();
103103
if (ways.size() == 1 && !force_multi) {
104104
auto &line = geom->set<linestring_t>();
105105
auto &way = *ways.begin();
@@ -122,11 +122,11 @@ void create_multilinestring(geometry_t *geom,
122122
}
123123
}
124124

125-
geometry_t create_multilinestring(osmium::memory::Buffer const &ways,
125+
geometry_t create_multilinestring(osmium::memory::Buffer const &buffer,
126126
bool force_multi)
127127
{
128128
geometry_t geom{};
129-
create_multilinestring(&geom, ways, force_multi);
129+
create_multilinestring(&geom, buffer, force_multi);
130130
return geom;
131131
}
132132

@@ -148,14 +148,14 @@ static void fill_polygon(polygon_t *polygon, osmium::Area const &area,
148148
}
149149

150150
void create_multipolygon(geometry_t *geom, osmium::Relation const &relation,
151-
osmium::memory::Buffer const &way_buffer)
151+
osmium::memory::Buffer const &buffer)
152152
{
153153
osmium::area::AssemblerConfig area_config;
154154
area_config.ignore_invalid_locations = true;
155155
osmium::area::GeomAssembler assembler{area_config};
156156
osmium::memory::Buffer area_buffer{1024};
157157

158-
if (!assembler(relation, way_buffer, area_buffer)) {
158+
if (!assembler(relation, buffer, area_buffer)) {
159159
geom->reset();
160160
return;
161161
}
@@ -176,19 +176,18 @@ void create_multipolygon(geometry_t *geom, osmium::Relation const &relation,
176176
}
177177

178178
geometry_t create_multipolygon(osmium::Relation const &relation,
179-
osmium::memory::Buffer const &way_buffer)
179+
osmium::memory::Buffer const &buffer)
180180
{
181181
geometry_t geom{};
182-
create_multipolygon(&geom, relation, way_buffer);
182+
create_multipolygon(&geom, relation, buffer);
183183
return geom;
184184
}
185185

186-
void create_collection(geometry_t *geom,
187-
osmium::memory::Buffer const &member_buffer)
186+
void create_collection(geometry_t *geom, osmium::memory::Buffer const &buffer)
188187
{
189188
auto &collection = geom->set<collection_t>();
190189

191-
for (auto const &obj : member_buffer) {
190+
for (auto const &obj : buffer) {
192191
if (obj.type() == osmium::item_type::node) {
193192
auto const &node = static_cast<osmium::Node const &>(obj);
194193
if (node.location().valid()) {
@@ -210,10 +209,10 @@ void create_collection(geometry_t *geom,
210209
}
211210
}
212211

213-
geometry_t create_collection(osmium::memory::Buffer const &member_buffer)
212+
geometry_t create_collection(osmium::memory::Buffer const &buffer)
214213
{
215214
geometry_t geom{};
216-
create_collection(&geom, member_buffer);
215+
create_collection(&geom, buffer);
217216
return geom;
218217
}
219218

src/geom-from-osm.hpp

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -92,31 +92,39 @@ void create_polygon(geometry_t *geom, osmium::Way const &way);
9292
/**
9393
* Create a multilinestring geometry from a bunch of ways (usually this
9494
* would be used for member ways of a relation). The result is always a
95-
* multilinestring, even if it only contains one linestring.
95+
* multilinestring, even if it only contains one linestring, unless
96+
* `force_multi` is set to false.
9697
*
9798
* If the resulting multilinestring would be invalid, a null geometry is
9899
* returned.
99100
*
100101
* \param geom Pointer to an existing geometry which will be used as output.
101-
* \param ways Buffer containing all the input ways.
102+
* \param ways Buffer containing all the input ways. Object types other than
103+
* ways in the buffer are ignored.
104+
* \param force_multi Should the result be a multilinestring even if it
105+
* contains only a single linestring?
102106
*/
103107
void create_multilinestring(geometry_t *geom,
104-
osmium::memory::Buffer const &ways,
108+
osmium::memory::Buffer const &buffer,
105109
bool force_multi = true);
106110

107111
/**
108112
* Create a multilinestring geometry from a bunch of ways (usually this
109113
* would be used for member ways of a relation). The result is always a
110-
* multilinestring, even if it only contains one linestring.
114+
* multilinestring, even if it only contains one linestring, unless
115+
* `force_multi` is set to false.
111116
*
112117
* If the resulting multilinestring would be invalid, a null geometry is
113118
* returned.
114119
*
115-
* \param ways Buffer containing all the input ways.
120+
* \param ways Buffer containing all the input ways. Object types other than
121+
* ways in the buffer are ignored.
122+
* \param force_multi Should the result be a multilinestring even if it
123+
* contains only a single linestring?
116124
* \returns The created geometry.
117125
*/
118126
[[nodiscard]] geometry_t
119-
create_multilinestring(osmium::memory::Buffer const &ways,
127+
create_multilinestring(osmium::memory::Buffer const &buffer,
120128
bool force_multi = true);
121129

122130
/**
@@ -127,10 +135,10 @@ create_multilinestring(osmium::memory::Buffer const &ways,
127135
*
128136
* \param geom Pointer to an existing geometry which will be used as output.
129137
* \param relation The input relation.
130-
* \param way_buffer Buffer containing all member ways.
138+
* \param buffer Buffer with OSM objects. Anything but ways are ignored.
131139
*/
132140
void create_multipolygon(geometry_t *geom, osmium::Relation const &relation,
133-
osmium::memory::Buffer const &way_buffer);
141+
osmium::memory::Buffer const &buffer);
134142

135143
/**
136144
* Create a (multi)polygon geometry from a relation and member ways.
@@ -139,37 +147,40 @@ void create_multipolygon(geometry_t *geom, osmium::Relation const &relation,
139147
* returned.
140148
*
141149
* \param relation The input relation.
142-
* \param way_buffer Buffer containing all member ways.
150+
* \param buffer Buffer with OSM objects. Anything but ways are ignored.
143151
* \returns The created geometry.
144152
*/
145153
[[nodiscard]] geometry_t
146154
create_multipolygon(osmium::Relation const &relation,
147-
osmium::memory::Buffer const &way_buffer);
155+
osmium::memory::Buffer const &buffer);
148156

149157
/**
150-
* Create a geometry collection from a relation and node/way members.
158+
* Create a geometry collection from nodes and ways, usually used for
159+
* relation members.
151160
*
152161
* If the resulting geometry would be empty or invalid, a null geometry is
153162
* returned.
154163
*
155164
* \param geom Pointer to an existing geometry which will be used as output.
156-
* \param relation The input relation.
157-
* \param way_buffer Buffer containing all member nodes and ways.
165+
* \param buffer Buffer with OSM objects. Nodes are turned into points,
166+
* ways into linestrings, anything else in the buffer is ignored.
158167
*/
159168
void create_collection(geometry_t *geom,
160-
osmium::memory::Buffer const &member_buffer);
169+
osmium::memory::Buffer const &buffer);
161170

162171
/**
163-
* Create a geometry collection from a relation and node/way members.
172+
* Create a geometry collection from nodes and ways, usually used for
173+
* relation members.
164174
*
165175
* If the resulting geometry would be empty or invalid, a null geometry is
166176
* returned.
167177
*
168-
* \param way_buffer Buffer containing all member nodes and ways.
178+
* \param buffer Buffer with OSM objects. Nodes are turned into points,
179+
* ways into linestrings, anything else in the buffer is ignored.
169180
* \returns The created geometry.
170181
*/
171182
[[nodiscard]] geometry_t
172-
create_collection(osmium::memory::Buffer const &member_buffer);
183+
create_collection(osmium::memory::Buffer const &buffer);
173184

174185
} // namespace geom
175186

0 commit comments

Comments
 (0)