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; }
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 (memberlist_t::const_iterator it = members.begin(); it != members.end(); ++it) { /* only interested in ways */ if (it->type == OSMTYPE_WAY) xid2.push_back(it->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) { geometry_builder::maybe_wkts_t wkts = builder.build_both(xnodes, 1, 1, 1000000, id); for (const auto& wkt: *wkts) { if (boost::starts_with(wkt.geom, "POLYGON") || boost::starts_with(wkt.geom, "MULTIPOLYGON")) { places.copy_out('R', id, wkt.geom, buffer); flush_place_buffer(); } else { /* add_polygon_error('R', id, "boundary", "adminitrative", &names, countrycode, wkt); */ } } } else { /* waterways result in multilinestrings */ geometry_builder::maybe_wkt_t wkt = builder.build_multilines(xnodes, id); if ((wkt->geom).length() > 0) { places.copy_out('R', id, wkt->geom, buffer); flush_place_buffer(); } } return 0; }