Diff of /trunk/src/diff.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 161 by harbaum, Sat Apr 11 11:28:56 2009 UTC revision 239 by harbaum, Thu Jul 23 13:15:53 2009 UTC
# Line 59  static void diff_save_nodes(node_t *node Line 59  static void diff_save_nodes(node_t *node
59        xmlNodePtr node_node = xmlNewChild(root_node, NULL,        xmlNodePtr node_node = xmlNewChild(root_node, NULL,
60                                           BAD_CAST "node", NULL);                                           BAD_CAST "node", NULL);
61    
62        diff_save_state_n_id(node->flags, node_node, node->id);        diff_save_state_n_id(node->flags, node_node, OSM_ID(node));
63    
64        if(!(node->flags & OSM_FLAG_DELETED)) {        if(!(node->flags & OSM_FLAG_DELETED)) {
65          char str[32];          char str[32];
# Line 69  static void diff_save_nodes(node_t *node Line 69  static void diff_save_nodes(node_t *node
69          xmlNewProp(node_node, BAD_CAST "lat", BAD_CAST str);          xmlNewProp(node_node, BAD_CAST "lat", BAD_CAST str);
70          g_ascii_formatd(str, sizeof(str), LL_FORMAT, node->pos.lon);          g_ascii_formatd(str, sizeof(str), LL_FORMAT, node->pos.lon);
71          xmlNewProp(node_node, BAD_CAST "lon", BAD_CAST str);          xmlNewProp(node_node, BAD_CAST "lon", BAD_CAST str);
72          snprintf(str, sizeof(str), "%lu", node->time);          snprintf(str, sizeof(str), "%lu", OSM_TIME(node));
73          xmlNewProp(node_node, BAD_CAST "time", BAD_CAST str);          xmlNewProp(node_node, BAD_CAST "time", BAD_CAST str);
74    
75          diff_save_tags(node->tag, node_node);          diff_save_tags(node->tag, node_node);
# Line 87  static void diff_save_ways(way_t *way, x Line 87  static void diff_save_ways(way_t *way, x
87        xmlNodePtr node_way = xmlNewChild(root_node, NULL,        xmlNodePtr node_way = xmlNewChild(root_node, NULL,
88                                           BAD_CAST "way", NULL);                                           BAD_CAST "way", NULL);
89    
90        diff_save_state_n_id(way->flags, node_way, way->id);        diff_save_state_n_id(way->flags, node_way, OSM_ID(way));
91    
92        if(way->flags & OSM_FLAG_HIDDEN)        if(way->flags & OSM_FLAG_HIDDEN)
93          xmlNewProp(node_way, BAD_CAST "hidden", BAD_CAST "true");          xmlNewProp(node_way, BAD_CAST "hidden", BAD_CAST "true");
# Line 101  static void diff_save_ways(way_t *way, x Line 101  static void diff_save_ways(way_t *way, x
101          while(node_chain) {          while(node_chain) {
102            xmlNodePtr node_node = xmlNewChild(node_way, NULL,            xmlNodePtr node_node = xmlNewChild(node_way, NULL,
103                                               BAD_CAST "nd", NULL);                                               BAD_CAST "nd", NULL);
104            char *id = g_strdup_printf(ITEM_ID_FORMAT, node_chain->node->id);            char *id = g_strdup_printf(ITEM_ID_FORMAT, OSM_ID(node_chain->node));
105            xmlNewProp(node_node, BAD_CAST "ref", BAD_CAST id);            xmlNewProp(node_node, BAD_CAST "ref", BAD_CAST id);
106            g_free(id);            g_free(id);
107            node_chain = node_chain->next;            node_chain = node_chain->next;
# Line 121  static void diff_save_relations(relation Line 121  static void diff_save_relations(relation
121        xmlNodePtr node_rel = xmlNewChild(root_node, NULL,        xmlNodePtr node_rel = xmlNewChild(root_node, NULL,
122                                           BAD_CAST "relation", NULL);                                           BAD_CAST "relation", NULL);
123    
124        diff_save_state_n_id(relation->flags, node_rel, relation->id);        diff_save_state_n_id(relation->flags, node_rel, OSM_ID(relation));
125    
126        if(!(relation->flags & OSM_FLAG_DELETED)) {        if(!(relation->flags & OSM_FLAG_DELETED)) {
127          /* additional info is only required if the relation */          /* additional info is only required if the relation */
# Line 135  static void diff_save_relations(relation Line 135  static void diff_save_relations(relation
135            switch(member->object.type) {            switch(member->object.type) {
136            case NODE:            case NODE:
137              xmlNewProp(node_member, BAD_CAST "type", BAD_CAST "node");              xmlNewProp(node_member, BAD_CAST "type", BAD_CAST "node");
138              ref = g_strdup_printf(ITEM_ID_FORMAT, member->object.node->id);              ref = g_strdup_printf(ITEM_ID_FORMAT, OBJECT_ID(member->object));
139              break;              break;
140            case WAY:            case WAY:
141              xmlNewProp(node_member, BAD_CAST "type", BAD_CAST "way");              xmlNewProp(node_member, BAD_CAST "type", BAD_CAST "way");
142              ref = g_strdup_printf(ITEM_ID_FORMAT, member->object.way->id);              ref = g_strdup_printf(ITEM_ID_FORMAT, OBJECT_ID(member->object));
143              break;              break;
144            case RELATION:            case RELATION:
145              xmlNewProp(node_member, BAD_CAST "type", BAD_CAST "relation");              xmlNewProp(node_member, BAD_CAST "type", BAD_CAST "relation");
146              ref = g_strdup_printf(ITEM_ID_FORMAT, member->object.relation->id);              ref = g_strdup_printf(ITEM_ID_FORMAT, OBJECT_ID(member->object));
147              break;              break;
148    
149              /* XXX_ID's are used if this is a reference to an item not */              /* XXX_ID's are used if this is a reference to an item not */
# Line 345  void diff_restore_node(xmlDoc *doc, xmlN Line 345  void diff_restore_node(xmlDoc *doc, xmlN
345      node = g_new0(node_t, 1);      node = g_new0(node_t, 1);
346      node->visible = TRUE;      node->visible = TRUE;
347      node->flags = OSM_FLAG_NEW;      node->flags = OSM_FLAG_NEW;
348      node->time = xml_get_prop_int(node_node, "time", 0);      OSM_TIME(node) = xml_get_prop_int(node_node, "time", 0);
349      if(!node->time) node->time = time(NULL);      if(!OSM_TIME(node)) OSM_TIME(node) = time(NULL);
350    
351      /* attach to end of node list */      /* attach to end of node list */
352      node_t **lnode = &osm->node;      node_t **lnode = &osm->node;
# Line 384  void diff_restore_node(xmlDoc *doc, xmlN Line 384  void diff_restore_node(xmlDoc *doc, xmlN
384    }    }
385    
386    /* update id and position from diff */    /* update id and position from diff */
387    node->id = id;    OSM_ID(node) = id;
388    if(pos) {    if(pos) {
389      node->pos.lat = pos->lat;      node->pos.lat = pos->lat;
390      node->pos.lon = pos->lon;      node->pos.lon = pos->lon;
# Line 436  void diff_restore_way(xmlDoc *doc, xmlNo Line 436  void diff_restore_way(xmlDoc *doc, xmlNo
436      way = g_new0(way_t, 1);      way = g_new0(way_t, 1);
437      way->visible = TRUE;      way->visible = TRUE;
438      way->flags = OSM_FLAG_NEW;      way->flags = OSM_FLAG_NEW;
439      way->time = xml_get_prop_int(node_node, "time", 0);      OSM_TIME(way) = xml_get_prop_int(node_node, "time", 0);
440      if(!way->time) way->time = time(NULL);      if(!OSM_TIME(way)) OSM_TIME(way) = time(NULL);
441    
442      /* attach to end of way list */      /* attach to end of way list */
443      way_t **lway = &osm->way;      way_t **lway = &osm->way;
# Line 474  void diff_restore_way(xmlDoc *doc, xmlNo Line 474  void diff_restore_way(xmlDoc *doc, xmlNo
474    }    }
475    
476    /* update id from diff */    /* update id from diff */
477    way->id = id;    OSM_ID(way) = id;
478    
479    /* update node_chain */    /* update node_chain */
480    if(hidden)    if(hidden)
# Line 551  void diff_restore_relation(xmlDoc *doc, Line 551  void diff_restore_relation(xmlDoc *doc,
551      relation = g_new0(relation_t, 1);      relation = g_new0(relation_t, 1);
552      relation->visible = TRUE;      relation->visible = TRUE;
553      relation->flags = OSM_FLAG_NEW;      relation->flags = OSM_FLAG_NEW;
554      relation->time = xml_get_prop_int(node_rel, "time", 0);      OSM_TIME(relation) = xml_get_prop_int(node_rel, "time", 0);
555      if(!relation->time) relation->time = time(NULL);      if(!OSM_TIME(relation)) OSM_TIME(relation) = time(NULL);
556    
557      /* attach to end of relation list */      /* attach to end of relation list */
558      relation_t **lrelation = &osm->relation;      relation_t **lrelation = &osm->relation;
# Line 589  void diff_restore_relation(xmlDoc *doc, Line 589  void diff_restore_relation(xmlDoc *doc,
589    }    }
590    
591    /* update id from diff */    /* update id from diff */
592    relation->id = id;    OSM_ID(relation) = id;
593    
594    /* update members */    /* update members */
595    

Legend:
Removed from v.161  
changed lines
  Added in v.239