]> git.street.me.uk Git - andy/viking.git/blame - src/datasource_wikipedia.c
SF Features#76: Add ability to handle and name trackpoints.
[andy/viking.git] / src / datasource_wikipedia.c
CommitLineData
3c29a566
RN
1/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
2/*
3 * viking -- GPS Data and Topo Analyzer, Explorer, and Manager
4 *
5 * Copyright (C) 2013, Rob Norris <rw_norris@hotmail.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 */
22#include <glib/gprintf.h>
23#include <glib/gi18n.h>
24
25#include "viking.h"
26#include "acquire.h"
27#include "geonamessearch.h"
28
29static gboolean datasource_wikipedia_process ( VikTrwLayer *vtl, const gchar *cmd, const gchar *extra, BabelStatusFunc status_cb, acq_dialog_widgets_t *adw );
30
31VikDataSourceInterface vik_datasource_wikipedia_interface = {
32 N_("Create Waypoints from Wikipedia Articles"),
33 N_("Wikipedia Waypoints"),
34 VIK_DATASOURCE_CREATENEWLAYER,
35 VIK_DATASOURCE_INPUTTYPE_NONE,
36 FALSE,
37 FALSE, // Not even using the dialog
38 FALSE, // Own method for getting data - does not fit encapsulation with current thread logic
39 (VikDataSourceInitFunc) NULL,
40 (VikDataSourceCheckExistenceFunc) NULL,
41 (VikDataSourceAddSetupWidgetsFunc) NULL,
42 (VikDataSourceGetCmdStringFunc) NULL,
43 (VikDataSourceProcessFunc) datasource_wikipedia_process,
44 (VikDataSourceProgressFunc) NULL,
45 (VikDataSourceAddProgressWidgetsFunc) NULL,
46 (VikDataSourceCleanupFunc) NULL,
47 (VikDataSourceOffFunc) NULL,
48
49 NULL,
50 0,
51 NULL,
52 NULL,
53 0
54};
55
56/**
57 * Process selected files and try to generate waypoints storing them in the given vtl
58 */
59static gboolean datasource_wikipedia_process ( VikTrwLayer *vtl, const gchar *cmd, const gchar *extra, BabelStatusFunc status_cb, acq_dialog_widgets_t *adw )
60{
61 struct LatLon maxmin[2] = { {0.0,0.0}, {0.0,0.0} };
62
63 // Note the order is max part first then min part - thus reverse order of use in min_max function:
64 vik_viewport_get_min_max_lat_lon ( adw->vvp, &maxmin[1].lat, &maxmin[0].lat, &maxmin[1].lon, &maxmin[0].lon );
65
66 if ( vtl ) {
67 a_geonames_wikipedia_box ( adw->vw, vtl, maxmin );
68 return TRUE;
69 }
70 else
71 return FALSE;
72}