/home/martin/workspace/OpenStreetNav/src/elements/Node.cpp
Go to the documentation of this file.
00001 /*
00002  * Node.cpp
00003  *
00004  *  Created on: Nov 5, 2011
00005  *      Author: martin
00006  */
00007 
00008 #include "Node.h"
00009 #include "../util.h"
00010 #include "../osmdb/osmdb.h"
00011 
00012 namespace osm
00013 {
00014 
00015 Node::Node()
00016 {
00017 }
00018 
00019 Node::Node(int64_t id, double lat, double lon):
00020     id(id),
00021     position(lat, lon)
00022 {
00023 }
00024 
00025 Node::~Node()
00026 {
00027 }
00028 
00029 bool Node::operator==(const Node& other) const
00030 {
00031     return id == other.id && position == other.position && tags == other.tags;
00032 }
00033 
00034 boost::property_tree::ptree Node::get_description()
00035 {
00036     boost::property_tree::ptree ret;
00037     boost::property_tree::ptree node;
00038     node.data() = util::to_str(id);
00039     boost::property_tree::ptree tags_desc;
00040     for (auto it = tags.begin(); it != tags.end(); ++it)
00041     {
00042         tags_desc.push_back(*it);
00043     }
00044     node.put_child("tags", tags_desc);
00045     ret.put_child("node", node);
00046     return ret;
00047 }
00048 
00049 void Node::fill(osmdb::PropertiesSelection& db)
00050 {
00051     auto p = db.get_position(id);
00052     position = p;
00053     tags = db.get_node_tags(id);
00054 }
00055 
00056 void Node::add_to_relation(osmdb::ElementImporter& db, int64_t relation, const std::string& role)
00057 {
00058     db.insert_member_node(relation, role, id);
00059 }
00060 
00061 osm::ObjectType Node::get_type() const
00062 {
00063     return osm::ObjectType::Node;
00064 }
00065 
00066 bool Node::operator !=(const Node& other) const
00067 {
00068     return !(*this == other);
00069 }
00070 
00071 int64_t Node::get_id() const
00072 {
00073     return id;
00074 }
00075 
00076 }
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines