]> git.street.me.uk Git - andy/viking.git/blob - src/osm.c
Fix compiler warnings in osm.c
[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 "vikwmscmapsource.h"
32 #include "vikwebtoolcenter.h"
33 #include "vikexttools.h"
34 #include "vikgotoxmltool.h"
35 #include "vikgoto.h"
36
37 /* initialisation */
38 void osm_init () {
39   VikMapSource *osmarender_type = 
40     VIK_MAP_SOURCE(g_object_new(VIK_TYPE_SLIPPY_MAP_SOURCE,
41                                 "id", 12,
42                                 "label", "OpenStreetMap (Osmarender)",
43                                 "hostname", "tah.openstreetmap.org",
44                                 "url", "/Tiles/tile/%d/%d/%d.png",
45                                 "check-file-server-time", TRUE,
46                                 "use-etag", FALSE,
47                                 NULL));
48   VikMapSource *mapnik_type =
49     VIK_MAP_SOURCE(g_object_new(VIK_TYPE_SLIPPY_MAP_SOURCE,
50                                 "id", 13,
51                                 "label", "OpenStreetMap (Mapnik)",
52                                 "hostname", "tile.openstreetmap.org",
53                                 "url", "/%d/%d/%d.png",
54                                 "check-file-server-time", FALSE,
55                                 "use-etag", TRUE,
56                                 NULL));
57   VikMapSource *maplint_type =
58     VIK_MAP_SOURCE(g_object_new(VIK_TYPE_SLIPPY_MAP_SOURCE,
59                                 "id", 14,
60                                 "label", "OpenStreetMap (Maplint)",
61                                 "hostname", "tah.openstreetmap.org",
62                                 "url", "/Tiles/maplint.php/%d/%d/%d.png",
63                                 "check-file-server-time", TRUE,
64                                 "use-etag", FALSE,
65                                 NULL));
66   VikMapSource *cycle_type =
67     VIK_MAP_SOURCE(g_object_new(VIK_TYPE_SLIPPY_MAP_SOURCE,
68                                 "id", 17,
69                                 "label", "OpenStreetMap (Cycle)",
70                                 "hostname", "b.tile.opencyclemap.org",
71                                 "url", "/cycle/%d/%d/%d.png",
72                                 "check-file-server-time", TRUE,
73                                 "use-etag", FALSE,
74                                 NULL));
75   VikMapSource *wms_type =
76     VIK_MAP_SOURCE(g_object_new(VIK_TYPE_WMSC_MAP_SOURCE,
77                                 "id", 18,
78                                 "label", "OpenStreetMap (WMS)",
79                                 "hostname", "full.wms.geofabrik.de",
80                                 "url", "/std/demo_key?LAYERS=osm-full&FORMAT=image/png&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=&SRS=EPSG:4326&BBOX=%s,%s,%s,%s&WIDTH=256&HEIGHT=256",
81                                 "check-file-server-time", FALSE,
82                                 NULL));
83
84   maps_layer_register_map_source (osmarender_type);
85   maps_layer_register_map_source (mapnik_type);
86   maps_layer_register_map_source (maplint_type);
87   maps_layer_register_map_source (cycle_type);
88   maps_layer_register_map_source (wms_type);
89
90   // Webtools
91   VikWebtoolCenter *webtool = NULL;
92   webtool = vik_webtool_center_new_with_members ( _("OSM (view)"), "http://openstreetmap.org/?lat=%s&lon=%s&zoom=%d&layers=B000FTF" );
93   vik_ext_tools_register ( VIK_EXT_TOOL ( webtool ) );
94   g_object_unref ( webtool );
95
96   webtool = vik_webtool_center_new_with_members ( _("OSM (edit)"), "http://www.openstreetmap.org/edit?lat=%s&lon=%s&zoom=%d" );
97   vik_ext_tools_register ( VIK_EXT_TOOL ( webtool ) );
98   g_object_unref ( webtool );
99
100   webtool = vik_webtool_center_new_with_members ( _("OSM (render)"), "http://www.informationfreeway.org/?lat=%s&lon=%s&zoom=%d&layers=B0000F000F" );
101   vik_ext_tools_register ( VIK_EXT_TOOL ( webtool ) );
102   g_object_unref ( webtool );
103
104   // Goto
105   VikGotoXmlTool *nominatim = VIK_GOTO_XML_TOOL ( g_object_new ( VIK_GOTO_XML_TOOL_TYPE, "label", "OSM Nominatim",
106     "url-format", "http://nominatim.openstreetmap.org/search?q=%s&format=xml",
107     "lat-path", "/searchresults/place",
108     "lat-attr", "lat",
109     "lon-path", "/searchresults/place",
110     "lon-attr", "lon",
111     NULL ) );
112     vik_goto_register ( VIK_GOTO_TOOL ( nominatim ) );
113     g_object_unref ( nominatim );
114
115   VikGotoXmlTool *namefinder = VIK_GOTO_XML_TOOL ( g_object_new ( VIK_GOTO_XML_TOOL_TYPE, "label", "OSM Name finder",
116     "url-format", "http://gazetteer.openstreetmap.org/namefinder/search.xml?find=%s&max=1",
117     "lat-path", "/searchresults/named",
118     "lat-attr", "lat",
119     "lon-path", "/searchresults/named",
120     "lon-attr", "lon",
121     NULL ) );
122     vik_goto_register ( VIK_GOTO_TOOL ( namefinder ) );
123     g_object_unref ( namefinder );
124 }
125