227 |
char buf[64]; |
char buf[64]; |
228 |
struct tm tm; |
struct tm tm; |
229 |
|
|
230 |
printf("Id: %lu\n", node->id); |
printf("Id: "ITEM_ID_FORMAT"\n", node->id); |
231 |
printf("User: %s\n", node->user?node->user->name:"<unspecified>"); |
printf("User: %s\n", node->user?node->user->name:"<unspecified>"); |
232 |
printf("Visible: %s\n", node->visible?"yes":"no"); |
printf("Visible: %s\n", node->visible?"yes":"no"); |
233 |
|
|
260 |
} |
} |
261 |
|
|
262 |
void osm_way_free(way_t *way) { |
void osm_way_free(way_t *way) { |
263 |
// printf("freeing way #%ld\n", way->id); |
// printf("freeing way #" ITEM_ID_FORMAT "\n", way->id); |
264 |
|
|
265 |
osm_node_chain_free(way->node_chain); |
osm_node_chain_free(way->node_chain); |
266 |
osm_tags_free(way->tag); |
osm_tags_free(way->tag); |
305 |
char buf[64]; |
char buf[64]; |
306 |
struct tm tm; |
struct tm tm; |
307 |
|
|
308 |
printf("Id: %lu\n", way->id); |
printf("Id: "ITEM_ID_FORMAT"\n", way->id); |
309 |
printf("User: %s\n", way->user?way->user->name:"<unspecified>"); |
printf("User: %s\n", way->user?way->user->name:"<unspecified>"); |
310 |
printf("Visible: %s\n", way->visible?"yes":"no"); |
printf("Visible: %s\n", way->visible?"yes":"no"); |
311 |
node_chain_t *node_chain = way->node_chain; |
node_chain_t *node_chain = way->node_chain; |
312 |
while(node_chain) { |
while(node_chain) { |
313 |
printf(" Node: %lu\n", node_chain->node->id); |
printf(" Node: "ITEM_ID_FORMAT"\n", node_chain->node->id); |
314 |
node_chain = node_chain->next; |
node_chain = node_chain->next; |
315 |
} |
} |
316 |
|
|
339 |
|
|
340 |
/* search matching node */ |
/* search matching node */ |
341 |
node_chain->node = osm_get_node_by_id(osm, id); |
node_chain->node = osm_get_node_by_id(osm, id); |
342 |
if(!node_chain->node) printf("Node id %lu not found\n", id); |
if(!node_chain->node) printf("Node id " ITEM_ID_FORMAT " not found\n", id); |
343 |
else node_chain->node->ways++; |
else node_chain->node->ways++; |
344 |
|
|
345 |
xmlFree(prop); |
xmlFree(prop); |
386 |
char buf[64]; |
char buf[64]; |
387 |
struct tm tm; |
struct tm tm; |
388 |
|
|
389 |
printf("Id: %lu\n", relation->id); |
printf("Id: "ITEM_ID_FORMAT"\n", relation->id); |
390 |
printf("User: %s\n", |
printf("User: %s\n", |
391 |
relation->user?relation->user->name:"<unspecified>"); |
relation->user?relation->user->name:"<unspecified>"); |
392 |
printf("Visible: %s\n", relation->visible?"yes":"no"); |
printf("Visible: %s\n", relation->visible?"yes":"no"); |
402 |
|
|
403 |
case NODE: |
case NODE: |
404 |
if(member->object.node) |
if(member->object.node) |
405 |
printf(" Member: Node, id = %lu, role = %s\n", |
printf(" Member: Node, id = " ITEM_ID_FORMAT ", role = %s\n", |
406 |
member->object.node->id, member->role); |
member->object.node->id, member->role); |
407 |
break; |
break; |
408 |
|
|
409 |
case WAY: |
case WAY: |
410 |
if(member->object.way) |
if(member->object.way) |
411 |
printf(" Member: Way, id = %lu, role = %s\n", |
printf(" Member: Way, id = " ITEM_ID_FORMAT ", role = %s\n", |
412 |
member->object.way->id, member->role); |
member->object.way->id, member->role); |
413 |
break; |
break; |
414 |
|
|
415 |
case RELATION: |
case RELATION: |
416 |
if(member->object.relation) |
if(member->object.relation) |
417 |
printf(" Member: Relation, id = %lu, role = %s\n", |
printf(" Member: Relation, id = " ITEM_ID_FORMAT ", role = %s\n", |
418 |
member->object.relation->id, member->role); |
member->object.relation->id, member->role); |
419 |
break; |
break; |
420 |
} |
} |
421 |
|
|
759 |
|
|
760 |
/* search matching node */ |
/* search matching node */ |
761 |
node_chain->node = osm_get_node_by_id(osm, id); |
node_chain->node = osm_get_node_by_id(osm, id); |
762 |
if(!node_chain->node) printf("Node id %lu not found\n", id); |
if(!node_chain->node) printf("Node id " ITEM_ID_FORMAT " not found\n", id); |
763 |
else node_chain->node->ways++; |
else node_chain->node->ways++; |
764 |
|
|
765 |
xmlFree(prop); |
xmlFree(prop); |
1262 |
node_chain_t *node_chain = way->node_chain; |
node_chain_t *node_chain = way->node_chain; |
1263 |
while(node_chain) { |
while(node_chain) { |
1264 |
xmlNodePtr nd_node = xmlNewChild(way_node, NULL, BAD_CAST "nd", NULL); |
xmlNodePtr nd_node = xmlNewChild(way_node, NULL, BAD_CAST "nd", NULL); |
1265 |
char *str = g_strdup_printf("%ld", node_chain->node->id); |
char *str = g_strdup_printf(ITEM_ID_FORMAT, node_chain->node->id); |
1266 |
xmlNewProp(nd_node, BAD_CAST "ref", BAD_CAST str); |
xmlNewProp(nd_node, BAD_CAST "ref", BAD_CAST str); |
1267 |
g_free(str); |
g_free(str); |
1268 |
node_chain = node_chain->next; |
node_chain = node_chain->next; |
1294 |
switch(member->object.type) { |
switch(member->object.type) { |
1295 |
case NODE: |
case NODE: |
1296 |
xmlNewProp(m_node, BAD_CAST "type", BAD_CAST "node"); |
xmlNewProp(m_node, BAD_CAST "type", BAD_CAST "node"); |
1297 |
str = g_strdup_printf("%ld", member->object.node->id); |
str = g_strdup_printf(ITEM_ID_FORMAT, member->object.node->id); |
1298 |
break; |
break; |
1299 |
|
|
1300 |
case WAY: |
case WAY: |
1301 |
xmlNewProp(m_node, BAD_CAST "type", BAD_CAST "way"); |
xmlNewProp(m_node, BAD_CAST "type", BAD_CAST "way"); |
1302 |
str = g_strdup_printf("%ld", member->object.way->id); |
str = g_strdup_printf(ITEM_ID_FORMAT, member->object.way->id); |
1303 |
break; |
break; |
1304 |
|
|
1305 |
case RELATION: |
case RELATION: |
1306 |
xmlNewProp(m_node, BAD_CAST "type", BAD_CAST "relation"); |
xmlNewProp(m_node, BAD_CAST "type", BAD_CAST "relation"); |
1307 |
str = g_strdup_printf("%ld", member->object.relation->id); |
str = g_strdup_printf(ITEM_ID_FORMAT, member->object.relation->id); |
1308 |
break; |
break; |
1309 |
|
|
1310 |
default: |
default: |
1608 |
|
|
1609 |
/* new nodes aren't stored on the server and are just deleted permanently */ |
/* new nodes aren't stored on the server and are just deleted permanently */ |
1610 |
if(node->flags & OSM_FLAG_NEW) { |
if(node->flags & OSM_FLAG_NEW) { |
1611 |
printf("About to delete NEW node #%ld -> force permanent delete\n", |
printf("About to delete NEW node #" ITEM_ID_FORMAT |
1612 |
node->id); |
" -> force permanent delete\n", node->id); |
1613 |
permanently = TRUE; |
permanently = TRUE; |
1614 |
} |
} |
1615 |
|
|
1645 |
} |
} |
1646 |
|
|
1647 |
if(!permanently) { |
if(!permanently) { |
1648 |
printf("mark node #%ld as deleted\n", node->id); |
printf("mark node #" ITEM_ID_FORMAT " as deleted\n", node->id); |
1649 |
node->flags |= OSM_FLAG_DELETED; |
node->flags |= OSM_FLAG_DELETED; |
1650 |
} else { |
} else { |
1651 |
printf("permanently delete node #%ld\n", node->id); |
printf("permanently delete node #" ITEM_ID_FORMAT "\n", node->id); |
1652 |
|
|
1653 |
/* remove it from the chain */ |
/* remove it from the chain */ |
1654 |
node_t **cnode = &osm->node; |
node_t **cnode = &osm->node; |
1801 |
/* be deleted */ |
/* be deleted */ |
1802 |
void osm_node_remove_from_relation(osm_t *osm, node_t *node) { |
void osm_node_remove_from_relation(osm_t *osm, node_t *node) { |
1803 |
relation_t *relation = osm->relation; |
relation_t *relation = osm->relation; |
1804 |
printf("removing node #%ld from all relations:\n", node->id); |
printf("removing node #" ITEM_ID_FORMAT " from all relations:\n", node->id); |
1805 |
|
|
1806 |
while(relation) { |
while(relation) { |
1807 |
member_t **member = &relation->member; |
member_t **member = &relation->member; |
1809 |
if(((*member)->object.type == NODE) && |
if(((*member)->object.type == NODE) && |
1810 |
((*member)->object.node == node)) { |
((*member)->object.node == node)) { |
1811 |
|
|
1812 |
printf(" from relation #%ld\n", relation->id); |
printf(" from relation #" ITEM_ID_FORMAT "\n", relation->id); |
1813 |
|
|
1814 |
member_t *cur = *member; |
member_t *cur = *member; |
1815 |
*member = (*member)->next; |
*member = (*member)->next; |
1826 |
/* remove the given way from all relations */ |
/* remove the given way from all relations */ |
1827 |
void osm_way_remove_from_relation(osm_t *osm, way_t *way) { |
void osm_way_remove_from_relation(osm_t *osm, way_t *way) { |
1828 |
relation_t *relation = osm->relation; |
relation_t *relation = osm->relation; |
1829 |
printf("removing way #%ld from all relations:\n", way->id); |
printf("removing way #" ITEM_ID_FORMAT " from all relations:\n", way->id); |
1830 |
|
|
1831 |
while(relation) { |
while(relation) { |
1832 |
member_t **member = &relation->member; |
member_t **member = &relation->member; |
1834 |
if(((*member)->object.type == WAY) && |
if(((*member)->object.type == WAY) && |
1835 |
((*member)->object.way == way)) { |
((*member)->object.way == way)) { |
1836 |
|
|
1837 |
printf(" from relation #%ld\n", relation->id); |
printf(" from relation #" ITEM_ID_FORMAT "\n", relation->id); |
1838 |
|
|
1839 |
member_t *cur = *member; |
member_t *cur = *member; |
1840 |
*member = (*member)->next; |
*member = (*member)->next; |
1885 |
|
|
1886 |
/* new ways aren't stored on the server and are just deleted permanently */ |
/* new ways aren't stored on the server and are just deleted permanently */ |
1887 |
if(way->flags & OSM_FLAG_NEW) { |
if(way->flags & OSM_FLAG_NEW) { |
1888 |
printf("About to delete NEW way #%ld -> force permanent delete\n", |
printf("About to delete NEW way #" ITEM_ID_FORMAT |
1889 |
way->id); |
" -> force permanent delete\n", way->id); |
1890 |
permanently = TRUE; |
permanently = TRUE; |
1891 |
} |
} |
1892 |
|
|
1895 |
while(*chain) { |
while(*chain) { |
1896 |
|
|
1897 |
(*chain)->node->ways--; |
(*chain)->node->ways--; |
1898 |
printf("checking node #%ld (still used by %d)\n", |
printf("checking node #" ITEM_ID_FORMAT " (still used by %d)\n", |
1899 |
(*chain)->node->id, (*chain)->node->ways); |
(*chain)->node->id, (*chain)->node->ways); |
1900 |
|
|
1901 |
/* this node must only be part of this way */ |
/* this node must only be part of this way */ |
1921 |
way->node_chain = NULL; |
way->node_chain = NULL; |
1922 |
|
|
1923 |
if(!permanently) { |
if(!permanently) { |
1924 |
printf("mark way #%ld as deleted\n", way->id); |
printf("mark way #" ITEM_ID_FORMAT " as deleted\n", way->id); |
1925 |
way->flags |= OSM_FLAG_DELETED; |
way->flags |= OSM_FLAG_DELETED; |
1926 |
} else { |
} else { |
1927 |
printf("permanently delete way #%ld\n", way->id); |
printf("permanently delete way #" ITEM_ID_FORMAT "\n", way->id); |
1928 |
|
|
1929 |
/* remove it from the chain */ |
/* remove it from the chain */ |
1930 |
way_t **cway = &osm->way; |
way_t **cway = &osm->way; |
1949 |
/* new relations aren't stored on the server and are just */ |
/* new relations aren't stored on the server and are just */ |
1950 |
/* deleted permanently */ |
/* deleted permanently */ |
1951 |
if(relation->flags & OSM_FLAG_NEW) { |
if(relation->flags & OSM_FLAG_NEW) { |
1952 |
printf("About to delete NEW relation #%ld -> force permanent delete\n", |
printf("About to delete NEW relation #" ITEM_ID_FORMAT |
1953 |
relation->id); |
" -> force permanent delete\n", relation->id); |
1954 |
permanently = TRUE; |
permanently = TRUE; |
1955 |
} |
} |
1956 |
|
|
1958 |
/* don't have any reference to the relation they are part of */ |
/* don't have any reference to the relation they are part of */ |
1959 |
|
|
1960 |
if(!permanently) { |
if(!permanently) { |
1961 |
printf("mark relation #%ld as deleted\n", relation->id); |
printf("mark relation #" ITEM_ID_FORMAT " as deleted\n", relation->id); |
1962 |
relation->flags |= OSM_FLAG_DELETED; |
relation->flags |= OSM_FLAG_DELETED; |
1963 |
} else { |
} else { |
1964 |
printf("permanently delete relation #%ld\n", relation->id); |
printf("permanently delete relation #" ITEM_ID_FORMAT "\n", relation->id); |
1965 |
|
|
1966 |
/* remove it from the chain */ |
/* remove it from the chain */ |
1967 |
relation_t **crelation = &osm->relation; |
relation_t **crelation = &osm->relation; |
2220 |
return g_strdup_printf("%s #<unspec>", type_str); |
return g_strdup_printf("%s #<unspec>", type_str); |
2221 |
break; |
break; |
2222 |
case NODE: |
case NODE: |
2223 |
return g_strdup_printf("%s #%ld", type_str, object->node->id); |
return g_strdup_printf("%s #" ITEM_ID_FORMAT, type_str, object->node->id); |
2224 |
break; |
break; |
2225 |
case WAY: |
case WAY: |
2226 |
return g_strdup_printf("%s #%ld", type_str, object->way->id); |
return g_strdup_printf("%s #" ITEM_ID_FORMAT, type_str, object->way->id); |
2227 |
break; |
break; |
2228 |
case RELATION: |
case RELATION: |
2229 |
return g_strdup_printf("%s #%ld", type_str, object->relation->id); |
return g_strdup_printf("%s #" ITEM_ID_FORMAT, type_str, |
2230 |
|
object->relation->id); |
2231 |
break; |
break; |
2232 |
case NODE_ID: |
case NODE_ID: |
2233 |
case WAY_ID: |
case WAY_ID: |
2234 |
case RELATION_ID: |
case RELATION_ID: |
2235 |
return g_strdup_printf("%s #%ld", type_str, object->id); |
return g_strdup_printf("%s #" ITEM_ID_FORMAT, type_str, object->id); |
2236 |
break; |
break; |
2237 |
} |
} |
2238 |
return NULL; |
return NULL; |
2246 |
return NULL; |
return NULL; |
2247 |
break; |
break; |
2248 |
case NODE: |
case NODE: |
2249 |
return g_strdup_printf("#%ld", object->node->id); |
return g_strdup_printf("#"ITEM_ID_FORMAT, object->node->id); |
2250 |
break; |
break; |
2251 |
case WAY: |
case WAY: |
2252 |
return g_strdup_printf("#%ld", object->way->id); |
return g_strdup_printf("#"ITEM_ID_FORMAT, object->way->id); |
2253 |
break; |
break; |
2254 |
case RELATION: |
case RELATION: |
2255 |
return g_strdup_printf("#%ld", object->relation->id); |
return g_strdup_printf("#"ITEM_ID_FORMAT, object->relation->id); |
2256 |
break; |
break; |
2257 |
case NODE_ID: |
case NODE_ID: |
2258 |
case WAY_ID: |
case WAY_ID: |
2259 |
case RELATION_ID: |
case RELATION_ID: |
2260 |
return g_strdup_printf("#%ld", object->id); |
return g_strdup_printf("#"ITEM_ID_FORMAT, object->id); |
2261 |
break; |
break; |
2262 |
} |
} |
2263 |
return NULL; |
return NULL; |