]> git.street.me.uk Git - andy/viking.git/blame - src/osm.c
Some spelling fixes in a comment
[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>
5ae894dc 5 * Copyright (C) 2007,2013, Guilhem Bonnefille <guilhem.bonnefille@gmail.com>
99f0d7df 6 * Copyright (c) 2012-2014, 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"
62e15495 30#include "map_ids.h"
f7d8a3c2 31#include "vikmapslayer.h"
8eb12ac6 32#include "vikslippymapsource.h"
50713970 33#include "vikwmscmapsource.h"
92806042 34#include "vikwebtoolcenter.h"
e1506f37 35#include "vikwebtoolbounds.h"
a3dcc49e 36#include "vikwebtoolformat.h"
82993cc7 37#include "vikwebtool_datasource.h"
92806042 38#include "vikexttools.h"
82993cc7 39#include "vikexttool_datasources.h"
5149a69d
GB
40#include "vikgotoxmltool.h"
41#include "vikgoto.h"
5ae894dc 42#include "vikrouting.h"
5ec699da 43#include "vikroutingwebengine.h"
4f92972b 44
67209ca8
GB
45/* initialisation */
46void osm_init () {
0f08bd0d
GB
47 VikMapSource *mapnik_type =
48 VIK_MAP_SOURCE(g_object_new(VIK_TYPE_SLIPPY_MAP_SOURCE,
62e15495 49 "id", MAP_ID_OSM_MAPNIK,
14dd983a 50 "label", _("OpenStreetMap (Mapnik)"),
2eb18edc 51 "name", "OSM-Mapnik",
0f08bd0d
GB
52 "hostname", "tile.openstreetmap.org",
53 "url", "/%d/%d/%d.png",
05dbd9ba
JJ
54 "check-file-server-time", FALSE,
55 "use-etag", TRUE,
e633ddef
RN
56 "zoom-min", 0,
57 "zoom-max", 19,
82aa018d 58 "copyright", "© OpenStreetMap contributors",
53ac8302
GB
59 "license", "CC-BY-SA",
60 "license-url", "http://www.openstreetmap.org/copyright",
0f08bd0d 61 NULL));
0f08bd0d
GB
62 VikMapSource *cycle_type =
63 VIK_MAP_SOURCE(g_object_new(VIK_TYPE_SLIPPY_MAP_SOURCE,
62e15495 64 "id", MAP_ID_OSM_CYCLE,
14dd983a 65 "label", _("OpenStreetMap (Cycle)"),
2eb18edc 66 "name", "OSM-Cycle",
e22353c2 67 "url", "https://tile.thunderforest.com/cycle/%d/%d/%d.png?apikey="VIK_CONFIG_THUNDERFOREST_KEY,
6693f5f9 68 "check-file-server-time", TRUE,
05dbd9ba 69 "use-etag", FALSE,
e633ddef
RN
70 "zoom-min", 0,
71 "zoom-max", 18,
82c3dd37 72 "copyright", "Tiles courtesy of Andy Allan © OpenStreetMap contributors",
53ac8302
GB
73 "license", "CC-BY-SA",
74 "license-url", "http://www.openstreetmap.org/copyright",
0f08bd0d 75 NULL));
5c9e34b9
RN
76 VikMapSource *transport_type =
77 VIK_MAP_SOURCE(g_object_new(VIK_TYPE_SLIPPY_MAP_SOURCE,
62e15495 78 "id", MAP_ID_OSM_TRANSPORT,
14dd983a 79 "label", _("OpenStreetMap (Transport)"),
2eb18edc 80 "name", "OSM-Transport",
12b68116 81 "hostname", "tile2.opencyclemap.org",
5c9e34b9
RN
82 "url", "/transport/%d/%d/%d.png",
83 "check-file-server-time", TRUE,
84 "use-etag", FALSE,
e633ddef
RN
85 "zoom-min", 0,
86 "zoom-max", 18,
5c9e34b9
RN
87 "copyright", "Tiles courtesy of Andy Allan © OpenStreetMap contributors",
88 "license", "CC-BY-SA",
89 "license-url", "http://www.openstreetmap.org/copyright",
90 NULL));
b18a7f39
RN
91 VikMapSource *hot_type =
92 VIK_MAP_SOURCE(g_object_new(VIK_TYPE_SLIPPY_MAP_SOURCE,
62e15495 93 "id", MAP_ID_OSM_HUMANITARIAN,
2eb18edc 94 "name", "OSM-Humanitarian",
14dd983a 95 "label", _("OpenStreetMap (Humanitarian)"),
b18a7f39
RN
96 "hostname", "c.tile.openstreetmap.fr",
97 "url", "/hot/%d/%d/%d.png",
98 "check-file-server-time", TRUE,
99 "use-etag", FALSE,
e633ddef
RN
100 "zoom-min", 0,
101 "zoom-max", 20, // Super detail!!
b18a7f39
RN
102 "copyright", "© OpenStreetMap contributors. Tiles courtesy of Humanitarian OpenStreetMap Team",
103 "license", "CC-BY-SA",
104 "license-url", "http://www.openstreetmap.org/copyright",
105 NULL));
427976e5 106
2673b29d
RN
107 // NB no cache needed for this type!!
108 VikMapSource *direct_type =
109 VIK_MAP_SOURCE(g_object_new(VIK_TYPE_SLIPPY_MAP_SOURCE,
62e15495 110 "id", MAP_ID_OSM_ON_DISK,
2673b29d
RN
111 "label", _("On Disk OSM Tile Format"),
112 // For using your own generated data assumed you know the license already!
113 "copyright", "© OpenStreetMap contributors", // probably
114 "use-direct-file-access", TRUE,
115 NULL));
116
0fb11294
RN
117 // NB no cache needed for this type!!
118 VikMapSource *mbtiles_type =
119 VIK_MAP_SOURCE(g_object_new(VIK_TYPE_SLIPPY_MAP_SOURCE,
62e15495 120 "id", MAP_ID_MBTILES,
0fb11294
RN
121 "label", _("MBTiles File"),
122 // For using your own generated data assumed you know the license already!
123 "copyright", "© OpenStreetMap contributors", // probably
124 "use-direct-file-access", TRUE,
125 "is-mbtiles", TRUE,
126 NULL));
127
99f0d7df
RN
128 // NB no cache needed for this type!!
129 VikMapSource *metatiles_type =
130 VIK_MAP_SOURCE(g_object_new(VIK_TYPE_SLIPPY_MAP_SOURCE,
62e15495 131 "id", MAP_ID_OSM_METATILES,
99f0d7df
RN
132 "label", _("OSM Metatiles"),
133 // For using your own generated data assumed you know the license already!
134 "copyright", "© OpenStreetMap contributors", // probably
135 "use-direct-file-access", TRUE,
136 "is-osm-meta-tiles", TRUE,
137 NULL));
138
ad8b1593 139 // Note using a registered token for the Mapbox Tileservice
05c5d7f6 140 // Thus not only will the (free) service allocation limit be reached by normal users
ad8b1593 141 // but by anymore who cares to read these sources and use the default themselves.
05c5d7f6
RN
142 VikMapSource *mapbox_type =
143 VIK_MAP_SOURCE(g_object_new(VIK_TYPE_SLIPPY_MAP_SOURCE,
144 "id", MAP_ID_MAPBOX_OUTDOORS,
145 "name", "Mapbox-Outdoors",
14dd983a 146 "label", _("Mapbox Outdoors"),
ad8b1593 147 "url", "https://api.tiles.mapbox.com/styles/v1/mapbox/outdoors-v9/tiles/256/%d/%d/%d?access_token="VIK_CONFIG_MAPBOX_TOKEN,
05c5d7f6
RN
148 "check-file-server-time", TRUE,
149 "use-etag", FALSE,
150 "zoom-min", 0,
151 "zoom-max", 19,
152 "copyright", "© Mapbox © OpenStreetMap",
14dd983a 153 "license", _("Mapbox Specific"),
05c5d7f6
RN
154 "license-url", "https://www.mapbox.com/tos",
155 NULL));
156
157 // NB The first registered map source is the default
158 // (unless the user has specified Map Layer defaults)
159 maps_layer_register_map_source (mapbox_type);
db03733a 160 maps_layer_register_map_source (mapnik_type);
db03733a 161 maps_layer_register_map_source (cycle_type);
5c9e34b9 162 maps_layer_register_map_source (transport_type);
b18a7f39 163 maps_layer_register_map_source (hot_type);
2673b29d 164 maps_layer_register_map_source (direct_type);
0fb11294 165 maps_layer_register_map_source (mbtiles_type);
99f0d7df 166 maps_layer_register_map_source (metatiles_type);
92806042
GB
167
168 // Webtools
169 VikWebtoolCenter *webtool = NULL;
e06998d2 170 webtool = vik_webtool_center_new_with_members ( _("OSM (view)"), "http://www.openstreetmap.org/?lat=%s&lon=%s&zoom=%d" );
92806042
GB
171 vik_ext_tools_register ( VIK_EXT_TOOL ( webtool ) );
172 g_object_unref ( webtool );
173
174 webtool = vik_webtool_center_new_with_members ( _("OSM (edit)"), "http://www.openstreetmap.org/edit?lat=%s&lon=%s&zoom=%d" );
175 vik_ext_tools_register ( VIK_EXT_TOOL ( webtool ) );
176 g_object_unref ( webtool );
177
875fa02a
RN
178 // Note the use of positional parameters
179 webtool = vik_webtool_center_new_with_members ( _("OSM (query)"), "http://www.openstreetmap.org/query?lat=%1$s&lon=%2$s#map=%3$d/%1$s/%2$s" );
180 vik_ext_tools_register ( VIK_EXT_TOOL ( webtool ) );
181 g_object_unref ( webtool );
182
92806042
GB
183 webtool = vik_webtool_center_new_with_members ( _("OSM (render)"), "http://www.informationfreeway.org/?lat=%s&lon=%s&zoom=%d&layers=B0000F000F" );
184 vik_ext_tools_register ( VIK_EXT_TOOL ( webtool ) );
185 g_object_unref ( webtool );
5149a69d 186
e1506f37
RN
187 VikWebtoolBounds *webtoolbounds = NULL;
188 // Example: http://127.0.0.1:8111/load_and_zoom?left=8.19&right=8.20&top=48.605&bottom=48.590&select=node413602999
189 // JOSM or merkaartor must already be running with remote interface enabled
190 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" );
191 vik_ext_tools_register ( VIK_EXT_TOOL ( webtoolbounds ) );
192 g_object_unref ( webtoolbounds );
193
a3dcc49e
RN
194 VikWebtoolFormat *vwtf = NULL;
195 vwtf = vik_webtool_format_new_with_members ( _("Geofabrik Map Compare"),
196 "http://tools.geofabrik.de/mc/#%s/%s/%s",
197 "ZAO" );
198 vik_ext_tools_register ( VIK_EXT_TOOL ( vwtf ) );
199 g_object_unref ( vwtf );
200
2241ad12 201 // Datasource
82993cc7 202 VikWebtoolDatasource *vwtds = NULL;
1a8f3840 203 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, NULL, NULL );
5910b4fb
RN
204 vik_ext_tool_datasources_register ( VIK_EXT_TOOL ( vwtds ) );
205 g_object_unref ( vwtds );
206
5149a69d
GB
207 // Goto
208 VikGotoXmlTool *nominatim = VIK_GOTO_XML_TOOL ( g_object_new ( VIK_GOTO_XML_TOOL_TYPE, "label", "OSM Nominatim",
209 "url-format", "http://nominatim.openstreetmap.org/search?q=%s&format=xml",
210 "lat-path", "/searchresults/place",
211 "lat-attr", "lat",
212 "lon-path", "/searchresults/place",
213 "lon-attr", "lon",
214 NULL ) );
215 vik_goto_register ( VIK_GOTO_TOOL ( nominatim ) );
216 g_object_unref ( nominatim );
54cef17b
GB
217
218 VikGotoXmlTool *namefinder = VIK_GOTO_XML_TOOL ( g_object_new ( VIK_GOTO_XML_TOOL_TYPE, "label", "OSM Name finder",
219 "url-format", "http://gazetteer.openstreetmap.org/namefinder/search.xml?find=%s&max=1",
220 "lat-path", "/searchresults/named",
221 "lat-attr", "lat",
222 "lon-path", "/searchresults/named",
223 "lon-attr", "lon",
224 NULL ) );
225 vik_goto_register ( VIK_GOTO_TOOL ( namefinder ) );
226 g_object_unref ( namefinder );
3346da31
RN
227
228 // Not really OSM but can't be bothered to create somewhere else to put it...
07e29a64 229 webtool = vik_webtool_center_new_with_members ( _("Wikimedia Toolserver GeoHack"), "http://tools.wmflabs.org/geohack/geohack.php?params=%s;%s" );
3346da31
RN
230 vik_ext_tools_register ( VIK_EXT_TOOL ( webtool ) );
231 g_object_unref ( webtool );
67209ca8
GB
232}
233