]> git.street.me.uk Git - andy/viking.git/blame - src/osm.c
SF#3601584: Fix minimum vertical size for the track properties dialog.
[andy/viking.git] / src / osm.c
CommitLineData
67209ca8
GB
1/*
2 * viking -- GPS Data and Topo Analyzer, Explorer, and Manager
3 *
4 * Copyright (C) 2003-2005, Evan Battaglia <gtoevan@gmx.net>
a482007a 5 * Copyright (C) 2007, Guilhem Bonnefille <guilhem.bonnefille@gmail.com>
2673b29d 6 * Copyright (c) 2012, Rob Norris <rw_norris@hotmail.com>
67209ca8
GB
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 *
22 */
8c00358d
GB
23#ifdef HAVE_CONFIG_H
24#include "config.h"
25#endif
67209ca8 26
92806042 27#include <glib/gi18n.h>
67209ca8 28
67209ca8 29#include "osm.h"
f7d8a3c2 30#include "vikmapslayer.h"
8eb12ac6 31#include "vikslippymapsource.h"
50713970 32#include "vikwmscmapsource.h"
92806042 33#include "vikwebtoolcenter.h"
e1506f37 34#include "vikwebtoolbounds.h"
82993cc7 35#include "vikwebtool_datasource.h"
92806042 36#include "vikexttools.h"
82993cc7 37#include "vikexttool_datasources.h"
5149a69d
GB
38#include "vikgotoxmltool.h"
39#include "vikgoto.h"
4f92972b 40
67209ca8
GB
41/* initialisation */
42void osm_init () {
0f08bd0d
GB
43 VikMapSource *mapnik_type =
44 VIK_MAP_SOURCE(g_object_new(VIK_TYPE_SLIPPY_MAP_SOURCE,
45 "id", 13,
46 "label", "OpenStreetMap (Mapnik)",
47 "hostname", "tile.openstreetmap.org",
48 "url", "/%d/%d/%d.png",
05dbd9ba
JJ
49 "check-file-server-time", FALSE,
50 "use-etag", TRUE,
82aa018d 51 "copyright", "© OpenStreetMap contributors",
53ac8302
GB
52 "license", "CC-BY-SA",
53 "license-url", "http://www.openstreetmap.org/copyright",
0f08bd0d 54 NULL));
0f08bd0d
GB
55 VikMapSource *cycle_type =
56 VIK_MAP_SOURCE(g_object_new(VIK_TYPE_SLIPPY_MAP_SOURCE,
57 "id", 17,
58 "label", "OpenStreetMap (Cycle)",
218cdecd
GB
59 "hostname", "b.tile.opencyclemap.org",
60 "url", "/cycle/%d/%d/%d.png",
6693f5f9 61 "check-file-server-time", TRUE,
05dbd9ba 62 "use-etag", FALSE,
82c3dd37 63 "copyright", "Tiles courtesy of Andy Allan © OpenStreetMap contributors",
53ac8302
GB
64 "license", "CC-BY-SA",
65 "license-url", "http://www.openstreetmap.org/copyright",
0f08bd0d 66 NULL));
5c9e34b9
RN
67 VikMapSource *transport_type =
68 VIK_MAP_SOURCE(g_object_new(VIK_TYPE_SLIPPY_MAP_SOURCE,
69 "id", 20,
70 "label", "OpenStreetMap (Transport)",
71 "hostname", "c.tile2.opencyclemap.org",
72 "url", "/transport/%d/%d/%d.png",
73 "check-file-server-time", TRUE,
74 "use-etag", FALSE,
75 "copyright", "Tiles courtesy of Andy Allan © OpenStreetMap contributors",
76 "license", "CC-BY-SA",
77 "license-url", "http://www.openstreetmap.org/copyright",
78 NULL));
bf6152e8 79 VikMapSource *wms_type =
50713970
GB
80 VIK_MAP_SOURCE(g_object_new(VIK_TYPE_WMSC_MAP_SOURCE,
81 "id", 18,
82 "label", "OpenStreetMap (WMS)",
83 "hostname", "full.wms.geofabrik.de",
84 "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",
85 "check-file-server-time", FALSE,
82aa018d 86 "copyright", "© OpenStreetMap contributors",
53ac8302
GB
87 "license", "CC-BY-SA",
88 "license-url", "http://www.openstreetmap.org/copyright",
50713970 89 NULL));
db03733a 90
427976e5
RN
91 VikMapSource *mapquest_type =
92 VIK_MAP_SOURCE(g_object_new(VIK_TYPE_SLIPPY_MAP_SOURCE,
93 "id", 19,
94 "label", "OpenStreetMap (MapQuest)",
95 "hostname", "otile1.mqcdn.com",
96 "url", "/tiles/1.0.0/osm/%d/%d/%d.png",
97 "check-file-server-time", TRUE,
98 "use-etag", FALSE,
99 "copyright", "Tiles Courtesy of MapQuest © OpenStreetMap contributors",
100 "license", "MapQuest Specific",
101 "license-url", "http://developer.mapquest.com/web/info/terms-of-use",
102 NULL));
103
2673b29d
RN
104 // NB no cache needed for this type!!
105 VikMapSource *direct_type =
106 VIK_MAP_SOURCE(g_object_new(VIK_TYPE_SLIPPY_MAP_SOURCE,
107 "id", 21,
108 "label", _("On Disk OSM Tile Format"),
109 // For using your own generated data assumed you know the license already!
110 "copyright", "© OpenStreetMap contributors", // probably
111 "use-direct-file-access", TRUE,
112 NULL));
113
427976e5 114 maps_layer_register_map_source (mapquest_type);
db03733a 115 maps_layer_register_map_source (mapnik_type);
db03733a 116 maps_layer_register_map_source (cycle_type);
5c9e34b9 117 maps_layer_register_map_source (transport_type);
50713970 118 maps_layer_register_map_source (wms_type);
2673b29d 119 maps_layer_register_map_source (direct_type);
92806042
GB
120
121 // Webtools
122 VikWebtoolCenter *webtool = NULL;
123 webtool = vik_webtool_center_new_with_members ( _("OSM (view)"), "http://openstreetmap.org/?lat=%s&lon=%s&zoom=%d&layers=B000FTF" );
124 vik_ext_tools_register ( VIK_EXT_TOOL ( webtool ) );
125 g_object_unref ( webtool );
126
127 webtool = vik_webtool_center_new_with_members ( _("OSM (edit)"), "http://www.openstreetmap.org/edit?lat=%s&lon=%s&zoom=%d" );
128 vik_ext_tools_register ( VIK_EXT_TOOL ( webtool ) );
129 g_object_unref ( webtool );
130
131 webtool = vik_webtool_center_new_with_members ( _("OSM (render)"), "http://www.informationfreeway.org/?lat=%s&lon=%s&zoom=%d&layers=B0000F000F" );
132 vik_ext_tools_register ( VIK_EXT_TOOL ( webtool ) );
133 g_object_unref ( webtool );
5149a69d 134
e1506f37
RN
135 VikWebtoolBounds *webtoolbounds = NULL;
136 // Example: http://127.0.0.1:8111/load_and_zoom?left=8.19&right=8.20&top=48.605&bottom=48.590&select=node413602999
137 // JOSM or merkaartor must already be running with remote interface enabled
138 webtoolbounds = vik_webtool_bounds_new_with_members ( _("Local port 8111 (eg JOSM)"), "http://localhost:8111/load_and_zoom?left=%s&right=%s&bottom=%s&top=%s" );
139 vik_ext_tools_register ( VIK_EXT_TOOL ( webtoolbounds ) );
140 g_object_unref ( webtoolbounds );
141
82993cc7
RN
142 // NB: THERE MUST BE AT LEAST ONE VikWebtoolDatasource defined otherwise the parsing of the datasource.xml will fail
143 // since it won't know about such a GObject type existing!
144 // (in fact this is a problem in the vikgobjectbuilder -> g_markup_parse_context_parse -> _start_element -> g_type_from_name )
145 VikWebtoolDatasource *vwtds = NULL;
5910b4fb
RN
146 vwtds = vik_webtool_datasource_new_with_members ( _("OpenStreetMap Notes"), "http://api.openstreetmap.org/api/0.6/notes.gpx?bbox=%s,%s,%s,%s&amp;closed=0", "LBRT", NULL );
147 vik_ext_tool_datasources_register ( VIK_EXT_TOOL ( vwtds ) );
148 g_object_unref ( vwtds );
149
82993cc7
RN
150 vwtds = vik_webtool_datasource_new_with_members ( _("OpenStreetBugs"), "http://openstreetbugs.schokokeks.org/api/0.1/getGPX?l=%s&r=%s&b=%s&t=%s&open=only_open_bugs", "LRBT", NULL );
151 vik_ext_tool_datasources_register ( VIK_EXT_TOOL ( vwtds ) );
152 g_object_unref ( vwtds );
153
5149a69d
GB
154 // Goto
155 VikGotoXmlTool *nominatim = VIK_GOTO_XML_TOOL ( g_object_new ( VIK_GOTO_XML_TOOL_TYPE, "label", "OSM Nominatim",
156 "url-format", "http://nominatim.openstreetmap.org/search?q=%s&format=xml",
157 "lat-path", "/searchresults/place",
158 "lat-attr", "lat",
159 "lon-path", "/searchresults/place",
160 "lon-attr", "lon",
161 NULL ) );
162 vik_goto_register ( VIK_GOTO_TOOL ( nominatim ) );
163 g_object_unref ( nominatim );
54cef17b
GB
164
165 VikGotoXmlTool *namefinder = VIK_GOTO_XML_TOOL ( g_object_new ( VIK_GOTO_XML_TOOL_TYPE, "label", "OSM Name finder",
166 "url-format", "http://gazetteer.openstreetmap.org/namefinder/search.xml?find=%s&max=1",
167 "lat-path", "/searchresults/named",
168 "lat-attr", "lat",
169 "lon-path", "/searchresults/named",
170 "lon-attr", "lon",
171 NULL ) );
172 vik_goto_register ( VIK_GOTO_TOOL ( namefinder ) );
173 g_object_unref ( namefinder );
3346da31
RN
174
175 // Not really OSM but can't be bothered to create somewhere else to put it...
176 webtool = vik_webtool_center_new_with_members ( _("Wikimedia Toolserver GeoHack"), "http://toolserver.org/~geohack/geohack.php?params=%s;%s" );
177 vik_ext_tools_register ( VIK_EXT_TOOL ( webtool ) );
178 g_object_unref ( webtool );
67209ca8
GB
179}
180