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, 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>
30 #include "vikmapslayer.h"
31 #include "vikslippymapsource.h"
32 #include "vikwmscmapsource.h"
33 #include "vikwebtoolcenter.h"
34 #include "vikwebtoolbounds.h"
35 #include "vikwebtool_datasource.h"
36 #include "vikexttools.h"
37 #include "vikexttool_datasources.h"
38 #include "vikgotoxmltool.h"
40 #include "vikrouting.h"
41 #include "vikroutingwebengine.h"
45 VikMapSource *mapnik_type =
46 VIK_MAP_SOURCE(g_object_new(VIK_TYPE_SLIPPY_MAP_SOURCE,
48 "label", "OpenStreetMap (Mapnik)",
49 "hostname", "tile.openstreetmap.org",
50 "url", "/%d/%d/%d.png",
51 "check-file-server-time", FALSE,
53 "copyright", "© OpenStreetMap contributors",
54 "license", "CC-BY-SA",
55 "license-url", "http://www.openstreetmap.org/copyright",
57 VikMapSource *cycle_type =
58 VIK_MAP_SOURCE(g_object_new(VIK_TYPE_SLIPPY_MAP_SOURCE,
60 "label", "OpenStreetMap (Cycle)",
61 "hostname", "b.tile.opencyclemap.org",
62 "url", "/cycle/%d/%d/%d.png",
63 "check-file-server-time", TRUE,
65 "copyright", "Tiles courtesy of Andy Allan © OpenStreetMap contributors",
66 "license", "CC-BY-SA",
67 "license-url", "http://www.openstreetmap.org/copyright",
69 VikMapSource *transport_type =
70 VIK_MAP_SOURCE(g_object_new(VIK_TYPE_SLIPPY_MAP_SOURCE,
72 "label", "OpenStreetMap (Transport)",
73 "hostname", "c.tile2.opencyclemap.org",
74 "url", "/transport/%d/%d/%d.png",
75 "check-file-server-time", TRUE,
77 "copyright", "Tiles courtesy of Andy Allan © OpenStreetMap contributors",
78 "license", "CC-BY-SA",
79 "license-url", "http://www.openstreetmap.org/copyright",
82 VikMapSource *mapquest_type =
83 VIK_MAP_SOURCE(g_object_new(VIK_TYPE_SLIPPY_MAP_SOURCE,
85 "label", "OpenStreetMap (MapQuest)",
86 "hostname", "otile1.mqcdn.com",
87 "url", "/tiles/1.0.0/osm/%d/%d/%d.png",
88 "check-file-server-time", TRUE,
90 "copyright", "Tiles Courtesy of MapQuest © OpenStreetMap contributors",
91 "license", "MapQuest Specific",
92 "license-url", "http://developer.mapquest.com/web/info/terms-of-use",
94 VikMapSource *hot_type =
95 VIK_MAP_SOURCE(g_object_new(VIK_TYPE_SLIPPY_MAP_SOURCE,
97 "label", "OpenStreetMap (Humanitarian)",
98 "hostname", "c.tile.openstreetmap.fr",
99 "url", "/hot/%d/%d/%d.png",
100 "check-file-server-time", TRUE,
102 "copyright", "© OpenStreetMap contributors. Tiles courtesy of Humanitarian OpenStreetMap Team",
103 "license", "CC-BY-SA",
104 "license-url", "http://www.openstreetmap.org/copyright",
107 // NB no cache needed for this type!!
108 VikMapSource *direct_type =
109 VIK_MAP_SOURCE(g_object_new(VIK_TYPE_SLIPPY_MAP_SOURCE,
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,
117 maps_layer_register_map_source (mapquest_type);
118 maps_layer_register_map_source (mapnik_type);
119 maps_layer_register_map_source (cycle_type);
120 maps_layer_register_map_source (transport_type);
121 maps_layer_register_map_source (hot_type);
122 maps_layer_register_map_source (direct_type);
125 VikWebtoolCenter *webtool = NULL;
126 webtool = vik_webtool_center_new_with_members ( _("OSM (view)"), "http://openstreetmap.org/?lat=%s&lon=%s&zoom=%d" );
127 vik_ext_tools_register ( VIK_EXT_TOOL ( webtool ) );
128 g_object_unref ( webtool );
130 webtool = vik_webtool_center_new_with_members ( _("OSM (edit)"), "http://www.openstreetmap.org/edit?lat=%s&lon=%s&zoom=%d" );
131 vik_ext_tools_register ( VIK_EXT_TOOL ( webtool ) );
132 g_object_unref ( webtool );
134 webtool = vik_webtool_center_new_with_members ( _("OSM (render)"), "http://www.informationfreeway.org/?lat=%s&lon=%s&zoom=%d&layers=B0000F000F" );
135 vik_ext_tools_register ( VIK_EXT_TOOL ( webtool ) );
136 g_object_unref ( webtool );
138 VikWebtoolBounds *webtoolbounds = NULL;
139 // Example: http://127.0.0.1:8111/load_and_zoom?left=8.19&right=8.20&top=48.605&bottom=48.590&select=node413602999
140 // JOSM or merkaartor must already be running with remote interface enabled
141 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" );
142 vik_ext_tools_register ( VIK_EXT_TOOL ( webtoolbounds ) );
143 g_object_unref ( webtoolbounds );
146 VikWebtoolDatasource *vwtds = NULL;
147 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 );
148 vik_ext_tool_datasources_register ( VIK_EXT_TOOL ( vwtds ) );
149 g_object_unref ( vwtds );
151 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 );
152 vik_ext_tool_datasources_register ( VIK_EXT_TOOL ( vwtds ) );
153 g_object_unref ( vwtds );
156 VikGotoXmlTool *nominatim = VIK_GOTO_XML_TOOL ( g_object_new ( VIK_GOTO_XML_TOOL_TYPE, "label", "OSM Nominatim",
157 "url-format", "http://nominatim.openstreetmap.org/search?q=%s&format=xml",
158 "lat-path", "/searchresults/place",
160 "lon-path", "/searchresults/place",
163 vik_goto_register ( VIK_GOTO_TOOL ( nominatim ) );
164 g_object_unref ( nominatim );
166 VikGotoXmlTool *namefinder = VIK_GOTO_XML_TOOL ( g_object_new ( VIK_GOTO_XML_TOOL_TYPE, "label", "OSM Name finder",
167 "url-format", "http://gazetteer.openstreetmap.org/namefinder/search.xml?find=%s&max=1",
168 "lat-path", "/searchresults/named",
170 "lon-path", "/searchresults/named",
173 vik_goto_register ( VIK_GOTO_TOOL ( namefinder ) );
174 g_object_unref ( namefinder );
176 // Not really OSM but can't be bothered to create somewhere else to put it...
177 webtool = vik_webtool_center_new_with_members ( _("Wikimedia Toolserver GeoHack"), "http://toolserver.org/~geohack/geohack.php?params=%s;%s" );
178 vik_ext_tools_register ( VIK_EXT_TOOL ( webtool ) );
179 g_object_unref ( webtool );
181 /* See API references: https://github.com/DennisOSRM/Project-OSRM/wiki/Server-api */
182 VikRoutingEngine *osrm = g_object_new ( VIK_ROUTING_WEB_ENGINE_TYPE,
186 "url-base", "http://router.project-osrm.org/viaroute?output=gpx",
187 "url-start-ll", "&loc=%s,%s",
188 "url-stop-ll", "&loc=%s,%s",
189 "url-via-ll", "&loc=%s,%s",
191 vik_routing_register ( VIK_ROUTING_ENGINE ( osrm ) );
192 g_object_unref ( osrm );