Overpass API regression suite coverage (Nova Scotia) / overpass_api/statements/id_query.cc
overpass_api/statements/id_query.cc
201 of 227 instrumented lines run by the suite (88.5%) 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 "../../template_db/block_backend.h"20#include "../../template_db/random_file.h"21#include "../core/settings.h"22#include "../data/abstract_processing.h"23#include "../data/collect_members.h"24#include "../data/filenames.h"25#include "id_query.h"27#include <sstream>30bool Id_Query_Statement::area_query_exists_ = false;33Id_Query_Statement::Statement_Maker Id_Query_Statement::statement_maker;34Id_Query_Statement::Criterion_Maker Id_Query_Statement::criterion_maker;37Statement* Id_Query_Statement::Criterion_Maker::create_criterion(const Token_Node_Ptr& input_tree,38 const std::string& result_type, const std::string& into,39 Statement::Factory& stmt_factory, Parsed_Query& global_settings, Error_Output* error_output)59408100 q if (result_type != "nwr" && result_type != "nw" && result_type != "wr" && result_type != "nr")77void collect_elems_flat(Resource_Manager& rman,78 const std::vector< uint64 >& ids,79 std::map< Uint31_Index, std::vector< Area_Skeleton > >& elems)92template< class TIndex, class TObject >93void filter_elems(const std::vector< uint64 > & ids,94 std::map< TIndex, std::vector< TObject > >& elems)111template< typename Id_Type >112std::vector< Id_Type > filtered_assign(const std::vector< uint64 >& arg)125//-----------------------------------------------------------------------------128class Id_Query_Constraint : public Query_Constraint129{130 public:135 bool get_ranges(Resource_Manager& rman, Ranges< Uint32_Index >& ranges);136 bool get_ranges(Resource_Manager& rman, Ranges< Uint31_Index >& ranges);138 bool get_node_ids139 (Resource_Manager& rman, std::vector< Node_Skeleton::Id_Type >& ids);140 bool get_way_ids141 (Resource_Manager& rman, std::vector< Way_Skeleton::Id_Type >& ids);142 bool get_relation_ids143 (Resource_Manager& rman, std::vector< Relation_Skeleton::Id_Type >& ids);144 bool get_area_ids145 (Resource_Manager& rman, std::vector< Area_Skeleton::Id_Type >& ids);147 void filter(Resource_Manager& rman, Set& into);150 private:151 Id_Query_Statement* stmt;152};155bool Id_Query_Constraint::get_node_ids(Resource_Manager& rman, std::vector< Node_Skeleton::Id_Type >& ids)162bool Id_Query_Constraint::get_way_ids(Resource_Manager& rman, std::vector< Way_Skeleton::Id_Type >& ids)169bool Id_Query_Constraint::get_relation_ids(Resource_Manager& rman, std::vector< Relation_Skeleton::Id_Type >& ids)176bool Id_Query_Constraint::get_area_ids(Resource_Manager& rman, std::vector< Area_Skeleton::Id_Type >& ids)183bool Id_Query_Constraint::get_ranges(Resource_Manager& rman, Ranges< Uint32_Index >& ranges)18588 q std::vector< Node_Skeleton::Id_Type > ids = filtered_assign< Node_Skeleton::Id_Type >(stmt->get_refs());197bool Id_Query_Constraint::get_ranges(Resource_Manager& rman, Ranges< Uint31_Index >& ranges)2031311 q std::vector< Way_Skeleton::Id_Type > ids = filtered_assign< Way_Skeleton::Id_Type >(stmt->get_refs());2101311 q std::vector< Relation_Skeleton::Id_Type > ids = filtered_assign< Relation_Skeleton::Id_Type >(stmt->get_refs());222void Id_Query_Constraint::filter(Resource_Manager& rman, Set& into)236//-----------------------------------------------------------------------------238Id_Query_Statement::Id_Query_Statement239 (int line_number_, const std::map< std::string, std::string >& input_attributes, Parsed_Query& global_settings)330// Nach "data" verschieben ---------------------------333template< typename Id_Type >334struct Id_Pair_First_Comparator335{336 bool operator()(const std::pair< Id_Type, uint64 >& lhs,337 const std::pair< Id_Type, uint64 >& rhs) const338 {339 return (lhs.first < rhs.first);340 }341};344template< typename Id_Type >345struct Id_Pair_Full_Comparator346{347 bool operator()(const std::pair< Id_Type, uint64 >& lhs,348 const std::pair< Id_Type, uint64 >& rhs) const349 {350 if (lhs.first < rhs.first)351 return true;352 if (rhs.first < lhs.first)353 return false;354 return (lhs.second < rhs.second);355 }356};359template< typename Index, typename Skeleton >360struct Attic_Skeleton_By_Id361{362 Attic_Skeleton_By_Id(const typename Skeleton::Id_Type& id_, uint64 timestamp_)363 : id(id_), timestamp(timestamp_), index(0u), meta_confirmed(false),364 elem(Skeleton(), 0xffffffffffffffffull) {}366 typename Skeleton::Id_Type id;367 uint64 timestamp;368 Index index;369 bool meta_confirmed;370 Attic< Skeleton > elem;372 bool operator<(const Attic_Skeleton_By_Id& rhs) const373 {374 if (id < rhs.id)375 return true;376 if (rhs.id < id)377 return false;378 return (rhs.timestamp < timestamp);379 }380};383template< typename Index, typename Skeleton >384void get_elements(const std::vector< uint64 >& refs, Statement* stmt, Resource_Manager& rman,385 std::map< Index, std::vector< Skeleton > >& current_result,386 std::map< Index, std::vector< Attic< Skeleton > > >& attic_result)3888972 q std::vector< typename Skeleton::Id_Type > ids = filtered_assign< typename Skeleton::Id_Type >(refs);3928972 q collect_items_discrete(context, req, Id_Predicate< Skeleton >(ids), current_result, attic_result);399void Id_Query_Statement::execute(Resource_Manager& rman)420Id_Query_Statement::~Id_Query_Statement()428Query_Constraint* Id_Query_Statement::get_query_constraint()