static int relationType_function(const char *_tag_,int _type_,const char *id) { static int64_t llid; /* static variable to store attributes from <relation> tag until </relation> tag */ if(_type_&XMLPARSE_TAG_START) { nrelations++; if(!(nrelations%1000)) printf_middle("Reading: Lines=%"PRIu64" Nodes=%"PRIu64" Ways=%"PRIu64" Relations=%"PRIu64,ParseXML_LineNumber(),nnodes,nways,nrelations); current_tags=NewTagList(); AddRelationRefs(0,0,0,NULL); /* Handle the relation information */ XMLPARSE_ASSERT_INTEGER(_tag_,id); llid=atoll(id); /* need int64_t conversion */ } if(_type_&XMLPARSE_TAG_END) { TagList *result=ApplyRelationTaggingRules(current_tags,llid); ProcessRelationTags(result,llid,current_mode); DeleteTagList(current_tags); current_tags=NULL; DeleteTagList(result); } return(0); }
TagList *ApplyTaggingRules(TaggingRuleList *rules,TagList *tags,node_t id) { TagList *result=NewTagList(); int i,j; for(i=0;i<rules->nrules;i++) { if(rules->rules[i].k && rules->rules[i].v) { for(j=0;j<tags->ntags;j++) if(!strcmp(tags->k[j],rules->rules[i].k) && !strcmp(tags->v[j],rules->rules[i].v)) apply_actions(rules,&rules->rules[i],j,tags,result,id); } else if(rules->rules[i].k && !rules->rules[i].v) { for(j=0;j<tags->ntags;j++) if(!strcmp(tags->k[j],rules->rules[i].k)) apply_actions(rules,&rules->rules[i],j,tags,result,id); } else if(!rules->rules[i].k && rules->rules[i].v) { for(j=0;j<tags->ntags;j++) if(!strcmp(tags->v[j],rules->rules[i].v)) apply_actions(rules,&rules->rules[i],j,tags,result,id); } else /* if(!rules->rules[i].k && !rules->rules[i].v) */ { for(j=0;j<tags->ntags;j++) apply_actions(rules,&rules->rules[i],j,tags,result,id); } } return(result); }
static int nodeType_function(const char *_tag_,int _type_,const char *id,const char *lat,const char *lon) { static int64_t llid; /* static variable to store attributes from <node> tag until </node> tag */ static double latitude,longitude; /* static variable to store attributes from <node> tag until </node> tag */ if(_type_&XMLPARSE_TAG_START) { nnodes++; if(!(nnodes%10000)) printf_middle("Reading: Lines=%"PRIu64" Nodes=%"PRIu64" Ways=%"PRIu64" Relations=%"PRIu64,ParseXML_LineNumber(),nnodes,nways,nrelations); current_tags=NewTagList(); /* Handle the node information */ XMLPARSE_ASSERT_INTEGER(_tag_,id); llid=atoll(id); /* need int64_t conversion */ if(current_mode!=MODE_DELETE) { XMLPARSE_ASSERT_FLOATING(_tag_,lat); latitude =atof(lat); XMLPARSE_ASSERT_FLOATING(_tag_,lon); longitude=atof(lon); } } if(_type_&XMLPARSE_TAG_END) { TagList *result=ApplyNodeTaggingRules(current_tags,llid); ProcessNodeTags(result,llid,latitude,longitude,current_mode); DeleteTagList(current_tags); current_tags=NULL; DeleteTagList(result); } return(0); }