@@ -109,7 +109,7 @@ namespace osmium {
109109 class XMLOutputBlock : public OutputBlock {
110110
111111 // operation (create, modify, delete) for osc files
112- enum class operation {
112+ enum class operation : std:: uint8_t {
113113 op_none = 0 ,
114114 op_create = 1 ,
115115 op_modify = 2 ,
@@ -243,6 +243,15 @@ namespace osmium {
243243 m_last_op = op;
244244 }
245245
246+ static operation get_operation (const osmium::OSMObject &object) noexcept {
247+ if (object.deleted ()) {
248+ return operation::op_delete;
249+ }
250+
251+ return object.version () == 1 ? operation::op_create
252+ : operation::op_modify;
253+ }
254+
246255 public:
247256
248257 XMLOutputBlock (osmium::memory::Buffer&& buffer, const xml_output_options& options) :
@@ -266,7 +275,7 @@ namespace osmium {
266275
267276 void node (const osmium::Node& node) {
268277 if (m_options.use_change_ops ) {
269- open_close_op_tag (node. visible () ? ( node. version () == 1 ? operation::op_create : operation::op_modify) : operation::op_delete );
278+ open_close_op_tag (get_operation ( node) );
270279 }
271280
272281 write_prefix ();
@@ -293,7 +302,7 @@ namespace osmium {
293302
294303 void way (const osmium::Way& way) {
295304 if (m_options.use_change_ops ) {
296- open_close_op_tag (way. visible () ? ( way. version () == 1 ? operation::op_create : operation::op_modify) : operation::op_delete );
305+ open_close_op_tag (get_operation ( way) );
297306 }
298307
299308 write_prefix ();
@@ -334,7 +343,7 @@ namespace osmium {
334343
335344 void relation (const osmium::Relation& relation) {
336345 if (m_options.use_change_ops ) {
337- open_close_op_tag (relation. visible () ? ( relation. version () == 1 ? operation::op_create : operation::op_modify) : operation::op_delete );
346+ open_close_op_tag (get_operation ( relation) );
338347 }
339348
340349 write_prefix ();
0 commit comments