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