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 "../statements/evaluator.h" 20#include "set_comparison.h" 29Extra_Data_For_Diff::Extra_Data_For_Diff( 30 Resource_Manager& rman, const Statement& stmt, const Set& to_print, unsigned int mode_, 31 double south, double north, double west, double east) 3291481 q : mode(mode_), way_geometry_store(0), attic_way_geometry_store(0), 3391481 q relation_geometry_store(0), attic_relation_geometry_store(0), roles(0), users(0) 3591481 q if (mode & (Output_Mode::GEOMETRY | Output_Mode::BOUNDS | Output_Mode::CENTER)) 3791481 q way_geometry_store = new Way_Bbox_Geometry_Store(to_print.ways, stmt, rman, south, north, west, east); 3891481 q if (rman.get_desired_timestamp() < NOW) 4061081 q attic_way_geometry_store = new Way_Bbox_Geometry_Store( 4161081 q to_print.attic_ways, stmt, rman, 4261081 q south, north, west, east); 4591481 q relation_geometry_store = new Relation_Geometry_Store( 4691481 q to_print.relations, stmt, rman, south, north, west, east); 4791481 q if (rman.get_desired_timestamp() < NOW) 4961081 q attic_relation_geometry_store = new Relation_Geometry_Store( 5061081 q to_print.attic_relations, stmt, rman, 5161081 q south, north, west, east); 5591481 q roles = &relation_member_roles(*rman.get_transaction()); 5791481 q if (mode & Output_Mode::META) 5891481 q users = &rman.users(); 62const std::map< uint32, std::string >* Extra_Data_For_Diff::get_users() const 68Extra_Data_For_Diff::~Extra_Data_For_Diff() 7091481 q delete way_geometry_store; 7191481 q delete attic_way_geometry_store; 7291481 q delete relation_geometry_store; 7391481 q delete attic_relation_geometry_store; 77void Set_Comparison::set_target(bool target) 7945781 q final_target = target; 8045781 q std::sort(nodes.begin(), nodes.end()); 8145781 q std::sort(ways.begin(), ways.end()); 8245781 q std::sort(relations.begin(), relations.end()); 86void Set_Comparison::print_item(Extra_Data_For_Diff& extra_data, uint32 ll_upper, const Node_Skeleton& skel, 87 const std::vector< std::pair< std::string, std::string > >* tags, 88 const OSM_Element_Metadata_Skeleton< Node_Skeleton::Id_Type >* meta, 89 const std::map< uint32, std::string >* users) 91136100734 q if (final_target) 92127268034 q compare_item(ll_upper, skel, tags, NOW, meta, users); 948832725 q store_item(ll_upper, skel, tags, NOW, meta, users); 98void Set_Comparison::print_item(Extra_Data_For_Diff& extra_data, uint32 ll_upper, const Attic< Node_Skeleton >& skel, 99 const std::vector< std::pair< std::string, std::string > >* tags, 100 const OSM_Element_Metadata_Skeleton< Node_Skeleton::Id_Type >* meta, 101 const std::map< uint32, std::string >* users) 104598010 q compare_item(ll_upper, skel, tags, skel.timestamp, meta, users); 1069722025 q store_item(ll_upper, skel, tags, skel.timestamp, meta, users); 110void Set_Comparison::print_item(Extra_Data_For_Diff& extra_data, uint32 ll_upper, const Way_Skeleton& skel, 111 const std::vector< std::pair< std::string, std::string > >* tags, 112 const OSM_Element_Metadata_Skeleton< Way_Skeleton::Id_Type >* meta, 113 const std::map< uint32, std::string >* users) 11522781039 q if (extra_data.way_geometry_store) 11722781039 q std::vector< Quad_Coord > geometry = extra_data.way_geometry_store->get_geometry(skel); 11822781039 q Double_Coords double_coords(geometry); 12022137039 q compare_item(ll_upper, skel, tags, 12122137039 q geometry.empty() ? 0 : bound_variant(double_coords, extra_data.mode), 12222137039 q ((extra_data.mode & Output_Mode::GEOMETRY) && geometry.size() == skel.nds.size()) ? &geometry : 0, 125644019 q store_item(ll_upper, skel, tags, 126644019 q geometry.empty() ? 0 : bound_variant(double_coords, extra_data.mode), 127644019 q ((extra_data.mode & Output_Mode::GEOMETRY) && geometry.size() == skel.nds.size()) ? &geometry : 0, 1330 compare_item(ll_upper, skel, tags, 0, 0, NOW, meta, users); 1350 store_item(ll_upper, skel, tags, 0, 0, NOW, meta, users); 140void Set_Comparison::print_item(Extra_Data_For_Diff& extra_data, uint32 ll_upper, const Attic< Way_Skeleton >& skel, 141 const std::vector< std::pair< std::string, std::string > >* tags, 142 const OSM_Element_Metadata_Skeleton< Way_Skeleton::Id_Type >* meta, 143 const std::map< uint32, std::string >* users) 1452238432 q if (extra_data.attic_way_geometry_store) 1472238432 q std::vector< Quad_Coord > geometry = extra_data.attic_way_geometry_store->get_geometry(skel); 1482238432 q Double_Coords double_coords(geometry); 150203410 q compare_item(ll_upper, skel, tags, 151203410 q geometry.empty() ? 0 : bound_variant(double_coords, extra_data.mode), 152203410 q ((extra_data.mode & Output_Mode::GEOMETRY) && geometry.size() == skel.nds.size()) ? &geometry : 0, 153203410 q skel.timestamp, meta, users); 1552035029 q store_item(ll_upper, skel, tags, 1562035029 q geometry.empty() ? 0 : bound_variant(double_coords, extra_data.mode), 1572035029 q ((extra_data.mode & Output_Mode::GEOMETRY) && geometry.size() == skel.nds.size()) ? &geometry : 0, 1582035029 q skel.timestamp, meta, users); 1630 compare_item(ll_upper, skel, tags, 0, 0, skel.timestamp, meta, users); 1650 store_item(ll_upper, skel, tags, 0, 0, skel.timestamp, meta, users); 170void Set_Comparison::print_item(Extra_Data_For_Diff& extra_data, uint32 ll_upper, const Relation_Skeleton& skel, 171 const std::vector< std::pair< std::string, std::string > >* tags, 172 const OSM_Element_Metadata_Skeleton< Relation_Skeleton::Id_Type >* meta, 173 const std::map< uint32, std::string >* users) 17581213 q if (extra_data.relation_geometry_store) 17781213 q std::vector< std::vector< Quad_Coord > > geometry = extra_data.relation_geometry_store->get_geometry(skel); 17881213 q Double_Coords double_coords(geometry); 18080213 q compare_item(ll_upper, skel, tags, 18180213 q geometry.empty() ? 0 : bound_variant(double_coords, extra_data.mode), 18280213 q ((extra_data.mode & Output_Mode::GEOMETRY) && geometry.size() == skel.members.size()) ? &geometry : 0, 185102 q store_item(ll_upper, skel, tags, 186102 q geometry.empty() ? 0 : bound_variant(double_coords, extra_data.mode), 187102 q ((extra_data.mode & Output_Mode::GEOMETRY) && geometry.size() == skel.members.size()) ? &geometry : 0, 1930 compare_item(ll_upper, skel, tags, 0, 0, NOW, meta, users); 1950 store_item(ll_upper, skel, tags, 0, 0, NOW, meta, users); 200void Set_Comparison::print_item(Extra_Data_For_Diff& extra_data, uint32 ll_upper, const Attic< Relation_Skeleton >& skel, 201 const std::vector< std::pair< std::string, std::string > >* tags, 202 const OSM_Element_Metadata_Skeleton< Relation_Skeleton::Id_Type >* meta, 203 const std::map< uint32, std::string >* users) 20531011 q if (extra_data.attic_relation_geometry_store) 20731011 q std::vector< std::vector< Quad_Coord > > geometry = extra_data.attic_relation_geometry_store->get_geometry(skel); 20831011 q Double_Coords double_coords(geometry); 2101244 q compare_item(ll_upper, skel, tags, 2111244 q geometry.empty() ? 0 : bound_variant(double_coords, extra_data.mode), 2121244 q ((extra_data.mode & Output_Mode::GEOMETRY) && geometry.size() == skel.members.size()) ? &geometry : 0, 2131244 q skel.timestamp, meta, users); 2151869 q store_item(ll_upper, skel, tags, 2161869 q geometry.empty() ? 0 : bound_variant(double_coords, extra_data.mode), 2171869 q ((extra_data.mode & Output_Mode::GEOMETRY) && geometry.size() == skel.members.size()) ? &geometry : 0, 2181869 q skel.timestamp, meta, users); 2230 compare_item(ll_upper, skel, tags, 0, 0, skel.timestamp, meta, users); 2250 store_item(ll_upper, skel, tags, 0, 0, skel.timestamp, meta, users); 230template< class Index, class Object > 231void Set_Comparison::tags_quadtile 232 (Extra_Data_For_Diff& extra_data, const std::map< Index, std::vector< Object > >& items, Resource_Manager& rman) 234264081 q Tag_Store< Index, Object > tag_store(*rman.get_transaction()); 235264081 q tag_store.prefetch_all(items); 237 // formulate meta query if meta data shall be printed 238264081 q Meta_Collector< Index, typename Object::Id_Type > meta_printer(items, *rman.get_transaction(), 239264081 q (extra_data.mode & Output_Mode::META) ? current_meta_file_properties< Object >() : 0); 241264081 q typename std::map< Index, std::vector< Object > >::const_iterator 242264081 q item_it(items.begin()); 2441736181 q while (item_it != items.end()) 2461472167 q for (typename std::vector< Object >::const_iterator it2(item_it->second.begin()); 247146079067 q it2 != item_it->second.end(); ++it2) 249144606963 q print_item(extra_data, item_it->first.val(), *it2, tag_store.get(item_it->first, *it2), 250144606963 q meta_printer.get(item_it->first, it2->id), extra_data.users); 257template< class Index, class Object > 258void Set_Comparison::tags_quadtile_attic 259 (Extra_Data_For_Diff& extra_data, const std::map< Index, std::vector< Attic< Object > > >& items, 260 Resource_Manager& rman) 262175881 q Tag_Store< Index, Object > tag_store(*rman.get_transaction()); 263175881 q tag_store.prefetch_all(items); 264 // formulate meta query if meta data shall be printed 265175881 q Attic_Meta_Collector< Index, Object > meta_printer( 266175881 q items, *rman.get_transaction(), extra_data.mode & Output_Mode::META); 268175881 q typename std::map< Index, std::vector< Attic< Object > > >::const_iterator 269175881 q item_it(items.begin()); 2701366781 q while (item_it != items.end()) 2721190965 q for (typename std::vector< Attic< Object > >::const_iterator it2(item_it->second.begin()); 27312962965 q it2 != item_it->second.end(); ++it2) 27411772051 q print_item(extra_data, item_it->first.val(), *it2, tag_store.get(item_it->first, *it2), 27511772051 q meta_printer.get(item_it->first, it2->id, it2->timestamp), extra_data.users); 281template< class Index, class Object > 282void Set_Comparison::tags_quadtile 283 (Extra_Data_For_Diff& extra_data, const std::map< Index, std::vector< Object > >& items, 284 const std::vector< typename Object::Id_Type >& id_list, Resource_Manager& rman) 28610217 q Tag_Store< Index, Object > tag_store(*rman.get_transaction()); 28710217 q tag_store.prefetch_all(items); 289 // formulate meta query if meta data shall be printed 29010217 q Meta_Collector< Index, typename Object::Id_Type > meta_printer(items, *rman.get_transaction(), 29110217 q (extra_data.mode & Output_Mode::META) ? current_meta_file_properties< Object >() : 0); 29310217 q typename std::map< Index, std::vector< Object > >::const_iterator 296137017 q while (item_it != items.end()) 298126811 q for (typename std::vector< Object >::const_iterator it2(item_it->second.begin()); 29916575311 q it2 != item_it->second.end(); ++it2) 30116448510 q if (std::binary_search(id_list.begin(), id_list.end(), it2->id)) 3021435609 q print_item(extra_data, item_it->first.val(), *it2, tag_store.get(item_it->first, *it2), 3031435609 q meta_printer.get(item_it->first, it2->id), extra_data.users); 310template< class Index, class Object > 311void Set_Comparison::tags_quadtile_attic 312 (Extra_Data_For_Diff& extra_data, const std::map< Index, std::vector< Attic< Object > > >& items, 313 const std::vector< typename Object::Id_Type >& id_list, Resource_Manager& rman) 3157217 q Tag_Store< Index, Object > tag_store(*rman.get_transaction()); 3167217 q tag_store.prefetch_all(items); 317 // formulate meta query if meta data shall be printed 3187217 q Attic_Meta_Collector< Index, Object > meta_printer( 3197217 q items, *rman.get_transaction(), extra_data.mode & Output_Mode::META); 3217217 q typename std::map< Index, std::vector< Attic< Object > > >::const_iterator 32384317 q while (item_it != items.end()) 32577111 q for (typename std::vector< Attic< Object > >::const_iterator it2(item_it->second.begin()); 326899511 q it2 != item_it->second.end(); ++it2) 32882246 q if (std::binary_search(id_list.begin(), id_list.end(), it2->id)) 32981745 q print_item(extra_data, item_it->first.val(), *it2, tag_store.get(item_it->first, *it2), 33081745 q meta_printer.get(item_it->first, it2->id, it2->timestamp), extra_data.users); 337template< typename Index, typename Skeleton > 338std::vector< typename Skeleton::Id_Type > find_still_existing_skeletons 339 (Resource_Manager& rman, uint64 timestamp, const std::vector< Index >& req, 340 const std::vector< typename Skeleton::Id_Type >& searched_ids) 342106833 q std::vector< typename Skeleton::Id_Type > found_ids; 343106833 q std::map< Index, std::vector< Skeleton > > current_result; 344106833 q std::map< Index, std::vector< Attic< Skeleton > > > attic_result; 346106833 q Request_Context context(0, rman); 347106833 q collect_items_discrete(context, req, 348106833 q Id_Predicate< Skeleton >(searched_ids), timestamp, current_result, attic_result); 349106833 q filter_attic_elements(rman, timestamp, current_result, attic_result); 351106833 q for (typename std::map< Index, std::vector< Skeleton > >::const_iterator it = current_result.begin(); 352522433 q it != current_result.end(); ++it) 354485424 q for (typename std::vector< Skeleton >::const_iterator it2 = it->second.begin(); it2 != it->second.end(); ++it2) 35569810 q found_ids.push_back(it2->id); 357106833 q for (typename std::map< Index, std::vector< Attic< Skeleton > > >::const_iterator it = attic_result.begin(); 358500533 q it != attic_result.end(); ++it) 360393724 q for (typename std::vector< Attic< Skeleton > >::const_iterator it2 = it->second.begin(); 361473124 q it2 != it->second.end(); ++it2) 36279413 q found_ids.push_back(it2->id); 364106833 q std::sort(found_ids.begin(), found_ids.end()); 365106833 q found_ids.erase(std::unique(found_ids.begin(), found_ids.end()), found_ids.end()); 371template< typename Index, typename Skeleton > 372std::map< typename Skeleton::Id_Type, OSM_Element_Metadata_Skeleton< typename Skeleton::Id_Type > > 374 (Resource_Manager& rman, uint64 timestamp, const std::vector< Index >& idx_set, 375 const std::vector< typename Skeleton::Id_Type >& searched_ids) 377106833 q std::map< typename Skeleton::Id_Type, OSM_Element_Metadata_Skeleton< typename Skeleton::Id_Type > > result; 379106833 q Block_Backend< Index, OSM_Element_Metadata_Skeleton< typename Skeleton::Id_Type >, 380106833 q typename std::vector< Index >::const_iterator > 381106833 q attic_meta_db(rman.get_transaction()->data_index(attic_meta_file_properties< Skeleton >())); 382106833 q for (typename Block_Backend< Index, OSM_Element_Metadata_Skeleton< typename Skeleton::Id_Type >, 383106833 q typename std::vector< Index >::const_iterator >::Discrete_Iterator 384106833 q it = attic_meta_db.discrete_begin(idx_set.begin(), idx_set.end()); 385636421333 q !(it == attic_meta_db.discrete_end()); ++it) 387636314524 q if (!(timestamp < it.object().timestamp) 388636314524 q && std::binary_search(searched_ids.begin(), searched_ids.end(), it.object().ref)) 3904710919 q typename std::map< typename Skeleton::Id_Type, OSM_Element_Metadata_Skeleton< typename Skeleton::Id_Type > > 3914710919 q ::iterator meta_it = result.find(it.object().ref); 3924710919 q if (meta_it == result.end()) 3931063419 q result.insert(std::make_pair(it.object().ref, it.object())); 3943647515 q else if (meta_it->second.timestamp < it.object().timestamp) 3953520815 q meta_it->second = it.object(); 399 // Same thing with current meta data 400106833 q Block_Backend< Index, OSM_Element_Metadata_Skeleton< typename Skeleton::Id_Type >, 401106833 q typename std::vector< Index >::const_iterator > 402106833 q meta_db(rman.get_transaction()->data_index(current_meta_file_properties< Skeleton >())); 404106833 q for (typename Block_Backend< Index, OSM_Element_Metadata_Skeleton< typename Skeleton::Id_Type >, 405106833 q typename std::vector< Index >::const_iterator >::Discrete_Iterator 406106833 q it = meta_db.discrete_begin(idx_set.begin(), idx_set.end()); 407338309333 q !(it == meta_db.discrete_end()); ++it) 409338202524 q if (!(timestamp < it.object().timestamp) 410338202524 q && std::binary_search(searched_ids.begin(), searched_ids.end(), it.object().ref)) 41269810 q typename std::map< typename Skeleton::Id_Type, OSM_Element_Metadata_Skeleton< typename Skeleton::Id_Type > > 41369810 q ::iterator meta_it = result.find(it.object().ref); 41469810 q if (meta_it == result.end()) 4151232 q result.insert(std::make_pair(it.object().ref, it.object())); 41657510 q else if (meta_it->second.timestamp < it.object().timestamp) 41757210 q meta_it->second = it.object(); 425void Set_Comparison::store_item(uint32 ll_upper, const Node_Skeleton& skel, 426 const std::vector< std::pair< std::string, std::string > >* tags, 427 uint64 timestamp, const OSM_Element_Metadata_Skeleton< Node::Id_Type >* meta, 428 const std::map< uint32, std::string >* users, const Output_Handler::Feature_Action& action, 429 const OSM_Element_Metadata_Skeleton< Node::Id_Type >* new_meta) 43118554728 q nodes.push_back(Node_With_Context(ll_upper, skel, timestamp, 43218554728 q meta ? *meta : OSM_Element_Metadata_Skeleton< Node_Skeleton::Id_Type >(), 43318554728 q tags ? *tags : std::vector< std::pair< std::string, std::string > >())); 437void Set_Comparison::compare_item(uint32 ll_upper, const Node_Skeleton& skel, 438 const std::vector< std::pair< std::string, std::string > >* tags, 439 uint64 timestamp, const OSM_Element_Metadata_Skeleton< Node::Id_Type >* meta, 440 const std::map< uint32, std::string >* users, const Output_Handler::Feature_Action& action, 441 const OSM_Element_Metadata_Skeleton< Node::Id_Type >* new_meta) 443127866036 q std::vector< Node_With_Context >::iterator nodes_it 444127866036 q = std::lower_bound(nodes.begin(), nodes.end(), Node_With_Context(ll_upper, skel, 0)); 446127866036 q if (nodes_it == nodes.end() || skel.id < nodes_it->elem.id) 447112681533 q result.different_nodes.push_back(std::make_pair( 448112681533 q Node_With_Context(0xffu, Node_Skeleton(skel.id), 0, 449112681533 q OSM_Element_Metadata_Skeleton< Node_Skeleton::Id_Type >(), 450112681533 q std::vector< std::pair< std::string, std::string > >()), 451112681533 q Node_With_Context(ll_upper, skel, timestamp, 452112681533 q meta ? *meta : OSM_Element_Metadata_Skeleton< Node_Skeleton::Id_Type >(), 453112681533 q tags ? *tags : std::vector< std::pair< std::string, std::string > >()))); 45615184528 q if (!(nodes_it->idx.val() == ll_upper) || !(nodes_it->elem.ll_lower == skel.ll_lower) || 45715184528 q (tags && !(nodes_it->tags == *tags)) || (meta && !(nodes_it->meta.timestamp == meta->timestamp))) 4586342925 q result.different_nodes.push_back(std::make_pair(*nodes_it, Node_With_Context(ll_upper, skel, timestamp, 4596342925 q meta ? *meta : OSM_Element_Metadata_Skeleton< Node_Skeleton::Id_Type >(), 4606342925 q tags ? *tags : std::vector< std::pair< std::string, std::string > >()))); 46215184528 q nodes_it->idx = 0xffu; 467void Set_Comparison::clear_nodes(Resource_Manager& rman, bool add_deletion_information) 46945781 q if (add_deletion_information) 47117833 q std::vector< Node_Skeleton::Id_Type > searched_ids; 4728706033 q for (std::vector< Node_With_Context >::const_iterator it = nodes.begin(); it != nodes.end(); ++it) 4748688213 q if (it->idx.val() != 0xffu) 475907510 q searched_ids.push_back(it->elem.id); 47817833 q std::vector< Uint32_Index > req = get_indexes_< Uint32_Index, Node_Skeleton >(searched_ids, rman, true); 47917833 q std::vector< Node_Skeleton::Id_Type > found_ids 48017833 q = find_still_existing_skeletons< Uint32_Index, Node_Skeleton >( 48117833 q rman, rman.get_desired_timestamp(), req, searched_ids); 48217833 q std::map< Node_Skeleton::Id_Type, OSM_Element_Metadata_Skeleton< Node::Id_Type > > found_meta 48317833 q = find_meta_elements< Node::Index, Node_Skeleton >(rman, rman.get_diff_to_timestamp(), req, searched_ids); 4858706033 q for (std::vector< Node_With_Context >::const_iterator it = nodes.begin(); it != nodes.end(); ++it) 4878688213 q if (it->idx.val() != 0xffu) 489907510 q std::map< Node_Skeleton::Id_Type, OSM_Element_Metadata_Skeleton< Node::Id_Type > >::const_iterator 490907510 q meta_it = found_meta.find(it->elem.id); 491907510 q result.different_nodes.push_back(std::make_pair(*it, 492907510 q Node_With_Context(std::binary_search(found_ids.begin(), found_ids.end(), it->elem.id) ? 0xfdu : 0xffu, 493907510 q Node_Skeleton(it->elem.id), 0, 494907510 q meta_it != found_meta.end() ? meta_it->second 495907510 q : OSM_Element_Metadata_Skeleton< Node_Skeleton::Id_Type >(), 496907510 q std::vector< std::pair< std::string, std::string > >()))); 50117833 q for (std::vector< std::pair< Node_With_Context, Node_With_Context > >::const_iterator 50265032733 q it = result.different_nodes.begin(); it != result.different_nodes.end(); ++it) 50465014914 q if (it->first.idx.val() == 0xffu) 50561752914 q searched_ids.push_back(it->second.elem.id); 50817833 q get_indexes_< Uint32_Index, Node_Skeleton >(searched_ids, rman, true).swap(req); 50917833 q find_still_existing_skeletons< Uint32_Index, Node_Skeleton >( 51017833 q rman, rman.get_diff_from_timestamp(), req, searched_ids).swap(found_ids); 51117833 q find_meta_elements< Node::Index, Node_Skeleton >( 51217833 q rman, rman.get_diff_from_timestamp(), req, searched_ids).swap(found_meta); 51417833 q for (std::vector< std::pair< Node_With_Context, Node_With_Context > >::iterator 51565032733 q it = result.different_nodes.begin(); it != result.different_nodes.end(); ++it) 51765014914 q if (it->first.idx.val() == 0xffu) 51961752914 q it->first.idx = std::binary_search(found_ids.begin(), found_ids.end(), it->second.elem.id) ? 0xfdu : 0xffu; 52061752914 q it->first.elem = Node_Skeleton(it->second.elem.id); 52261752914 q std::map< Node_Skeleton::Id_Type, OSM_Element_Metadata_Skeleton< Node::Id_Type > >::const_iterator 52361752914 q meta_it = found_meta.find(it->second.elem.id); 52461752914 q if (meta_it != found_meta.end()) 5251336 q it->first.meta = meta_it->second; 5319894448 q for (std::vector< Node_With_Context >::const_iterator it = nodes.begin(); it != nodes.end(); ++it) 5339866515 q if (it->idx.val() != 0xffu) 5342462711 q result.different_nodes.push_back(std::make_pair(*it, 5352462711 q Node_With_Context(0xffu, Node_Skeleton(it->elem.id), 0, 5362462711 q OSM_Element_Metadata_Skeleton< Node_Skeleton::Id_Type >(), 5372462711 q std::vector< std::pair< std::string, std::string > >()))); 54145781 q std::sort(result.different_nodes.begin(), result.different_nodes.end()); 545void Set_Comparison::store_item(uint32 ll_upper, const Way_Skeleton& skel, 546 const std::vector< std::pair< std::string, std::string > >* tags, 547 const std::pair< Quad_Coord, Quad_Coord* >* bounds, 548 const std::vector< Quad_Coord >* geometry, 549 uint64 timestamp, const OSM_Element_Metadata_Skeleton< Way::Id_Type >* meta, 550 const std::map< uint32, std::string >* users, const Output_Handler::Feature_Action& action, 551 const OSM_Element_Metadata_Skeleton< Way::Id_Type >* new_meta) 5532679031 q ways.push_back(Way_With_Context(ll_upper, skel, 5542679031 q geometry ? *geometry : std::vector< Quad_Coord >(), 5552679031 q timestamp, meta ? *meta : OSM_Element_Metadata_Skeleton< Way_Skeleton::Id_Type >(), 5562679031 q tags ? *tags : std::vector< std::pair< std::string, std::string > >())); 560void Set_Comparison::compare_item(uint32 ll_upper, const Way_Skeleton& skel, 561 const std::vector< std::pair< std::string, std::string > >* tags, 562 const std::pair< Quad_Coord, Quad_Coord* >* bounds, 563 const std::vector< Quad_Coord >* geometry, 564 uint64 timestamp, const OSM_Element_Metadata_Skeleton< Way::Id_Type >* meta, 565 const std::map< uint32, std::string >* users, const Output_Handler::Feature_Action& action, 566 const OSM_Element_Metadata_Skeleton< Way::Id_Type >* new_meta) 56822340441 q std::vector< Way_With_Context >::iterator ways_it 56922340441 q = std::lower_bound(ways.begin(), ways.end(), 57022340441 q Way_With_Context(ll_upper, skel, std::vector< Quad_Coord >(), timestamp)); 57222340441 q if (ways_it == ways.end() || skel.id < ways_it->elem.id) 57320033139 q result.different_ways.push_back(std::make_pair( 57420033139 q Way_With_Context(0xffu, Way_Skeleton(skel.id), 57520033139 q std::vector< Quad_Coord >(), 57620033139 q 0, OSM_Element_Metadata_Skeleton< Way_Skeleton::Id_Type >(), 57720033139 q std::vector< std::pair< std::string, std::string > >()), 57820033139 q Way_With_Context(ll_upper, skel, 57920033139 q geometry ? *geometry : std::vector< Quad_Coord >(), 58020033139 q timestamp, meta ? *meta : OSM_Element_Metadata_Skeleton< Way_Skeleton::Id_Type >(), 58120033139 q tags ? *tags : std::vector< std::pair< std::string, std::string > >()))); 5842307329 q if (!(ways_it->idx.val() == ll_upper) || !(ways_it->elem.nds == skel.nds) || 5852307329 q (geometry && !(ways_it->geometry == *geometry)) || 5862307329 q (tags && !(ways_it->tags == *tags)) || (meta && !(ways_it->meta.timestamp == meta->timestamp))) 5871644827 q result.different_ways.push_back(std::make_pair(*ways_it, Way_With_Context(ll_upper, skel, 5881644827 q geometry ? *geometry : std::vector< Quad_Coord >(), 5891644827 q timestamp, meta ? *meta : OSM_Element_Metadata_Skeleton< Way_Skeleton::Id_Type >(), 5901644827 q tags ? *tags : std::vector< std::pair< std::string, std::string > >()))); 597void Set_Comparison::clear_ways(Resource_Manager& rman, bool add_deletion_information) 59945781 q if (add_deletion_information) 60117833 q std::vector< Way_Skeleton::Id_Type > searched_ids; 6021493633 q for (std::vector< Way_With_Context >::const_iterator it = ways.begin(); it != ways.end(); ++it) 6041475814 q if (it->idx.val() != 0xffu) 605149711 q searched_ids.push_back(it->elem.id); 60817833 q std::vector< Uint31_Index > req = get_indexes_< Uint31_Index, Way_Skeleton >(searched_ids, rman, true); 60917833 q std::vector< Way_Skeleton::Id_Type > found_ids 61017833 q = find_still_existing_skeletons< Uint31_Index, Way_Skeleton >( 61117833 q rman, rman.get_desired_timestamp(), req, searched_ids); 61217833 q std::map< Way_Skeleton::Id_Type, OSM_Element_Metadata_Skeleton< Way::Id_Type > > found_meta 61317833 q = find_meta_elements< Way::Index, Way_Skeleton >(rman, rman.get_diff_to_timestamp(), req, searched_ids); 6151493633 q for (std::vector< Way_With_Context >::const_iterator it = ways.begin(); it != ways.end(); ++it) 6171475814 q if (it->idx.val() != 0xffu) 619149711 q std::map< Way_Skeleton::Id_Type, OSM_Element_Metadata_Skeleton< Way::Id_Type > >::const_iterator 620149711 q meta_it = found_meta.find(it->elem.id); 621149711 q result.different_ways.push_back(std::make_pair(*it, 622149711 q Way_With_Context(std::binary_search(found_ids.begin(), found_ids.end(), it->elem.id) ? 0xfdu : 0xffu, 623149711 q Way_Skeleton(it->elem.id), 624149711 q std::vector< Quad_Coord >(), 625149711 q 0, meta_it != found_meta.end() ? meta_it->second 626149711 q : OSM_Element_Metadata_Skeleton< Way_Skeleton::Id_Type >(), 627149711 q std::vector< std::pair< std::string, std::string > >()))); 63217833 q for (std::vector< std::pair< Way_With_Context, Way_With_Context > >::const_iterator 63310734333 q it = result.different_ways.begin(); it != result.different_ways.end(); ++it) 63510716520 q if (it->first.idx.val() == 0xffu) 6369787119 q searched_ids.push_back(it->second.elem.id); 63917833 q get_indexes_< Uint31_Index, Way_Skeleton >(searched_ids, rman, true).swap(req); 64017833 q find_still_existing_skeletons< Uint31_Index, Way_Skeleton >( 64117833 q rman, rman.get_diff_from_timestamp(), req, searched_ids).swap(found_ids); 64217833 q find_meta_elements< Way::Index, Way_Skeleton >( 64317833 q rman, rman.get_diff_from_timestamp(), req, searched_ids).swap(found_meta); 64517833 q for (std::vector< std::pair< Way_With_Context, Way_With_Context > >::iterator 64610734333 q it = result.different_ways.begin(); it != result.different_ways.end(); ++it) 64810716520 q if (it->first.idx.val() == 0xffu) 6509787119 q it->first.idx = std::binary_search(found_ids.begin(), found_ids.end(), it->second.elem.id) ? 0xfdu : 0xffu; 6519787119 q it->first.elem = Way_Skeleton(it->second.elem.id); 6539787119 q std::map< Way_Skeleton::Id_Type, OSM_Element_Metadata_Skeleton< Way::Id_Type > >::const_iterator 6549787119 q meta_it = found_meta.find(it->second.elem.id); 6559787119 q if (meta_it != found_meta.end()) 656526 q it->first.meta = meta_it->second; 6621231148 q for (std::vector< Way_With_Context >::const_iterator it = ways.begin(); it != ways.end(); ++it) 6641203217 q if (it->idx.val() != 0xffu) 665222013 q result.different_ways.push_back(std::make_pair(*it, 666222013 q Way_With_Context(0xffu, Way_Skeleton(it->elem.id), 667222013 q std::vector< Quad_Coord >(), 668222013 q 0, OSM_Element_Metadata_Skeleton< Way_Skeleton::Id_Type >(), 669222013 q std::vector< std::pair< std::string, std::string > >()))); 67345781 q std::sort(result.different_ways.begin(), result.different_ways.end()); 677void Set_Comparison::store_item(uint32 ll_upper, const Relation_Skeleton& skel, 678 const std::vector< std::pair< std::string, std::string > >* tags, 679 const std::pair< Quad_Coord, Quad_Coord* >* bounds, 680 const std::vector< std::vector< Quad_Coord > >* geometry, 681 uint64 timestamp, const OSM_Element_Metadata_Skeleton< Relation::Id_Type >* meta, 682 const std::map< uint32, std::string >* users, const Output_Handler::Feature_Action& action, 683 const OSM_Element_Metadata_Skeleton< Relation::Id_Type >* new_meta) 6851969 q relations.push_back(Relation_With_Context(ll_upper, skel, 6861969 q geometry ? *geometry : std::vector< std::vector< Quad_Coord > >(), 6871969 q timestamp, meta ? *meta : OSM_Element_Metadata_Skeleton< Relation_Skeleton::Id_Type >(), 6881969 q tags ? *tags : std::vector< std::pair< std::string, std::string > >())); 692void Set_Comparison::compare_item(uint32 ll_upper, const Relation_Skeleton& skel, 693 const std::vector< std::pair< std::string, std::string > >* tags, 694 const std::pair< Quad_Coord, Quad_Coord* >* bounds, 695 const std::vector< std::vector< Quad_Coord > >* geometry, 696 uint64 timestamp, const OSM_Element_Metadata_Skeleton< Relation::Id_Type >* meta, 697 const std::map< uint32, std::string >* users, const Output_Handler::Feature_Action& action, 698 const OSM_Element_Metadata_Skeleton< Relation::Id_Type >* new_meta) 70092615 q std::vector< Relation_With_Context >::iterator relations_it 70192615 q = std::lower_bound(relations.begin(), relations.end(), 70292615 q Relation_With_Context(ll_upper, skel, std::vector< std::vector< Quad_Coord > >(), 0)); 70492615 q if (relations_it == relations.end() || skel.id < relations_it->elem.id) 70574813 q result.different_relations.push_back(std::make_pair( 70674813 q Relation_With_Context(0xffu, Relation_Skeleton(skel.id), 70774813 q std::vector< std::vector< Quad_Coord > >(), 70874813 q 0, OSM_Element_Metadata_Skeleton< Relation_Skeleton::Id_Type >(), 70974813 q std::vector< std::pair< std::string, std::string > >()), 71074813 q Relation_With_Context(ll_upper, skel, 71174813 q geometry ? *geometry : std::vector< std::vector< Quad_Coord > >(), 71274813 q timestamp, meta ? *meta : OSM_Element_Metadata_Skeleton< Relation_Skeleton::Id_Type >(), 71374813 q tags ? *tags : std::vector< std::pair< std::string, std::string > >()))); 7161789 q if (!(relations_it->idx.val() == ll_upper) || !(relations_it->elem.members == skel.members) || 7171789 q (geometry && !(relations_it->geometry == *geometry)) || 7181789 q (tags && !(relations_it->tags == *tags)) || (meta && !(relations_it->meta.timestamp == meta->timestamp))) 7191629 q result.different_relations.push_back(std::make_pair(*relations_it, Relation_With_Context(ll_upper, skel, 7201629 q geometry ? *geometry : std::vector< std::vector< Quad_Coord > >(), 7211629 q timestamp, meta ? *meta : OSM_Element_Metadata_Skeleton< Relation_Skeleton::Id_Type >(), 7221629 q tags ? *tags : std::vector< std::pair< std::string, std::string > >()))); 7241789 q relations_it->idx = 0xffu; 729void Set_Comparison::clear_relations(Resource_Manager& rman, bool add_deletion_information) 73145781 q if (add_deletion_information) 73317833 q std::vector< Relation_Skeleton::Id_Type > searched_ids; 73418833 q for (std::vector< Relation_With_Context >::const_iterator it = relations.begin(); it != relations.end(); ++it) 736101 q if (it->idx.val() != 0xffu) 7370 searched_ids.push_back(it->elem.id); 74017833 q std::vector< Uint31_Index > req = get_indexes_< Uint31_Index, Relation_Skeleton >(searched_ids, rman, true); 74117833 q std::vector< Relation_Skeleton::Id_Type > found_ids 74217833 q = find_still_existing_skeletons< Uint31_Index, Relation_Skeleton >( 74317833 q rman, rman.get_diff_to_timestamp(), req, searched_ids); 74417833 q std::map< Relation_Skeleton::Id_Type, OSM_Element_Metadata_Skeleton< Relation::Id_Type > > found_meta 74517833 q = find_meta_elements< Relation::Index, Relation_Skeleton >( 74617833 q rman, rman.get_diff_to_timestamp(), req, searched_ids); 74818833 q for (std::vector< Relation_With_Context >::const_iterator it = relations.begin(); it != relations.end(); ++it) 750101 q if (it->idx.val() != 0xffu) 7520 std::map< Relation_Skeleton::Id_Type, OSM_Element_Metadata_Skeleton< Relation::Id_Type > >::const_iterator 7530 meta_it = found_meta.find(it->elem.id); 7540 result.different_relations.push_back(std::make_pair(*it, 7550 Relation_With_Context(std::binary_search(found_ids.begin(), found_ids.end(), it->elem.id) ? 0xfdu : 0xffu, 7560 Relation_Skeleton(it->elem.id), 7570 std::vector< std::vector< Quad_Coord > >(), 7580 0, meta_it != found_meta.end() ? meta_it->second 7590 : OSM_Element_Metadata_Skeleton< Relation_Skeleton::Id_Type >(), 7600 std::vector< std::pair< std::string, std::string > >()))); 763101 q req = get_indexes_< Uint31_Index, Relation_Skeleton >(searched_ids, rman, true); 76717833 q for (std::vector< std::pair< Relation_With_Context, Relation_With_Context > >::const_iterator 76820733 q it = result.different_relations.begin(); it != result.different_relations.end(); ++it) 770293 q if (it->first.idx.val() == 0xffu) 771193 q searched_ids.push_back(it->second.elem.id); 77417833 q get_indexes_< Uint31_Index, Relation_Skeleton >(searched_ids, rman, true).swap(req); 77517833 q find_still_existing_skeletons< Uint31_Index, Relation_Skeleton >( 77617833 q rman, rman.get_diff_from_timestamp(), req, searched_ids).swap(found_ids); 77717833 q find_meta_elements< Relation::Index, Relation_Skeleton >( 77817833 q rman, rman.get_diff_from_timestamp(), req, searched_ids).swap(found_meta); 78017833 q for (std::vector< std::pair< Relation_With_Context, Relation_With_Context > >::iterator 78120733 q it = result.different_relations.begin(); it != result.different_relations.end(); ++it) 783293 q if (it->first.idx.val() == 0xffu) 785193 q it->first.idx = std::binary_search(found_ids.begin(), found_ids.end(), it->second.elem.id) ? 0xfdu : 0xffu; 786193 q it->first.elem = Relation_Skeleton(it->second.elem.id); 788193 q std::map< Relation_Skeleton::Id_Type, OSM_Element_Metadata_Skeleton< Relation::Id_Type > >::const_iterator 789193 q meta_it = found_meta.find(it->second.elem.id); 790193 q if (meta_it != found_meta.end()) 7910 it->first.meta = meta_it->second; 79746948 q for (std::vector< Relation_With_Context >::const_iterator it = relations.begin(); it != relations.end(); ++it) 7991908 q if (it->idx.val() != 0xffu) 800233 q result.different_relations.push_back(std::make_pair(*it, 801233 q Relation_With_Context(0xffu, Relation_Skeleton(it->elem.id), 802233 q std::vector< std::vector< Quad_Coord > >(), 803233 q 0, OSM_Element_Metadata_Skeleton< Relation_Skeleton::Id_Type >(), 804233 q std::vector< std::pair< std::string, std::string > >()))); 80845781 q std::sort(result.different_relations.begin(), result.different_relations.end()); 812struct Derived_Structure_Handle 814 Derived_Structure_Handle(Uint31_Index idx, const Derived_Structure& elem_) 8152119 q : elem(&elem_), center(elem_.get_geometry() && elem_.get_geometry()->has_center() ? 8160 Point_Double(elem_.get_geometry()->center_lat(), elem_.get_geometry()->center_lon()) 8172119 q : Point_Double(100., 0.)) {} 819 bool operator<(const Derived_Structure_Handle& rhs) const; 821 const Derived_Structure* elem; 826int compare_geometry(const Opaque_Geometry& lhs_geom, const Opaque_Geometry& rhs_geom) 82841 q if (lhs_geom.has_center()) 8300 if (rhs_geom.has_center()) 8320 if (lhs_geom.center_lat() < rhs_geom.center_lat()) 8340 if (rhs_geom.center_lat() < lhs_geom.center_lat()) 8360 if (lhs_geom.center_lon() < rhs_geom.center_lon()) 8380 if (rhs_geom.center_lon() < lhs_geom.center_lon()) 84441 q else if (rhs_geom.has_center()) 84741 q if (lhs_geom.has_components()) 84941 q if (rhs_geom.has_components()) 85141 q const std::vector< Opaque_Geometry* >& lhs_comp = *lhs_geom.get_components(); 85241 q const std::vector< Opaque_Geometry* >& rhs_comp = *rhs_geom.get_components(); 85441 q if (lhs_comp.size() != rhs_comp.size()) 8550 return lhs_comp.size() < rhs_comp.size() ? -1 : 1; 85741 q for (uint i = 0; i < lhs_comp.size(); ++i) 8590 int cmp = compare_geometry(*lhs_comp[i], *rhs_comp[i]); 8690 else if (rhs_geom.has_components()) 8720 if (lhs_geom.has_line_geometry()) 8740 if (rhs_geom.has_line_geometry()) 8760 const std::vector< Point_Double >& lhs_comp = *lhs_geom.get_line_geometry(); 8770 const std::vector< Point_Double >& rhs_comp = *rhs_geom.get_line_geometry(); 8790 if (lhs_comp.size() != rhs_comp.size()) 8800 return lhs_comp.size() < rhs_comp.size() ? -1 : 1; 8820 for (uint i = 0; i < lhs_comp.size(); ++i) 8840 if (lhs_comp[i] < rhs_comp[i]) 8860 if (rhs_comp[i] < lhs_comp[i]) 8950 else if (rhs_geom.has_line_geometry()) 8980 if (lhs_geom.has_multiline_geometry()) 9000 if (rhs_geom.has_multiline_geometry()) 9020 const std::vector< std::vector< Point_Double > >& lhs_comp = *lhs_geom.get_multiline_geometry(); 9030 const std::vector< std::vector< Point_Double > >& rhs_comp = *rhs_geom.get_multiline_geometry(); 9050 if (lhs_comp.size() != rhs_comp.size()) 9060 return lhs_comp.size() < rhs_comp.size() ? -1 : 1; 9080 for (uint i = 0; i < lhs_comp.size(); ++i) 9100 if (lhs_comp[i].size() < rhs_comp[i].size()) 9120 if (rhs_comp[i].size() < lhs_comp[i].size()) 9150 for (uint j = 0; j < lhs_comp[i].size(); ++j) 9170 if (lhs_comp[i][j] < rhs_comp[i][j]) 9190 if (rhs_comp[i][j] < lhs_comp[i][j]) 9290 else if (rhs_geom.has_multiline_geometry()) 936bool Derived_Structure_Handle::operator<(const Derived_Structure_Handle& rhs) const 93811639 q if (center.lat < 100.) 9400 if (rhs.center.lat < 100.) 9420 if (center.lat != rhs.center.lat) 9430 return center.lat < rhs.center.lat; 9440 if (center.lon != rhs.center.lon) 9450 return center.lon < rhs.center.lon; 95011639 q else if (rhs.center.lat < 100.) 95311639 q if (elem->get_geometry()) 95541 q if (rhs.elem->get_geometry()) 95741 q int cmp = compare_geometry(*elem->get_geometry(), *rhs.elem->get_geometry()); 96611599 q else if (rhs.elem->get_geometry()) 96911639 q std::vector< std::pair< std::string, std::string > >::const_iterator it_tl = elem->tags.begin(); 97011639 q std::vector< std::pair< std::string, std::string > >::const_iterator it_tr = rhs.elem->tags.begin(); 97116929 q while (it_tl != elem->tags.end() && it_tr != rhs.elem->tags.end()) 97312439 q if (*it_tl == *it_tr) 9787145 q else if (it_tl->first == "_next" || it_tl->first == "_previous") 9807145 q else if (it_tr->first == "_next" || it_tr->first == "_previous") 9827145 q else if (*it_tl < *it_tr) 9874498 q while (it_tl != elem->tags.end() && (it_tl->first == "_next" || it_tl->first == "_previous")) 9894498 q while (it_tr != rhs.elem->tags.end() && (it_tr->first == "_next" || it_tr->first == "_previous")) 9924498 q if (it_tr != rhs.elem->tags.end()) 9944498 q if (it_tl != elem->tags.end()) 1001void Set_Comparison::compute_deriveds(std::map< Uint31_Index, std::vector< Derived_Structure > > rhs_deriveds) 100344081 q std::vector< Derived_Structure_Handle > lhs_handles; 100444081 q for (std::map< Uint31_Index, std::vector< Derived_Structure > >::const_iterator 100546181 q it_idx = lhs_set_.deriveds.begin(); it_idx != lhs_set_.deriveds.end(); ++it_idx) 1007219 q for (std::vector< Derived_Structure >::const_iterator it_elem = it_idx->second.begin(); 1008779 q it_elem != it_idx->second.end(); ++it_elem) 1009569 q lhs_handles.push_back(Derived_Structure_Handle(it_idx->first, *it_elem)); 101144081 q std::sort(lhs_handles.begin(), lhs_handles.end()); 101344081 q std::vector< Derived_Structure_Handle > rhs_handles; 101444081 q for (std::map< Uint31_Index, std::vector< Derived_Structure > >::const_iterator 101546181 q it_idx = rhs_deriveds.begin(); it_idx != rhs_deriveds.end(); ++it_idx) 1017219 q for (std::vector< Derived_Structure >::const_iterator it_elem = it_idx->second.begin(); 10181769 q it_elem != it_idx->second.end(); ++it_elem) 10191559 q rhs_handles.push_back(Derived_Structure_Handle(it_idx->first, *it_elem)); 102144081 q std::sort(rhs_handles.begin(), rhs_handles.end()); 102344081 q std::vector< Derived_Structure_Handle >::const_iterator it_lhs = lhs_handles.begin(); 102444081 q std::vector< Derived_Structure_Handle >::const_iterator it_rhs = rhs_handles.begin(); 102658981 q while (it_lhs != lhs_handles.end() && it_rhs != rhs_handles.end()) 1030102 q result.lhs_deriveds.push_back(*it_lhs->elem); 10331399 q else if (*it_rhs < *it_lhs) 1035954 q result.rhs_deriveds.push_back(*it_rhs->elem); 104444281 q while (it_lhs != lhs_handles.end()) 104621 q result.lhs_deriveds.push_back(*it_lhs->elem); 104945681 q while (it_rhs != rhs_handles.end()) 1051163 q result.rhs_deriveds.push_back(*it_rhs->elem); 1057Diff_Set Set_Comparison::compare_to_lhs(Resource_Manager& rman, const Statement& stmt, 1058 const Set& input_set, double south, double north, double west, double east, bool add_deletion_information) 106244081 q uint64 rhs_timestamp = rman.get_desired_timestamp(); 106344081 q rman.set_desired_timestamp(lhs_timestamp_); 106544081 q Extra_Data_For_Diff extra_data_lhs(rman, stmt, lhs_set_, Output_Mode::ID 106644081 q | Output_Mode::COORDS | Output_Mode::NDS | Output_Mode::MEMBERS 106744081 q | Output_Mode::TAGS | Output_Mode::VERSION | Output_Mode::META 106844081 q | Output_Mode::GEOMETRY, south, north, west, east); 107044081 q tags_quadtile(extra_data_lhs, lhs_set_.nodes, rman); 107144081 q if (rman.get_desired_timestamp() != NOW) 107244081 q tags_quadtile_attic(extra_data_lhs, lhs_set_.attic_nodes, rman); 107444081 q tags_quadtile(extra_data_lhs, lhs_set_.ways, rman); 107544081 q if (rman.get_desired_timestamp() != NOW) 107644081 q tags_quadtile_attic(extra_data_lhs, lhs_set_.attic_ways, rman); 107844081 q tags_quadtile(extra_data_lhs, lhs_set_.relations, rman); 107944081 q if (rman.get_desired_timestamp() != NOW) 108044081 q tags_quadtile_attic(extra_data_lhs, lhs_set_.attic_relations, rman); 108244081 q rman.set_desired_timestamp(rhs_timestamp); 108644081 q Extra_Data_For_Diff extra_data_rhs(rman, stmt, input_set, Output_Mode::ID 108744081 q | Output_Mode::COORDS | Output_Mode::NDS | Output_Mode::MEMBERS 108844081 q | Output_Mode::TAGS | Output_Mode::VERSION | Output_Mode::META 108944081 q | Output_Mode::GEOMETRY, south, north, west, east); 109144081 q tags_quadtile(extra_data_rhs, input_set.nodes, rman); 109244081 q if (rman.get_desired_timestamp() != NOW) 109314623 q tags_quadtile_attic(extra_data_rhs, input_set.attic_nodes, rman); 109444081 q clear_nodes(rman, add_deletion_information); 109644081 q tags_quadtile(extra_data_rhs, input_set.ways, rman); 109744081 q if (rman.get_desired_timestamp() != NOW) 109814623 q tags_quadtile_attic(extra_data_rhs, input_set.attic_ways, rman); 109944081 q clear_ways(rman, add_deletion_information); 110144081 q tags_quadtile(extra_data_rhs, input_set.relations, rman); 110244081 q if (rman.get_desired_timestamp() != NOW) 110314623 q tags_quadtile_attic(extra_data_rhs, input_set.attic_relations, rman); 110444081 q clear_relations(rman, add_deletion_information); 110644081 q compute_deriveds(input_set.deriveds); 1114template< typename A, typename B > 1115struct First_Comparator 1117 bool operator()(const std::pair< A, B >& lhs, const std::pair< A, B >& rhs) 111928975317 q return lhs.first < rhs.first; 1124template< typename Index, typename Id_Type, typename Maybe_Attic > 1125void eval_lhs_elems(const std::map< Index, std::vector< Maybe_Attic > >& items, 1126 std::vector< std::pair< Id_Type, std::string > >& result, Set_With_Context& into_context, Eval_Task& task) 112810217 q for (typename std::map< Index, std::vector< Maybe_Attic > >::const_iterator it_idx = items.begin(); 1129120517 q it_idx != items.end(); ++it_idx) 1131110310 q for (typename std::vector< Maybe_Attic >::const_iterator it_elem = it_idx->second.begin(); 11323021410 q it_elem != it_idx->second.end(); ++it_elem) 1133291117 q result.push_back(std::make_pair( 1134291117 q it_elem->id, task.eval(into_context.get_context(it_idx->first, *it_elem), 0))); 113710217 q std::sort(result.begin(), result.end(), First_Comparator< Id_Type, std::string >()); 1141template< typename Index, typename Id_Type, typename Maybe_Attic > 1142void eval_rhs_elems(const std::map< Index, std::vector< Maybe_Attic > >& items, 1143 std::vector< std::pair< Id_Type, std::string > >& lhs_set, std::vector< Id_Type >& result, 1144 Set_With_Context& into_context, Eval_Task& task) 114610217 q for (typename std::map< Index, std::vector< Maybe_Attic > >::const_iterator it_idx = items.begin(); 1147103817 q it_idx != items.end(); ++it_idx) 114993612 q for (typename std::vector< Maybe_Attic >::const_iterator it_elem = it_idx->second.begin(); 115016547412 q it_elem != it_idx->second.end(); ++it_elem) 115216453811 q std::string rhs_val = task.eval(into_context.get_context(it_idx->first, *it_elem), 0); 115316453811 q typename std::vector< std::pair< Id_Type, std::string > >::iterator it_lhs = 115416453811 q std::lower_bound(lhs_set.begin(), lhs_set.end(), std::make_pair(it_elem->id, ""), 115516453811 q First_Comparator< Id_Type, std::string >()); 115716453811 q if (it_lhs == lhs_set.end() || !(it_lhs->first == it_elem->id)) 116014170410 q result.push_back(it_elem->id); 1164227966 q if (rhs_val != it_lhs->second) 116518592 q result.push_back(it_elem->id); 1167227966 q it_lhs->second.clear(); 1174template< typename Id_Type > 1175void clear_elems(std::vector< std::pair< Id_Type, std::string > >& lhs_set, std::vector< Id_Type >& result) 11775117 q for (typename std::vector< std::pair< Id_Type, std::string > >::const_iterator it_lhs = lhs_set.begin(); 11782916217 q it_lhs != lhs_set.end(); ++it_lhs) 1180291117 q if (!it_lhs->second.empty()) 118163124 q result.push_back(it_lhs->first); 11855117 q std::sort(result.begin(), result.end()); 1189template< typename Index, typename Id_Type, typename Maybe_Attic > 1190void filter_by_id(std::map< Index, std::vector< Maybe_Attic > >& items, const std::vector< Id_Type >& id_list) 119210217 q for (typename std::map< Index, std::vector< Maybe_Attic > >::iterator it_idx = items.begin(); 1193120517 q it_idx != items.end(); ++it_idx) 1195110310 q std::vector< Maybe_Attic > result; 1196110310 q for (typename std::vector< Maybe_Attic >::const_iterator it_elem = it_idx->second.begin(); 11973021410 q it_elem != it_idx->second.end(); ++it_elem) 1199291117 q if (std::binary_search(id_list.begin(), id_list.end(), it_elem->id)) 120081714 q result.push_back(*it_elem); 1202110310 q result.swap(it_idx->second); 1207Diff_Set Set_Comparison::compare_to_lhs(Resource_Manager& rman, const Statement& stmt, 1208 const Set& input_set, Evaluator* evaluator, bool add_deletion_information) 12121717 q uint64 rhs_timestamp = rman.get_desired_timestamp(); 12131717 q rman.set_desired_timestamp(lhs_timestamp_); 12161717 q Requested_Context requested_context = evaluator->request_context(); 12171717 q Prepare_Task_Context context(requested_context, stmt, rman); 12191717 q Owner< Eval_Task > task(evaluator->get_string_task(context, 0)); 12211717 q Set_With_Context into_context; 12231717 q into_context.parent = &context; 12241717 q into_context.prefetch(requested_context.object_usage, lhs_set_, stmt, rman); 12291717 q eval_lhs_elems(lhs_set_.nodes, node_values, into_context, *task); 12301717 q eval_lhs_elems(lhs_set_.attic_nodes, node_values, into_context, *task); 12331717 q eval_lhs_elems(lhs_set_.ways, way_values, into_context, *task); 12341717 q eval_lhs_elems(lhs_set_.attic_ways, way_values, into_context, *task); 12371717 q eval_lhs_elems(lhs_set_.relations, relation_values, into_context, *task); 12381717 q eval_lhs_elems(lhs_set_.attic_relations, relation_values, into_context, *task); 12421717 q rman.set_desired_timestamp(rhs_timestamp); 12441717 q std::vector< Node_Skeleton::Id_Type > changed_nodes; 12451717 q std::vector< Way_Skeleton::Id_Type > changed_ways; 12461717 q std::vector< Relation_Skeleton::Id_Type > changed_relations; 12481717 q Requested_Context requested_context = evaluator->request_context(); 12491717 q Prepare_Task_Context context(requested_context, stmt, rman); 12511717 q Owner< Eval_Task > task(evaluator->get_string_task(context, 0)); 12531717 q Set_With_Context into_context; 12551717 q into_context.parent = &context; 12561717 q into_context.prefetch(requested_context.object_usage, input_set, stmt, rman); 12601717 q eval_rhs_elems(input_set.nodes, node_values, changed_nodes, into_context, *task); 12611717 q eval_rhs_elems(input_set.attic_nodes, node_values, changed_nodes, into_context, *task); 12621717 q clear_elems(node_values, changed_nodes); 12641717 q eval_rhs_elems(input_set.ways, way_values, changed_ways, into_context, *task); 12651717 q eval_rhs_elems(input_set.attic_ways, way_values, changed_ways, into_context, *task); 12661717 q clear_elems(way_values, changed_ways); 12681717 q eval_rhs_elems(input_set.relations, relation_values, changed_relations, into_context, *task); 12691717 q eval_rhs_elems(input_set.attic_relations, relation_values, changed_relations, into_context, *task); 12701717 q clear_elems(relation_values, changed_relations); 12741717 q rman.set_desired_timestamp(lhs_timestamp_); 12761717 q filter_by_id(lhs_set_.nodes, changed_nodes); 12771717 q filter_by_id(lhs_set_.attic_nodes, changed_nodes); 12781717 q filter_by_id(lhs_set_.ways, changed_ways); 12791717 q filter_by_id(lhs_set_.attic_ways, changed_ways); 12801717 q filter_by_id(lhs_set_.relations, changed_relations); 12811717 q filter_by_id(lhs_set_.attic_relations, changed_relations); 12831717 q Extra_Data_For_Diff extra_data_lhs(rman, stmt, lhs_set_, Output_Mode::ID 12841717 q | Output_Mode::COORDS | Output_Mode::NDS | Output_Mode::MEMBERS 12851717 q | Output_Mode::TAGS | Output_Mode::VERSION | Output_Mode::META 12861717 q | Output_Mode::GEOMETRY, 1., 0., 0., 0.); 12881717 q tags_quadtile(extra_data_lhs, lhs_set_.nodes, changed_nodes, rman); 12891717 q if (rman.get_desired_timestamp() != NOW) 12901717 q tags_quadtile_attic(extra_data_lhs, lhs_set_.attic_nodes, changed_nodes, rman); 12921717 q tags_quadtile(extra_data_lhs, lhs_set_.ways, changed_ways, rman); 12931717 q if (rman.get_desired_timestamp() != NOW) 12941717 q tags_quadtile_attic(extra_data_lhs, lhs_set_.attic_ways, changed_ways, rman); 12961717 q tags_quadtile(extra_data_lhs, lhs_set_.relations, changed_relations, rman); 12971717 q if (rman.get_desired_timestamp() != NOW) 12981717 q tags_quadtile_attic(extra_data_lhs, lhs_set_.attic_relations, changed_relations, rman); 13001717 q rman.set_desired_timestamp(rhs_timestamp); 13041717 q Extra_Data_For_Diff extra_data_rhs(rman, stmt, input_set, Output_Mode::ID 13051717 q | Output_Mode::COORDS | Output_Mode::NDS | Output_Mode::MEMBERS 13061717 q | Output_Mode::TAGS | Output_Mode::VERSION | Output_Mode::META 13071717 q | Output_Mode::GEOMETRY, 1., 0., 0., 0.); 13091717 q tags_quadtile(extra_data_rhs, input_set.nodes, changed_nodes, rman); 13101717 q if (rman.get_desired_timestamp() != NOW) 131177 q tags_quadtile_attic(extra_data_rhs, input_set.attic_nodes, changed_nodes, rman); 13121717 q clear_nodes(rman, add_deletion_information); 13141717 q tags_quadtile(extra_data_rhs, input_set.ways, changed_ways, rman); 13151717 q if (rman.get_desired_timestamp() != NOW) 131677 q tags_quadtile_attic(extra_data_rhs, input_set.attic_ways, changed_ways, rman); 13171717 q clear_ways(rman, add_deletion_information); 13191717 q tags_quadtile(extra_data_rhs, input_set.relations, changed_relations, rman); 13201717 q if (rman.get_desired_timestamp() != NOW) 132177 q tags_quadtile_attic(extra_data_rhs, input_set.attic_relations, changed_relations, rman); 13221717 q clear_relations(rman, add_deletion_information);