/home/martin/workspace/OpenStreetNav/src/osmdb/PropertiesSelection.h
Go to the documentation of this file.
00001 /*
00002  * PropertiesSelection.h
00003  *
00004  *  Created on: Jan 1, 2012
00005  *      Author: martin
00006  */
00007 
00008 #ifndef PROPERTIESSELECTION_H_
00009 #define PROPERTIESSELECTION_H_
00010 
00011 #include "../psql/psql.h"
00012 #include "OsmDatabase.h"
00013 
00014 namespace osmdb
00015 {
00016 
00021 class PropertiesSelection
00022 {
00023 public:
00024     PropertiesSelection(OsmDatabase& db);
00025     std::set<std::pair<std::string, std::string> > get_node_tags(int64_t id);
00026     std::set<std::pair<std::string, std::string> > get_way_tags(int64_t id);
00027     std::set<std::pair<std::string, std::string> > get_relation_tags(int64_t id);
00028     std::vector<int64_t> get_waynodes(int64_t way_id);
00029     std::multimap<std::string, int64_t> get_node_members(int64_t rel_id);
00030     std::multimap<std::string, int64_t> get_way_members(int64_t rel_id);
00031     std::multimap<std::string, int64_t> get_relation_members(int64_t rel_id);
00032     geo::Point get_position(int64_t node_id);
00033     virtual ~PropertiesSelection();
00034 private:
00035     OsmDatabase& db;
00036     psql::Statement<psql::BindTypes<int64_t>, psql::RetTypes<std::string, std::string> > get_node_attrs_st;
00037     psql::Statement<psql::BindTypes<int64_t>, psql::RetTypes<std::string, std::string> > get_way_attrs_st;
00038     psql::Statement<psql::BindTypes<int64_t>, psql::RetTypes<std::string, std::string> > get_rel_attrs_st;
00039     psql::Statement<psql::BindTypes<int64_t>, psql::RetTypes<int64_t> > get_waynodes_st;
00040     psql::Statement<psql::BindTypes<int64_t>, psql::RetTypes<std::string, int64_t> > get_node_members_st;
00041     psql::Statement<psql::BindTypes<int64_t>, psql::RetTypes<std::string, int64_t> > get_way_members_st;
00042     psql::Statement<psql::BindTypes<int64_t>, psql::RetTypes<std::string, int64_t> > get_rel_members_st;
00043     psql::Statement<psql::BindTypes<int64_t>, psql::RetTypes<double, double> > get_node_pos_st;
00044     template <typename Cont, typename K, typename V, typename... Args>
00045     Cont get_multimap(psql::Statement<psql::BindTypes<Args...>, psql::RetTypes<K, V> >& st, Args... a)
00046     {
00047         st.execute(a...);
00048         Cont ret;
00049         for (int i = 0; i < st.row_count(); ++i)
00050         {
00051             auto const& r = st.get_row(i);
00052             ret.insert(std::make_pair(std::get<0>(r), std::get<1>(r)));
00053         }
00054         return ret;
00055     }
00056 
00057 };
00058 
00059 } /* namespace osmdb */
00060 #endif /* PROPERTIESSELECTION_H_ */
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines