]> git.street.me.uk Git - andy/viking.git/blob - src/osm.c
Set 'OK' default for goto dialogs.
[andy/viking.git] / src / osm.c
1 /*
2  * viking -- GPS Data and Topo Analyzer, Explorer, and Manager
3  *
4  * Copyright (C) 2003-2005, Evan Battaglia <gtoevan@gmx.net>
5  * Copyright (C) 2007, Guilhem Bonnefille <guilhem.bonnefille@gmail.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 #ifdef HAVE_CONFIG_H
23 #include "config.h"
24 #endif
25
26 #include <glib/gi18n.h>
27
28 #include "osm.h"
29 #include "vikmapslayer.h"
30 #include "vikslippymapsource.h"
31 #include "vikwebtoolcenter.h"
32 #include "vikexttools.h"
33 #include "vikgotoxmltool.h"
34 #include "vikgoto.h"
35
36 /* initialisation */
37 void osm_init () {
38   VikMapSource *osmarender_type = 
39     VIK_MAP_SOURCE(g_object_new(VIK_TYPE_SLIPPY_MAP_SOURCE,
40                                 "id", 12,
41                                 "label", "OpenStreetMap (Osmarender)",
42                                 "hostname", "tah.openstreetmap.org",
43                                 "url", "/Tiles/tile/%d/%d/%d.png",
44                                 "check-file-server-time", TRUE,
45                                 "use-etag", FALSE,
46                                 NULL));
47   VikMapSource *mapnik_type =
48     VIK_MAP_SOURCE(g_object_new(VIK_TYPE_SLIPPY_MAP_SOURCE,
49                                 "id", 13,
50                                 "label", "OpenStreetMap (Mapnik)",
51                                 "hostname", "tile.openstreetmap.org",
52                                 "url", "/%d/%d/%d.png",
53                                 "check-file-server-time", FALSE,
54                                 "use-etag", TRUE,
55                                 NULL));
56   VikMapSource *maplint_type =
57     VIK_MAP_SOURCE(g_object_new(VIK_TYPE_SLIPPY_MAP_SOURCE,
58                                 "id", 14,
59                                 "label", "OpenStreetMap (Maplint)",
60                                 "hostname", "tah.openstreetmap.org",
61                                 "url", "/Tiles/maplint.php/%d/%d/%d.png",
62                                 "check-file-server-time", TRUE,
63                                 "use-etag", FALSE,
64                                 NULL));
65   VikMapSource *cycle_type =
66     VIK_MAP_SOURCE(g_object_new(VIK_TYPE_SLIPPY_MAP_SOURCE,
67                                 "id", 17,
68                                 "label", "OpenStreetMap (Cycle)",
69                                 "hostname", "b.tile.opencyclemap.org",
70                                 "url", "/cycle/%d/%d/%d.png",
71                                 "check-file-server-time", TRUE,
72                                 "use-etag", FALSE,
73                                 NULL));
74
75   maps_layer_register_map_source (osmarender_type);
76   maps_layer_register_map_source (mapnik_type);
77   maps_layer_register_map_source (maplint_type);
78   maps_layer_register_map_source (cycle_type);
79
80   // Webtools
81   VikWebtoolCenter *webtool = NULL;
82   webtool = vik_webtool_center_new_with_members ( _("OSM (view)"), "http://openstreetmap.org/?lat=%s&lon=%s&zoom=%d&layers=B000FTF" );
83   vik_ext_tools_register ( VIK_EXT_TOOL ( webtool ) );
84   g_object_unref ( webtool );
85
86   webtool = vik_webtool_center_new_with_members ( _("OSM (edit)"), "http://www.openstreetmap.org/edit?lat=%s&lon=%s&zoom=%d" );
87   vik_ext_tools_register ( VIK_EXT_TOOL ( webtool ) );
88   g_object_unref ( webtool );
89
90   webtool = vik_webtool_center_new_with_members ( _("OSM (render)"), "http://www.informationfreeway.org/?lat=%s&lon=%s&zoom=%d&layers=B0000F000F" );
91   vik_ext_tools_register ( VIK_EXT_TOOL ( webtool ) );
92   g_object_unref ( webtool );
93
94   // Goto
95   VikGotoXmlTool *nominatim = VIK_GOTO_XML_TOOL ( g_object_new ( VIK_GOTO_XML_TOOL_TYPE, "label", "OSM Nominatim",
96     "url-format", "http://nominatim.openstreetmap.org/search?q=%s&format=xml",
97     "lat-path", "/searchresults/place",
98     "lat-attr", "lat",
99     "lon-path", "/searchresults/place",
100     "lon-attr", "lon",
101     NULL ) );
102     vik_goto_register ( VIK_GOTO_TOOL ( nominatim ) );
103     g_object_unref ( nominatim );
104
105   VikGotoXmlTool *namefinder = VIK_GOTO_XML_TOOL ( g_object_new ( VIK_GOTO_XML_TOOL_TYPE, "label", "OSM Name finder",
106     "url-format", "http://gazetteer.openstreetmap.org/namefinder/search.xml?find=%s&max=1",
107     "lat-path", "/searchresults/named",
108     "lat-attr", "lat",
109     "lon-path", "/searchresults/named",
110     "lon-attr", "lon",
111     NULL ) );
112     vik_goto_register ( VIK_GOTO_TOOL ( namefinder ) );
113     g_object_unref ( namefinder );
114 }
115