-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathchoice_t_testing.c
More file actions
94 lines (82 loc) · 2.26 KB
/
choice_t_testing.c
File metadata and controls
94 lines (82 loc) · 2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// This program is using switch cases to give your choie and find all result.
#include <stdio.h>
#include "readosm.h"
//lng (min/max): 9.63621043828/10.6304495617 lat (min/max): 54.0434449275/54.6231550725
int no_of_entry=0;
static int print_node (const void *user_data, const readosm_node *node)
{
char buf[128];
int i,j;
const readosm_tag *tag;
for (j=0; j < node->tag_count; j++)
{
tag = node->tags + j;
if(strcmp(tag->value, user_data) == 0) {
if (node->tag_count > 0){
sprintf(buf, "%lld", node->id);
printf("\t<node id=\"%s\"",buf);
if (node->latitude != READOSM_UNDEFINED)
printf (" lat=\"%1.7f\"", node->latitude);
if (node->longitude != READOSM_UNDEFINED)
printf (" lon=\"%1.7f\"", node->longitude);
printf (" />\n");
for (i = 0; i < node->tag_count; i++)
{
tag = node->tags + i;
printf ("\t\t<tag k=\"%s\" v=\"%s\" />\n", tag->key,tag->value);
}
printf ("\t</node>\n");
no_of_entry = no_of_entry +1;
}
}
}
return READOSM_OK;
}
int main(int argc, char *argv[])
{
const void *osm_handle;
int ret, choice;
if(argc !=2)
{
fprintf(stderr, "Usage: tag_testing path-to-OSM-file\n");
return -1;
}
ret = readosm_open(argv[1], &osm_handle);
if(ret != READOSM_OK)
{
fprintf(stderr, "Unable to open file %d\n", ret);
goto stop;
}
// found way how to take argument to pass as user_data - check helper/str_string.c
printf("\tChoose from below 4 searching points: \n\n");
printf("1. Tankstelle | 2.Restaurant \n");
printf("3. Bankautomat | 4.Krankenhaus \n\n");
scanf("%d", &choice);
switch(choice)
{
case 1:
ret = readosm_parse(osm_handle, "fuel",print_node, NULL, NULL);
break;
case 2:
ret = readosm_parse(osm_handle, "restaurant",print_node, NULL, NULL);
break;
case 3:
ret = readosm_parse(osm_handle, "bank",print_node, NULL, NULL);
break;
case 4:
ret = readosm_parse(osm_handle, "Krankenhaus",print_node, NULL, NULL);
break;
default:
printf("Choice is not correct");
break;
}
if(ret != READOSM_OK)
{
fprintf(stderr, "Parsing error: %d\n", ret);
goto stop;
}
printf("Total Number of Entry found: %d\n",no_of_entry);
stop:
readosm_close(osm_handle);
return 0;
}