IN2OSM  1.0.1
OSM Namespace Reference

Functions

template<class T1 >
T1 matching_id (std::vector< T1 > &a, string b)
 
string Read_tag (string input)
 
CONVERTER::Poscompute2DPolygonCentroid (const std::vector< CONVERTER::Pos *> vertices, int vertexCount)
 
bool Cellspace_check (std::vector< CONVERTER::IC *>input)
 
std::vector< CONVERTER::IC * > Read (std::string PATH)
 
template<class T1 >
T1 matching_id (std::vector< T1 > &a, int b)
 
char * Read_tag (char *input)
 
std::vector< std::string > split (std::string &strToSplit, char delimeter)
 
std::string trim (const std::string &str)
 using because of IndoorGML Description More...
 
std::string Write_tag (std::string &input)
 
void Write (std::vector< CONVERTER::IC *>IC_vector, std::string PATH)
 

Function Documentation

◆ Cellspace_check()

bool Cellspace_check ( std::vector< CONVERTER::IC *>  input)

Definition at line 72 of file OSM_Reader.cpp.

72  {
73  bool result=false;
74  if(input.front()->osm_id==input.back()->osm_id){
75  result=true;
76  }
77  return result;
78  }
Here is the caller graph for this function:

◆ compute2DPolygonCentroid()

CONVERTER::Pos * compute2DPolygonCentroid ( const std::vector< CONVERTER::Pos *>  vertices,
int  vertexCount 
)

Definition at line 30 of file OSM_Reader.cpp.

30  {
31  CONVERTER::Point2D centroid= {0,0};
32  CONVERTER::Pos * output=new CONVERTER::Pos();
33  double signedArea = 0.0;
34  double x0 = 0.0; // Current vertex X
35  double y0 = 0.0; // Current vertex Y
36  double x1 = 0.0; // Next vertex X
37  double y1 = 0.0; // Next vertex Y
38  double a = 0.0; // Partial signed area
39 
40  // For all vertices except last
41  int i=0;
42  for (i=0; i<vertexCount-1; ++i) {
43  x0 = stod(vertices[i]->longitude);
44  y0 = stod(vertices[i]->latitude);
45  x1 = stod(vertices[i+1]->longitude);
46  y1 = stod(vertices[i+1]->latitude);
47  a = x0*y1 - x1*y0;
48  signedArea += a;
49  centroid.x += (x0 + x1)*a;
50  centroid.y += (y0 + y1)*a;
51  }
52  // Do last vertex separately to avoid performing an expensive
53  // modulus operation in each iteration.
54  x0 = stod(vertices[i]->longitude);
55  y0 = stod(vertices[i]->latitude);
56  x1 = stod(vertices[0]->longitude);
57  y1 = stod(vertices[0]->latitude);
58  a = x0*y1 - x1*y0;
59  signedArea += a;
60  centroid.x += (x0 + x1)*a;
61  centroid.y += (y0 + y1)*a;
62 
63  signedArea *= 0.5;
64  centroid.x /= (6.0*signedArea);
65  centroid.y /= (6.0*signedArea);
66 
67  output->longitude=to_string(centroid.x);
68  output->latitude=to_string(centroid.y);
69  return output;
70  }
std::string longitude
Definition: Transform.h:64
std::string latitude
Definition: Transform.h:63
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition: pointer.h:1181
Pos class in IndoorGML, Node in OSM latitude in OSM and IndoorGML longitude in OSM and IndoorGML h...
Definition: Transform.h:61

◆ matching_id() [1/2]

T1 OSM::matching_id ( std::vector< T1 > &  a,
string  b 
)

Definition at line 14 of file OSM_Reader.cpp.

14  {
15  T1 result=NULL;
16  for(auto iter=a.begin();iter!=a.end();++iter){
17  if(b.compare((*iter)->osm_id)==0){
18  result=*iter;
19  }
20  }
21  return result;
22  }
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition: pointer.h:1181
Here is the caller graph for this function:

◆ matching_id() [2/2]

T1 OSM::matching_id ( std::vector< T1 > &  a,
int  b 
)
Template Parameters
T1
Parameters
a- vector<IC*> IC vector
b- OSM id(Node, Way, Relation)
Returns
- IC*

◆ Read()

std::vector< CONVERTER::IC * > Read ( std::string  path)
Parameters
path- input OSM data
Returns
- IC *

Definition at line 80 of file OSM_Reader.cpp.

80  {
81  vector <CONVERTER::CellSpace*> CellSpace_vector;
82  vector <CONVERTER::CellSpaceBoundary*>CellSpaceBoundary_vector;
83  vector <CONVERTER::State*>State_vector;
84  vector <CONVERTER::Transition*>Transition_vector;
85  vector <CONVERTER::Pos*> node_vector;
86  vector <CONVERTER::IC*> IC_vector;
87  cout << "OSM to ..."<<endl ;
88  xml_document<> doc;//input
89  xml_node<> * root_node;
90  ifstream theFile (PATH);
91  vector<char> buffer((istreambuf_iterator<char>(theFile)), istreambuf_iterator<char>());
92  buffer.push_back('\0');
93  doc.parse<0>(&buffer[0]);
94  root_node = doc.first_node("osm");
95 
96  for (xml_node<> * xml_node = root_node->first_node("node"); xml_node; xml_node = xml_node->next_sibling("node")) {
97  if(xml_node->first_attribute("action")!=NULL)
98  if(strcmp(xml_node->first_attribute("action")->value(),"delete")==0)continue;
99  CONVERTER::Pos *node_input = new CONVERTER::Pos();
100  std::string osm_str(xml_node->first_attribute("id")->value());
101  node_input->osm_id=osm_str;
102  node_input->latitude=xml_node->first_attribute("lat")->value();
103  node_input->longitude=xml_node->first_attribute("lon")->value();
104  node_vector.push_back(node_input);
105  IC_vector.push_back(node_input);
106  }//node input
107 
108 
109  for (xml_node<> * xml_relation = root_node->first_node("relation"); xml_relation; xml_relation = xml_relation->next_sibling("relation")) {
110  if(xml_relation->first_attribute("action")!=NULL)
111  if(strcmp(xml_relation->first_attribute("action")->value(),"delete")==0)continue;
112  xml_node<> * xml_tag = xml_relation->first_node("tag");
113  if(xml_tag==NULL)continue;
114  if (strcmp(IO::lowercase(xml_tag->first_attribute("v")->value()),"cellspace") == 0){
115  for(xml_node<> * xml_member = xml_relation->first_node("member"); xml_member; xml_member = xml_member->next_sibling("member")){
116  CONVERTER::CellSpace *cellspace_input = new CONVERTER::CellSpace();
117  std::string osm_str(xml_member->first_attribute("ref")->value());
118  cellspace_input->osm_id=osm_str;
119  cellspace_input->gml_id="C"+to_string(CellSpace_ID++);
120  cellspace_input->outer=1;
121  CellSpace_vector.push_back(cellspace_input);
122  IC_vector.push_back(cellspace_input);
123  }
124  }
125  else if (strcmp(IO::lowercase(xml_tag->first_attribute("v")->value()), "cellspaceboundary") == 0) {
126  for(xml_node<> * xml_member = xml_relation->first_node("member"); xml_member; xml_member = xml_member->next_sibling("member")){
127  CONVERTER::CellSpaceBoundary *cellspaceboundary_input = new CONVERTER::CellSpaceBoundary();
128  std::string osm_str(xml_member->first_attribute("ref")->value());
129  cellspaceboundary_input->osm_id=osm_str;
130  cellspaceboundary_input->gml_id="B"+to_string(CellSpaceBoundary_ID++);
131  CellSpaceBoundary_vector.push_back(cellspaceboundary_input);
132  IC_vector.push_back(cellspaceboundary_input);
133  }
134  }
135  else if (strcmp(IO::lowercase(xml_tag->first_attribute("v")->value()), "state") == 0) {
136  for(xml_node<> * xml_member = xml_relation->first_node("member"); xml_member; xml_member = xml_member->next_sibling("member")){
137  CONVERTER::State *state_input = new CONVERTER::State();
138  std::string osm_str(xml_member->first_attribute("ref")->value());
139  state_input->pos=matching_id(node_vector,osm_str);
140  state_input->osm_id=state_input->pos->osm_id;
141  state_input->gml_id="S"+to_string(State_id++);
142  State_vector.push_back(state_input);
143  IC_vector.push_back(state_input);
144  }
145  }
146  else if (strcmp(IO::lowercase(xml_tag->first_attribute("v")->value()), "transition") == 0) {
147  for(xml_node<> * xml_member = xml_relation->first_node("member"); xml_member; xml_member = xml_member->next_sibling("member")){
148  CONVERTER::Transition *transition_input=new CONVERTER::Transition();
149  std::string osm_str(xml_member->first_attribute("ref")->value());
150  transition_input->osm_id=osm_str;
151  transition_input->gml_id="T"+to_string(Transition_id++);
152  Transition_vector.push_back(transition_input);
153  IC_vector.push_back(transition_input);
154  }
155  }
156  }//cellspace, cellspaceboundary,state,transition push->Relation 이 들어왔다는 가정함.
157  for (xml_node<> * xml_way = root_node->first_node("way"); xml_way; xml_way = xml_way->next_sibling("way")) {
158  if(xml_way->first_attribute("action")!=NULL)
159  if(strcmp(xml_way->first_attribute("action")->value(),"delete")==0)continue;
160  std::vector<CONVERTER::IC*>close;
161  for(xml_node<> *xml_nd=xml_way->first_node("nd");xml_nd;xml_nd=xml_nd->next_sibling("nd")){
162  std::string osm_str(xml_nd->first_attribute("ref")->value());
163  close.push_back(matching_id(IC_vector,osm_str));
164  }
165  if(Cellspace_check(close)==false)continue;
166  std::string osm_str(xml_way->first_attribute("id")->value());
167  if(matching_id(CellSpace_vector,osm_str)!=NULL)continue;
168  CONVERTER::CellSpace *cellspace_input = new CONVERTER::CellSpace();
169  cellspace_input->osm_id=osm_str;
170  cellspace_input->gml_id="C"+to_string(CellSpace_ID++);
171  for(xml_node<>*xml_tag=xml_way->first_node("tag");xml_tag;xml_tag=xml_tag->next_sibling("tag")){
172  if(strcmp(xml_tag->first_attribute("k")->value(),"level")==0){
173  cellspace_input->outer=1;
174  }
175  }
176  CellSpace_vector.push_back(cellspace_input);
177  IC_vector.push_back(cellspace_input);
178  }
179 
180  for (xml_node<> * xml_way = root_node->first_node("way"); xml_way; xml_way = xml_way->next_sibling("way")) {
181  std::string osm_str(xml_way->first_attribute("id")->value());
182  if(matching_id(CellSpace_vector,osm_str)!=NULL){
183  CONVERTER::CellSpace * CellSpace_Pointer=matching_id(CellSpace_vector,osm_str);
184  for(xml_node<>*xml_nd=xml_way->first_node("nd");xml_nd;xml_nd=xml_nd->next_sibling("nd")){
185  std::string nd_str(xml_nd->first_attribute("ref")->value());
186  CellSpace_Pointer->pos_vector.push_back(matching_id(node_vector,nd_str));
187  }
188 
189  for(xml_node<>*xml_tag=xml_way->first_node("tag");xml_tag;xml_tag=xml_tag->next_sibling("tag")){
190  if(strcmp(xml_tag->first_attribute("k")->value(),"name")==0){
191  CellSpace_Pointer->name=xml_tag->first_attribute("v")->value();
192  continue;
193  }
194  if(strcmp(xml_tag->first_attribute("k")->value(),"level")==0){
195  CellSpace_Pointer->storey=atoi(xml_tag->first_attribute("v")->value());
196  continue;
197  }
198  string str = Read_tag(string(xml_tag->first_attribute("k")->value()));
199  CellSpace_Pointer->Description.append(str);
200  CellSpace_Pointer->Description.append("=");
201  if(strcmp(xml_tag->first_attribute("k")->value(),"level")==0){
202  CellSpace_Pointer->storey=atoi(xml_tag->first_attribute("v")->value());
203  }
204  CellSpace_Pointer->Description.append(xml_tag->first_attribute("v")->value());
205  CellSpace_Pointer->Description.append(";");
206  }
207 // //make state
208 // if(CellSpace_Pointer->outer==1) {
209 // CONVERTER::State *state_input = new CONVERTER::State();
210 // state_input->pos = compute2DPolygonCentroid(CellSpace_Pointer->pos_vector,CellSpace_Pointer->pos_vector.size());
211 // state_input->osm_id = state_input->pos->osm_id;
212 // state_input->gml_id = "S" + to_string(State_id++);
213 // state_input->storey = CellSpace_Pointer->storey;
214 // State_vector.push_back(state_input);
215 // IC_vector.push_back(state_input);
216 // }
217 // //
218  }//Cellspace_way
219  if(matching_id(CellSpaceBoundary_vector,osm_str)!=NULL){
220  CONVERTER::CellSpaceBoundary * CellSpaceBoundary_Pointer=matching_id(CellSpaceBoundary_vector,osm_str);
221  for(xml_node<>*xml_nd=xml_way->first_node("nd");xml_nd;xml_nd=xml_nd->next_sibling("nd")){
222  std::string nd_str(xml_nd->first_attribute("ref")->value());
223  CellSpaceBoundary_Pointer->pos_vector.push_back(matching_id(node_vector,nd_str));
224  }
225  for(xml_node<>*xml_tag=xml_way->first_node("tag");xml_tag;xml_tag=xml_tag->next_sibling("tag")){
226  if(strcmp(xml_tag->first_attribute("k")->value(),"name")==0){
227  CellSpaceBoundary_Pointer->name=xml_tag->first_attribute("v")->value();
228  continue;
229  }
230  }
231  }//CellSpaceBoundary_way
232  if(matching_id(Transition_vector,osm_str)!=NULL){
233  CONVERTER::Transition * Transition_Pointer=matching_id(Transition_vector,osm_str);
234  for(xml_node<>*xml_nd=xml_way->first_node("nd");xml_nd;xml_nd=xml_nd->next_sibling("nd")){
235  std::string nd_str(xml_nd->first_attribute("ref")->value());
236  Transition_Pointer->pos_vector.push_back(matching_id(node_vector,nd_str));
237  }
238  for(xml_node<>*xml_tag=xml_way->first_node("tag");xml_tag;xml_tag=xml_tag->next_sibling("tag")){
239  if(strcmp(xml_tag->first_attribute("k")->value(),"name")==0){
240  Transition_Pointer->name=xml_tag->first_attribute("v")->value();
241  continue;
242  }
243  string str = Read_tag(string(xml_tag->first_attribute("k")->value()));
244  Transition_Pointer->Description.append(str);
245  Transition_Pointer->Description.append("=");
246  if(strcmp(xml_tag->first_attribute("k")->value(),"level")==0){
247  Transition_Pointer->storey=atoi(xml_tag->first_attribute("v")->value());
248  }
249  Transition_Pointer->Description.append(xml_tag->first_attribute("v")->value());
250  Transition_Pointer->Description.append(";");
251  }
252  for(auto it:Transition_Pointer->pos_vector){
253  it->storey=Transition_Pointer->storey;
254  }
255 
256 
257  }//Transition_way
258  }
259 
260  for (xml_node<> * xml_relation = root_node->first_node("relation"); xml_relation; xml_relation = xml_relation->next_sibling("relation")) {
261  xml_node<> * xml_tag = xml_relation->first_node("tag");
262  if(xml_tag==NULL)continue;
263  if(strcmp(IO::lowercase(xml_tag->first_attribute("v")->value()),"duality")==0){
264  xml_node<> *xml_member=xml_relation->first_node("member");
265  xml_node<> *xml_member_1=xml_member->next_sibling("member");
266  std::string member(xml_member->first_attribute("ref")->value());
267  std::string member_1(xml_member_1->first_attribute("ref")->value());
268  if(matching_id(IC_vector,member)==NULL)continue;
269  if(matching_id(IC_vector,member_1)==NULL)continue;
270  matching_id(IC_vector,member)->duality=matching_id(IC_vector,member_1);
271  matching_id(IC_vector,member_1)->duality=matching_id(IC_vector,member);
272  if(matching_id(IC_vector,member)->storey!=99999)
273  matching_id(IC_vector,member_1)->storey=matching_id(IC_vector,member)->storey;
274  if(matching_id(IC_vector,member_1)->storey!=99999)
275  matching_id(IC_vector,member)->storey=matching_id(IC_vector,member_1)->storey;
276  }
277  if(strcmp(IO::lowercase(xml_tag->first_attribute("v")->value()),"connects")==0){
278  xml_node<> *xml_member=xml_relation->first_node("member");
279  xml_node<> *xml_member_1=xml_member->next_sibling("member");
280  std::string member(xml_member->first_attribute("ref")->value());
281  std::string member_1(xml_member_1->first_attribute("ref")->value());
282  if(matching_id(IC_vector,member)==NULL)continue;
283  if(matching_id(IC_vector,member_1)==NULL)continue;
284  matching_id(IC_vector,member)->connects.push_back(matching_id(IC_vector,member_1));
285  matching_id(IC_vector,member_1)->connects.push_back(matching_id(IC_vector,member));
286  }
287  if(strcmp(IO::lowercase(xml_tag->first_attribute("v")->value()),"partialboundedby")==0){
288  xml_node<> *xml_member=xml_relation->first_node("member");
289  xml_node<> *xml_member_1=xml_member->next_sibling("member");
290  std::string member(xml_member->first_attribute("ref")->value());
291  std::string member_1(xml_member_1->first_attribute("ref")->value());
292  if(matching_id(IC_vector,member)==NULL)continue;
293  if(matching_id(IC_vector,member_1)==NULL)continue;
294  matching_id(IC_vector,member)->partialboundedBy.push_back(matching_id(IC_vector,member_1));
295  matching_id(IC_vector,member_1)->partialboundedBy.push_back(matching_id(IC_vector,member));
296  }
297  }
298 
299  for (xml_node<> * xml_relation = root_node->first_node("relation"); xml_relation; xml_relation = xml_relation->next_sibling("relation")) {
300  CONVERTER::IC * IC_POINTER;
301  int level=99999;
302  for(xml_node<>*xml_tag=xml_relation->first_node("tag");xml_tag;xml_tag=xml_tag->next_sibling("tag")){
303  if(strcmp(xml_tag->first_attribute("k")->value(),"level")==0){
304  level=atoi(xml_tag->first_attribute("v")->value());
305  }
306  }
307  if(level==99999)continue;
308  for(xml_node<> *xml_member=xml_relation->first_node("member");xml_member;xml_member=xml_member->next_sibling("member")){
309  if(strcmp(xml_member->first_attribute("role")->value(),"outer")==0){
310  IC_POINTER = matching_id(IC_vector,xml_member->first_attribute("ref")->value());
311  matching_id(IC_vector,xml_member->first_attribute("ref")->value())->outer= 1;
312  matching_id(IC_vector,xml_member->first_attribute("ref")->value())->Description.append("storey=");
313  ((CONVERTER::CellSpace*)matching_id(IC_vector,xml_member->first_attribute("ref")->value()))->storey=level;
314  matching_id(IC_vector,xml_member->first_attribute("ref")->value())->Description.append(to_string(level)+";");
315  }
316  }
317  if(IC_POINTER==NULL)continue;
318  for(xml_node<> *xml_member=xml_relation->first_node("member");xml_member;xml_member=xml_member->next_sibling("member")){
319  if(strcmp(xml_member->first_attribute("role")->value(),"inner")==0){
320  IC_POINTER->inner.push_back(matching_id(IC_vector,xml_member->first_attribute("ref")->value()));
321  matching_id(IC_vector,xml_member->first_attribute("ref")->value())->outer= 2;
322  }
323  }
324  }
325  doc.clear();
326  return IC_vector;
327  }
T1 matching_id(std::vector< T1 > &a, string b)
Definition: OSM_Reader.cpp:14
std::string name
Definition: Transform.h:119
xml_node< Ch > * next_sibling(const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const
Definition: rapidxml.hpp:1004
int CellSpace_ID
Definition: IO.cpp:10
std::vector< Pos * > pos_vector
Definition: Transform.h:121
std::vector< Pos * > pos_vector
Definition: Transform.h:81
std::vector< IC * > inner
Definition: Transform.h:51
std::string Description
Definition: Transform.h:47
std::string gml_id
Definition: Transform.h:44
std::string name
Definition: Transform.h:80
xml_node< Ch > * first_node(const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const
Definition: rapidxml.hpp:936
Parent class both Indoorgml and OSM.
Definition: Transform.h:38
void parse(Ch *text)
Definition: rapidxml.hpp:1381
std::vector< Pos * > pos_vector
Definition: Transform.h:94
Transition class in IndoorGML, Transition(way) in OSM weight in IndoorGML Member of pos in Transiti...
Definition: Transform.h:117
int State_id
Definition: IO.cpp:12
std::string longitude
Definition: Transform.h:64
std::string latitude
Definition: Transform.h:63
string Read_tag(string input)
Definition: OSM_Reader.cpp:24
CellSpaceBoundary class in IndoorGML, CellSpaceBoundary(way) in OSM Member of pos in CellSpaceBounda...
Definition: Transform.h:91
std::string osm_id
Definition: Transform.h:45
int Transition_id
Definition: IO.cpp:13
bool Cellspace_check(std::vector< CONVERTER::IC *>input)
Definition: OSM_Reader.cpp:72
int CellSpaceBoundary_ID
Definition: IO.cpp:11
Pos class in IndoorGML, Node in OSM latitude in OSM and IndoorGML longitude in OSM and IndoorGML h...
Definition: Transform.h:61
State class in IndoorGML, State(Node) in OSM State Pos.
Definition: Transform.h:104
xml_attribute< Ch > * first_attribute(const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const
Definition: rapidxml.hpp:1025
char * lowercase(char *input)
change char * to lower case
Definition: IO.cpp:18
Definition: IMDF_UNIT.h:9
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Read_tag() [1/2]

string OSM::Read_tag ( string  input)

Definition at line 24 of file OSM_Reader.cpp.

24  {
25  if(input =="level")
26  return string("storey");
27  else
28  return input;
29  }
Here is the caller graph for this function:

◆ Read_tag() [2/2]

char* OSM::Read_tag ( char *  input)

◆ split()

std::vector< std::string > split ( std::string &  strToSplit,
char  delimeter 
)

Definition at line 11 of file OSM_Writer.cpp.

11  {
12  std::stringstream ss(strToSplit);
13  std::string item;
14  std::vector<std::string> splittedStrings;
15  while (std::getline(ss, item, delimeter)) {
16  if(item.length()==0)continue;
17  for(int i=0;i<item.length();i++) {
18  if (item.at(i) == '\n') {
19  item.at(i)=' ';
20  }
21  }
22  item=trim(item);
23  splittedStrings.push_back(item);
24  }
25  return splittedStrings;
26  }
std::string trim(const std::string &str)
using because of IndoorGML Description
Definition: OSM_Writer.cpp:28
Here is the call graph for this function:
Here is the caller graph for this function:

◆ trim()

std::string trim ( const std::string &  str)

using because of IndoorGML Description

Parameters
strsting
Returns
string

Definition at line 28 of file OSM_Writer.cpp.

28  {
29  std::string result;
30  std::string whitespaces=" \t\r\n";
31  size_t begin = str.find_first_not_of(whitespaces);
32  size_t end = str.find_last_not_of(whitespaces);
33  if (begin != std::string::npos && end != std::string::npos)
34  result = str.substr(begin, end - begin + 1);
35 
36  return result;
37  }
Here is the caller graph for this function:

◆ Write()

void Write ( std::vector< CONVERTER::IC * >  IC_vector,
std::string  PATH 
)
Parameters
IC_vector- memory IC vector
PATH- Output OSM data Path

Definition at line 45 of file OSM_Writer.cpp.

45  {
46  std::cout<<"OSM"<<std::endl;
49  decl->append_attribute(doc1.allocate_attribute("version", "1.0"));
50  decl->append_attribute(doc1.allocate_attribute("encoding", "UTF-8"));
51  doc1.append_node(decl);
52 
53 // root node
55  root->append_attribute(doc1.allocate_attribute("version", "0.6"));
56  root->append_attribute(doc1.allocate_attribute("generator", "PNU_STEM_LAB"));
57  doc1.append_node(root);
58 
59  for(auto it:IC_vector){
60  if(it->type!=0)continue;
62  node->append_attribute(doc1.allocate_attribute("action", "modify"));
63  node->append_attribute(doc1.allocate_attribute("visible", "true"));
64  node->append_attribute(doc1.allocate_attribute("id", doc1.allocate_string(it->osm_id.c_str())));
65  node->append_attribute(doc1.allocate_attribute("lat", doc1.allocate_string((((CONVERTER::Pos*)it)->latitude).c_str())));
66  node->append_attribute(doc1.allocate_attribute("lon", doc1.allocate_string((((CONVERTER::Pos*)it)->longitude).c_str())));
67  root->append_node(node);
68  }//append node
69 
70 
71  for(auto it :IC_vector){//Cellspace
72  if(it->type!=1)continue;
74  way->append_attribute(doc1.allocate_attribute("id", doc1.allocate_string(it->osm_id.c_str())));
75  way->append_attribute(doc1.allocate_attribute("action", "modify"));
76  way->append_attribute(doc1.allocate_attribute("visible", "true"));
77  for(int i=0;i < ((CONVERTER::CellSpace*)it)->pos_vector.size(); i++) {
79  nd->append_attribute(doc1.allocate_attribute("ref", doc1.allocate_string(((CONVERTER::CellSpace*)it)->pos_vector[i]->osm_id.c_str())));
80  way->append_node(nd);
81  }
82  if(((CONVERTER::CellSpace*)it)->name.c_str()!=NULL) {
84  tag->append_attribute(doc1.allocate_attribute("k", "name"));
85  tag->append_attribute(doc1.allocate_attribute("v", doc1.allocate_string((((CONVERTER::CellSpace *) it)->name).c_str())));
86  way->append_node(tag);
87  }//name이 있으면 name추가
88 
89  if(((CONVERTER::CellSpace*)it)->Description.c_str()!=NULL) {
90  std::vector<std::string> splittedStrings = split(it->Description, ';');
91  for (auto it : splittedStrings) {
92  std::vector<std::string> token = split(it, '=');
94  tag->append_attribute(doc1.allocate_attribute("k", doc1.allocate_string(Write_tag(token[0]).c_str())));
95  tag->append_attribute(doc1.allocate_attribute("v", doc1.allocate_string((token[1].c_str()))));
96  way->append_node(tag);
97  }
98  }//Description이 있으면 Description 추가
99  root->append_node(way);
100  }//append Cellspace
101 
102  for(auto it:IC_vector){//CellspaceBoundary
103  if(it->type!=2)continue;
105  way->append_attribute(doc1.allocate_attribute("id", doc1.allocate_string(it->osm_id.c_str())));
106  way->append_attribute(doc1.allocate_attribute("action", "modify"));
107  way->append_attribute(doc1.allocate_attribute("visible", "true"));
108  for(int i=0;i < ((CONVERTER::CellSpaceBoundary*)it)->pos_vector.size(); i++) {
110  nd->append_attribute(doc1.allocate_attribute("ref", doc1.allocate_string((((CONVERTER::CellSpaceBoundary*)it)->pos_vector[i]->osm_id).c_str())));
111  way->append_node(nd);
112  }
113  if(((CONVERTER::CellSpaceBoundary*)it)->name!="") {
115  tag->append_attribute(doc1.allocate_attribute("k", "name"));
116  tag->append_attribute(doc1.allocate_attribute("v", doc1.allocate_string((((CONVERTER::CellSpaceBoundary*) it)->name).c_str())));
117  way->append_node(tag);
118  }//name이 있으면 name 추가
119  if(((CONVERTER::CellSpace*)it)->Description.c_str()!=NULL) {
120  std::vector<std::string> splittedStrings = split(it->Description, ';');
121  for (auto it : splittedStrings) {
122  std::vector<std::string> token = split(it, '=');
124  tag->append_attribute(doc1.allocate_attribute("k", doc1.allocate_string(Write_tag(token[0]).c_str())));
125  tag->append_attribute(doc1.allocate_attribute("v", doc1.allocate_string((token[1].c_str()))));
126  way->append_node(tag);
127  }
128  }//Description이 있으면 Description 추가
129  root->append_node(way);
130  }//append Cellspaceboundary
131 
132  for(auto it:IC_vector){//Transition
133  if(it->type!=4)continue;
135  way->append_attribute(doc1.allocate_attribute("id", doc1.allocate_string((it->osm_id).c_str())));
136  way->append_attribute(doc1.allocate_attribute("action", "modify"));
137  way->append_attribute(doc1.allocate_attribute("visible", "true"));
138  for(int i=0;i < ((CONVERTER::Transition*)it)->pos_vector.size(); i++) {
140  nd->append_attribute(doc1.allocate_attribute("ref", doc1.allocate_string((((CONVERTER::Transition*)it)->pos_vector[i]->osm_id).c_str())));
141  way->append_node(nd);
142  }
143  if(((CONVERTER::CellSpace*)it)->Description.c_str()!=NULL) {
144  std::vector<std::string> splittedStrings = split(it->Description, ';');
145  for (auto it : splittedStrings) {
146  std::vector<std::string> token = split(it, '=');
148  tag->append_attribute(doc1.allocate_attribute("k", doc1.allocate_string(Write_tag(token[0]).c_str())));
149  tag->append_attribute(doc1.allocate_attribute("v", doc1.allocate_string((token[1].c_str()))));
150  way->append_node(tag);
151  }
152  }//Description이 있으면 Description 추가
153  root->append_node(way);
154  }//append Transition
155 
156 
157  rapidxml::xml_node<> *relation_cellspace = doc1.allocate_node(rapidxml::node_element, "relation");
158  relation_cellspace->append_attribute(doc1.allocate_attribute("id", doc1.allocate_string(std::to_string(OSM_RELATION_ID--).c_str())));
159  relation_cellspace->append_attribute(doc1.allocate_attribute("action", "modify"));
160  relation_cellspace->append_attribute(doc1.allocate_attribute("visible", "true"));
161 
162  for(auto it:IC_vector){
163  if(it->type!=1)continue;
165  member->append_attribute(doc1.allocate_attribute("type", "way"));
166  member->append_attribute(doc1.allocate_attribute("ref", doc1.allocate_string((it->osm_id).c_str())));
167  relation_cellspace->append_node(member);
168  }
170  tag->append_attribute(doc1.allocate_attribute("k", "type"));
171  tag->append_attribute(doc1.allocate_attribute("v", "CellSpace"));
172  relation_cellspace->append_node(tag);
173  root->append_node(relation_cellspace);//Cellspace entity
174 
175  rapidxml::xml_node<> *relation_cellspaceboundary = doc1.allocate_node(rapidxml::node_element, "relation");
176  relation_cellspaceboundary->append_attribute(doc1.allocate_attribute("id", doc1.allocate_string(std::to_string(OSM_RELATION_ID--).c_str())));
177  relation_cellspaceboundary->append_attribute(doc1.allocate_attribute("action", "modify"));
178  relation_cellspaceboundary->append_attribute(doc1.allocate_attribute("visible", "true"));
179  for(auto it:IC_vector){
180  if(it->type!=2)continue;
182  member->append_attribute(doc1.allocate_attribute("type", "way"));
183  member->append_attribute(doc1.allocate_attribute("ref", doc1.allocate_string((it->osm_id).c_str())));
184  relation_cellspaceboundary->append_node(member);
185  }
186  tag = doc1.allocate_node(rapidxml::node_element, "tag");
187  tag->append_attribute(doc1.allocate_attribute("k", "type"));
188  tag->append_attribute(doc1.allocate_attribute("v", "CellSpaceBoundary"));
189  relation_cellspaceboundary->append_node(tag);
190  root->append_node(relation_cellspaceboundary);//CellspaceBoundary entity
191 
192  rapidxml::xml_node<> *relation_state = doc1.allocate_node(rapidxml::node_element, "relation");
193  relation_state->append_attribute(doc1.allocate_attribute("id", doc1.allocate_string(std::to_string(OSM_RELATION_ID--).c_str())));
194  relation_state->append_attribute(doc1.allocate_attribute("action", "modify"));
195  relation_state->append_attribute(doc1.allocate_attribute("visible", "true"));
196  for(auto it:IC_vector){
197  if(it->type!=3)continue;
199  member->append_attribute(doc1.allocate_attribute("type", "node"));
200  member->append_attribute(doc1.allocate_attribute("ref", doc1.allocate_string((it->osm_id).c_str())));
201  relation_state->append_node(member);
202  }
203  tag = doc1.allocate_node(rapidxml::node_element, "tag");
204  tag->append_attribute(doc1.allocate_attribute("k", "type"));
205  tag->append_attribute(doc1.allocate_attribute("v", "State"));
206  relation_state->append_node(tag);
207  root->append_node(relation_state);//State entity
208 
209  rapidxml::xml_node<> *relation_transition = doc1.allocate_node(rapidxml::node_element, "relation");
210  relation_transition->append_attribute(doc1.allocate_attribute("id", doc1.allocate_string(std::to_string(OSM_RELATION_ID--).c_str())));
211  relation_transition->append_attribute(doc1.allocate_attribute("action", "modify"));
212  relation_transition->append_attribute(doc1.allocate_attribute("visible", "true"));
213  for(auto it:IC_vector){
214  if(it->type!=4)continue;
216  member->append_attribute(doc1.allocate_attribute("type", "way"));
217  member->append_attribute(doc1.allocate_attribute("ref", doc1.allocate_string((it->osm_id).c_str())));
218  relation_transition->append_node(member);
219  }
220  tag = doc1.allocate_node(rapidxml::node_element, "tag");
221  tag->append_attribute(doc1.allocate_attribute("k", "type"));
222  tag->append_attribute(doc1.allocate_attribute("v", "Transition"));
223  relation_transition->append_node(tag);
224  root->append_node(relation_transition);//State entity
225 
226  for(auto it:IC_vector){
227  if(it->type!=3)continue;
228  if(it->duality==NULL)continue;
229  rapidxml::xml_node<> *relation = doc1.allocate_node(rapidxml::node_element, "relation");
230  relation->append_attribute(doc1.allocate_attribute("id", doc1.allocate_string(std::to_string(OSM_RELATION_ID--).c_str())));
231  relation->append_attribute(doc1.allocate_attribute("action", "modify"));
232  relation->append_attribute(doc1.allocate_attribute("visible", "true"));
234  member->append_attribute(doc1.allocate_attribute("type", "node"));
235  member->append_attribute(doc1.allocate_attribute("ref", doc1.allocate_string((it->osm_id).c_str())));
236  member->append_attribute(doc1.allocate_attribute("role", "State"));
237  relation->append_node(member);
238  member = doc1.allocate_node(rapidxml::node_element, "member");
239  member->append_attribute(doc1.allocate_attribute("type", "way"));
240  member->append_attribute(doc1.allocate_attribute("ref", doc1.allocate_string((it->duality->osm_id).c_str())));
241  member->append_attribute(doc1.allocate_attribute("role", "CellSpace"));
242  relation->append_node(member);
243  tag = doc1.allocate_node(rapidxml::node_element, "tag");
244  tag->append_attribute(doc1.allocate_attribute("k", "type"));
245  tag->append_attribute(doc1.allocate_attribute("v", "duality"));
246  relation->append_node(tag);
247  root->append_node(relation);
248  }//State<->Cellspace Duality
249 
250  for(auto it:IC_vector){
251  if(it->type!=4)continue;
252  if(it->duality==NULL)continue;
253  rapidxml::xml_node<> *relation = doc1.allocate_node(rapidxml::node_element, "relation");
254  relation->append_attribute(doc1.allocate_attribute("id", doc1.allocate_string(std::to_string(OSM_RELATION_ID--).c_str())));
255  relation->append_attribute(doc1.allocate_attribute("action", "modify"));
256  relation->append_attribute(doc1.allocate_attribute("visible", "true"));
258  member->append_attribute(doc1.allocate_attribute("type", "way"));
259  member->append_attribute(doc1.allocate_attribute("ref", doc1.allocate_string((it->osm_id).c_str())));
260  member->append_attribute(doc1.allocate_attribute("role", "Transition"));
261  rapidxml::xml_node<> * member_1 = doc1.allocate_node(rapidxml::node_element, "member");
262  member_1->append_attribute(doc1.allocate_attribute("type", "way"));
263  member_1->append_attribute(doc1.allocate_attribute("ref", doc1.allocate_string((it->duality->osm_id).c_str())));
264  member_1->append_attribute(doc1.allocate_attribute("role", "CellSpaceBoundary"));
265  relation->append_node(member);
266  relation->append_node(member_1);
267  tag = doc1.allocate_node(rapidxml::node_element, "tag");
268  tag->append_attribute(doc1.allocate_attribute("k", "type"));
269  tag->append_attribute(doc1.allocate_attribute("v", "duality"));
270  relation->append_node(tag);
271  root->append_node(relation);
272  }//Transition<->CellSpaceBoundary duality
273 
274  for(auto it:IC_vector){
275  if(it->type!=3)continue;
276  if(it->connects.size()==0)continue;
277  for(auto it1:it->connects) {
278  rapidxml::xml_node<> *relation = doc1.allocate_node(rapidxml::node_element, "relation");
279  relation->append_attribute(doc1.allocate_attribute("id", doc1.allocate_string(std::to_string(OSM_RELATION_ID--).c_str())));
280  relation->append_attribute(doc1.allocate_attribute("action", "modify"));
281  relation->append_attribute(doc1.allocate_attribute("visible", "true"));
283  member->append_attribute(doc1.allocate_attribute("type", "node"));
284  member->append_attribute(doc1.allocate_attribute("ref", doc1.allocate_string((it->osm_id).c_str())));
285  member->append_attribute(doc1.allocate_attribute("role", "State"));
286  rapidxml::xml_node<> *member_1 = doc1.allocate_node(rapidxml::node_element, "member");
287  member_1->append_attribute(doc1.allocate_attribute("type", "way"));
288  member_1->append_attribute(doc1.allocate_attribute("ref", doc1.allocate_string((it1->osm_id).c_str())));
289  member_1->append_attribute(doc1.allocate_attribute("role", "Transition"));
290  relation->append_node(member);
291  relation->append_node(member_1);
292  tag = doc1.allocate_node(rapidxml::node_element, "tag");
293  tag->append_attribute(doc1.allocate_attribute("k", "type"));
294  tag->append_attribute(doc1.allocate_attribute("v", "connects"));
295  relation->append_node(tag);
296  root->append_node(relation);
297  }
298  }//State<->Transition Connect
299 
300  for(auto it:IC_vector){
301  if(it->type!=1)continue;
302  if(it->partialboundedBy.size()==0)continue;
303  for(auto it1:it->partialboundedBy) {
304  rapidxml::xml_node<> *relation = doc1.allocate_node(rapidxml::node_element, "relation");
305  relation->append_attribute(doc1.allocate_attribute("id", doc1.allocate_string(std::to_string(OSM_RELATION_ID--).c_str())));
306  relation->append_attribute(doc1.allocate_attribute("action", "modify"));
307  relation->append_attribute(doc1.allocate_attribute("visible", "true"));
309  member->append_attribute(doc1.allocate_attribute("type", "way"));
310  member->append_attribute(doc1.allocate_attribute("ref", doc1.allocate_string((it->osm_id).c_str())));
311  member->append_attribute(doc1.allocate_attribute("role", "CellSpace"));
312  rapidxml::xml_node<> *member_1 = doc1.allocate_node(rapidxml::node_element, "member");
313  member_1->append_attribute(doc1.allocate_attribute("type", "way"));
314  member_1->append_attribute(doc1.allocate_attribute("ref", doc1.allocate_string((it1->osm_id).c_str())));
315  member_1->append_attribute(doc1.allocate_attribute("role", "CellSpaceBoundary"));
316  relation->append_node(member);
317  relation->append_node(member_1);
318  tag = doc1.allocate_node(rapidxml::node_element, "tag");
319  tag->append_attribute(doc1.allocate_attribute("k", "type"));
320  tag->append_attribute(doc1.allocate_attribute("v", "partialboundedBy"));
321  relation->append_node(tag);
322  root->append_node(relation);
323  }
324  }//CellSpace<->CellSpaceboundary partialboundedby
325 
326 
327  std::ofstream file_stored(PATH);
328  file_stored << doc1;
329  file_stored.close();
330  doc1.clear();
331  std::cout<<"SUCESS"<<std::endl;
332  }
xml_node< Ch > * allocate_node(node_type type, const Ch *name=0, const Ch *value=0, std::size_t name_size=0, std::size_t value_size=0)
Definition: rapidxml.hpp:415
void append_attribute(xml_attribute< Ch > *attribute)
Definition: rapidxml.hpp:1217
std::string Description
Definition: Transform.h:47
int OSM_RELATION_ID
Definition: IO.cpp:16
Ch * allocate_string(const Ch *source=0, std::size_t size=0)
Definition: rapidxml.hpp:476
void append_node(xml_node< Ch > *child)
Definition: rapidxml.hpp:1097
std::vector< std::string > split(std::string &strToSplit, char delimeter)
Definition: OSM_Writer.cpp:11
An element node. Name contains element name. Value contains text of first data node.
Definition: rapidxml.hpp:146
A declaration node. Name and value are empty. Declaration parameters (version, encoding and standalon...
Definition: rapidxml.hpp:150
IC * duality
Definition: Transform.h:48
Transition class in IndoorGML, Transition(way) in OSM weight in IndoorGML Member of pos in Transiti...
Definition: Transform.h:117
CellSpaceBoundary class in IndoorGML, CellSpaceBoundary(way) in OSM Member of pos in CellSpaceBounda...
Definition: Transform.h:91
std::vector< IC * > connects
Definition: Transform.h:50
std::string osm_id
Definition: Transform.h:45
xml_attribute< Ch > * allocate_attribute(const Ch *name=0, const Ch *value=0, std::size_t name_size=0, std::size_t value_size=0)
Definition: rapidxml.hpp:447
Pos class in IndoorGML, Node in OSM latitude in OSM and IndoorGML longitude in OSM and IndoorGML h...
Definition: Transform.h:61
std::string Write_tag(std::string &input)
Definition: OSM_Writer.cpp:38
std::vector< IC * > partialboundedBy
Definition: Transform.h:49
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Write_tag()

std::string Write_tag ( std::string &  input)

Definition at line 38 of file OSM_Writer.cpp.

38  {
39  std::string out;
40  out=input;
41  if(input=="storey")
42  out="level";
43  return out;
44  }
Here is the caller graph for this function: