2592 |
} |
} |
2593 |
} |
} |
2594 |
|
|
2595 |
|
void osm_relation_delete(osm_t *osm, relation_t *relation, |
2596 |
|
gboolean permanently) { |
2597 |
|
|
2598 |
|
/* new relations aren't stored on the server and are just */ |
2599 |
|
/* deleted permanently */ |
2600 |
|
if(relation->flags & OSM_FLAG_NEW) { |
2601 |
|
printf("About to delete NEW relation #%ld -> force permanent delete\n", |
2602 |
|
relation->id); |
2603 |
|
permanently = TRUE; |
2604 |
|
} |
2605 |
|
|
2606 |
|
/* the deletion of a relation doesn't affect the members as they */ |
2607 |
|
/* don't have any reference to the relation they are part of */ |
2608 |
|
|
2609 |
|
if(!permanently) { |
2610 |
|
printf("mark relation #%ld as deleted\n", relation->id); |
2611 |
|
relation->flags |= OSM_FLAG_DELETED; |
2612 |
|
} else { |
2613 |
|
printf("permanently delete relation #%ld\n", relation->id); |
2614 |
|
|
2615 |
|
/* remove it from the chain */ |
2616 |
|
relation_t **crelation = &osm->relation; |
2617 |
|
int found = 0; |
2618 |
|
|
2619 |
|
while(*crelation) { |
2620 |
|
if(*crelation == relation) { |
2621 |
|
found++; |
2622 |
|
*crelation = (*crelation)->next; |
2623 |
|
|
2624 |
|
osm_relation_free(relation); |
2625 |
|
} else |
2626 |
|
crelation = &((*crelation)->next); |
2627 |
|
} |
2628 |
|
g_assert(found == 1); |
2629 |
|
} |
2630 |
|
} |
2631 |
|
|
2632 |
void osm_way_revert(way_t *way) { |
void osm_way_revert(way_t *way) { |
2633 |
node_chain_t *new = NULL; |
node_chain_t *new = NULL; |
2634 |
|
|
2748 |
case NODE_ID: |
case NODE_ID: |
2749 |
case WAY_ID: |
case WAY_ID: |
2750 |
case RELATION_ID: |
case RELATION_ID: |
2751 |
return g_strdup_printf("%s #%ld", type_str, *((item_id_t*)object)); |
return g_strdup_printf("%s #%ld", type_str, ((item_id_t)object)); |
2752 |
|
break; |
2753 |
|
} |
2754 |
|
return NULL; |
2755 |
|
} |
2756 |
|
|
2757 |
|
char *osm_id_string(type_t type, void *object) { |
2758 |
|
if(!object) return NULL; |
2759 |
|
|
2760 |
|
switch(type) { |
2761 |
|
case ILLEGAL: |
2762 |
|
return NULL; |
2763 |
|
break; |
2764 |
|
case NODE: |
2765 |
|
return g_strdup_printf("#%ld", ((node_t*)object)->id); |
2766 |
|
break; |
2767 |
|
case WAY: |
2768 |
|
return g_strdup_printf("#%ld", ((way_t*)object)->id); |
2769 |
|
break; |
2770 |
|
case RELATION: |
2771 |
|
return g_strdup_printf("#%ld", ((relation_t*)object)->id); |
2772 |
|
break; |
2773 |
|
case NODE_ID: |
2774 |
|
case WAY_ID: |
2775 |
|
case RELATION_ID: |
2776 |
|
return g_strdup_printf("#%ld", ((item_id_t)object)); |
2777 |
|
break; |
2778 |
|
} |
2779 |
|
return NULL; |
2780 |
|
} |
2781 |
|
|
2782 |
|
tag_t *osm_object_get_tags(type_t type, void *object) { |
2783 |
|
if(!object) return NULL; |
2784 |
|
|
2785 |
|
switch(type) { |
2786 |
|
case ILLEGAL: |
2787 |
|
return NULL; |
2788 |
|
break; |
2789 |
|
case NODE: |
2790 |
|
return ((node_t*)object)->tag; |
2791 |
|
break; |
2792 |
|
case WAY: |
2793 |
|
return ((way_t*)object)->tag; |
2794 |
|
break; |
2795 |
|
case RELATION: |
2796 |
|
return ((relation_t*)object)->tag; |
2797 |
|
break; |
2798 |
|
case NODE_ID: |
2799 |
|
case WAY_ID: |
2800 |
|
case RELATION_ID: |
2801 |
|
return NULL; |
2802 |
break; |
break; |
2803 |
} |
} |
2804 |
return NULL; |
return NULL; |
2805 |
} |
} |
2806 |
|
|
2807 |
|
|
2808 |
|
gint osm_relation_members_num(relation_t *relation) { |
2809 |
|
gint num = 0; |
2810 |
|
member_t *member = relation->member; |
2811 |
|
while(member) { |
2812 |
|
num++; |
2813 |
|
member = member->next; |
2814 |
|
} |
2815 |
|
return num; |
2816 |
|
} |
2817 |
|
|
2818 |
// vim:et:ts=8:sw=2:sts=2:ai |
// vim:et:ts=8:sw=2:sts=2:ai |