Overpass API regression suite coverage (Nova Scotia) / overpass_api/data/set_comparison.cc

overpass_api/data/set_comparison.cc

812 of 986 instrumented lines run by the suite (82.4%) at 8edf11b0419c (this file on GitHub).

runnever runcolumns: line, executions, queries (click for the queries that run the line)

1/** Copyright 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 Roland Olbricht et al.
2 *
3 * This file is part of Overpass_API.
4 *
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.
9 *
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.
14 *
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/>.
17 */
19#include "../statements/evaluator.h"
20#include "set_comparison.h"
22#include <algorithm>
23#include <map>
24#include <string>
25#include <utility>
26#include <vector>
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)
3286276 q : mode(mode_), way_geometry_store(0), attic_way_geometry_store(0),
3386276 q relation_geometry_store(0), attic_relation_geometry_store(0), roles(0), users(0)
3486276 q{
3586276 q if (mode & (Output_Mode::GEOMETRY | Output_Mode::BOUNDS | Output_Mode::CENTER))
3686276 q {
3786276 q way_geometry_store = new Way_Bbox_Geometry_Store(to_print.ways, stmt, rman, south, north, west, east);
3886276 q if (rman.get_desired_timestamp() < NOW)
3954376 q {
4054376 q attic_way_geometry_store = new Way_Bbox_Geometry_Store(
4154376 q to_print.attic_ways, stmt, rman,
4254376 q south, north, west, east);
4354376 q }
4586276 q relation_geometry_store = new Relation_Geometry_Store(
4686276 q to_print.relations, stmt, rman, south, north, west, east);
4786276 q if (rman.get_desired_timestamp() < NOW)
4854376 q {
4954376 q attic_relation_geometry_store = new Relation_Geometry_Store(
5054376 q to_print.attic_relations, stmt, rman,
5154376 q south, north, west, east);
5254376 q }
5386276 q }
5586276 q roles = &relation_member_roles(*rman.get_transaction());
5786276 q if (mode & Output_Mode::META)
5886276 q users = &rman.users();
5986276 q}
62const std::map< uint32, std::string >* Extra_Data_For_Diff::get_users() const
630{
640 return users;
650}
68Extra_Data_For_Diff::~Extra_Data_For_Diff()
6986276 q{
7086276 q delete way_geometry_store;
7186276 q delete attic_way_geometry_store;
7286276 q delete relation_geometry_store;
7386276 q delete attic_relation_geometry_store;
7486276 q}
77void Set_Comparison::set_target(bool target)
7843176 q{
7943176 q final_target = target;
8043176 q std::sort(nodes.begin(), nodes.end());
8143176 q std::sort(ways.begin(), ways.end());
8243176 q std::sort(relations.begin(), relations.end());
8343176 q}
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)
9086736437 q{
9186736437 q if (final_target)
9276012937 q compare_item(ll_upper, skel, tags, NOW, meta, users);
9310723520 q else
9410723520 q store_item(ll_upper, skel, tags, NOW, meta, users);
9586736437 q}
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)
1028679824 q{
1038679824 q if (final_target)
10447047 q compare_item(ll_upper, skel, tags, skel.timestamp, meta, users);
1058209422 q else
1068209422 q store_item(ll_upper, skel, tags, skel.timestamp, meta, users);
1078679824 q}
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)
11414529547 q{
11514529547 q if (extra_data.way_geometry_store)
11614529547 q {
11714529547 q std::vector< Quad_Coord > geometry = extra_data.way_geometry_store->get_geometry(skel);
11814529547 q Double_Coords double_coords(geometry);
11914529547 q if (final_target)
12013523047 q compare_item(ll_upper, skel, tags,
12113523047 q geometry.empty() ? 0 : bound_variant(double_coords, extra_data.mode),
12213523047 q ((extra_data.mode & Output_Mode::GEOMETRY) && geometry.size() == skel.nds.size()) ? &geometry : 0,
12313523047 q NOW, meta, users);
1241006518 q else
1251006518 q store_item(ll_upper, skel, tags,
1261006518 q geometry.empty() ? 0 : bound_variant(double_coords, extra_data.mode),
1271006518 q ((extra_data.mode & Output_Mode::GEOMETRY) && geometry.size() == skel.nds.size()) ? &geometry : 0,
1281006518 q NOW, meta, users);
12914529547 q }
1300 else
1310 {
1320 if (final_target)
1330 compare_item(ll_upper, skel, tags, 0, 0, NOW, meta, users);
1340 else
1350 store_item(ll_upper, skel, tags, 0, 0, NOW, meta, users);
1360 }
13714529547 q}
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)
144709533 q{
145709533 q if (extra_data.attic_way_geometry_store)
146709533 q {
147709533 q std::vector< Quad_Coord > geometry = extra_data.attic_way_geometry_store->get_geometry(skel);
148709533 q Double_Coords double_coords(geometry);
149709533 q if (final_target)
15083911 q compare_item(ll_upper, skel, tags,
15183911 q geometry.empty() ? 0 : bound_variant(double_coords, extra_data.mode),
15283911 q ((extra_data.mode & Output_Mode::GEOMETRY) && geometry.size() == skel.nds.size()) ? &geometry : 0,
15383911 q skel.timestamp, meta, users);
154625630 q else
155625630 q store_item(ll_upper, skel, tags,
156625630 q geometry.empty() ? 0 : bound_variant(double_coords, extra_data.mode),
157625630 q ((extra_data.mode & Output_Mode::GEOMETRY) && geometry.size() == skel.nds.size()) ? &geometry : 0,
158625630 q skel.timestamp, meta, users);
159709533 q }
1600 else
1610 {
1620 if (final_target)
1630 compare_item(ll_upper, skel, tags, 0, 0, skel.timestamp, meta, users);
1640 else
1650 store_item(ll_upper, skel, tags, 0, 0, skel.timestamp, meta, users);
1660 }
167709533 q}
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)
17589024 q if (extra_data.relation_geometry_store)
17689024 q {
17789024 q std::vector< std::vector< Quad_Coord > > geometry = extra_data.relation_geometry_store->get_geometry(skel);
17889024 q Double_Coords double_coords(geometry);
17989024 q if (final_target)
18087824 q compare_item(ll_upper, skel, tags,
18187824 q geometry.empty() ? 0 : bound_variant(double_coords, extra_data.mode),
18287824 q ((extra_data.mode & Output_Mode::GEOMETRY) && geometry.size() == skel.members.size()) ? &geometry : 0,
18387824 q NOW, meta, users);
184123 q else
185123 q store_item(ll_upper, skel, tags,
186123 q geometry.empty() ? 0 : bound_variant(double_coords, extra_data.mode),
187123 q ((extra_data.mode & Output_Mode::GEOMETRY) && geometry.size() == skel.members.size()) ? &geometry : 0,
188123 q NOW, meta, users);
18989024 q }
1900 else
1910 {
1920 if (final_target)
1930 compare_item(ll_upper, skel, tags, 0, 0, NOW, meta, users);
1940 else
1950 store_item(ll_upper, skel, tags, 0, 0, NOW, meta, users);
1960 }
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)
20539818 q if (extra_data.attic_relation_geometry_store)
20639818 q {
20739818 q std::vector< std::vector< Quad_Coord > > geometry = extra_data.attic_relation_geometry_store->get_geometry(skel);
20839818 q Double_Coords double_coords(geometry);
20939818 q if (final_target)
2101596 q compare_item(ll_upper, skel, tags,
2111596 q geometry.empty() ? 0 : bound_variant(double_coords, extra_data.mode),
2121596 q ((extra_data.mode & Output_Mode::GEOMETRY) && geometry.size() == skel.members.size()) ? &geometry : 0,
2131596 q skel.timestamp, meta, users);
21423915 q else
21523915 q store_item(ll_upper, skel, tags,
21623915 q geometry.empty() ? 0 : bound_variant(double_coords, extra_data.mode),
21723915 q ((extra_data.mode & Output_Mode::GEOMETRY) && geometry.size() == skel.members.size()) ? &geometry : 0,
21823915 q skel.timestamp, meta, users);
21939818 q }
2200 else
2210 {
2220 if (final_target)
2230 compare_item(ll_upper, skel, tags, 0, 0, skel.timestamp, meta, users);
2240 else
2250 store_item(ll_upper, skel, tags, 0, 0, skel.timestamp, meta, users);
2260 }
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)
233249676 q{
234249676 q Tag_Store< Index, Object > tag_store(*rman.get_transaction());
235249676 q tag_store.prefetch_all(items);
237 // formulate meta query if meta data shall be printed
238249676 q Meta_Collector< Index, typename Object::Id_Type > meta_printer(items, *rman.get_transaction(),
239249676 q (extra_data.mode & Output_Mode::META) ? current_meta_file_properties< Object >() : 0);
241249676 q typename std::map< Index, std::vector< Object > >::const_iterator
242249676 q item_it(items.begin());
243 // print the result
2446723076 q while (item_it != items.end())
2456473461 q {
2466473461 q for (typename std::vector< Object >::const_iterator it2(item_it->second.begin());
247107546461 q it2 != item_it->second.end(); ++it2)
248101073059 q {
249101073059 q print_item(extra_data, item_it->first.val(), *it2, tag_store.get(item_it->first, *it2),
250101073059 q meta_printer.get(item_it->first, it2->id), extra_data.users);
251101073059 q }
2526473461 q ++item_it;
2536473461 q }
254249676 q}
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)
261156676 q{
262156676 q Tag_Store< Index, Object > tag_store(*rman.get_transaction());
263156676 q tag_store.prefetch_all(items);
264 // formulate meta query if meta data shall be printed
265156676 q Attic_Meta_Collector< Index, Object > meta_printer(
266156676 q items, *rman.get_transaction(), extra_data.mode & Output_Mode::META);
268156676 q typename std::map< Index, std::vector< Attic< Object > > >::const_iterator
269156676 q item_it(items.begin());
2703255176 q while (item_it != items.end())
2713098557 q {
2723098557 q for (typename std::vector< Attic< Object > >::const_iterator it2(item_it->second.begin());
27312505557 q it2 != item_it->second.end(); ++it2)
2749407044 q print_item(extra_data, item_it->first.val(), *it2, tag_store.get(item_it->first, *it2),
2759407044 q meta_printer.get(item_it->first, it2->id, it2->timestamp), extra_data.users);
2763098557 q ++item_it;
2773098557 q }
278156676 q}
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)
2869015 q Tag_Store< Index, Object > tag_store(*rman.get_transaction());
2879015 q tag_store.prefetch_all(items);
289 // formulate meta query if meta data shall be printed
2909015 q Meta_Collector< Index, typename Object::Id_Type > meta_printer(items, *rman.get_transaction(),
2919015 q (extra_data.mode & Output_Mode::META) ? current_meta_file_properties< Object >() : 0);
2939015 q typename std::map< Index, std::vector< Object > >::const_iterator
2949015 q item_it(items.begin());
295 // print the result
296942715 q while (item_it != items.end())
297933710 q {
298933710 q for (typename std::vector< Object >::const_iterator it2(item_it->second.begin());
2991275910 q it2 != item_it->second.end(); ++it2)
30034227 q {
30134227 q if (std::binary_search(id_list.begin(), id_list.end(), it2->id))
30228194 q print_item(extra_data, item_it->first.val(), *it2, tag_store.get(item_it->first, *it2),
30328194 q meta_printer.get(item_it->first, it2->id), extra_data.users);
30434227 q }
305933710 q ++item_it;
306933710 q }
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)
3156315 q Tag_Store< Index, Object > tag_store(*rman.get_transaction());
3166315 q tag_store.prefetch_all(items);
317 // formulate meta query if meta data shall be printed
3186315 q Attic_Meta_Collector< Index, Object > meta_printer(
3196315 q items, *rman.get_transaction(), extra_data.mode & Output_Mode::META);
3216315 q typename std::map< Index, std::vector< Attic< Object > > >::const_iterator
3226315 q item_it(items.begin());
323896715 q while (item_it != items.end())
324890410 q {
325890410 q for (typename std::vector< Attic< Object > >::const_iterator it2(item_it->second.begin());
326913510 q it2 != item_it->second.end(); ++it2)
3272316 q {
3282316 q if (std::binary_search(id_list.begin(), id_list.end(), it2->id))
3292215 q print_item(extra_data, item_it->first.val(), *it2, tag_store.get(item_it->first, *it2),
3302215 q meta_printer.get(item_it->first, it2->id, it2->timestamp), extra_data.users);
3312316 q }
332890410 q ++item_it;
333890410 q }
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)
341113432 q{
342113432 q std::vector< typename Skeleton::Id_Type > found_ids;
343113432 q std::map< Index, std::vector< Skeleton > > current_result;
344113432 q std::map< Index, std::vector< Attic< Skeleton > > > attic_result;
346113432 q Request_Context context(0, rman);
347113432 q collect_items_discrete(context, req,
348113432 q Id_Predicate< Skeleton >(searched_ids), timestamp, current_result, attic_result);
349113432 q filter_attic_elements(rman, timestamp, current_result, attic_result);
351113432 q for (typename std::map< Index, std::vector< Skeleton > >::const_iterator it = current_result.begin();
352605032 q it != current_result.end(); ++it)
353491623 q {
354500023 q for (typename std::vector< Skeleton >::const_iterator it2 = it->second.begin(); it2 != it->second.end(); ++it2)
355845 q found_ids.push_back(it2->id);
356491623 q }
357113432 q for (typename std::map< Index, std::vector< Attic< Skeleton > > >::const_iterator it = attic_result.begin();
358601032 q it != attic_result.end(); ++it)
359487623 q {
360487623 q for (typename std::vector< Attic< Skeleton > >::const_iterator it2 = it->second.begin();
361493023 q it2 != it->second.end(); ++it2)
362544 q found_ids.push_back(it2->id);
363487623 q }
364113432 q std::sort(found_ids.begin(), found_ids.end());
365113432 q found_ids.erase(std::unique(found_ids.begin(), found_ids.end()), found_ids.end());
367113432 q return found_ids;
368113432 q}
371template< typename Index, typename Skeleton >
372std::map< typename Skeleton::Id_Type, OSM_Element_Metadata_Skeleton< typename Skeleton::Id_Type > >
373 find_meta_elements
374 (Resource_Manager& rman, uint64 timestamp, const std::vector< Index >& idx_set,
375 const std::vector< typename Skeleton::Id_Type >& searched_ids)
376113432 q{
377113432 q std::map< typename Skeleton::Id_Type, OSM_Element_Metadata_Skeleton< typename Skeleton::Id_Type > > result;
379113432 q Block_Backend< Index, OSM_Element_Metadata_Skeleton< typename Skeleton::Id_Type >,
380113432 q typename std::vector< Index >::const_iterator >
381113432 q attic_meta_db(rman.get_transaction()->data_index(attic_meta_file_properties< Skeleton >()));
382113432 q for (typename Block_Backend< Index, OSM_Element_Metadata_Skeleton< typename Skeleton::Id_Type >,
383113432 q typename std::vector< Index >::const_iterator >::Discrete_Iterator
384113432 q it = attic_meta_db.discrete_begin(idx_set.begin(), idx_set.end());
385206456132 q !(it == attic_meta_db.discrete_end()); ++it)
386206342724 q {
387206342724 q if (!(timestamp < it.object().timestamp)
388206342724 q && std::binary_search(searched_ids.begin(), searched_ids.end(), it.object().ref))
3894805913 q {
3904805913 q typename std::map< typename Skeleton::Id_Type, OSM_Element_Metadata_Skeleton< typename Skeleton::Id_Type > >
3914805913 q ::iterator meta_it = result.find(it.object().ref);
3924805913 q if (meta_it == result.end())
3932261313 q result.insert(std::make_pair(it.object().ref, it.object()));
3942544613 q else if (meta_it->second.timestamp < it.object().timestamp)
3952538113 q meta_it->second = it.object();
3964805913 q }
397206342724 q }
399 // Same thing with current meta data
400113432 q Block_Backend< Index, OSM_Element_Metadata_Skeleton< typename Skeleton::Id_Type >,
401113432 q typename std::vector< Index >::const_iterator >
402113432 q meta_db(rman.get_transaction()->data_index(current_meta_file_properties< Skeleton >()));
404113432 q for (typename Block_Backend< Index, OSM_Element_Metadata_Skeleton< typename Skeleton::Id_Type >,
405113432 q typename std::vector< Index >::const_iterator >::Discrete_Iterator
406113432 q it = meta_db.discrete_begin(idx_set.begin(), idx_set.end());
407184315232 q !(it == meta_db.discrete_end()); ++it)
408184201824 q {
409184201824 q if (!(timestamp < it.object().timestamp)
410184201824 q && std::binary_search(searched_ids.begin(), searched_ids.end(), it.object().ref))
411845 q {
412845 q typename std::map< typename Skeleton::Id_Type, OSM_Element_Metadata_Skeleton< typename Skeleton::Id_Type > >
413845 q ::iterator meta_it = result.find(it.object().ref);
414845 q if (meta_it == result.end())
4150 result.insert(std::make_pair(it.object().ref, it.object()));
416845 q else if (meta_it->second.timestamp < it.object().timestamp)
417845 q meta_it->second = it.object();
418845 q }
419184201824 q }
421113432 q return result;
422113432 q}
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)
43018932924 q{
43118932924 q nodes.push_back(Node_With_Context(ll_upper, skel, timestamp,
43218932924 q meta ? *meta : OSM_Element_Metadata_Skeleton< Node_Skeleton::Id_Type >(),
43318932924 q tags ? *tags : std::vector< std::pair< std::string, std::string > >()));
43418932924 q}
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)
44276483338 q{
44376483338 q std::vector< Node_With_Context >::iterator nodes_it
44476483338 q = std::lower_bound(nodes.begin(), nodes.end(), Node_With_Context(ll_upper, skel, 0));
44676483338 q if (nodes_it == nodes.end() || skel.id < nodes_it->elem.id)
44761115536 q result.different_nodes.push_back(std::make_pair(
44861115536 q Node_With_Context(0xffu, Node_Skeleton(skel.id), 0,
44961115536 q OSM_Element_Metadata_Skeleton< Node_Skeleton::Id_Type >(),
45061115536 q std::vector< std::pair< std::string, std::string > >()),
45161115536 q Node_With_Context(ll_upper, skel, timestamp,
45261115536 q meta ? *meta : OSM_Element_Metadata_Skeleton< Node_Skeleton::Id_Type >(),
45361115536 q tags ? *tags : std::vector< std::pair< std::string, std::string > >())));
45415367822 q else
45515367822 q {
45615367822 q if (!(nodes_it->idx.val() == ll_upper) || !(nodes_it->elem.ll_lower == skel.ll_lower) ||
45715367822 q (tags && !(nodes_it->tags == *tags)) || (meta && !(nodes_it->meta.timestamp == meta->timestamp)))
4584643919 q result.different_nodes.push_back(std::make_pair(*nodes_it, Node_With_Context(ll_upper, skel, timestamp,
4594643919 q meta ? *meta : OSM_Element_Metadata_Skeleton< Node_Skeleton::Id_Type >(),
4604643919 q tags ? *tags : std::vector< std::pair< std::string, std::string > >())));
46215367822 q nodes_it->idx = 0xffu;
46315367822 q }
46476483338 q}
467void Set_Comparison::clear_nodes(Resource_Manager& rman, bool add_deletion_information)
46943176 q if (add_deletion_information)
47018932 q {
47118932 q std::vector< Node_Skeleton::Id_Type > searched_ids;
47212782732 q for (std::vector< Node_With_Context >::const_iterator it = nodes.begin(); it != nodes.end(); ++it)
47312763811 q {
47412763811 q if (it->idx.val() != 0xffu)
475212858 q searched_ids.push_back(it->elem.id);
47612763811 q }
47818932 q std::vector< Uint32_Index > req = get_indexes_< Uint32_Index, Node_Skeleton >(searched_ids, rman, true);
47918932 q std::vector< Node_Skeleton::Id_Type > found_ids
48018932 q = find_still_existing_skeletons< Uint32_Index, Node_Skeleton >(
48118932 q rman, rman.get_desired_timestamp(), req, searched_ids);
48218932 q std::map< Node_Skeleton::Id_Type, OSM_Element_Metadata_Skeleton< Node::Id_Type > > found_meta
48318932 q = find_meta_elements< Node::Index, Node_Skeleton >(rman, rman.get_diff_to_timestamp(), req, searched_ids);
48512782732 q for (std::vector< Node_With_Context >::const_iterator it = nodes.begin(); it != nodes.end(); ++it)
48612763811 q {
48712763811 q if (it->idx.val() != 0xffu)
488212858 q {
489212858 q std::map< Node_Skeleton::Id_Type, OSM_Element_Metadata_Skeleton< Node::Id_Type > >::const_iterator
490212858 q meta_it = found_meta.find(it->elem.id);
491212858 q result.different_nodes.push_back(std::make_pair(*it,
492212858 q Node_With_Context(std::binary_search(found_ids.begin(), found_ids.end(), it->elem.id) ? 0xfdu : 0xffu,
493212858 q Node_Skeleton(it->elem.id), 0,
494212858 q meta_it != found_meta.end() ? meta_it->second
495212858 q : OSM_Element_Metadata_Skeleton< Node_Skeleton::Id_Type >(),
496212858 q std::vector< std::pair< std::string, std::string > >())));
497212858 q }
49812763811 q }
50018932 q searched_ids.clear();
50118932 q for (std::vector< std::pair< Node_With_Context, Node_With_Context > >::const_iterator
50234770632 q it = result.different_nodes.begin(); it != result.different_nodes.end(); ++it)
50334751717 q {
50434751717 q if (it->first.idx.val() == 0xffu)
50528957215 q searched_ids.push_back(it->second.elem.id);
50634751717 q }
50818932 q get_indexes_< Uint32_Index, Node_Skeleton >(searched_ids, rman, true).swap(req);
50918932 q find_still_existing_skeletons< Uint32_Index, Node_Skeleton >(
51018932 q rman, rman.get_diff_from_timestamp(), req, searched_ids).swap(found_ids);
51118932 q find_meta_elements< Node::Index, Node_Skeleton >(
51218932 q rman, rman.get_diff_from_timestamp(), req, searched_ids).swap(found_meta);
51418932 q for (std::vector< std::pair< Node_With_Context, Node_With_Context > >::iterator
51534770632 q it = result.different_nodes.begin(); it != result.different_nodes.end(); ++it)
51634751717 q {
51734751717 q if (it->first.idx.val() == 0xffu)
51828957215 q {
51928957215 q it->first.idx = std::binary_search(found_ids.begin(), found_ids.end(), it->second.elem.id) ? 0xfdu : 0xffu;
52028957215 q it->first.elem = Node_Skeleton(it->second.elem.id);
52228957215 q std::map< Node_Skeleton::Id_Type, OSM_Element_Metadata_Skeleton< Node::Id_Type > >::const_iterator
52328957215 q meta_it = found_meta.find(it->second.elem.id);
52428957215 q if (meta_it != found_meta.end())
525271 q it->first.meta = meta_it->second;
52628957215 q }
52734751717 q }
52818932 q }
52924244 q else
53024244 q {
5316193344 q for (std::vector< Node_With_Context >::const_iterator it = nodes.begin(); it != nodes.end(); ++it)
5326169113 q {
5336169113 q if (it->idx.val() != 0xffu)
5341436612 q result.different_nodes.push_back(std::make_pair(*it,
5351436612 q Node_With_Context(0xffu, Node_Skeleton(it->elem.id), 0,
5361436612 q OSM_Element_Metadata_Skeleton< Node_Skeleton::Id_Type >(),
5371436612 q std::vector< std::pair< std::string, std::string > >())));
5386169113 q }
53924244 q }
54143176 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)
5521632131 q{
5531632131 q ways.push_back(Way_With_Context(ll_upper, skel,
5541632131 q geometry ? *geometry : std::vector< Quad_Coord >(),
5551632131 q timestamp, meta ? *meta : OSM_Element_Metadata_Skeleton< Way_Skeleton::Id_Type >(),
5561632131 q tags ? *tags : std::vector< std::pair< std::string, std::string > >()));
5571632131 q}
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)
56713606947 q{
56813606947 q std::vector< Way_With_Context >::iterator ways_it
56913606947 q = std::lower_bound(ways.begin(), ways.end(),
57013606947 q Way_With_Context(ll_upper, skel, std::vector< Quad_Coord >(), timestamp));
57213606947 q if (ways_it == ways.end() || skel.id < ways_it->elem.id)
57312176842 q result.different_ways.push_back(std::make_pair(
57412176842 q Way_With_Context(0xffu, Way_Skeleton(skel.id),
57512176842 q std::vector< Quad_Coord >(),
57612176842 q 0, OSM_Element_Metadata_Skeleton< Way_Skeleton::Id_Type >(),
57712176842 q std::vector< std::pair< std::string, std::string > >()),
57812176842 q Way_With_Context(ll_upper, skel,
57912176842 q geometry ? *geometry : std::vector< Quad_Coord >(),
58012176842 q timestamp, meta ? *meta : OSM_Element_Metadata_Skeleton< Way_Skeleton::Id_Type >(),
58112176842 q tags ? *tags : std::vector< std::pair< std::string, std::string > >())));
5821430127 q else
5831430127 q {
5841430127 q if (!(ways_it->idx.val() == ll_upper) || !(ways_it->elem.nds == skel.nds) ||
5851430127 q (geometry && !(ways_it->geometry == *geometry)) ||
5861430127 q (tags && !(ways_it->tags == *tags)) || (meta && !(ways_it->meta.timestamp == meta->timestamp)))
587413225 q result.different_ways.push_back(std::make_pair(*ways_it, Way_With_Context(ll_upper, skel,
588413225 q geometry ? *geometry : std::vector< Quad_Coord >(),
589413225 q timestamp, meta ? *meta : OSM_Element_Metadata_Skeleton< Way_Skeleton::Id_Type >(),
590413225 q tags ? *tags : std::vector< std::pair< std::string, std::string > >())));
5921430127 q ways_it->idx = 0xffu;
5931430127 q }
59413606947 q}
597void Set_Comparison::clear_ways(Resource_Manager& rman, bool add_deletion_information)
59943176 q if (add_deletion_information)
60018932 q {
60118932 q std::vector< Way_Skeleton::Id_Type > searched_ids;
6021192632 q for (std::vector< Way_With_Context >::const_iterator it = ways.begin(); it != ways.end(); ++it)
6031173711 q {
6041173711 q if (it->idx.val() != 0xffu)
60512748 q searched_ids.push_back(it->elem.id);
6061173711 q }
60818932 q std::vector< Uint31_Index > req = get_indexes_< Uint31_Index, Way_Skeleton >(searched_ids, rman, true);
60918932 q std::vector< Way_Skeleton::Id_Type > found_ids
61018932 q = find_still_existing_skeletons< Uint31_Index, Way_Skeleton >(
61118932 q rman, rman.get_desired_timestamp(), req, searched_ids);
61218932 q std::map< Way_Skeleton::Id_Type, OSM_Element_Metadata_Skeleton< Way::Id_Type > > found_meta
61318932 q = find_meta_elements< Way::Index, Way_Skeleton >(rman, rman.get_diff_to_timestamp(), req, searched_ids);
6151192632 q for (std::vector< Way_With_Context >::const_iterator it = ways.begin(); it != ways.end(); ++it)
6161173711 q {
6171173711 q if (it->idx.val() != 0xffu)
61812748 q {
61912748 q std::map< Way_Skeleton::Id_Type, OSM_Element_Metadata_Skeleton< Way::Id_Type > >::const_iterator
62012748 q meta_it = found_meta.find(it->elem.id);
62112748 q result.different_ways.push_back(std::make_pair(*it,
62212748 q Way_With_Context(std::binary_search(found_ids.begin(), found_ids.end(), it->elem.id) ? 0xfdu : 0xffu,
62312748 q Way_Skeleton(it->elem.id),
62412748 q std::vector< Quad_Coord >(),
62512748 q 0, meta_it != found_meta.end() ? meta_it->second
62612748 q : OSM_Element_Metadata_Skeleton< Way_Skeleton::Id_Type >(),
62712748 q std::vector< std::pair< std::string, std::string > >())));
62812748 q }
6291173711 q }
63118932 q searched_ids.clear();
63218932 q for (std::vector< std::pair< Way_With_Context, Way_With_Context > >::const_iterator
6333203532 q it = result.different_ways.begin(); it != result.different_ways.end(); ++it)
6343184618 q {
6353184618 q if (it->first.idx.val() == 0xffu)
6362787516 q searched_ids.push_back(it->second.elem.id);
6373184618 q }
63918932 q get_indexes_< Uint31_Index, Way_Skeleton >(searched_ids, rman, true).swap(req);
64018932 q find_still_existing_skeletons< Uint31_Index, Way_Skeleton >(
64118932 q rman, rman.get_diff_from_timestamp(), req, searched_ids).swap(found_ids);
64218932 q find_meta_elements< Way::Index, Way_Skeleton >(
64318932 q rman, rman.get_diff_from_timestamp(), req, searched_ids).swap(found_meta);
64518932 q for (std::vector< std::pair< Way_With_Context, Way_With_Context > >::iterator
6463203532 q it = result.different_ways.begin(); it != result.different_ways.end(); ++it)
6473184618 q {
6483184618 q if (it->first.idx.val() == 0xffu)
6492787516 q {
6502787516 q it->first.idx = std::binary_search(found_ids.begin(), found_ids.end(), it->second.elem.id) ? 0xfdu : 0xffu;
6512787516 q it->first.elem = Way_Skeleton(it->second.elem.id);
6532787516 q std::map< Way_Skeleton::Id_Type, OSM_Element_Metadata_Skeleton< Way::Id_Type > >::const_iterator
6542787516 q meta_it = found_meta.find(it->second.elem.id);
6552787516 q if (meta_it != found_meta.end())
656274 q it->first.meta = meta_it->second;
6572787516 q }
6583184618 q }
65918932 q }
66024244 q else
66124244 q {
662482644 q for (std::vector< Way_With_Context >::const_iterator it = ways.begin(); it != ways.end(); ++it)
663458420 q {
664458420 q if (it->idx.val() != 0xffu)
66574616 q result.different_ways.push_back(std::make_pair(*it,
66674616 q Way_With_Context(0xffu, Way_Skeleton(it->elem.id),
66774616 q std::vector< Quad_Coord >(),
66874616 q 0, OSM_Element_Metadata_Skeleton< Way_Skeleton::Id_Type >(),
66974616 q std::vector< std::pair< std::string, std::string > >())));
670458420 q }
67124244 q }
67343176 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)
68525115 q relations.push_back(Relation_With_Context(ll_upper, skel,
68625115 q geometry ? *geometry : std::vector< std::vector< Quad_Coord > >(),
68725115 q timestamp, meta ? *meta : OSM_Element_Metadata_Skeleton< Relation_Skeleton::Id_Type >(),
68825115 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)
699103725 q{
700103725 q std::vector< Relation_With_Context >::iterator relations_it
701103725 q = std::lower_bound(relations.begin(), relations.end(),
702103725 q Relation_With_Context(ll_upper, skel, std::vector< std::vector< Quad_Coord > >(), 0));
704103725 q if (relations_it == relations.end() || skel.id < relations_it->elem.id)
70582223 q result.different_relations.push_back(std::make_pair(
70682223 q Relation_With_Context(0xffu, Relation_Skeleton(skel.id),
70782223 q std::vector< std::vector< Quad_Coord > >(),
70882223 q 0, OSM_Element_Metadata_Skeleton< Relation_Skeleton::Id_Type >(),
70982223 q std::vector< std::pair< std::string, std::string > >()),
71082223 q Relation_With_Context(ll_upper, skel,
71182223 q geometry ? *geometry : std::vector< std::vector< Quad_Coord > >(),
71282223 q timestamp, meta ? *meta : OSM_Element_Metadata_Skeleton< Relation_Skeleton::Id_Type >(),
71382223 q tags ? *tags : std::vector< std::pair< std::string, std::string > >())));
71421515 q else
71521515 q {
71621515 q if (!(relations_it->idx.val() == ll_upper) || !(relations_it->elem.members == skel.members) ||
71721515 q (geometry && !(relations_it->geometry == *geometry)) ||
71821515 q (tags && !(relations_it->tags == *tags)) || (meta && !(relations_it->meta.timestamp == meta->timestamp)))
71920315 q result.different_relations.push_back(std::make_pair(*relations_it, Relation_With_Context(ll_upper, skel,
72020315 q geometry ? *geometry : std::vector< std::vector< Quad_Coord > >(),
72120315 q timestamp, meta ? *meta : OSM_Element_Metadata_Skeleton< Relation_Skeleton::Id_Type >(),
72220315 q tags ? *tags : std::vector< std::pair< std::string, std::string > >())));
72421515 q relations_it->idx = 0xffu;
72521515 q }
726103725 q}
729void Set_Comparison::clear_relations(Resource_Manager& rman, bool add_deletion_information)
73143176 q if (add_deletion_information)
73218932 q {
73318932 q std::vector< Relation_Skeleton::Id_Type > searched_ids;
73423132 q for (std::vector< Relation_With_Context >::const_iterator it = relations.begin(); it != relations.end(); ++it)
735423 q {
736423 q if (it->idx.val() != 0xffu)
7370 searched_ids.push_back(it->elem.id);
738423 q }
74018932 q std::vector< Uint31_Index > req = get_indexes_< Uint31_Index, Relation_Skeleton >(searched_ids, rman, true);
74118932 q std::vector< Relation_Skeleton::Id_Type > found_ids
74218932 q = find_still_existing_skeletons< Uint31_Index, Relation_Skeleton >(
74318932 q rman, rman.get_diff_to_timestamp(), req, searched_ids);
74418932 q std::map< Relation_Skeleton::Id_Type, OSM_Element_Metadata_Skeleton< Relation::Id_Type > > found_meta
74518932 q = find_meta_elements< Relation::Index, Relation_Skeleton >(
74618932 q rman, rman.get_diff_to_timestamp(), req, searched_ids);
74823132 q for (std::vector< Relation_With_Context >::const_iterator it = relations.begin(); it != relations.end(); ++it)
749423 q {
750423 q if (it->idx.val() != 0xffu)
7510 {
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 > >())));
7610 }
763423 q req = get_indexes_< Uint31_Index, Relation_Skeleton >(searched_ids, rman, true);
764423 q }
76618932 q searched_ids.clear();
76718932 q for (std::vector< std::pair< Relation_With_Context, Relation_With_Context > >::const_iterator
76850432 q it = result.different_relations.begin(); it != result.different_relations.end(); ++it)
7693157 q {
7703157 q if (it->first.idx.val() == 0xffu)
7712766 q searched_ids.push_back(it->second.elem.id);
7723157 q }
77418932 q get_indexes_< Uint31_Index, Relation_Skeleton >(searched_ids, rman, true).swap(req);
77518932 q find_still_existing_skeletons< Uint31_Index, Relation_Skeleton >(
77618932 q rman, rman.get_diff_from_timestamp(), req, searched_ids).swap(found_ids);
77718932 q find_meta_elements< Relation::Index, Relation_Skeleton >(
77818932 q rman, rman.get_diff_from_timestamp(), req, searched_ids).swap(found_meta);
78018932 q for (std::vector< std::pair< Relation_With_Context, Relation_With_Context > >::iterator
78150432 q it = result.different_relations.begin(); it != result.different_relations.end(); ++it)
7823157 q {
7833157 q if (it->first.idx.val() == 0xffu)
7842766 q {
7852766 q it->first.idx = std::binary_search(found_ids.begin(), found_ids.end(), it->second.elem.id) ? 0xfdu : 0xffu;
7862766 q it->first.elem = Relation_Skeleton(it->second.elem.id);
7882766 q std::map< Relation_Skeleton::Id_Type, OSM_Element_Metadata_Skeleton< Relation::Id_Type > >::const_iterator
7892766 q meta_it = found_meta.find(it->second.elem.id);
7902766 q if (meta_it != found_meta.end())
7910 it->first.meta = meta_it->second;
7922766 q }
7933157 q }
79418932 q }
79524244 q else
79624244 q {
79745144 q for (std::vector< Relation_With_Context >::const_iterator it = relations.begin(); it != relations.end(); ++it)
79820912 q {
79920912 q if (it->idx.val() != 0xffu)
800365 q result.different_relations.push_back(std::make_pair(*it,
801365 q Relation_With_Context(0xffu, Relation_Skeleton(it->elem.id),
802365 q std::vector< std::vector< Quad_Coord > >(),
803365 q 0, OSM_Element_Metadata_Skeleton< Relation_Skeleton::Id_Type >(),
804365 q std::vector< std::pair< std::string, std::string > >())));
80520912 q }
80624244 q }
80843176 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_)
81532364313 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())
81732364313 q : Point_Double(100., 0.)) {}
819 bool operator<(const Derived_Structure_Handle& rhs) const;
821 const Derived_Structure* elem;
822 Point_Double center;
823};
826int compare_geometry(const Opaque_Geometry& lhs_geom, const Opaque_Geometry& rhs_geom)
8270{
8280 if (lhs_geom.has_center())
8290 {
8300 if (rhs_geom.has_center())
8310 {
8320 if (lhs_geom.center_lat() < rhs_geom.center_lat())
8330 return -1;
8340 if (rhs_geom.center_lat() < lhs_geom.center_lat())
8350 return 1;
8360 if (lhs_geom.center_lon() < rhs_geom.center_lon())
8370 return -1;
8380 if (rhs_geom.center_lon() < lhs_geom.center_lon())
8390 return 1;
8400 }
8410 else
8420 return -1;
8430 }
8440 else if (rhs_geom.has_center())
8450 return 1;
8470 if (lhs_geom.has_components())
8480 {
8490 if (rhs_geom.has_components())
8500 {
8510 const std::vector< Opaque_Geometry* >& lhs_comp = *lhs_geom.get_components();
8520 const std::vector< Opaque_Geometry* >& rhs_comp = *rhs_geom.get_components();
8540 if (lhs_comp.size() != rhs_comp.size())
8550 return lhs_comp.size() < rhs_comp.size() ? -1 : 1;
8570 for (uint i = 0; i < lhs_comp.size(); ++i)
8580 {
8590 int cmp = compare_geometry(*lhs_comp[i], *rhs_comp[i]);
8600 if (cmp)
8610 return cmp;
8620 }
8640 return 0;
8650 }
8660 else
8670 return 1;
8680 }
8690 else if (rhs_geom.has_components())
8700 return -1;
8720 if (lhs_geom.has_line_geometry())
8730 {
8740 if (rhs_geom.has_line_geometry())
8750 {
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)
8830 {
8840 if (lhs_comp[i] < rhs_comp[i])
8850 return -1;
8860 if (rhs_comp[i] < lhs_comp[i])
8870 return 1;
8880 }
8900 return 0;
8910 }
8920 else
8930 return -1;
8940 }
8950 else if (rhs_geom.has_line_geometry())
8960 return 1;
8980 if (lhs_geom.has_multiline_geometry())
8990 {
9000 if (rhs_geom.has_multiline_geometry())
9010 {
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)
9090 {
9100 if (lhs_comp[i].size() < rhs_comp[i].size())
9110 return -1;
9120 if (rhs_comp[i].size() < lhs_comp[i].size())
9130 return 1;
9150 for (uint j = 0; j < lhs_comp[i].size(); ++j)
9160 {
9170 if (lhs_comp[i][j] < rhs_comp[i][j])
9180 return -1;
9190 if (rhs_comp[i][j] < lhs_comp[i][j])
9200 return 1;
9210 }
9220 }
9240 return 0;
9250 }
9260 else
9270 return -1;
9280 }
9290 else if (rhs_geom.has_multiline_geometry())
9300 return 1;
9320 return 0;
9330}
936bool Derived_Structure_Handle::operator<(const Derived_Structure_Handle& rhs) const
937960393413 q{
938960393413 q if (center.lat < 100.)
9390 {
9400 if (rhs.center.lat < 100.)
9410 {
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;
9460 }
9470 else
9480 return true;
9490 }
950960393413 q else if (rhs.center.lat < 100.)
9510 return false;
953960393413 q if (elem->get_geometry())
9540 {
9550 if (rhs.elem->get_geometry())
9560 {
9570 int cmp = compare_geometry(*elem->get_geometry(), *rhs.elem->get_geometry());
9580 if (cmp < 0)
9590 return true;
9600 else if (cmp > 0)
9610 return false;
9620 }
9630 else
9640 return true;
9650 }
966960393413 q else if (rhs.elem->get_geometry())
9670 return false;
969960393413 q std::vector< std::pair< std::string, std::string > >::const_iterator it_tl = elem->tags.begin();
970960393413 q std::vector< std::pair< std::string, std::string > >::const_iterator it_tr = rhs.elem->tags.begin();
9712878540413 q while (it_tl != elem->tags.end() && it_tr != rhs.elem->tags.end())
9722878498213 q {
9732878498213 q if (*it_tl == *it_tr)
9741918147010 q {
9751918147010 q ++it_tl;
9761918147010 q ++it_tr;
9771918147010 q }
97896035128 q else if (it_tl->first == "_next" || it_tl->first == "_previous")
9790 ++it_tl;
98096035128 q else if (it_tr->first == "_next" || it_tr->first == "_previous")
9810 ++it_tr;
98296035128 q else if (*it_tl < *it_tr)
98370508616 q return true;
98425526515 q else
98525526515 q return false;
9862878498213 q }
98742210 q while (it_tl != elem->tags.end() && (it_tl->first == "_next" || it_tl->first == "_previous"))
9880 ++it_tl;
98942210 q while (it_tr != rhs.elem->tags.end() && (it_tr->first == "_next" || it_tr->first == "_previous"))
9900 ++it_tr;
99242210 q if (it_tr != rhs.elem->tags.end())
9930 return true;
99442210 q if (it_tl != elem->tags.end())
9950 return false;
99742210 q return false;
1001void Set_Comparison::compute_deriveds(std::map< Uint31_Index, std::vector< Derived_Structure > > rhs_deriveds)
100341676 q std::vector< Derived_Structure_Handle > lhs_handles;
100441676 q for (std::map< Uint31_Index, std::vector< Derived_Structure > >::const_iterator
100544976 q it_idx = lhs_set_.deriveds.begin(); it_idx != lhs_set_.deriveds.end(); ++it_idx)
10073313 q for (std::vector< Derived_Structure >::const_iterator it_elem = it_idx->second.begin();
100830113 q it_elem != it_idx->second.end(); ++it_elem)
100926813 q lhs_handles.push_back(Derived_Structure_Handle(it_idx->first, *it_elem));
101141676 q std::sort(lhs_handles.begin(), lhs_handles.end());
101341676 q std::vector< Derived_Structure_Handle > rhs_handles;
101441676 q for (std::map< Uint31_Index, std::vector< Derived_Structure > >::const_iterator
101544976 q it_idx = rhs_deriveds.begin(); it_idx != rhs_deriveds.end(); ++it_idx)
10173313 q for (std::vector< Derived_Structure >::const_iterator it_elem = it_idx->second.begin();
101832340813 q it_elem != it_idx->second.end(); ++it_elem)
101932337513 q rhs_handles.push_back(Derived_Structure_Handle(it_idx->first, *it_elem));
102141676 q std::sort(rhs_handles.begin(), rhs_handles.end());
102341676 q std::vector< Derived_Structure_Handle >::const_iterator it_lhs = lhs_handles.begin();
102441676 q std::vector< Derived_Structure_Handle >::const_iterator it_rhs = rhs_handles.begin();
102628207876 q while (it_lhs != lhs_handles.end() && it_rhs != rhs_handles.end())
102728166213 q {
102828166213 q if (*it_lhs < *it_rhs)
10291505 q {
10301505 q result.lhs_deriveds.push_back(*it_lhs->elem);
10311505 q ++it_lhs;
10321505 q }
103328151210 q else if (*it_rhs < *it_lhs)
10342813943 q {
10352813943 q result.rhs_deriveds.push_back(*it_rhs->elem);
10362813943 q ++it_rhs;
10372813943 q }
103811810 q else
104011810 q ++it_lhs;
104111810 q ++it_rhs;
104328166213 q }
104441676 q while (it_lhs != lhs_handles.end())
10450 {
10460 result.lhs_deriveds.push_back(*it_lhs->elem);
10470 ++it_lhs;
10480 }
10494227976 q while (it_rhs != rhs_handles.end())
1050418636 q {
1051418636 q result.rhs_deriveds.push_back(*it_rhs->elem);
1052418636 q ++it_rhs;
1053418636 q }
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)
106041676 q result.clear();
106241676 q uint64 rhs_timestamp = rman.get_desired_timestamp();
106341676 q rman.set_desired_timestamp(lhs_timestamp_);
106541676 q Extra_Data_For_Diff extra_data_lhs(rman, stmt, lhs_set_, Output_Mode::ID
106641676 q | Output_Mode::COORDS | Output_Mode::NDS | Output_Mode::MEMBERS
106741676 q | Output_Mode::TAGS | Output_Mode::VERSION | Output_Mode::META
106841676 q | Output_Mode::GEOMETRY, south, north, west, east);
107041676 q tags_quadtile(extra_data_lhs, lhs_set_.nodes, rman);
107141676 q if (rman.get_desired_timestamp() != NOW)
107241676 q tags_quadtile_attic(extra_data_lhs, lhs_set_.attic_nodes, rman);
107441676 q tags_quadtile(extra_data_lhs, lhs_set_.ways, rman);
107541676 q if (rman.get_desired_timestamp() != NOW)
107641676 q tags_quadtile_attic(extra_data_lhs, lhs_set_.attic_ways, rman);
107841676 q tags_quadtile(extra_data_lhs, lhs_set_.relations, rman);
107941676 q if (rman.get_desired_timestamp() != NOW)
108041676 q tags_quadtile_attic(extra_data_lhs, lhs_set_.attic_relations, rman);
108241676 q rman.set_desired_timestamp(rhs_timestamp);
108441676 q set_target(true);
108641676 q Extra_Data_For_Diff extra_data_rhs(rman, stmt, input_set, Output_Mode::ID
108741676 q | Output_Mode::COORDS | Output_Mode::NDS | Output_Mode::MEMBERS
108841676 q | Output_Mode::TAGS | Output_Mode::VERSION | Output_Mode::META
108941676 q | Output_Mode::GEOMETRY, south, north, west, east);
109141676 q tags_quadtile(extra_data_rhs, input_set.nodes, rman);
109241676 q if (rman.get_desired_timestamp() != NOW)
109310620 q tags_quadtile_attic(extra_data_rhs, input_set.attic_nodes, rman);
109441676 q clear_nodes(rman, add_deletion_information);
109641676 q tags_quadtile(extra_data_rhs, input_set.ways, rman);
109741676 q if (rman.get_desired_timestamp() != NOW)
109810620 q tags_quadtile_attic(extra_data_rhs, input_set.attic_ways, rman);
109941676 q clear_ways(rman, add_deletion_information);
110141676 q tags_quadtile(extra_data_rhs, input_set.relations, rman);
110241676 q if (rman.get_desired_timestamp() != NOW)
110310620 q tags_quadtile_attic(extra_data_rhs, input_set.attic_relations, rman);
110441676 q clear_relations(rman, add_deletion_information);
110641676 q compute_deriveds(input_set.deriveds);
110841676 q Diff_Set local_result;
110941676 q local_result.swap(result);
111041676 q return local_result;
1114template< typename A, typename B >
1115struct First_Comparator
1117 bool operator()(const std::pair< A, B >& lhs, const std::pair< A, B >& rhs)
1118177138 q {
1119177138 q return lhs.first < rhs.first;
1120177138 q }
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)
11289015 q for (typename std::map< Index, std::vector< Maybe_Attic > >::const_iterator it_idx = items.begin();
11291765015 q it_idx != items.end(); ++it_idx)
11301756011 q {
11311756011 q for (typename std::vector< Maybe_Attic >::const_iterator it_elem = it_idx->second.begin();
11321792511 q it_elem != it_idx->second.end(); ++it_elem)
11333658 q result.push_back(std::make_pair(
11343658 q it_elem->id, task.eval(into_context.get_context(it_idx->first, *it_elem), 0)));
11351756011 q }
11379015 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)
11469015 q for (typename std::map< Index, std::vector< Maybe_Attic > >::const_iterator it_idx = items.begin();
114777115 q it_idx != items.end(); ++it_idx)
11486819 q {
11496819 q for (typename std::vector< Maybe_Attic >::const_iterator it_elem = it_idx->second.begin();
115042989 q it_elem != it_idx->second.end(); ++it_elem)
115136178 q {
115236178 q std::string rhs_val = task.eval(into_context.get_context(it_idx->first, *it_elem), 0);
115336178 q typename std::vector< std::pair< Id_Type, std::string > >::iterator it_lhs =
115436178 q std::lower_bound(lhs_set.begin(), lhs_set.end(), std::make_pair(it_elem->id, ""),
115536178 q First_Comparator< Id_Type, std::string >());
115736178 q if (it_lhs == lhs_set.end() || !(it_lhs->first == it_elem->id))
115833525 q {
115933525 q if (!rhs_val.empty())
116030024 q result.push_back(it_elem->id);
116133525 q }
11622657 q else
11632657 q {
11642657 q if (rhs_val != it_lhs->second)
116522 q result.push_back(it_elem->id);
11672657 q it_lhs->second.clear();
11682657 q }
116936178 q }
11706819 q }
1174template< typename Id_Type >
1175void clear_elems(std::vector< std::pair< Id_Type, std::string > >& lhs_set, std::vector< Id_Type >& result)
11774515 q for (typename std::vector< std::pair< Id_Type, std::string > >::const_iterator it_lhs = lhs_set.begin();
117841015 q it_lhs != lhs_set.end(); ++it_lhs)
11793658 q {
11803658 q if (!it_lhs->second.empty())
1181343 q result.push_back(it_lhs->first);
11823658 q }
11844515 q lhs_set.clear();
11854515 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)
11929015 q for (typename std::map< Index, std::vector< Maybe_Attic > >::iterator it_idx = items.begin();
11931765015 q it_idx != items.end(); ++it_idx)
11941756011 q {
11951756011 q std::vector< Maybe_Attic > result;
11961756011 q for (typename std::vector< Maybe_Attic >::const_iterator it_elem = it_idx->second.begin();
11971792511 q it_elem != it_idx->second.end(); ++it_elem)
11983658 q {
11993658 q if (std::binary_search(id_list.begin(), id_list.end(), it_elem->id))
1200364 q result.push_back(*it_elem);
12013658 q }
12021756011 q result.swap(it_idx->second);
12031756011 q }
1207Diff_Set Set_Comparison::compare_to_lhs(Resource_Manager& rman, const Statement& stmt,
1208 const Set& input_set, Evaluator* evaluator, bool add_deletion_information)
12101515 q result.clear();
12121515 q uint64 rhs_timestamp = rman.get_desired_timestamp();
12131515 q rman.set_desired_timestamp(lhs_timestamp_);
12161515 q Requested_Context requested_context = evaluator->request_context();
12171515 q Prepare_Task_Context context(requested_context, stmt, rman);
12191515 q Owner< Eval_Task > task(evaluator->get_string_task(context, 0));
12211515 q Set_With_Context into_context;
12221515 q into_context.name = "";
12231515 q into_context.parent = &context;
12241515 q into_context.prefetch(requested_context.object_usage, lhs_set_, stmt, rman);
12261515 q if (task)
12281515 q node_values.clear();
12291515 q eval_lhs_elems(lhs_set_.nodes, node_values, into_context, *task);
12301515 q eval_lhs_elems(lhs_set_.attic_nodes, node_values, into_context, *task);
12321515 q way_values.clear();
12331515 q eval_lhs_elems(lhs_set_.ways, way_values, into_context, *task);
12341515 q eval_lhs_elems(lhs_set_.attic_ways, way_values, into_context, *task);
12361515 q relation_values.clear();
12371515 q eval_lhs_elems(lhs_set_.relations, relation_values, into_context, *task);
12381515 q eval_lhs_elems(lhs_set_.attic_relations, relation_values, into_context, *task);
12421515 q rman.set_desired_timestamp(rhs_timestamp);
12441515 q std::vector< Node_Skeleton::Id_Type > changed_nodes;
12451515 q std::vector< Way_Skeleton::Id_Type > changed_ways;
12461515 q std::vector< Relation_Skeleton::Id_Type > changed_relations;
12481515 q Requested_Context requested_context = evaluator->request_context();
12491515 q Prepare_Task_Context context(requested_context, stmt, rman);
12511515 q Owner< Eval_Task > task(evaluator->get_string_task(context, 0));
12531515 q Set_With_Context into_context;
12541515 q into_context.name = "";
12551515 q into_context.parent = &context;
12561515 q into_context.prefetch(requested_context.object_usage, input_set, stmt, rman);
12581515 q if (task)
12601515 q eval_rhs_elems(input_set.nodes, node_values, changed_nodes, into_context, *task);
12611515 q eval_rhs_elems(input_set.attic_nodes, node_values, changed_nodes, into_context, *task);
12621515 q clear_elems(node_values, changed_nodes);
12641515 q eval_rhs_elems(input_set.ways, way_values, changed_ways, into_context, *task);
12651515 q eval_rhs_elems(input_set.attic_ways, way_values, changed_ways, into_context, *task);
12661515 q clear_elems(way_values, changed_ways);
12681515 q eval_rhs_elems(input_set.relations, relation_values, changed_relations, into_context, *task);
12691515 q eval_rhs_elems(input_set.attic_relations, relation_values, changed_relations, into_context, *task);
12701515 q clear_elems(relation_values, changed_relations);
12741515 q rman.set_desired_timestamp(lhs_timestamp_);
12761515 q filter_by_id(lhs_set_.nodes, changed_nodes);
12771515 q filter_by_id(lhs_set_.attic_nodes, changed_nodes);
12781515 q filter_by_id(lhs_set_.ways, changed_ways);
12791515 q filter_by_id(lhs_set_.attic_ways, changed_ways);
12801515 q filter_by_id(lhs_set_.relations, changed_relations);
12811515 q filter_by_id(lhs_set_.attic_relations, changed_relations);
12831515 q Extra_Data_For_Diff extra_data_lhs(rman, stmt, lhs_set_, Output_Mode::ID
12841515 q | Output_Mode::COORDS | Output_Mode::NDS | Output_Mode::MEMBERS
12851515 q | Output_Mode::TAGS | Output_Mode::VERSION | Output_Mode::META
12861515 q | Output_Mode::GEOMETRY, 1., 0., 0., 0.);
12881515 q tags_quadtile(extra_data_lhs, lhs_set_.nodes, changed_nodes, rman);
12891515 q if (rman.get_desired_timestamp() != NOW)
12901515 q tags_quadtile_attic(extra_data_lhs, lhs_set_.attic_nodes, changed_nodes, rman);
12921515 q tags_quadtile(extra_data_lhs, lhs_set_.ways, changed_ways, rman);
12931515 q if (rman.get_desired_timestamp() != NOW)
12941515 q tags_quadtile_attic(extra_data_lhs, lhs_set_.attic_ways, changed_ways, rman);
12961515 q tags_quadtile(extra_data_lhs, lhs_set_.relations, changed_relations, rman);
12971515 q if (rman.get_desired_timestamp() != NOW)
12981515 q tags_quadtile_attic(extra_data_lhs, lhs_set_.attic_relations, changed_relations, rman);
13001515 q rman.set_desired_timestamp(rhs_timestamp);
13021515 q set_target(true);
13041515 q Extra_Data_For_Diff extra_data_rhs(rman, stmt, input_set, Output_Mode::ID
13051515 q | Output_Mode::COORDS | Output_Mode::NDS | Output_Mode::MEMBERS
13061515 q | Output_Mode::TAGS | Output_Mode::VERSION | Output_Mode::META
13071515 q | Output_Mode::GEOMETRY, 1., 0., 0., 0.);
13091515 q tags_quadtile(extra_data_rhs, input_set.nodes, changed_nodes, rman);
13101515 q if (rman.get_desired_timestamp() != NOW)
131166 q tags_quadtile_attic(extra_data_rhs, input_set.attic_nodes, changed_nodes, rman);
13121515 q clear_nodes(rman, add_deletion_information);
13141515 q tags_quadtile(extra_data_rhs, input_set.ways, changed_ways, rman);
13151515 q if (rman.get_desired_timestamp() != NOW)
131666 q tags_quadtile_attic(extra_data_rhs, input_set.attic_ways, changed_ways, rman);
13171515 q clear_ways(rman, add_deletion_information);
13191515 q tags_quadtile(extra_data_rhs, input_set.relations, changed_relations, rman);
13201515 q if (rman.get_desired_timestamp() != NOW)
132166 q tags_quadtile_attic(extra_data_rhs, input_set.attic_relations, changed_relations, rman);
13221515 q clear_relations(rman, add_deletion_information);
13241515 q Diff_Set local_result;
13251515 q local_result.swap(result);
13261515 q return local_result;