Diff of /trunk/src/map_edit.c

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

revision 54 by harbaum, Fri Feb 6 12:06:30 2009 UTC revision 105 by harbaum, Tue Mar 3 15:27:55 2009 UTC
# Line 269  void map_edit_way_add_ok(map_t *map) { Line 269  void map_edit_way_add_ok(map_t *map) {
269    }    }
270    
271    /* attach to existing way if the user requested so */    /* attach to existing way if the user requested so */
272    gboolean revert = FALSE;    gboolean reverse = FALSE;
273    if(map->action.extending) {    if(map->action.extending) {
274      node_t *nfirst = map->action.way->node_chain->node;      node_t *nfirst = map->action.way->node_chain->node;
275    
# Line 277  void map_edit_way_add_ok(map_t *map) { Line 277  void map_edit_way_add_ok(map_t *map) {
277    
278      if(osm_way_get_first_node(map->action.extending) == nfirst) {      if(osm_way_get_first_node(map->action.extending) == nfirst) {
279        printf("  need to prepend\n");        printf("  need to prepend\n");
280        osm_way_revert(map->action.extending);        osm_way_reverse(map->action.extending);
281        revert = TRUE;        reverse = TRUE;
282      } else if(osm_way_get_last_node(map->action.extending) == nfirst)      } else if(osm_way_get_last_node(map->action.extending) == nfirst)
283        printf("  need to append\n");        printf("  need to append\n");
284    
# Line 302  void map_edit_way_add_ok(map_t *map) { Line 302  void map_edit_way_add_ok(map_t *map) {
302      map->action.way->flags |= OSM_FLAG_DIRTY;      map->action.way->flags |= OSM_FLAG_DIRTY;
303    
304      /* and undo reversion of required */      /* and undo reversion of required */
305      if(revert)      if(reverse)
306        osm_way_revert(map->action.way);        osm_way_reverse(map->action.way);
307    
308    } else {    } else {
309      /* now move the way itself into the main data structure */      /* now move the way itself into the main data structure */
# Line 327  void map_edit_way_add_ok(map_t *map) { Line 327  void map_edit_way_add_ok(map_t *map) {
327    if(map->action.ends_on) {    if(map->action.ends_on) {
328      printf("  this new way ends on another way\n");      printf("  this new way ends on another way\n");
329    
330      /* if revert is true the node in question is the first one */      /* If reverse is true the node in question is the first one */
331      /* of the newly created way. thus is it revertes again before */      /* of the newly created way. Thus it is reversed again before */
332      /* attaching and the result is finally reverted once more */      /* attaching and the result is finally reversed once more */
333    
334      /* this is slightly more complex as this time two full tagged */      /* this is slightly more complex as this time two full tagged */
335      /* ways may be involved as the new way may be an extended existing */      /* ways may be involved as the new way may be an extended existing */
336      /* way being connected to another way. This happens if you connect */      /* way being connected to another way. This happens if you connect */
337      /* two existing ways using a new way between them */      /* two existing ways using a new way between them */
338    
339      if(revert) osm_way_revert(map->action.way);      if (reverse) osm_way_reverse(map->action.way);
340    
341      /* and open dialog to resolve tag collisions if necessary */      /* and open dialog to resolve tag collisions if necessary */
342      if(combine_tags(&map->action.way->tag, map->action.ends_on->tag))      if(combine_tags(&map->action.way->tag, map->action.ends_on->tag))
# Line 349  void map_edit_way_add_ok(map_t *map) { Line 349  void map_edit_way_add_ok(map_t *map) {
349      /* make way member of all relations ends_on already is */      /* make way member of all relations ends_on already is */
350      transfer_relations(map->appdata->osm, map->action.way, map->action.ends_on);      transfer_relations(map->appdata->osm, map->action.way, map->action.ends_on);
351    
352      /* check if we have to revert (again?) to match the way order */      /* check if we have to reverse (again?) to match the way order */
353      if(osm_way_get_last_node(map->action.ends_on) ==      if(osm_way_get_last_node(map->action.ends_on) ==
354         osm_way_get_last_node(map->action.way)) {         osm_way_get_last_node(map->action.way)) {
355    
356        printf("  need to prepend ends_on\n");        printf("  need to prepend ends_on\n");
357    
358        /* need to revert ends_on way */        /* need to reverse ends_on way */
359        osm_way_revert(map->action.ends_on);        osm_way_reverse(map->action.ends_on);
360        revert = !revert;        reverse = !reverse;
361      }      }
362    
363      /* search end of node chain */      /* search end of node chain */
# Line 372  void map_edit_way_add_ok(map_t *map) { Line 372  void map_edit_way_add_ok(map_t *map) {
372      /* erase and free ends_on (now only containing the first node anymore) */      /* erase and free ends_on (now only containing the first node anymore) */
373      map_way_delete(map->appdata, map->action.ends_on);      map_way_delete(map->appdata, map->action.ends_on);
374    
375      if(revert) osm_way_revert(map->action.way);      if(reverse) osm_way_reverse(map->action.way);
376    }    }
377    
378    /* remove prior version of this way */    /* remove prior version of this way */
# Line 403  void map_edit_way_node_add_highlight(map Line 403  void map_edit_way_node_add_highlight(map
403    
404  void map_edit_way_node_add(map_t *map, gint x, gint y) {  void map_edit_way_node_add(map_t *map, gint x, gint y) {
405    /* check if we are still hovering above the selected way */    /* check if we are still hovering above the selected way */
406    map_item_t *item = map_real_item_at(map, x, y);    map_item_t *item = map_item_at(map, x, y);
407    if(item && map_item_is_selected_way(map, item)) {    if(item && map_item_is_selected_way(map, item)) {
408      /* convert mouse position to canvas (world) position */      /* convert mouse position to canvas (world) position */
409      canvas_window2world(map->canvas, x, y, &x, &y);      canvas_window2world(map->canvas, x, y, &x, &y);
# Line 486  void map_edit_way_cut_highlight(map_t *m Line 486  void map_edit_way_cut_highlight(map_t *m
486  void map_edit_way_cut(map_t *map, gint x, gint y) {  void map_edit_way_cut(map_t *map, gint x, gint y) {
487    
488    /* check if we are still hovering above the selected way */    /* check if we are still hovering above the selected way */
489    map_item_t *item = map_real_item_at(map, x, y);    map_item_t *item = map_item_at(map, x, y);
490    if(item && (map_item_is_selected_way(map, item) ||    if(item && (map_item_is_selected_way(map, item) ||
491                map_item_is_selected_node(map, item))) {                map_item_is_selected_node(map, item))) {
492      gboolean cut_at_node = map_item_is_selected_node(map, item);      gboolean cut_at_node = map_item_is_selected_node(map, item);
# Line 769  void map_edit_node_move(appdata_t *appda Line 769  void map_edit_node_move(appdata_t *appda
769    
770            /* take all nodes from way[1] and append them to way[0] */            /* take all nodes from way[1] and append them to way[0] */
771            /* check if we have to append or prepend to way[0] */            /* check if we have to append or prepend to way[0] */
772            gboolean revert = FALSE;            gboolean reverse = FALSE;
773            if(ways2join[0]->node_chain->node == node) {            if(ways2join[0]->node_chain->node == node) {
774              /* make "prepend" to be "append" by reverting way[0] */              /* make "prepend" to be "append" by reversing way[0] */
775              printf("  target prepend -> revert\n");              printf("  target prepend -> reverse\n");
776              revert = TRUE;              reverse = TRUE;
777              osm_way_revert(ways2join[0]);              osm_way_reverse(ways2join[0]);
778            }            }
779    
780            /* verify the common node is last in the target way */            /* verify the common node is last in the target way */
# Line 785  void map_edit_node_move(appdata_t *appda Line 785  void map_edit_node_move(appdata_t *appda
785    
786            /* common node must be first in the chain to attach */            /* common node must be first in the chain to attach */
787            if(ways2join[1]->node_chain->node != node) {            if(ways2join[1]->node_chain->node != node) {
788              printf("  source revert\n");              printf("  source reverse\n");
789              osm_way_revert(ways2join[1]);              osm_way_reverse(ways2join[1]);
790            }            }
791    
792            /* verify the common node is first in the source way */            /* verify the common node is first in the source way */
# Line 930  void map_edit_way_reverse(appdata_t *app Line 930  void map_edit_way_reverse(appdata_t *app
930    
931    g_assert(item.type == MAP_TYPE_WAY);    g_assert(item.type == MAP_TYPE_WAY);
932    
933    osm_way_revert(item.way);    osm_way_reverse(item.way);
934    item.way->flags |= OSM_FLAG_DIRTY;    guint n_tags_flipped = osm_way_reverse_direction_sensitive_tags(item.way);
935      guint n_roles_flipped = osm_way_reverse_direction_sensitive_roles(appdata->osm, item.way);
936    
937      item.way->flags |= OSM_FLAG_DIRTY;
938    map_way_select(appdata, item.way);    map_way_select(appdata, item.way);
939    
940      // Flash a message about any side-effects
941      char *msg = NULL;
942      if (n_tags_flipped && !n_roles_flipped) {
943        msg = g_strdup_printf(ngettext("%d tag updated", "%d tags updated",
944                                       n_tags_flipped),
945                              n_tags_flipped);
946      }
947      else if (!n_tags_flipped && n_roles_flipped) {
948        msg = g_strdup_printf(ngettext("%d relation updated",
949                                       "%d relations updated",
950                                       n_roles_flipped),
951                              n_roles_flipped);
952      }
953      else if (n_tags_flipped && n_roles_flipped) {
954        char *msg1 = g_strdup_printf(ngettext("%d tag", "%d tags",
955                                              n_tags_flipped),
956                                     n_tags_flipped);
957        char *msg2 = g_strdup_printf(ngettext("%d relation", "%d relations",
958                                              n_roles_flipped),
959                                     n_roles_flipped);
960        msg = g_strdup_printf(_("%s & %s updated"), msg1, msg2);
961        g_free(msg1);
962        g_free(msg2);
963      }
964      if (msg) {
965        banner_show_info(appdata, msg);
966        g_free(msg);
967      }
968  }  }
969    
970    // vim:et:ts=8:sw=2:sts=2:ai

Legend:
Removed from v.54  
changed lines
  Added in v.105