Overpass API regression suite coverage (Saxony) / overpass_api/statements/map_to_area.cc
overpass_api/statements/map_to_area.cc
104 of 104 instrumented lines run by the suite (100.0%) 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. 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 "../../template_db/block_backend.h" 20#include "../data/collect_members.h" 21#include "map_to_area.h" 24Generic_Statement_Maker< Map_To_Area_Statement > Map_To_Area_Statement::statement_maker("map-to-area"); 26bool Map_To_Area_Statement::is_used_ = false; 28Map_To_Area_Statement::Map_To_Area_Statement 29 (int line_number_, const std::map< std::string, std::string >& input_attributes, Parsed_Query& global_settings) 305418 q : Output_Statement(line_number_) 345418 q std::map< std::string, std::string > attributes; 365418 q attributes["from"] = "_"; 375418 q attributes["into"] = "_"; 395418 q eval_attributes_array(get_name(), attributes, input_attributes); 415418 q input = attributes["from"]; 425418 q set_output(attributes["into"]); 46std::vector< Area_Skeleton::Id_Type > get_area_ids_for_ways(const std::map< Uint31_Index, std::vector< Way_Skeleton > >& ways) 481817 q std::vector<Area::Id_Type> area_ids; 491817 q for (std::map<Uint31_Index, std::vector<Way_Skeleton> >::const_iterator it = 50148217 q ways.begin(); it != ways.end(); ++it) 5214649 q for (std::vector<Way_Skeleton>::const_iterator sit = it->second.begin(); 531081099 q sit != it->second.end(); ++sit) 551066458 q area_ids.push_back(sit->id.val() + 2400000000u); 62std::vector< Area_Skeleton::Id_Type > get_area_ids_for_attic_ways(const std::map< Uint31_Index, std::vector< Attic< Way_Skeleton > > >& attic_ways) 641817 q std::vector<Area::Id_Type> area_ids; 651817 q for (std::map<Uint31_Index, std::vector<Attic<Way_Skeleton> > >::const_iterator it = 666117 q attic_ways.begin(); it != attic_ways.end(); ++it) 68434 q for (std::vector<Attic<Way_Skeleton> >::const_iterator sit = it->second.begin(); 691724 q sit != it->second.end(); ++sit) 711294 q area_ids.push_back(sit->id.val() + 2400000000u); 78std::vector< Area_Skeleton::Id_Type > get_area_ids_for_relations(const std::map< Uint31_Index, std::vector< Relation_Skeleton > >& rels) 801817 q std::vector<Area::Id_Type> area_ids; 811817 q for (std::map<Uint31_Index, std::vector<Relation_Skeleton> >::const_iterator it = 8256417 q rels.begin(); it != rels.end(); ++it) 845467 q for (std::vector<Relation_Skeleton>::const_iterator sit = it->second.begin(); 8525227 q sit != it->second.end(); ++sit) 8719766 q area_ids.push_back(sit->id.val() + 3600000000u); 94std::vector< Area_Skeleton::Id_Type > get_area_ids_for_attic_relations(const std::map< Uint31_Index, std::vector< Attic< Relation_Skeleton > > >& attic_rels) 961817 q std::vector<Area::Id_Type> area_ids; 971817 q for (std::map<Uint31_Index, std::vector<Attic<Relation_Skeleton> > >::const_iterator it = 982077417 q attic_rels.begin(); it != attic_rels.end(); ++it) 100207563 q for (std::vector<Attic<Relation_Skeleton> >::const_iterator sit = 101208473 q it->second.begin(); sit != it->second.end(); ++sit) 103912 q area_ids.push_back(sit->id.val() + 3600000000u); 110void collect_elems_flat(Resource_Manager& rman, 111 const std::vector< Area_Skeleton::Id_Type >& ids, 112 std::map< Uint31_Index, std::vector< Area_Skeleton > >& elems) 1171312 q std::vector<Area_Skeleton::Id_Type>::const_iterator lower = min_element(ids.begin(), ids.end()); 1181312 q std::vector<Area_Skeleton::Id_Type>::const_iterator upper = max_element(ids.begin(), ids.end()); 1201312 q Block_Backend< Uint31_Index, Area_Skeleton > elems_db 1211312 q (rman.get_transaction()->data_index(area_settings().AREAS)); 1221312 q for (Block_Backend< Uint31_Index, Area_Skeleton >::Flat_Iterator 1239131212 q it = elems_db.flat_begin(); !(it == elems_db.flat_end()); ++it) 1259129912 q if (!(it.object().id < (*lower).val()) && it.object().id < ((*upper).val() + 1) && 1269129912 q binary_search(ids.begin(), ids.end(), it.object().id)) 1282876 q elems[it.index()].push_back(it.object()); 133void Map_To_Area_Statement::execute(Resource_Manager& rman) 1361918 q std::vector< Area_Skeleton::Id_Type > idx; 1381918 q const Set* input_set = rman.get_set(input); 1411817 q std::vector< Area_Skeleton::Id_Type > ways_idx = get_area_ids_for_ways(input_set->ways); 1421817 q std::vector< Area_Skeleton::Id_Type > rels_idx = get_area_ids_for_relations(input_set->relations); 1431817 q std::vector< Area_Skeleton::Id_Type > attic_ways_idx = get_area_ids_for_attic_ways(input_set->attic_ways); 1441817 q std::vector< Area_Skeleton::Id_Type > attic_rels_idx = get_area_ids_for_attic_relations(input_set->attic_relations); 1461817 q idx.insert(idx.end(), ways_idx.begin(), ways_idx.end()); 1471817 q idx.insert(idx.end(), rels_idx.begin(), rels_idx.end()); 1481817 q idx.insert(idx.end(), attic_ways_idx.begin(), attic_ways_idx.end()); 1491817 q idx.insert(idx.end(), attic_rels_idx.begin(), attic_rels_idx.end()); 1511817 q sort(idx.begin(), idx.end()); 1521817 q idx.erase(unique(idx.begin(), idx.end()), idx.end()); 1541817 q into.ways = input_set->ways; 1551817 q filter_elems_for_closed_ways(into.ways); 1561817 q into.attic_ways = input_set->attic_ways; 1571817 q filter_elems_for_closed_ways(into.attic_ways); 1601918 q collect_elems_flat(rman, idx, into.areas); 1621918 q transfer_output(rman, into); 1631918 q rman.health_check(*this);