]> git.street.me.uk Git - andy/viking.git/blame_incremental - src/osm.c
[QA] Extra info when using bzip2.
[andy/viking.git] / src / osm.c
... / ...
CommitLineData
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,2013, Guilhem Bonnefille <guilhem.bonnefille@gmail.com>
6 * Copyright (c) 2012-2014, Rob Norris <rw_norris@hotmail.com>
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 */
23#ifdef HAVE_CONFIG_H
24#include "config.h"
25#endif
26
27#include <glib/gi18n.h>
28
29#include "osm.h"
30#include "map_ids.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"
41#include "vikgoto.h"
42#include "vikrouting.h"
43#include "vikroutingwebengine.h"
44
45/* initialisation */
46void osm_init () {
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)",
51 "name", "OSM-Mapnik",
52 "hostname", "tile.openstreetmap.org",
53 "url", "/%d/%d/%d.png",
54 "check-file-server-time", FALSE,
55 "use-etag", TRUE,
56 "zoom-min", 0,
57 "zoom-max", 19,
58 "copyright", "© OpenStreetMap contributors",
59 "license", "CC-BY-SA",
60 "license-url", "http://www.openstreetmap.org/copyright",
61 NULL));
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)",
66 "name", "OSM-Cycle",
67 "hostname", "tile.opencyclemap.org",
68 "url", "/cycle/%d/%d/%d.png",
69 "check-file-server-time", TRUE,
70 "use-etag", FALSE,
71 "zoom-min", 0,
72 "zoom-max", 18,
73 "copyright", "Tiles courtesy of Andy Allan © OpenStreetMap contributors",
74 "license", "CC-BY-SA",
75 "license-url", "http://www.openstreetmap.org/copyright",
76 NULL));
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,
85 "use-etag", FALSE,
86 "zoom-min", 0,
87 "zoom-max", 18,
88 "copyright", "Tiles courtesy of Andy Allan © OpenStreetMap contributors",
89 "license", "CC-BY-SA",
90 "license-url", "http://www.openstreetmap.org/copyright",
91 NULL));
92 VikMapSource *mapquest_type =
93 VIK_MAP_SOURCE(g_object_new(VIK_TYPE_SLIPPY_MAP_SOURCE,
94 "id", MAP_ID_MAPQUEST_OSM,
95 "name", "OSM-MapQuest",
96 "label", "OpenStreetMap (MapQuest)",
97 "hostname", "otile1.mqcdn.com",
98 "url", "/tiles/1.0.0/osm/%d/%d/%d.png",
99 "check-file-server-time", TRUE,
100 "use-etag", FALSE,
101 "zoom-min", 0,
102 "zoom-max", 19,
103 "copyright", "Tiles Courtesy of MapQuest © OpenStreetMap contributors",
104 "license", "MapQuest Specific",
105 "license-url", "http://developer.mapquest.com/web/info/terms-of-use",
106 NULL));
107 VikMapSource *hot_type =
108 VIK_MAP_SOURCE(g_object_new(VIK_TYPE_SLIPPY_MAP_SOURCE,
109 "id", MAP_ID_OSM_HUMANITARIAN,
110 "name", "OSM-Humanitarian",
111 "label", "OpenStreetMap (Humanitarian)",
112 "hostname", "c.tile.openstreetmap.fr",
113 "url", "/hot/%d/%d/%d.png",
114 "check-file-server-time", TRUE,
115 "use-etag", FALSE,
116 "zoom-min", 0,
117 "zoom-max", 20, // Super detail!!
118 "copyright", "© OpenStreetMap contributors. Tiles courtesy of Humanitarian OpenStreetMap Team",
119 "license", "CC-BY-SA",
120 "license-url", "http://www.openstreetmap.org/copyright",
121 NULL));
122
123 // NB no cache needed for this type!!
124 VikMapSource *direct_type =
125 VIK_MAP_SOURCE(g_object_new(VIK_TYPE_SLIPPY_MAP_SOURCE,
126 "id", MAP_ID_OSM_ON_DISK,
127 "label", _("On Disk OSM Tile Format"),
128 // For using your own generated data assumed you know the license already!
129 "copyright", "© OpenStreetMap contributors", // probably
130 "use-direct-file-access", TRUE,
131 NULL));
132
133 // NB no cache needed for this type!!
134 VikMapSource *mbtiles_type =
135 VIK_MAP_SOURCE(g_object_new(VIK_TYPE_SLIPPY_MAP_SOURCE,
136 "id", MAP_ID_MBTILES,
137 "label", _("MBTiles File"),
138 // For using your own generated data assumed you know the license already!
139 "copyright", "© OpenStreetMap contributors", // probably
140 "use-direct-file-access", TRUE,
141 "is-mbtiles", TRUE,
142 NULL));
143
144 // NB no cache needed for this type!!
145 VikMapSource *metatiles_type =
146 VIK_MAP_SOURCE(g_object_new(VIK_TYPE_SLIPPY_MAP_SOURCE,
147 "id", MAP_ID_OSM_METATILES,
148 "label", _("OSM Metatiles"),
149 // For using your own generated data assumed you know the license already!
150 "copyright", "© OpenStreetMap contributors", // probably
151 "use-direct-file-access", TRUE,
152 "is-osm-meta-tiles", TRUE,
153 NULL));
154
155 maps_layer_register_map_source (mapquest_type);
156 maps_layer_register_map_source (mapnik_type);
157 maps_layer_register_map_source (cycle_type);
158 maps_layer_register_map_source (transport_type);
159 maps_layer_register_map_source (hot_type);
160 maps_layer_register_map_source (direct_type);
161 maps_layer_register_map_source (mbtiles_type);
162 maps_layer_register_map_source (metatiles_type);
163
164 // Webtools
165 VikWebtoolCenter *webtool = NULL;
166 webtool = vik_webtool_center_new_with_members ( _("OSM (view)"), "http://www.openstreetmap.org/?lat=%s&lon=%s&zoom=%d" );
167 vik_ext_tools_register ( VIK_EXT_TOOL ( webtool ) );
168 g_object_unref ( webtool );
169
170 webtool = vik_webtool_center_new_with_members ( _("OSM (edit)"), "http://www.openstreetmap.org/edit?lat=%s&lon=%s&zoom=%d" );
171 vik_ext_tools_register ( VIK_EXT_TOOL ( webtool ) );
172 g_object_unref ( webtool );
173
174 // Note the use of positional parameters
175 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" );
176 vik_ext_tools_register ( VIK_EXT_TOOL ( webtool ) );
177 g_object_unref ( webtool );
178
179 webtool = vik_webtool_center_new_with_members ( _("OSM (render)"), "http://www.informationfreeway.org/?lat=%s&lon=%s&zoom=%d&layers=B0000F000F" );
180 vik_ext_tools_register ( VIK_EXT_TOOL ( webtool ) );
181 g_object_unref ( webtool );
182
183 VikWebtoolBounds *webtoolbounds = NULL;
184 // Example: http://127.0.0.1:8111/load_and_zoom?left=8.19&right=8.20&top=48.605&bottom=48.590&select=node413602999
185 // JOSM or merkaartor must already be running with remote interface enabled
186 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" );
187 vik_ext_tools_register ( VIK_EXT_TOOL ( webtoolbounds ) );
188 g_object_unref ( webtoolbounds );
189
190 VikWebtoolFormat *vwtf = NULL;
191 vwtf = vik_webtool_format_new_with_members ( _("Geofabrik Map Compare"),
192 "http://tools.geofabrik.de/mc/#%s/%s/%s",
193 "ZAO" );
194 vik_ext_tools_register ( VIK_EXT_TOOL ( vwtf ) );
195 g_object_unref ( vwtf );
196
197 // Datasource
198 VikWebtoolDatasource *vwtds = NULL;
199 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 );
200 vik_ext_tool_datasources_register ( VIK_EXT_TOOL ( vwtds ) );
201 g_object_unref ( vwtds );
202
203 // Goto
204 VikGotoXmlTool *nominatim = VIK_GOTO_XML_TOOL ( g_object_new ( VIK_GOTO_XML_TOOL_TYPE, "label", "OSM Nominatim",
205 "url-format", "http://nominatim.openstreetmap.org/search?q=%s&format=xml",
206 "lat-path", "/searchresults/place",
207 "lat-attr", "lat",
208 "lon-path", "/searchresults/place",
209 "lon-attr", "lon",
210 NULL ) );
211 vik_goto_register ( VIK_GOTO_TOOL ( nominatim ) );
212 g_object_unref ( nominatim );
213
214 VikGotoXmlTool *namefinder = VIK_GOTO_XML_TOOL ( g_object_new ( VIK_GOTO_XML_TOOL_TYPE, "label", "OSM Name finder",
215 "url-format", "http://gazetteer.openstreetmap.org/namefinder/search.xml?find=%s&max=1",
216 "lat-path", "/searchresults/named",
217 "lat-attr", "lat",
218 "lon-path", "/searchresults/named",
219 "lon-attr", "lon",
220 NULL ) );
221 vik_goto_register ( VIK_GOTO_TOOL ( namefinder ) );
222 g_object_unref ( namefinder );
223
224 // Not really OSM but can't be bothered to create somewhere else to put it...
225 webtool = vik_webtool_center_new_with_members ( _("Wikimedia Toolserver GeoHack"), "http://tools.wmflabs.org/geohack/geohack.php?params=%s;%s" );
226 vik_ext_tools_register ( VIK_EXT_TOOL ( webtool ) );
227 g_object_unref ( webtool );
228
229 /* See API references: https://github.com/DennisOSRM/Project-OSRM/wiki/Server-api */
230 VikRoutingEngine *osrm = g_object_new ( VIK_ROUTING_WEB_ENGINE_TYPE,
231 "id", "osrm",
232 "label", "OSRM",
233 "format", "gpx",
234 "url-base", "http://router.project-osrm.org/viaroute?output=gpx",
235 "url-start-ll", "&loc=%s,%s",
236 "url-stop-ll", "&loc=%s,%s",
237 "url-via-ll", "&loc=%s,%s",
238 NULL);
239 vik_routing_register ( VIK_ROUTING_ENGINE ( osrm ) );
240 g_object_unref ( osrm );
241}
242