Overpass API regression suite coverage (Nova Scotia) / 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) 304514 q : Output_Statement(line_number_) 344514 q std::map< std::string, std::string > attributes; 364514 q attributes["from"] = "_"; 374514 q attributes["into"] = "_"; 394514 q eval_attributes_array(get_name(), attributes, input_attributes); 414514 q input = attributes["from"]; 424514 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) 481413 q std::vector<Area::Id_Type> area_ids; 491413 q for (std::map<Uint31_Index, std::vector<Way_Skeleton> >::const_iterator it = 50391813 q ways.begin(); it != ways.end(); ++it) 5239048 q for (std::vector<Way_Skeleton>::const_iterator sit = it->second.begin(); 53115558 q sit != it->second.end(); ++sit) 5576517 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) 641413 q std::vector<Area::Id_Type> area_ids; 651413 q for (std::map<Uint31_Index, std::vector<Attic<Way_Skeleton> > >::const_iterator it = 661813 q attic_ways.begin(); it != attic_ways.end(); ++it) 6842 q for (std::vector<Attic<Way_Skeleton> >::const_iterator sit = it->second.begin(); 6982 q sit != it->second.end(); ++sit) 7142 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) 801413 q std::vector<Area::Id_Type> area_ids; 811413 q for (std::map<Uint31_Index, std::vector<Relation_Skeleton> >::const_iterator it = 8282513 q rels.begin(); it != rels.end(); ++it) 848116 q for (std::vector<Relation_Skeleton>::const_iterator sit = it->second.begin(); 8539316 q sit != it->second.end(); ++sit) 8731205 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) 961413 q std::vector<Area::Id_Type> area_ids; 971413 q for (std::map<Uint31_Index, std::vector<Attic<Relation_Skeleton> > >::const_iterator it = 983613 q attic_rels.begin(); it != attic_rels.end(); ++it) 100222 q for (std::vector<Attic<Relation_Skeleton> >::const_iterator sit = 101232 q it->second.begin(); sit != it->second.end(); ++sit) 10311 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) 117109 q std::vector<Area_Skeleton::Id_Type>::const_iterator lower = min_element(ids.begin(), ids.end()); 118109 q std::vector<Area_Skeleton::Id_Type>::const_iterator upper = max_element(ids.begin(), ids.end()); 120109 q Block_Backend< Uint31_Index, Area_Skeleton > elems_db 121109 q (rman.get_transaction()->data_index(area_settings().AREAS)); 122109 q for (Block_Backend< Uint31_Index, Area_Skeleton >::Flat_Iterator 123780509 q it = elems_db.flat_begin(); !(it == elems_db.flat_end()); ++it) 125780409 q if (!(it.object().id < (*lower).val()) && it.object().id < ((*upper).val() + 1) && 126780409 q binary_search(ids.begin(), ids.end(), it.object().id)) 12830055 q elems[it.index()].push_back(it.object()); 133void Map_To_Area_Statement::execute(Resource_Manager& rman) 1361514 q std::vector< Area_Skeleton::Id_Type > idx; 1381514 q const Set* input_set = rman.get_set(input); 1411413 q std::vector< Area_Skeleton::Id_Type > ways_idx = get_area_ids_for_ways(input_set->ways); 1421413 q std::vector< Area_Skeleton::Id_Type > rels_idx = get_area_ids_for_relations(input_set->relations); 1431413 q std::vector< Area_Skeleton::Id_Type > attic_ways_idx = get_area_ids_for_attic_ways(input_set->attic_ways); 1441413 q std::vector< Area_Skeleton::Id_Type > attic_rels_idx = get_area_ids_for_attic_relations(input_set->attic_relations); 1461413 q idx.insert(idx.end(), ways_idx.begin(), ways_idx.end()); 1471413 q idx.insert(idx.end(), rels_idx.begin(), rels_idx.end()); 1481413 q idx.insert(idx.end(), attic_ways_idx.begin(), attic_ways_idx.end()); 1491413 q idx.insert(idx.end(), attic_rels_idx.begin(), attic_rels_idx.end()); 1511413 q sort(idx.begin(), idx.end()); 1521413 q idx.erase(unique(idx.begin(), idx.end()), idx.end()); 1541413 q into.ways = input_set->ways; 1551413 q filter_elems_for_closed_ways(into.ways); 1561413 q into.attic_ways = input_set->attic_ways; 1571413 q filter_elems_for_closed_ways(into.attic_ways); 1601514 q collect_elems_flat(rman, idx, into.areas); 1621514 q transfer_output(rman, into); 1631514 q rman.health_check(*this);