2 * viking -- GPS Data and Topo Analyzer, Explorer, and Manager
4 * Copyright (C) 2003-2005, Evan Battaglia <gtoevan@gmx.net>
5 * Copyright (C) 2007,2013, Guilhem Bonnefille <guilhem.bonnefille@gmail.com>
6 * Copyright (c) 2012-2014, Rob Norris <rw_norris@hotmail.com>
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.
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.
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
27 #include <glib/gi18n.h>
31 #include "vikmapslayer.h"
32 #include "vikslippymapsource.h"
33 #include "vikwmscmapsource.h"
34 #include "vikwebtoolcenter.h"
35 #include "vikwebtoolbounds.h"
36 #include "vikwebtoolformat.h"
37 #include "vikwebtool_datasource.h"
38 #include "vikexttools.h"
39 #include "vikexttool_datasources.h"
40 #include "vikgotoxmltool.h"
42 #include "vikrouting.h"
43 #include "vikroutingwebengine.h"
47 VikMapSource *mapnik_type =
48 VIK_MAP_SOURCE(g_object_new(VIK_TYPE_SLIPPY_MAP_SOURCE,
49 "id", MAP_ID_OSM_MAPNIK,
50 "label", _("OpenStreetMap (Mapnik)"),
52 "hostname", "tile.openstreetmap.org",
53 "url", "/%d/%d/%d.png",
54 "check-file-server-time", FALSE,
58 "copyright", "© OpenStreetMap contributors",
59 "license", "CC-BY-SA",
60 "license-url", "http://www.openstreetmap.org/copyright",
62 VikMapSource *cycle_type =
63 VIK_MAP_SOURCE(g_object_new(VIK_TYPE_SLIPPY_MAP_SOURCE,
64 "id", MAP_ID_OSM_CYCLE,
65 "label", _("OpenStreetMap (Cycle)"),
67 "hostname", "tile.opencyclemap.org",
68 "url", "/cycle/%d/%d/%d.png",
69 "check-file-server-time", TRUE,
73 "copyright", "Tiles courtesy of Andy Allan © OpenStreetMap contributors",
74 "license", "CC-BY-SA",
75 "license-url", "http://www.openstreetmap.org/copyright",
77 VikMapSource *transport_type =
78 VIK_MAP_SOURCE(g_object_new(VIK_TYPE_SLIPPY_MAP_SOURCE,
79 "id", MAP_ID_OSM_TRANSPORT,
80 "label", _("OpenStreetMap (Transport)"),
81 "name", "OSM-Transport",
82 "hostname", "tile2.opencyclemap.org",
83 "url", "/transport/%d/%d/%d.png",
84 "check-file-server-time", TRUE,
88 "copyright", "Tiles courtesy of Andy Allan © OpenStreetMap contributors",
89 "license", "CC-BY-SA",
90 "license-url", "http://www.openstreetmap.org/copyright",
92 VikMapSource *hot_type =
93 VIK_MAP_SOURCE(g_object_new(VIK_TYPE_SLIPPY_MAP_SOURCE,
94 "id", MAP_ID_OSM_HUMANITARIAN,
95 "name", "OSM-Humanitarian",
96 "label", _("OpenStreetMap (Humanitarian)"),
97 "hostname", "c.tile.openstreetmap.fr",
98 "url", "/hot/%d/%d/%d.png",
99 "check-file-server-time", TRUE,
102 "zoom-max", 20, // Super detail!!
103 "copyright", "© OpenStreetMap contributors. Tiles courtesy of Humanitarian OpenStreetMap Team",
104 "license", "CC-BY-SA",
105 "license-url", "http://www.openstreetmap.org/copyright",
108 // NB no cache needed for this type!!
109 VikMapSource *direct_type =
110 VIK_MAP_SOURCE(g_object_new(VIK_TYPE_SLIPPY_MAP_SOURCE,
111 "id", MAP_ID_OSM_ON_DISK,
112 "label", _("On Disk OSM Tile Format"),
113 // For using your own generated data assumed you know the license already!
114 "copyright", "© OpenStreetMap contributors", // probably
115 "use-direct-file-access", TRUE,
118 // NB no cache needed for this type!!
119 VikMapSource *mbtiles_type =
120 VIK_MAP_SOURCE(g_object_new(VIK_TYPE_SLIPPY_MAP_SOURCE,
121 "id", MAP_ID_MBTILES,
122 "label", _("MBTiles File"),
123 // For using your own generated data assumed you know the license already!
124 "copyright", "© OpenStreetMap contributors", // probably
125 "use-direct-file-access", TRUE,
129 // NB no cache needed for this type!!
130 VikMapSource *metatiles_type =
131 VIK_MAP_SOURCE(g_object_new(VIK_TYPE_SLIPPY_MAP_SOURCE,
132 "id", MAP_ID_OSM_METATILES,
133 "label", _("OSM Metatiles"),
134 // For using your own generated data assumed you know the license already!
135 "copyright", "© OpenStreetMap contributors", // probably
136 "use-direct-file-access", TRUE,
137 "is-osm-meta-tiles", TRUE,
140 // Note using a registered token for the Mapbox Tileservice
141 // Thus not only will the (free) service allocation limit be reached by normal users
142 // but by anymore who cares to read these sources and use the default themselves.
143 VikMapSource *mapbox_type =
144 VIK_MAP_SOURCE(g_object_new(VIK_TYPE_SLIPPY_MAP_SOURCE,
145 "id", MAP_ID_MAPBOX_OUTDOORS,
146 "name", "Mapbox-Outdoors",
147 "label", _("Mapbox Outdoors"),
148 "url", "https://api.tiles.mapbox.com/styles/v1/mapbox/outdoors-v9/tiles/256/%d/%d/%d?access_token="VIK_CONFIG_MAPBOX_TOKEN,
149 "check-file-server-time", TRUE,
153 "copyright", "© Mapbox © OpenStreetMap",
154 "license", _("Mapbox Specific"),
155 "license-url", "https://www.mapbox.com/tos",
158 // NB The first registered map source is the default
159 // (unless the user has specified Map Layer defaults)
160 maps_layer_register_map_source (mapbox_type);
161 maps_layer_register_map_source (mapnik_type);
162 maps_layer_register_map_source (cycle_type);
163 maps_layer_register_map_source (transport_type);
164 maps_layer_register_map_source (hot_type);
165 maps_layer_register_map_source (direct_type);
166 maps_layer_register_map_source (mbtiles_type);
167 maps_layer_register_map_source (metatiles_type);
170 VikWebtoolCenter *webtool = NULL;
171 webtool = vik_webtool_center_new_with_members ( _("OSM (view)"), "http://www.openstreetmap.org/?lat=%s&lon=%s&zoom=%d" );
172 vik_ext_tools_register ( VIK_EXT_TOOL ( webtool ) );
173 g_object_unref ( webtool );
175 webtool = vik_webtool_center_new_with_members ( _("OSM (edit)"), "http://www.openstreetmap.org/edit?lat=%s&lon=%s&zoom=%d" );
176 vik_ext_tools_register ( VIK_EXT_TOOL ( webtool ) );
177 g_object_unref ( webtool );
179 // Note the use of positional parameters
180 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" );
181 vik_ext_tools_register ( VIK_EXT_TOOL ( webtool ) );
182 g_object_unref ( webtool );
184 webtool = vik_webtool_center_new_with_members ( _("OSM (render)"), "http://www.informationfreeway.org/?lat=%s&lon=%s&zoom=%d&layers=B0000F000F" );
185 vik_ext_tools_register ( VIK_EXT_TOOL ( webtool ) );
186 g_object_unref ( webtool );
188 VikWebtoolBounds *webtoolbounds = NULL;
189 // Example: http://127.0.0.1:8111/load_and_zoom?left=8.19&right=8.20&top=48.605&bottom=48.590&select=node413602999
190 // JOSM or merkaartor must already be running with remote interface enabled
191 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" );
192 vik_ext_tools_register ( VIK_EXT_TOOL ( webtoolbounds ) );
193 g_object_unref ( webtoolbounds );
195 VikWebtoolFormat *vwtf = NULL;
196 vwtf = vik_webtool_format_new_with_members ( _("Geofabrik Map Compare"),
197 "http://tools.geofabrik.de/mc/#%s/%s/%s",
199 vik_ext_tools_register ( VIK_EXT_TOOL ( vwtf ) );
200 g_object_unref ( vwtf );
203 VikWebtoolDatasource *vwtds = NULL;
204 vwtds = vik_webtool_datasource_new_with_members ( _("OpenStreetMap Notes"), "http://api.openstreetmap.org/api/0.6/notes.gpx?bbox=%s,%s,%s,%s&closed=0", "LBRT", NULL, NULL, NULL );
205 vik_ext_tool_datasources_register ( VIK_EXT_TOOL ( vwtds ) );
206 g_object_unref ( vwtds );
209 VikGotoXmlTool *nominatim = VIK_GOTO_XML_TOOL ( g_object_new ( VIK_GOTO_XML_TOOL_TYPE, "label", "OSM Nominatim",
210 "url-format", "http://nominatim.openstreetmap.org/search?q=%s&format=xml",
211 "lat-path", "/searchresults/place",
213 "lon-path", "/searchresults/place",
216 vik_goto_register ( VIK_GOTO_TOOL ( nominatim ) );
217 g_object_unref ( nominatim );
219 VikGotoXmlTool *namefinder = VIK_GOTO_XML_TOOL ( g_object_new ( VIK_GOTO_XML_TOOL_TYPE, "label", "OSM Name finder",
220 "url-format", "http://gazetteer.openstreetmap.org/namefinder/search.xml?find=%s&max=1",
221 "lat-path", "/searchresults/named",
223 "lon-path", "/searchresults/named",
226 vik_goto_register ( VIK_GOTO_TOOL ( namefinder ) );
227 g_object_unref ( namefinder );
229 // Not really OSM but can't be bothered to create somewhere else to put it...
230 webtool = vik_webtool_center_new_with_members ( _("Wikimedia Toolserver GeoHack"), "http://tools.wmflabs.org/geohack/geohack.php?params=%s;%s" );
231 vik_ext_tools_register ( VIK_EXT_TOOL ( webtool ) );
232 g_object_unref ( webtool );