1/** Copyright 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 Roland Olbricht et al. 3 * This file is part of Overpass_API. 5 * Overpass_API is free software: you can redistribute it and/or modify 6 * it under the terms of the GNU Affero General Public License as 7 * published by the Free Software Foundation, either version 3 of the 8 * License, or (at your option) any later version. 10 * Overpass_API is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 15 * You should have received a copy of the GNU Affero General Public License 16 * along with Overpass_API. If not, see <http://www.gnu.org/licenses/>. 19#include "../core/index_computations.h" 20#include "../data/collect_members.h" 21#include "../data/filenames.h" 22#include "../data/geometry_from_quad_coords.h" 23#include "../data/meta_collector.h" 24#include "../data/relation_geometry_store.h" 25#include "../data/set_comparison.h" 26#include "../data/tag_store.h" 27#include "../data/utils.h" 28#include "../data/way_geometry_store.h" 41const unsigned int NODE_FLUSH_SIZE = 1024*1024; 42const unsigned int WAY_FLUSH_SIZE = 512*1024; 43const unsigned int RELATION_FLUSH_SIZE = 512*1024; 44const unsigned int AREA_FLUSH_SIZE = 64*1024; 47Generic_Statement_Maker< Print_Statement > Print_Statement::statement_maker("print"); 50Print_Statement::Print_Statement 51 (int line_number_, const std::map< std::string, std::string >& input_attributes, Parsed_Query& global_settings) 5210749597 q : Statement(line_number_), 5310749597 q mode(0), order(order_by_id), limit(std::numeric_limits< unsigned int >::max()), 5410749597 q collection_print_target(0), diff_valid(true), 5510749597 q south(1.0), north(0.0), west(0.0), east(0.0) 5710749597 q std::map< std::string, std::string > attributes; 5910749597 q attributes["from"] = "_"; 6010749597 q attributes["ids"] = "yes"; 6110749597 q attributes["mode"] = "body"; 6210749597 q attributes["order"] = "id"; 6310749597 q attributes["limit"] = ""; 6410749597 q attributes["geometry"] = "skeleton"; 7010749597 q eval_attributes_array(get_name(), attributes, input_attributes); 7210749597 q input = attributes["from"]; 7410749597 q if (attributes["mode"] == "ids_only") 754545580 q mode = Output_Mode::ID; 766204595 q else if (attributes["mode"] == "skeleton") 776020 q mode = Output_Mode::ID 786020 q | Output_Mode::COORDS | Output_Mode::NDS | Output_Mode::MEMBERS; 796144595 q else if (attributes["mode"] == "tags") 80124 q mode = Output_Mode::ID | Output_Mode::TAGS; 816132594 q else if (attributes["mode"] == "body") 831431457 q | Output_Mode::COORDS | Output_Mode::NDS | Output_Mode::MEMBERS 854701579 q else if (attributes["mode"] == "meta") 867224 q mode = Output_Mode::ID 877224 q | Output_Mode::COORDS | Output_Mode::NDS | Output_Mode::MEMBERS 887224 q | Output_Mode::TAGS | Output_Mode::VERSION | Output_Mode::META; 894629579 q else if (attributes["mode"] == "count") 904626579 q mode = Output_Mode::ID | Output_Mode::COUNT; 9331 q mode = Output_Mode::ID; 9431 q std::ostringstream temp; 9531 q temp<<"For the attribute \"mode\" of the element \"print\"" 9631 q <<" the only allowed values are \"ids_only\", \"skeleton\", \"body\", \"tags\", \"count\", or \"meta\"."; 9731 q add_static_error(temp.str()); 10010749597 q if (attributes["order"] == "id") 10211438 q else if (attributes["order"] == "quadtile") 10311438 q order = order_by_quadtile; 1060 std::ostringstream temp; 1070 temp<<"For the attribute \"order\" of the element \"print\"" 1080 <<" the only allowed values are \"id\" or \"quadtile\"."; 1090 add_static_error(temp.str()); 11210749597 q if (attributes["limit"] != "") 1134560578 q limit = atoll(attributes["limit"].c_str()); 11510749597 q if (attributes["geometry"] == "skeleton") 11715348 q else if (attributes["geometry"] == "full") 1187222 q mode = mode | Output_Mode::GEOMETRY | Output_Mode::BOUNDS; 1198127 q else if (attributes["geometry"] == "bounds") 1204515 q mode = mode | Output_Mode::BOUNDS; 1213612 q else if (attributes["geometry"] == "center") 1223612 q mode = mode | Output_Mode::CENTER; 1250 std::ostringstream temp; 1260 temp<<"For the attribute \"geometry\" of the element \"print\"" 1270 <<" the only allowed values are \"skeleton\", \"full\", \"bounds\", or \"center\"."; 1280 add_static_error(temp.str()); 13110749597 q if (attributes["ids"] == "yes") 1333010 q else if (attributes["ids"] == "no") 1343010 q mode = mode & ~Output_Mode::ID; 1370 std::ostringstream temp; 1380 temp<<"For the attribute \"ids\" of the element \"print\"" 1390 <<" the only allowed values are \"yes\" or \"no\"."; 1400 add_static_error(temp.str()); 14310749597 q south = atof(attributes["s"].c_str()); 14410749597 q if ((south < -90.0) || (south > 90.0)) 1460 std::ostringstream temp; 1470 temp<<"For the attribute \"s\" of the element \"print\"" 1480 <<" the only allowed values are floats between -90.0 and 90.0."; 1490 add_static_error(temp.str()); 15110749597 q north = atof(attributes["n"].c_str()); 15210749597 q if ((north < -90.0) || (north > 90.0)) 1540 std::ostringstream temp; 1550 temp<<"For the attribute \"n\" of the element \"print\"" 1560 <<" the only allowed values are floats between -90.0 and 90.0."; 1570 add_static_error(temp.str()); 1610 std::ostringstream temp; 1620 temp<<"The value of attribute \"n\" of the element \"print\"" 1630 <<" must always be greater or equal than the value of attribute \"s\"."; 1640 add_static_error(temp.str()); 16710749597 q west = atof(attributes["w"].c_str()); 16810749597 q if ((west < -180.0) || (west > 180.0)) 1700 std::ostringstream temp; 1710 temp<<"For the attribute \"w\" of the element \"print\"" 1720 <<" the only allowed values are floats between -180.0 and 180.0."; 1730 add_static_error(temp.str()); 17510749597 q east = atof(attributes["e"].c_str()); 17610749597 q if ((east < -180.0) || (east > 180.0)) 1780 std::ostringstream temp; 1790 temp<<"For the attribute \"e\" of the element \"print\"" 1800 <<" the only allowed values are floats between -180.0 and 180.0."; 1810 add_static_error(temp.str()); 18310749597 q if ((attributes["n"] == "") && (attributes["s"] == "") && 18410749597 q (attributes["w"] == "") && (attributes["e"] == "")) 195 Resource_Manager& rman, const Statement& stmt, const Set& to_print, 196 unsigned int mode_, Output_Handler::Feature_Action action_, 197 double south, double north, double west, double east); 200 const std::map< uint32, std::string >* get_users() const; 203 Output_Handler::Feature_Action action; 204 Way_Bbox_Geometry_Store* way_geometry_store; 205 Way_Bbox_Geometry_Store* attic_way_geometry_store; 206 Relation_Geometry_Store* relation_geometry_store; 207 Relation_Geometry_Store* attic_relation_geometry_store; 208 const std::map< uint32, std::string >* roles; 209 const std::map< uint32, std::string >* users; 213Extra_Data::Extra_Data( 214 Resource_Manager& rman, const Statement& stmt, const Set& to_print, 215 unsigned int mode_, Output_Handler::Feature_Action action_, 216 double south, double north, double west, double east) 2177583514 q : mode(mode_), action(action_), way_geometry_store(0), attic_way_geometry_store(0), 2187583514 q relation_geometry_store(0), attic_relation_geometry_store(0), roles(0), users(0) 2207583514 q if (mode & (Output_Mode::GEOMETRY | Output_Mode::BOUNDS | Output_Mode::CENTER)) 2224138 q way_geometry_store = new Way_Bbox_Geometry_Store(to_print.ways, stmt, rman, south, north, west, east); 2234138 q if (rman.get_desired_timestamp() < NOW) 2251211 q attic_way_geometry_store = new Way_Bbox_Geometry_Store( 2261211 q to_print.attic_ways, stmt, rman, 2271211 q south, north, west, east); 2304138 q relation_geometry_store = new Relation_Geometry_Store( 2314138 q to_print.relations, stmt, rman, south, north, west, east); 2324138 q if (rman.get_desired_timestamp() < NOW) 2341211 q attic_relation_geometry_store = new Relation_Geometry_Store( 2351211 q to_print.attic_relations, stmt, rman, 2361211 q south, north, west, east); 2407583514 q roles = &relation_member_roles(*rman.get_transaction()); 2427583514 q if (mode & Output_Mode::META) 247const std::map< uint32, std::string >* Extra_Data::get_users() const 253Extra_Data::~Extra_Data() 2567583514 q delete attic_way_geometry_store; 2577583514 q delete relation_geometry_store; 2587583514 q delete attic_relation_geometry_store; 262void print_item(Extra_Data& extra_data, Output_Handler& output, uint32 ll_upper, const Node_Skeleton& skel, 263 const std::vector< std::pair< std::string, std::string > >* tags = 0, 264 const OSM_Element_Metadata_Skeleton< Node_Skeleton::Id_Type >* meta = 0) 2661160764245 q output.print_item(skel, Point_Geometry(::lat(ll_upper, skel.ll_lower), ::lon(ll_upper, skel.ll_lower)), 2671160764245 q tags, meta, extra_data.get_users(), Output_Mode(extra_data.mode), extra_data.action); 271void print_item(Extra_Data& extra_data, Output_Handler& output, uint32 ll_upper, const Way_Skeleton& skel, 272 const std::vector< std::pair< std::string, std::string > >* tags = 0, 273 const OSM_Element_Metadata_Skeleton< Way_Skeleton::Id_Type >* meta = 0) 2751036208250 q Geometry_From_Quad_Coords broker; 2771036208250 q broker.make_way_geom(skel, extra_data.mode, extra_data.way_geometry_store), 2781036208250 q tags, meta, extra_data.get_users(), Output_Mode(extra_data.mode), extra_data.action); 282void print_item(Extra_Data& extra_data, Output_Handler& output, uint32 ll_upper, const Attic< Way_Skeleton >& skel, 283 const std::vector< std::pair< std::string, std::string > >* tags = 0, 284 const OSM_Element_Metadata_Skeleton< Way_Skeleton::Id_Type >* meta = 0) 2864884072 q Geometry_From_Quad_Coords broker; 2874884072 q output.print_item(skel, 2884884072 q broker.make_way_geom(skel, extra_data.mode, extra_data.attic_way_geometry_store), 2894884072 q tags, meta, extra_data.get_users(), Output_Mode(extra_data.mode), extra_data.action); 293void print_item(Extra_Data& extra_data, Output_Handler& output, uint32 ll_upper, const Relation_Skeleton& skel, 294 const std::vector< std::pair< std::string, std::string > >* tags = 0, 295 const OSM_Element_Metadata_Skeleton< Relation_Skeleton::Id_Type >* meta = 0) 297148128148 q Geometry_From_Quad_Coords broker; 299148128148 q broker.make_relation_geom(skel, extra_data.mode, extra_data.relation_geometry_store), 300148128148 q tags, meta, extra_data.roles, extra_data.get_users(), Output_Mode(extra_data.mode), extra_data.action); 304void print_item(Extra_Data& extra_data, Output_Handler& output, uint32 ll_upper, const Attic< Relation_Skeleton >& skel, 305 const std::vector< std::pair< std::string, std::string > >* tags = 0, 306 const OSM_Element_Metadata_Skeleton< Relation_Skeleton::Id_Type >* meta = 0) 308947344 q Geometry_From_Quad_Coords broker; 309947344 q output.print_item(skel, 310947344 q broker.make_relation_geom(skel, extra_data.mode, extra_data.attic_relation_geometry_store), 311947344 q tags, meta, extra_data.roles, extra_data.get_users(), Output_Mode(extra_data.mode), extra_data.action); 315void print_item(Extra_Data& extra_data, Output_Handler& output, uint32 ll_upper, const Area_Skeleton& skel, 316 const std::vector< std::pair< std::string, std::string > >* tags = 0, 317 const OSM_Element_Metadata_Skeleton< Area_Skeleton::Id_Type >* meta = 0) 319380982 q Derived_Skeleton derived("area", Uint64(skel.id.val())); 320380982 q output.print_item(derived, Null_Geometry(), tags, Output_Mode(extra_data.mode), extra_data.action); 324void print_item(Extra_Data& extra_data, Output_Handler& output, uint32 ll_upper, const Derived_Structure& skel, 325 const std::vector< std::pair< std::string, std::string > >* tags = 0, 326 const OSM_Element_Metadata_Skeleton< Derived_Skeleton::Id_Type >* meta = 0) 3293826348 q output.print_item(skel, *skel.get_geometry(), tags, Output_Mode(extra_data.mode), extra_data.action); 33135208494 q output.print_item(skel, Null_Geometry(), tags, Output_Mode(extra_data.mode), extra_data.action); 335template< class TIndex, class TObject > 337 (const std::map< TIndex, std::vector< TObject > >& items, Output_Handler& output, 338 Transaction& transaction, Extra_Data& extra_data, uint32 limit, uint32& element_count) 34012417 q typename std::map< TIndex, std::vector< TObject > >::const_iterator 343831817 q while (item_it != items.end()) 345820016 q for (typename std::vector< TObject >::const_iterator it2(item_it->second.begin()); 3462908116 q it2 != item_it->second.end(); ++it2) 3482088714 q if (++element_count > limit) 3502088114 q print_item(extra_data, output, item_it->first.val(), *it2); 357template< class Index, class Object > 359 (Extra_Data& extra_data, const std::map< Index, std::vector< Object > >& items, 360 Output_Handler& output, 361 Resource_Manager& rman, Transaction& transaction, uint32 limit, uint32& element_count) 3638420 q Tag_Store< Index, Object > tag_store(*rman.get_transaction()); 3648420 q tag_store.prefetch_all(items); 366 // formulate meta query if meta data shall be printed 3678420 q Meta_Collector< Index, typename Object::Id_Type > meta_printer(items, transaction, 3688420 q (extra_data.mode & Output_Mode::META) ? current_meta_file_properties< Object >() : 0); 3708420 q typename std::map< Index, std::vector< Object > >::const_iterator 373775020 q while (item_it != items.end()) 375767118 q for (typename std::vector< Object >::const_iterator it2(item_it->second.begin()); 3762004418 q it2 != item_it->second.end(); ++it2) 3781237816 q if (++element_count > limit) 3801237316 q print_item(extra_data, output, item_it->first.val(), *it2, tag_store.get(item_it->first, *it2), 3811237316 q meta_printer.get(item_it->first, it2->id)); 388template< class Index, class Object > 389void tags_quadtile_attic_ 390 (Extra_Data& extra_data, const std::map< Index, std::vector< Attic< Object > > >& items, 391 Output_Handler& output, 392 Resource_Manager& rman, Transaction& transaction, uint32 limit, uint32& element_count) 3943311 q Tag_Store< Index, Object > tag_store(transaction); 3953311 q tag_store.prefetch_all(items); 3973311 q Attic_Meta_Collector< Index, Object > meta_printer(items, transaction, extra_data.mode & Output_Mode::META); 3993311 q typename std::map< Index, std::vector< Attic< Object > > >::const_iterator 401719611 q while (item_it != items.end()) 40371659 q for (typename std::vector< Attic< Object > >::const_iterator it2(item_it->second.begin()); 40475689 q it2 != item_it->second.end(); ++it2) 4064058 q if (++element_count > limit) 4084036 q print_item(extra_data, output, item_it->first.val(), *it2, tag_store.get(item_it->first, *it2), 4094036 q meta_printer.get(item_it->first, it2->id, it2->timestamp)); 416template< class TComp > 417struct Skeleton_Comparator_By_Id { 418 bool operator() (const std::pair< const TComp*, uint32 >& a, 419 const std::pair< const TComp*, uint32 >& b) 42140201095249 q return (a.first->id < b.first->id); 426template< typename Index, typename Object > 427struct Maybe_Attic_Ref 430 Maybe_Attic_Ref(Index idx_, const Object* obj_, uint64 timestamp_) 43115821058411 q : idx(idx_), obj(obj_), timestamp(timestamp_) {} 437391220430364 q bool operator<(const Maybe_Attic_Ref& rhs) const { return obj->id < rhs.obj->id; } 441template< class Index, class Object > 442std::vector< std::pair< const Object*, uint32 > > collect_items_by_id( 443 const std::map< Index, std::vector< Object > >& items) 44519103513 q std::vector< std::pair< const Object*, uint32 > > items_by_id; 44719103513 q for (typename std::map< Index, std::vector< Object > >::const_iterator 448357545513 q it(items.begin()); it != items.end(); ++it) 450338442506 q for (typename std::vector< Object >::const_iterator it2(it->second.begin()); 4512386755506 q it2 != it->second.end(); ++it2) 4522048313506 q items_by_id.push_back(std::make_pair(&(*it2), it->first.val())); 45419103513 q sort(items_by_id.begin(), items_by_id.end(), 45519103513 q Skeleton_Comparator_By_Id< Object >()); 461template< class Index, class Object > 462std::vector< Maybe_Attic_Ref< Index, Object > > collect_items_by_id( 463 const std::map< Index, std::vector< Object > >& items, 464 const std::map< Index, std::vector< Attic< Object > > >& attic_items) 46611835496 q std::vector< Maybe_Attic_Ref< Index, Object > > items_by_id; 46711835496 q for (typename std::map< Index, std::vector< Object > >::const_iterator 4681358241496 q it(items.begin()); it != items.end(); ++it) 4701346406401 q for (typename std::vector< Object >::const_iterator it2(it->second.begin()); 47116772483401 q it2 != it->second.end(); ++it2) 47215426077386 q items_by_id.push_back(Maybe_Attic_Ref< Index, Object >(it->first, &(*it2), NOW)); 47411835496 q for (typename std::map< Index, std::vector< Attic< Object > > >::const_iterator 475143039496 q it(attic_items.begin()); it != attic_items.end(); ++it) 477131204136 q for (typename std::vector< Attic< Object > >::const_iterator it2(it->second.begin()); 478526185136 q it2 != it->second.end(); ++it2) 479394981109 q items_by_id.push_back(Maybe_Attic_Ref< Index, Object >(it->first, &(*it2), it2->timestamp)); 48111835496 q sort(items_by_id.begin(), items_by_id.end()); 487template< class Index, class Object > 489 (const std::map< Index, std::vector< Object > >& items, Output_Handler& output, 490 Transaction& transaction, Extra_Data& extra_data, uint32 limit, uint32& element_count) 4921919491 q std::vector< std::pair< const Object*, uint32 > > items_by_id = collect_items_by_id(items); 494 // iterate over the result 49534622491 q for (uint32 i(0); i < items_by_id.size(); ++i) 49732731184 q if (++element_count > limit) 49932703183 q print_item(extra_data, output, items_by_id[i].second, *(items_by_id[i].first)); 504template< class Index, class Object > 506 (const std::map< Index, std::vector< Object > >& items, 507 const std::map< Index, std::vector< Attic< Object > > >& attic_items, 508 Output_Handler& output, 509 Transaction& transaction, Extra_Data& extra_data, uint32 limit, uint32& element_count) 5114800491 q std::vector< Maybe_Attic_Ref< Index, Object > > items_by_id = collect_items_by_id(items, attic_items); 513 // iterate over the result 514472050491 q for (uint32 i(0); i < items_by_id.size(); ++i) 516467601410 q if (++element_count > limit) 518467250410 q if (items_by_id[i].timestamp == NOW) 519321449386 q print_item(extra_data, output, items_by_id[i].idx.val(), *items_by_id[i].obj); 521145801107 q print_item(extra_data, output, items_by_id[i].idx.val(), 522145801107 q Attic< Object >(*items_by_id[i].obj, items_by_id[i].timestamp)); 527template< class Index, class Object > 528void collect_metadata(std::set< OSM_Element_Metadata_Skeleton< typename Object::Id_Type > >& metadata, 529 const std::map< Index, std::vector< Object > >& items, 530 typename Object::Id_Type lower_id_bound, typename Object::Id_Type upper_id_bound, 531 Meta_Collector< Index, typename Object::Id_Type >& meta_printer) 53314278 q for (typename std::map< Index, std::vector< Object > >::const_iterator 5345629978 q it(items.begin()); it != items.end(); ++it) 5365615762 q for (typename std::vector< Object >::const_iterator it2(it->second.begin()); 53723948362 q it2 != it->second.end(); ++it2) 53918332658 q if (!(it2->id < lower_id_bound) && (it2->id < upper_id_bound)) 54118332658 q const OSM_Element_Metadata_Skeleton< typename Object::Id_Type >* meta 54218332658 q = meta_printer.get(it->first, it2->id); 54410134216 q metadata.insert(*meta); 551template< class Index, class Object > 552void collect_metadata(std::set< OSM_Element_Metadata_Skeleton< typename Object::Id_Type > >& metadata, 553 const std::map< Index, std::vector< Attic< Object > > >& items, 554 typename Object::Id_Type lower_id_bound, typename Object::Id_Type upper_id_bound, 555 Attic_Meta_Collector< Index, Object >& meta_printer) 55712469 q for (typename std::map< Index, std::vector< Attic< Object > > >::const_iterator 558738169 q it(items.begin()); it != items.end(); ++it) 560725763 q for (typename std::vector< Attic< Object > >::const_iterator it2(it->second.begin()); 5613474063 q it2 != it->second.end(); ++it2) 5632748359 q if (!(it2->id < lower_id_bound) && (it2->id < upper_id_bound)) 5652748359 q const OSM_Element_Metadata_Skeleton< typename Object::Id_Type >* meta 5662748359 q = meta_printer.get(it->first, it2->id, it2->timestamp); 5688578 q metadata.insert(*meta); 575template< typename Id_Type > 576typename std::set< OSM_Element_Metadata_Skeleton< Id_Type > >::const_iterator 577 find_matching_metadata 578 (const std::set< OSM_Element_Metadata_Skeleton< Id_Type > >& metadata, 579 Id_Type ref, uint64 timestamp) 5812560959 q typename std::set< OSM_Element_Metadata_Skeleton< Id_Type > >::iterator it 5822560959 q = metadata.lower_bound(OSM_Element_Metadata_Skeleton< Id_Type >(ref, timestamp)); 5832560959 q if (it == metadata.begin()) 5842475252 q return metadata.end(); 5890 return metadata.end(); 593template< class Index, class Object > 595 (Extra_Data& extra_data, const std::map< Index, std::vector< Object > >& items, 596 uint32 FLUSH_SIZE, Output_Handler& output, 597 Resource_Manager& rman, Meta_Collector< Index, typename Object::Id_Type >* meta_printer, 598 Tag_Store< Index, Object >& tag_store, uint32 limit, uint32& element_count) 60017184511 q std::vector< std::pair< const Object*, uint32 > > items_by_id = collect_items_by_id(items); 602 // iterate over the result 60323053511 q for (typename Object::Id_Type id_pos; id_pos < items_by_id.size(); id_pos += FLUSH_SIZE) 605 // Disable health_check: This ensures that a result will be always printed completely 606 //rman.health_check(*this); 6085877506 q typename Object::Id_Type lower_id_bound(items_by_id[id_pos.val()].first->id); 6095877506 q typename Object::Id_Type upper_id_bound; 6105877506 q if (id_pos + FLUSH_SIZE < items_by_id.size()) 6110 upper_id_bound = items_by_id[(id_pos + FLUSH_SIZE).val()].first->id; 6145877506 q upper_id_bound = items_by_id[items_by_id.size()-1].first->id; 6185877506 q tag_store.prefetch_chunk(items, lower_id_bound, upper_id_bound); 6205877506 q std::set< OSM_Element_Metadata_Skeleton< typename Object::Id_Type > > metadata; 623 // collect metadata if required 624189 q collect_metadata(metadata, items, lower_id_bound, upper_id_bound, *meta_printer); 625189 q meta_printer->reset(); 6295877506 q for (typename Object::Id_Type i(id_pos); 6301835908506 q (i < id_pos + FLUSH_SIZE) && (i < items_by_id.size()); ++i) 6321830039506 q if (++element_count > limit) 6341830031506 q typename std::set< OSM_Element_Metadata_Skeleton< typename Object::Id_Type > >::const_iterator meta_it 6351830031506 q = metadata.lower_bound(OSM_Element_Metadata_Skeleton< typename Object::Id_Type > 6361830031506 q (items_by_id[i.val()].first->id)); 6371830031506 q print_item(extra_data, output, items_by_id[i.val()].second, *(items_by_id[i.val()].first), 6381830031506 q tag_store.get(Index(items_by_id[i.val()].second), *items_by_id[i.val()].first), 6391830031506 q (meta_it != metadata.end() && meta_it->ref == items_by_id[i.val()].first->id) ? 647template< class Index, class Object > 649 (const std::map< Index, std::vector< Object > >& current_items, 650 const std::map< Index, std::vector< Attic< Object > > >& attic_items, 651 Extra_Data& extra_data, uint32 FLUSH_SIZE, Output_Handler& output, 652 Resource_Manager& rman, Transaction& transaction, uint32 limit, uint32& element_count) 6547035176 q std::vector< Maybe_Attic_Ref< Index, Object > > items_by_id = collect_items_by_id(current_items, attic_items); 6567035176 q Tag_Store< Index, Object > current_tag_store(transaction); 6577035176 q Tag_Store< Index, Object > attic_tag_store(transaction); 659 // formulate meta query if meta data shall be printed 6607035176 q Meta_Collector< Index, typename Object::Id_Type > only_current_meta_printer 6617035176 q (current_items, transaction, 6627035176 q (extra_data.mode & Output_Mode::META) ? current_meta_file_properties< Object >() : 0); 6647153176 q for (typename Object::Id_Type id_pos; id_pos < items_by_id.size(); id_pos += FLUSH_SIZE) 666 // Disable health_check: This ensures that a result will be always printed completely 667 //rman.health_check(*this); 66912469 q typename Object::Id_Type lower_id_bound(items_by_id[id_pos.val()].obj->id); 67012469 q typename Object::Id_Type upper_id_bound; 67112469 q if (id_pos + FLUSH_SIZE < items_by_id.size()) 6720 upper_id_bound = items_by_id[(id_pos + FLUSH_SIZE).val()].obj->id; 67512469 q upper_id_bound = items_by_id[items_by_id.size()-1].obj->id; 67912469 q current_tag_store.prefetch_chunk(current_items, lower_id_bound, upper_id_bound); 68012469 q attic_tag_store.prefetch_chunk(attic_items, lower_id_bound, upper_id_bound); 682 // collect metadata if required 68312469 q std::set< OSM_Element_Metadata_Skeleton< typename Object::Id_Type > > only_current_metadata; 68412469 q collect_metadata(only_current_metadata, current_items, lower_id_bound, upper_id_bound, 68512469 q only_current_meta_printer); 68612469 q only_current_meta_printer.reset(); 68812469 q Attic_Meta_Collector< Index, Object > meta_printer(attic_items, transaction, extra_data.mode & Output_Mode::META); 68912469 q std::set< OSM_Element_Metadata_Skeleton< typename Object::Id_Type > > attic_metadata; 69012469 q collect_metadata(attic_metadata, attic_items, lower_id_bound, upper_id_bound, meta_printer); 69312469 q for (typename Object::Id_Type i(id_pos); 69411717669 q (i < id_pos + FLUSH_SIZE) && (i < items_by_id.size()); ++i) 69611705869 q if (++element_count > limit) 69811705269 q if (items_by_id[i.val()].timestamp == NOW) 7009144349 q typename std::set< OSM_Element_Metadata_Skeleton< typename Object::Id_Type > >::const_iterator meta_it 7019144349 q = only_current_metadata.lower_bound(OSM_Element_Metadata_Skeleton< typename Object::Id_Type > 7029144349 q (items_by_id[i.val()].obj->id)); 7039144349 q print_item(extra_data, output, items_by_id[i.val()].idx.val(), *items_by_id[i.val()].obj, 7049144349 q current_tag_store.get(items_by_id[i.val()].idx, *items_by_id[i.val()].obj), 7059144349 q (meta_it != only_current_metadata.end() && meta_it->ref == items_by_id[i.val()].obj->id) ? 7102560959 q typename std::set< OSM_Element_Metadata_Skeleton< typename Object::Id_Type > >::const_iterator meta_it 7112560959 q = find_matching_metadata(attic_metadata, 7122560959 q items_by_id[i.val()].obj->id, items_by_id[i.val()].timestamp); 7132560959 q print_item(extra_data, output, items_by_id[i.val()].idx.val(), 7142560959 q Attic< Object >(*items_by_id[i.val()].obj, items_by_id[i.val()].timestamp), 7152560959 q attic_tag_store.get(items_by_id[i.val()].idx, *items_by_id[i.val()].obj), 7162560959 q meta_it != attic_metadata.end() ? &*meta_it : 0); 723template< class Index, class Object > 725 (Extra_Data& extra_data, const std::map< Index, std::vector< Object > >& items, 726 const std::map< Index, std::vector< Attic< Object > > >& attic_items, 727 unsigned int mode, uint32 FLUSH_SIZE, Output_Handler& output, Resource_Manager& rman, 728 uint32 limit, uint32& element_count) 73017838511 q if (mode & Output_Mode::META) 7325719 q if (rman.get_desired_timestamp() == NOW) 7343010 q Tag_Store< Index, Object > tag_store(*rman.get_transaction()); 7353010 q Meta_Collector< Index, typename Object::Id_Type > meta_printer(items, *rman.get_transaction(), 7363010 q current_meta_file_properties< Object >()); 7373010 q tags_by_id(extra_data, items, FLUSH_SIZE, output, rman, &meta_printer, tag_store, limit, element_count); 740279 q tags_by_id_attic(items, attic_items, extra_data, FLUSH_SIZE, output, rman, *rman.get_transaction(), 741279 q limit, element_count); 74517781511 q if (rman.get_desired_timestamp() == NOW) 74710773340 q Tag_Store< Index, Object > tag_store(*rman.get_transaction()); 74810773340 q tags_by_id(extra_data, items, FLUSH_SIZE, output, rman, 74910773340 q (Meta_Collector< Index, typename Object::Id_Type >*)0, tag_store, limit, element_count); 7527008176 q tags_by_id_attic(items, attic_items, extra_data, FLUSH_SIZE, output, rman, *rman.get_transaction(), 758std::vector< std::pair< std::string, std::string > > make_count_tags(const Set& set, bool include_areas) 7603177494 q unsigned int num_nodes = count(set.nodes) + count(set.attic_nodes); 7613177494 q unsigned int num_ways = count(set.ways) + count(set.attic_ways); 7623177494 q unsigned int num_relations = count(set.relations) + count(set.attic_relations); 7633177494 q unsigned int num_areas = include_areas ? count(set.areas) : 0; 7653177494 q std::vector< std::pair< std::string, std::string > > count_tags; 7663177494 q count_tags.push_back(std::make_pair("nodes", to_string(num_nodes))); 7673177494 q count_tags.push_back(std::make_pair("ways", to_string(num_ways))); 7683177494 q count_tags.push_back(std::make_pair("relations", to_string(num_relations))); 770366100 q count_tags.push_back(std::make_pair("areas", to_string(num_areas))); 7713177494 q count_tags.push_back(std::make_pair("total", to_string(num_nodes + num_ways + num_relations + num_areas))); 777void Print_Statement::execute(Resource_Manager& rman) 7818549585 q Diff_Action::_ action = rman.get_desired_action(); 7828549585 q if (action == Diff_Action::collect_lhs 7838549585 q || action == Diff_Action::collect_rhs_no_del || action == Diff_Action::collect_rhs_with_del) 78593676 q execute_comparison(rman); 7897613514 q if (action == Diff_Action::positive && rman.area_updater()) 7900 rman.area_updater()->flush(); 7927613514 q const Set* input_set = rman.get_set(input); 7957613514 q const Set* output_items = 0; 7967613514 q if (mode & Output_Mode::COUNT) 7983177494 q count_set.deriveds[Uint31_Index(0u)].push_back(Derived_Structure("count", Uint64(0ull), 7993177494 q make_count_tags(input_set ? *input_set : Set(), rman.get_area_transaction()), 0)); 8013177494 q mode = mode | Output_Mode::TAGS; 8117583514 q Output_Handler::Feature_Action feature_action = Output_Handler::keep; 8127583514 q if (action == Diff_Action::show_old) 81355 q feature_action = Output_Handler::show_from; 8147578514 q else if (action == Diff_Action::show_new) 81555 q feature_action = Output_Handler::show_to; 8177583514 q Extra_Data extra_data(rman, *this, *output_items, mode, feature_action, south, north, west, east); 8187583514 q Output_Handler& output_handler = *rman.get_global_settings().get_output_handler(); 8237546513 q if (mode & Output_Mode::TAGS) 8255946511 q tags_by_id(extra_data, output_items->nodes, output_items->attic_nodes, mode, NODE_FLUSH_SIZE, 8265946511 q output_handler, rman, limit, element_count); 8275946511 q tags_by_id(extra_data, output_items->ways, output_items->attic_ways, mode, WAY_FLUSH_SIZE, 8285946511 q output_handler, rman, limit, element_count); 8295946511 q tags_by_id(extra_data, output_items->relations, output_items->attic_relations, mode, RELATION_FLUSH_SIZE, 8305946511 q output_handler, rman, limit, element_count); 8325946511 q if (rman.get_area_transaction()) 834435100 q Tag_Store< Uint31_Index, Area_Skeleton > tag_store(*rman.get_transaction()); 835435100 q tags_by_id(extra_data, output_items->areas, AREA_FLUSH_SIZE, output_handler, rman, 836435100 q (Meta_Collector< Uint31_Index, Area_Skeleton::Id_Type >*)0, 837435100 q tag_store, limit, element_count); 8405946511 q Tag_Store< Uint31_Index, Derived_Structure > tag_store; 8415946511 q tags_by_id(extra_data, output_items->deriveds, std::numeric_limits< uint32 >::max(), output_handler, rman, 8425946511 q (Meta_Collector< Uint31_Index, Derived_Structure::Id_Type >*)0, tag_store, limit, element_count); 8461600491 q by_id(output_items->nodes, output_items->attic_nodes, 8471600491 q output_handler, *rman.get_transaction(), extra_data, limit, element_count); 8481600491 q by_id(output_items->ways, output_items->attic_ways, 8491600491 q output_handler, *rman.get_transaction(), extra_data, limit, element_count); 8501600491 q by_id(output_items->relations, output_items->attic_relations, 8511600491 q output_handler, *rman.get_transaction(), extra_data, limit, element_count); 8521600491 q if (rman.get_area_transaction()) 85331999 q by_id(output_items->areas, output_handler, *rman.get_area_transaction(), extra_data, limit, element_count); 8541600491 q by_id(output_items->deriveds, output_handler, *rman.get_transaction(), extra_data, limit, element_count); 8593737 q if (mode & Output_Mode::TAGS) 8612020 q tags_quadtile_(extra_data, output_items->nodes, 8622020 q output_handler, rman, *rman.get_transaction(), limit, element_count); 8642020 q if (rman.get_desired_timestamp() != NOW) 8651111 q tags_quadtile_attic_(extra_data, output_items->attic_nodes, 8661111 q output_handler, rman, *rman.get_transaction(), limit, element_count); 8682020 q tags_quadtile_(extra_data, output_items->ways, 8692020 q output_handler, rman, *rman.get_transaction(), limit, element_count); 8712020 q if (rman.get_desired_timestamp() != NOW) 8721111 q tags_quadtile_attic_(extra_data, output_items->attic_ways, 8731111 q output_handler, rman, *rman.get_transaction(), limit, element_count); 8752020 q tags_quadtile_(extra_data, output_items->relations, 8762020 q output_handler, rman, *rman.get_transaction(), limit, element_count); 8782020 q if (rman.get_desired_timestamp() != NOW) 8791111 q tags_quadtile_attic_(extra_data, output_items->attic_relations, 8801111 q output_handler, rman, *rman.get_transaction(), limit, element_count); 8822020 q if (rman.get_area_transaction()) 88344 q tags_quadtile_(extra_data, output_items->areas, 88444 q output_handler, rman, *rman.get_area_transaction(), limit, element_count); 8862020 q tags_quadtile_(extra_data, output_items->deriveds, 8872020 q output_handler, rman, *rman.get_transaction(), limit, element_count); 8911717 q quadtile_(output_items->nodes, output_handler, *rman.get_transaction(), extra_data, limit, element_count); 8921717 q quadtile_(output_items->attic_nodes, output_handler, *rman.get_transaction(), extra_data, limit, element_count); 8941717 q quadtile_(output_items->ways, output_handler, *rman.get_transaction(), extra_data, limit, element_count); 8951717 q quadtile_(output_items->attic_ways, output_handler, *rman.get_transaction(), extra_data, limit, element_count); 8971717 q quadtile_(output_items->relations, output_handler, *rman.get_transaction(), extra_data, limit, element_count); 8981717 q quadtile_(output_items->attic_relations, output_handler, *rman.get_transaction(), extra_data, limit, element_count); 9001717 q if (rman.get_area_transaction()) 90155 q quadtile_(output_items->areas, output_handler, *rman.get_area_transaction(), extra_data, limit, element_count); 9031717 q quadtile_(output_items->deriveds, output_handler, *rman.get_transaction(), extra_data, limit, element_count); 911void Print_Statement::execute_comparison(Resource_Manager& rman) 91393676 q Diff_Action::_ action = rman.get_desired_action(); 91593676 q const Diff_Set* input_diff_set = rman.get_diff_set(input); 9183616 q print_diff_set(*input_diff_set, mode, rman.get_global_settings().get_output_handler(), 9193616 q rman.users(), relation_member_roles(*rman.get_transaction()), action == Diff_Action::collect_rhs_with_del); 92390076 q const Set* input_set = rman.get_set(input); 92787876 q if (action == Diff_Action::collect_lhs) 92945376 q if (collection_print_target && diff_valid) 93111 q runtime_error("A print statement cannot be executed in a loop in a diff setting."); 93311 q delete collection_print_target; 93411 q collection_print_target = 0; 93745276 q delete collection_print_target; 93845276 q collection_print_target = new Set_Comparison( 93945276 q *rman.get_transaction(), *input_set, rman.get_desired_timestamp()); 94342576 q if (!diff_valid || !collection_print_target) 94641576 q Diff_Set result = collection_print_target->compare_to_lhs(rman, *this, *input_set, 94741576 q south, north, west, east, action == Diff_Action::collect_rhs_with_del); 94941576 q print_diff_set(result, mode, rman.get_global_settings().get_output_handler(), 95041576 q rman.users(), relation_member_roles(*rman.get_transaction()), action == Diff_Action::collect_rhs_with_del); 95386776 q rman.health_check(*this); 957Print_Statement::~Print_Statement() 95910749597 q delete collection_print_target;