]> git.street.me.uk Git - andy/viking.git/blame - test/test_vikgotoxmltool.c
Add 'View Waypoints' option to the TrackWaypoint layer menu options, which sets the...
[andy/viking.git] / test / test_vikgotoxmltool.c
CommitLineData
3556399a
GB
1#include <math.h>
2#include <vikgotoxmltool.h>
3
4void parse(VikGotoTool *tool, gchar *filename)
5{
6 struct LatLon ll;
7 ll.lat = NAN;
8 ll.lon = NAN;
9 if (vik_goto_tool_parse_file_for_latlon(tool, filename, &ll))
10 printf("Found %g %g in %s\n", ll.lat, ll.lon, filename);
11 else
12 printf("Failed to parse file %s\n", filename);
13}
14
15int main(int argc, char *argv[])
16{
17 g_type_init();
18
19 VikGotoXmlTool *with_element = VIK_GOTO_XML_TOOL ( g_object_new ( VIK_GOTO_XML_TOOL_TYPE, "label", "OSM",
20 "url-format", "http://ws.geonames.org/search?q=%s&maxRows=1&lang=es&style=short",
21 "lat-path", "/geonames/geoname/lat",
22 "lon-path", "/geonames/geoname/lng",
23 NULL ) );
24
25 VikGotoXmlTool *with_attr = VIK_GOTO_XML_TOOL ( g_object_new ( VIK_GOTO_XML_TOOL_TYPE, "label", "OSM",
26 "url-format", "http://ws.geonames.org/search?q=%s&maxRows=1&lang=es&style=short",
27 "lat-path", "/geonames/geoname",
28 "lat-attr", "lat",
29 "lon-path", "/geonames/geoname",
30 "lon-attr", "lng",
31 NULL ) );
87b8d3d4
GB
32
33 VikGotoXmlTool *with_xpath = VIK_GOTO_XML_TOOL ( g_object_new ( VIK_GOTO_XML_TOOL_TYPE, "label", "OSM",
34 "url-format", "http://ws.geonames.org/search?q=%s&maxRows=1&lang=es&style=short",
35 "lat-path", "/geonames/geoname@lat",
36 "lon-path", "/geonames/geoname@lng",
37 NULL ) );
3556399a
GB
38
39 int i;
40 for (i = 1; i<argc ; i++)
41 {
0034ee33
RN
42 parse(VIK_GOTO_TOOL(with_element), argv[i]);
43 parse(VIK_GOTO_TOOL(with_attr), argv[i]);
44 parse(VIK_GOTO_TOOL(with_xpath), argv[i]);
3556399a 45 }
0034ee33 46 return 0;
3556399a 47}