forked from osm2pgsql-dev/osm2pgsql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
output-gazetteer.cpp
775 lines (691 loc) · 25.7 KB
/
output-gazetteer.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
#include <libpq-fe.h>
#include <boost/algorithm/string/predicate.hpp>
#include <boost/format.hpp>
#include "osmtypes.hpp"
#include "middle.hpp"
#include "pgsql.hpp"
#include "reprojection.hpp"
#include "output-gazetteer.hpp"
#include "options.hpp"
#include "util.hpp"
#include <algorithm>
#include <iostream>
#include <memory>
#define CREATE_PLACE_TABLE \
"CREATE TABLE place (" \
" osm_type CHAR(1) NOT NULL," \
" osm_id " POSTGRES_OSMID_TYPE " NOT NULL," \
" class TEXT NOT NULL," \
" type TEXT NOT NULL," \
" name HSTORE," \
" admin_level INTEGER," \
" housenumber TEXT," \
" street TEXT," \
" addr_place TEXT," \
" isin TEXT," \
" postcode TEXT," \
" country_code VARCHAR(2)," \
" extratags HSTORE" \
") %s %s"
#define ADMINLEVEL_NONE 100
#define CREATE_PLACE_ID_INDEX \
"CREATE INDEX place_id_idx ON place USING BTREE (osm_type, osm_id) %s %s"
enum { BUFFER_SIZE = 4092 };
void place_tag_processor::clear()
{
// set members to sane defaults
src = nullptr;
admin_level = ADMINLEVEL_NONE;
countrycode = 0;
housenumber.assign("\\N");
street = 0;
addr_place = 0;
postcode = 0;
places.clear();
extratags.clear();
address.clear();
names.clear();
}
struct UnnamedPredicate
{
bool operator()(const tag_t &val) const {
return val.key == "natural" ||
val.key == "railway" ||
val.key == "waterway" ||
val.key == "boundary" ||
(val.key == "highway" &&
(val.value == "traffic_signals" ||
val.value == "service" ||
val.value == "cycleway" ||
val.value == "path" ||
val.value == "footway" ||
val.value == "steps" ||
val.value == "bridleway" ||
val.value == "track" ||
val.value == "byway" ||
boost::ends_with(val.value, "_link")));
}
};
void place_tag_processor::process_tags(const taglist_t &tags)
{
bool placeadmin = false;
bool placehouse = false;
bool placebuilding = false;
const tag_t *place = 0;
const tag_t *junction = 0;
const tag_t *landuse = 0;
bool isnamed = false;
bool isinterpolation = false;
const std::string *house_nr = 0;
const std::string *conscr_nr = 0;
const std::string *street_nr = 0;
clear();
src = &tags;
for (const auto& item: tags) {
if (boost::ends_with(item.key, "source")) {
// ignore
} else if (item.key == "name:prefix" ||
item.key == "name:botanical" ||
boost::ends_with(item.key, "wikidata")) {
extratags.push_back(&item);
} else if (item.key == "ref" ||
item.key == "int_ref" ||
item.key == "nat_ref" ||
item.key == "reg_ref" ||
item.key == "loc_ref" ||
item.key == "old_ref" ||
item.key == "iata" ||
item.key == "icao" ||
item.key == "operator" ||
item.key == "pcode" ||
boost::starts_with(item.key, "pcode:")) {
names.push_back(&item);
} else if (item.key == "name" ||
boost::starts_with(item.key, "name:") ||
item.key == "int_name" ||
boost::starts_with(item.key, "int_name:") ||
item.key == "nat_name" ||
boost::starts_with(item.key, "nat_name:") ||
item.key == "reg_name" ||
boost::starts_with(item.key, "reg_name:") ||
item.key == "loc_name" ||
boost::starts_with(item.key, "loc_name:") ||
item.key == "old_name" ||
boost::starts_with(item.key, "old_name:") ||
item.key == "alt_name" ||
boost::starts_with(item.key, "alt_name:") ||
boost::starts_with(item.key, "alt_name_") ||
item.key == "official_name" ||
boost::starts_with(item.key, "official_name:") ||
item.key == "place_name" ||
boost::starts_with(item.key, "place_name:") ||
item.key == "short_name" ||
boost::starts_with(item.key, "short_name:") ||
item.key == "brand") {
names.push_back(&item);
isnamed = true;
} else if (item.key == "addr:housename") {
names.push_back(&item);
placehouse = true;
} else if (item.key == "emergency") {
if (item.value != "fire_hydrant" &&
item.value != "yes" &&
item.value != "no")
places.push_back(item);
} else if (item.key == "tourism" ||
item.key == "historic" ||
item.key == "military") {
if (item.value != "no" && item.value != "yes")
places.push_back(item);
} else if (item.key == "natural") {
if (item.value != "no" &&
item.value != "yes" &&
item.value != "coastline")
places.push_back(item);
} else if (item.key == "landuse") {
if (item.value == "cemetry")
places.push_back(item);
else
landuse = &item;
} else if (item.key == "highway") {
if (item.value == "footway") {
auto *footway = tags.get("footway");
if (footway == nullptr || *footway != "sidewalk")
places.push_back(item);
} else if (item.value != "no" &&
item.value != "turning_circle" &&
item.value != "mini_roundabout" &&
item.value != "noexit" &&
item.value != "crossing")
places.push_back(item);
} else if (item.key == "railway") {
if (item.value != "level_crossing" &&
item.value != "no")
places.push_back(item);
} else if (item.key == "man_made") {
if (item.value != "survey_point" &&
item.value != "cutline")
places.push_back(item);
} else if (item.key == "aerialway") {
if (item.value != "pylon" &&
item.value != "no")
places.push_back(item);
} else if (item.key == "boundary") {
if (item.value == "administrative")
placeadmin = true;
places.push_back(item);
} else if (item.key == "aeroway" ||
item.key == "amenity" ||
item.key == "boundary" ||
item.key == "bridge" ||
item.key == "craft" ||
item.key == "leisure" ||
item.key == "office" ||
item.key == "shop" ||
item.key == "tunnel" ||
item.key == "mountain_pass") {
if (item.value != "no")
{
places.push_back(item);
}
} else if (item.key == "waterway") {
if (item.value != "riverbank")
places.push_back(item);
} else if (item.key == "place") {
place = &item;
} else if (item.key == "junction") {
junction = &item;
} else if (item.key == "addr:interpolation") {
housenumber.clear();
escape(item.value, housenumber);
isinterpolation = true;
} else if (item.key == "addr:housenumber") {
house_nr = &item.value;
placehouse = true;
} else if (item.key == "addr:conscriptionnumber") {
conscr_nr = &item.value;
placehouse = true;
} else if (item.key == "addr:streetnumber") {
street_nr = &item.value;
placehouse = true;
} else if (item.key == "addr:street") {
street = &item.value;
} else if (item.key == "addr:place") {
addr_place = &item.value;
} else if (item.key == "postal_code" ||
item.key == "postcode" ||
item.key == "addr:postcode" ||
item.key == "tiger:zip_left" ||
item.key == "tiger:zip_right") {
if (!postcode)
postcode = &item.value;
} else if (item.key == "country_code" ||
item.key == "ISO3166-1" ||
item.key == "is_in:country_code" ||
item.key == "addr:country" ||
item.key == "addr:country_code") {
if (item.value.length() == 2)
countrycode = &item.value;
} else if (boost::starts_with(item.key, "addr:") ||
item.key == "is_in" ||
boost::starts_with(item.key, "is_in:") ||
item.key == "tiger:county") {
address.push_back(&item);
} else if (item.key == "admin_level") {
admin_level = atoi(item.value.c_str());
if (admin_level <= 0 || admin_level > 100)
admin_level = 100;
} else if (item.key == "tracktype" ||
item.key == "traffic_calming" ||
item.key == "service" ||
item.key == "cuisine" ||
item.key == "capital" ||
item.key == "dispensing" ||
item.key == "religion" ||
item.key == "denomination" ||
item.key == "sport" ||
item.key == "internet_access" ||
item.key == "lanes" ||
item.key == "surface" ||
item.key == "smoothness" ||
item.key == "width" ||
item.key == "est_width" ||
item.key == "incline" ||
item.key == "opening_hours" ||
item.key == "collection_times" ||
item.key == "service_times" ||
item.key == "disused" ||
item.key == "wheelchair" ||
item.key == "sac_scale" ||
item.key == "trail_visibility" ||
item.key == "mtb:scale" ||
item.key == "mtb:description" ||
item.key == "wood" ||
item.key == "drive_through" ||
item.key == "drive_in" ||
item.key == "access" ||
item.key == "vehicle" ||
item.key == "bicyle" ||
item.key == "foot" ||
item.key == "goods" ||
item.key == "hgv" ||
item.key == "motor_vehicle" ||
item.key == "motor_car" ||
boost::starts_with(item.key, "access:") ||
boost::starts_with(item.key, "contact:") ||
boost::starts_with(item.key, "drink:") ||
item.key == "oneway" ||
item.key == "date_on" ||
item.key == "date_off" ||
item.key == "day_on" ||
item.key == "day_off" ||
item.key == "hour_on" ||
item.key == "hour_off" ||
item.key == "maxweight" ||
item.key == "maxheight" ||
item.key == "maxspeed" ||
item.key == "fee" ||
item.key == "toll" ||
boost::starts_with(item.key, "toll:") ||
item.key == "charge" ||
item.key == "population" ||
item.key == "description" ||
item.key == "image" ||
item.key == "attribution" ||
item.key == "fax" ||
item.key == "email" ||
item.key == "url" ||
item.key == "website" ||
item.key == "phone" ||
item.key == "real_ale" ||
item.key == "smoking" ||
item.key == "food" ||
item.key == "camera" ||
item.key == "brewery" ||
item.key == "locality" ||
item.key == "wikipedia" ||
boost::starts_with(item.key, "wikipedia:")) {
extratags.push_back(&item);
} else if (item.key == "building") {
placebuilding = true;
}
}
// skip some tags, if they don't have a proper name (ref doesn't count)
if (!isnamed) {
if (!places.empty())
places.erase(std::remove_if(places.begin(), places.end(),
UnnamedPredicate()),
places.end());
}
if (isinterpolation)
places.push_back(tag_t("place", "houses"));
if (place) {
if (isinterpolation ||
(placeadmin &&
place ->value != "island" &&
place ->value != "islet"))
extratags.push_back(place);
else
places.push_back(*place);
}
if (isnamed && places.empty()) {
if (junction)
places.push_back(*junction);
else if (landuse)
places.push_back(*landuse);
}
if (places.empty()) {
if (placebuilding && (!names.empty() || placehouse || postcode)) {
places.push_back(tag_t("building", "yes"));
} else if (placehouse) {
places.push_back(tag_t("place", "house"));
} else if (postcode) {
places.push_back(tag_t("place", "postcode"));
}
}
// housenumbers
if (!isinterpolation) {
if (street_nr && conscr_nr) {
housenumber.clear();
escape(*conscr_nr, housenumber);
housenumber.append("/");
escape(*street_nr, housenumber);
} else if (conscr_nr) {
housenumber.clear();
escape(*conscr_nr, housenumber);
} else if (street_nr) {
housenumber.clear();
escape(*street_nr, housenumber);
} else if (house_nr) {
housenumber.clear();
escape(*house_nr, housenumber);
}
}
}
void place_tag_processor::copy_out(char osm_type, osmid_t osm_id,
const std::string &geom,
std::string &buffer)
{
for (const auto& place: places) {
std::string name;
if (place.key == "bridge" || place.key == "tunnel") {
name = domain_name(place.key);
if (name.empty())
continue; // don't include unnamed bridges and tunnels
}
// osm_type
buffer += osm_type;
buffer += '\t';
// osm_id
buffer += (single_fmt % osm_id).str();
// class
escape(place.key, buffer);
buffer += '\t';
// type
escape(place.value, buffer);
buffer += '\t';
// names
if (!name.empty()) {
buffer += name;
buffer += '\t';
} else if (!names.empty()) {
bool first = true;
// operator will be ignored on anything but these classes
// (amenity for restaurant and fuel)
bool shop = (place.key == "shop") ||
(place.key == "amenity") ||
(place.key == "tourism");
for (const auto entry: names) {
if (!shop && (entry->key == "operator"))
continue;
if (first)
first = false;
else
buffer += ',';
buffer += "\"";
escape_array_record(entry->key, buffer);
buffer += "\"=>\"";
escape_array_record(entry->value, buffer);
buffer += "\"";
}
buffer += '\t';
} else
buffer += "\\N\t";
// admin_level
buffer += (single_fmt % admin_level).str();
// house number
buffer += housenumber;
buffer += '\t';
// street
copy_opt_string(street, buffer);
// addr_place
copy_opt_string(addr_place, buffer);
// isin
if (!address.empty()) {
for (const auto entry: address) {
if (entry->key == "tiger:county") {
escape(std::string(entry->value, 0, entry->value.find(",")),
buffer);
buffer += " county";
} else {
escape(entry->value, buffer);
}
buffer += ',';
}
buffer[buffer.length() - 1] = '\t';
} else
buffer += "\\N\t";
// postcode
copy_opt_string(postcode, buffer);
// country code
copy_opt_string(countrycode, buffer);
// extra tags
if (extratags.empty()) {
buffer += "\\N\t";
} else {
bool first = true;
for (const auto entry: extratags) {
if (first)
first = false;
else
buffer += ',';
buffer += "\"";
escape_array_record(entry->key, buffer);
buffer += "\"=>\"";
escape_array_record(entry->value, buffer);
buffer += "\"";
}
buffer += "\t";
}
// geometry
buffer += srid_str;
buffer += geom;
buffer += '\n';
}
}
void output_gazetteer_t::stop_copy(void)
{
/* Do we have a copy active? */
if (!copy_active) return;
if (buffer.length() > 0)
{
pgsql_CopyData("place", Connection, buffer);
buffer.clear();
}
/* Terminate the copy */
if (PQputCopyEnd(Connection, nullptr) != 1)
{
std::cerr << "COPY_END for place failed: " << PQerrorMessage(Connection) << "\n";
util::exit_nicely();
}
/* Check the result */
PGresult *res = PQgetResult(Connection);
if (PQresultStatus(res) != PGRES_COMMAND_OK)
{
std::cerr << "COPY_END for place failed: " << PQerrorMessage(Connection) << "\n";
PQclear(res);
util::exit_nicely();
}
/* Discard the result */
PQclear(res);
/* We no longer have an active copy */
copy_active = false;
}
void output_gazetteer_t::delete_unused_classes(char osm_type, osmid_t osm_id) {
char tmp2[2];
tmp2[0] = osm_type; tmp2[1] = '\0';
char const *paramValues[2];
paramValues[0] = tmp2;
paramValues[1] = (single_fmt % osm_id).str().c_str();
PGresult *res = pgsql_execPrepared(ConnectionDelete, "get_classes", 2,
paramValues, PGRES_TUPLES_OK);
int sz = PQntuples(res);
if (sz > 0 && !places.has_data()) {
PQclear(res);
/* unconditional delete of all places */
delete_place(osm_type, osm_id);
} else {
std::string clslist;
for (int i = 0; i < sz; i++) {
std::string cls(PQgetvalue(res, i, 0));
if (!places.has_place(cls)) {
clslist.reserve(clslist.length() + cls.length() + 3);
if (!clslist.empty())
clslist += ',';
clslist += '\'';
clslist += cls;
clslist += '\'';
}
}
PQclear(res);
if (!clslist.empty()) {
/* Stop any active copy */
stop_copy();
/* Delete all places for this object */
pgsql_exec(Connection, PGRES_COMMAND_OK,
"DELETE FROM place WHERE osm_type = '%c' AND osm_id = %"
PRIdOSMID " and class = any(ARRAY[%s])",
osm_type, osm_id, clslist.c_str());
}
}
}
void output_gazetteer_t::delete_place(char osm_type, osmid_t osm_id)
{
/* Stop any active copy */
stop_copy();
/* Delete all places for this object */
pgsql_exec(Connection, PGRES_COMMAND_OK, "DELETE FROM place WHERE osm_type = '%c' AND osm_id = %" PRIdOSMID, osm_type, osm_id);
return;
}
int output_gazetteer_t::connect() {
/* Connection to the database */
Connection = PQconnectdb(m_options.database_options.conninfo().c_str());
/* Check to see that the backend connection was successfully made */
if (PQstatus(Connection) != CONNECTION_OK) {
std::cerr << "Connection to database failed: " << PQerrorMessage(Connection) << "\n";
return 1;
}
if (m_options.append) {
ConnectionDelete = PQconnectdb(m_options.database_options.conninfo().c_str());
if (PQstatus(ConnectionDelete) != CONNECTION_OK)
{
std::cerr << "Connection to database failed: " << PQerrorMessage(Connection) << "\n";
return 1;
}
pgsql_exec(ConnectionDelete, PGRES_COMMAND_OK, "PREPARE get_classes (CHAR(1), " POSTGRES_OSMID_TYPE ") AS SELECT class FROM place WHERE osm_type = $1 and osm_id = $2");
}
return 0;
}
int output_gazetteer_t::start()
{
int srid = m_options.projection->target_srs();
builder.set_exclude_broken_polygon(m_options.excludepoly);
places.srid_str = (boost::format("SRID=%1%;") % srid).str();
if(connect())
util::exit_nicely();
/* Start a transaction */
pgsql_exec(Connection, PGRES_COMMAND_OK, "BEGIN");
/* (Re)create the table unless we are appending */
if (!m_options.append) {
/* Drop any existing table */
pgsql_exec(Connection, PGRES_COMMAND_OK, "DROP TABLE IF EXISTS place");
/* Create the new table */
if (m_options.tblsmain_data) {
pgsql_exec(Connection, PGRES_COMMAND_OK,
CREATE_PLACE_TABLE, "TABLESPACE", m_options.tblsmain_data->c_str());
} else {
pgsql_exec(Connection, PGRES_COMMAND_OK, CREATE_PLACE_TABLE, "", "");
}
if (m_options.tblsmain_index) {
pgsql_exec(Connection, PGRES_COMMAND_OK,
CREATE_PLACE_ID_INDEX, "TABLESPACE", m_options.tblsmain_index->c_str());
} else {
pgsql_exec(Connection, PGRES_COMMAND_OK, CREATE_PLACE_ID_INDEX, "", "");
}
pgsql_exec(Connection, PGRES_TUPLES_OK, "SELECT AddGeometryColumn('place', 'geometry', %d, 'GEOMETRY', 2)", srid);
pgsql_exec(Connection, PGRES_COMMAND_OK, "ALTER TABLE place ALTER COLUMN geometry SET NOT NULL");
}
return 0;
}
void output_gazetteer_t::stop()
{
/* Stop any active copy */
stop_copy();
/* Commit transaction */
pgsql_exec(Connection, PGRES_COMMAND_OK, "COMMIT");
PQfinish(Connection);
if (ConnectionDelete)
PQfinish(ConnectionDelete);
if (ConnectionError)
PQfinish(ConnectionError);
return;
}
int output_gazetteer_t::process_node(osmid_t id, double lat, double lon,
const taglist_t &tags)
{
places.process_tags(tags);
if (m_options.append)
delete_unused_classes('N', id);
/* Are we interested in this item? */
if (places.has_data()) {
std::string wkt = (point_fmt % lon % lat).str();
places.copy_out('N', id, wkt, buffer);
flush_place_buffer();
}
return 0;
}
int output_gazetteer_t::process_way(osmid_t id, const idlist_t &nds, const taglist_t &tags)
{
places.process_tags(tags);
if (m_options.append)
delete_unused_classes('W', id);
/* Are we interested in this item? */
if (places.has_data()) {
/* Fetch the node details */
nodelist_t nodes;
m_mid->nodes_get_list(nodes, nds);
/* Get the geometry of the object */
auto geom = builder.get_wkb_simple(nodes, 1);
if (geom.valid()) {
places.copy_out('W', id, geom.geom, buffer);
flush_place_buffer();
}
}
return 0;
}
int output_gazetteer_t::process_relation(osmid_t id, const memberlist_t &members,
const taglist_t &tags)
{
const std::string *type = tags.get("type");
if (!type) {
delete_unused_full('R', id);
return 0;
}
int cmp_waterway = type->compare("waterway");
if (*type == "associatedStreet"
|| !(*type == "boundary" || *type == "multipolygon" || !cmp_waterway)) {
delete_unused_full('R', id);
return 0;
}
places.process_tags(tags);
if (m_options.append)
delete_unused_classes('R', id);
/* Are we interested in this item? */
if (!places.has_data())
return 0;
/* get the boundary path (ways) */
idlist_t xid2;
for (const auto& member: members) {
/* only interested in ways */
if (member.type == OSMTYPE_WAY)
xid2.push_back(member.id);
}
if (xid2.empty()) {
if (m_options.append)
delete_unused_full('R', id);
return 0;
}
multitaglist_t xtags;
multinodelist_t xnodes;
idlist_t xid;
m_mid->ways_get_list(xid2, xid, xtags, xnodes);
if (cmp_waterway) {
auto geoms = builder.build_both(xnodes, 1, 1, 1000000, id);
for (const auto& geom: geoms) {
if (geom.is_polygon()) {
places.copy_out('R', id, geom.geom, buffer);
flush_place_buffer();
} else {
/* add_polygon_error('R', id, "boundary", "adminitrative", &names, countrycode, wkt); */
}
}
} else {
/* waterways result in multilinestrings */
auto geom = builder.build_multilines(xnodes, id);
if (geom.valid()) {
places.copy_out('R', id, geom.geom, buffer);
flush_place_buffer();
}
}
return 0;
}