Overpass API regression suite coverage (Saxony) / overpass_api/statements/pivot.cc
overpass_api/statements/pivot.cc
144 of 204 instrumented lines run by the suite (70.6%) 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 modify6 * it under the terms of the GNU Affero General Public License as7 * published by the Free Software Foundation, either version 3 of the8 * 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 of12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * GNU General Public License for more details.14 *15 * You should have received a copy of the GNU Affero General Public License16 * along with Overpass_API. If not, see <http://www.gnu.org/licenses/>.17 */19#include <sstream>21#include "../../template_db/block_backend.h"22#include "../../template_db/random_file.h"23#include "../core/settings.h"24#include "../data/abstract_processing.h"25#include "../data/collect_members.h"26#include "pivot.h"27#include "query.h"30Pivot_Statement::Statement_Maker Pivot_Statement::statement_maker;31Pivot_Statement::Criterion_Maker Pivot_Statement::criterion_maker;34Statement* Pivot_Statement::Criterion_Maker::create_criterion(const Token_Node_Ptr& tree_it,35 const std::string& type, const std::string& into,36 Statement::Factory& stmt_factory, Parsed_Query& global_settings, Error_Output* error_output)50template< class TIndex, class TObject >51void collect_elems(Resource_Manager& rman, const File_Properties& prop,52 const std::vector< typename TObject::Id_Type >& ids,53 std::map< TIndex, std::vector< TObject > >& elems)57126 q Random_File< typename TObject::Id_Type, TIndex > random(rman.get_transaction()->random_index(&prop));65133406 q for (auto it = elems_db.discrete_begin(req.begin(), req.end()); !(it == elems_db.discrete_end()); ++it)73template< class TIndex, class TObject >74void filter_elems(const std::vector< typename TObject::Id_Type >& ids,75 std::map< TIndex, std::vector< TObject > >& elems)76{77 for (typename std::map< TIndex, std::vector< TObject > >::iterator it = elems.begin();78 it != elems.end(); ++it)79 {80 std::vector< TObject > local_into;81 for (typename std::vector< TObject >::const_iterator iit = it->second.begin();82 iit != it->second.end(); ++iit)83 {84 if (binary_search(ids.begin(), ids.end(), iit->id))85 local_into.push_back(*iit);86 }87 it->second.swap(local_into);88 }89}92std::vector< Node::Id_Type > get_node_pivot_ids(const std::map< Uint31_Index, std::vector< Area_Skeleton > >& areas)9596 q for (std::map< Uint31_Index, std::vector< Area_Skeleton > >::const_iterator it = areas.begin();9862575 q for (std::vector< Area_Skeleton >::const_iterator sit = it->second.begin(); sit != it->second.end(); ++sit)109std::vector< Way::Id_Type > get_way_pivot_ids(const std::map< Uint31_Index, std::vector< Area_Skeleton > >& areas)11296 q for (std::map< Uint31_Index, std::vector< Area_Skeleton > >::const_iterator it = areas.begin();11562575 q for (std::vector< Area_Skeleton >::const_iterator sit = it->second.begin(); sit != it->second.end(); ++sit)126std::vector< Relation::Id_Type > get_relation_pivot_ids(const std::map< Uint31_Index, std::vector< Area_Skeleton > >& areas)129126 q for (std::map< Uint31_Index, std::vector< Area_Skeleton > >::const_iterator it = areas.begin();13262665 q for (std::vector< Area_Skeleton >::const_iterator sit = it->second.begin(); sit != it->second.end(); ++sit)143//-----------------------------------------------------------------------------146class Pivot_Constraint : public Query_Constraint147{148 public:153 virtual bool get_data(const Statement& query, Resource_Manager& rman, Set& into,154 const Ranges< Uint32_Index >& ranges,155 const std::vector< Node::Id_Type >& ids,156 bool invert_ids);157 virtual bool get_data(const Statement& query, Resource_Manager& rman, Set& into,158 const Ranges< Uint31_Index >& ranges,159 int type,160 const std::vector< Uint32_Index >& ids,161 bool invert_ids);162 void filter(Resource_Manager& rman, Set& into);165 private:166 Pivot_Statement* stmt;167};170bool Pivot_Constraint::get_data171 (const Statement& query, Resource_Manager& rman, Set& into,172 const Ranges< Uint32_Index >& ranges,173 const std::vector< Node_Skeleton::Id_Type >& ids,174 bool invert_ids)199bool Pivot_Constraint::get_data200 (const Statement& query, Resource_Manager& rman, Set& into,201 const Ranges< Uint31_Index >& ranges,202 int type,203 const std::vector< Uint32_Index >& ids,204 bool invert_ids)257void Pivot_Constraint::filter(Resource_Manager& rman, Set& into)290//-----------------------------------------------------------------------------292Pivot_Statement::Pivot_Statement293 (int line_number_, const std::map< std::string, std::string >& input_attributes, Parsed_Query& global_settings)308void Pivot_Statement::execute(Resource_Manager& rman)3150 collect_elems(rman, *osm_base_settings().NODES, get_node_pivot_ids(input_set->areas), into.nodes);3160 collect_elems(rman, *osm_base_settings().WAYS, get_way_pivot_ids(input_set->areas), into.ways);3190 collect_elems(rman, *osm_base_settings().RELATIONS, get_relation_pivot_ids(input_set->areas), into.relations);327Pivot_Statement::~Pivot_Statement()335Query_Constraint* Pivot_Statement::get_query_constraint()