]> git.street.me.uk Git - andy/viking.git/blame - src/osm.c
Add map name property which is used in the directory path of the cache storage.
[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>
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"
a3dcc49e 35#include "vikwebtoolformat.h"
82993cc7 36#include "vikwebtool_datasource.h"
92806042 37#include "vikexttools.h"
82993cc7 38#include "vikexttool_datasources.h"
5149a69d
GB
39#include "vikgotoxmltool.h"
40#include "vikgoto.h"
5ae894dc 41#include "vikrouting.h"
5ec699da 42#include "vikroutingwebengine.h"
4f92972b 43
67209ca8
GB
44/* initialisation */
45void osm_init () {
0f08bd0d
GB
46 VikMapSource *mapnik_type =
47 VIK_MAP_SOURCE(g_object_new(VIK_TYPE_SLIPPY_MAP_SOURCE,
48 "id", 13,
49 "label", "OpenStreetMap (Mapnik)",
2eb18edc 50 "name", "OSM-Mapnik",
0f08bd0d
GB
51 "hostname", "tile.openstreetmap.org",
52 "url", "/%d/%d/%d.png",
05dbd9ba
JJ
53 "check-file-server-time", FALSE,
54 "use-etag", TRUE,
82aa018d 55 "copyright", "© OpenStreetMap contributors",
53ac8302
GB
56 "license", "CC-BY-SA",
57 "license-url", "http://www.openstreetmap.org/copyright",
0f08bd0d 58 NULL));
0f08bd0d
GB
59 VikMapSource *cycle_type =
60 VIK_MAP_SOURCE(g_object_new(VIK_TYPE_SLIPPY_MAP_SOURCE,
61 "id", 17,
62 "label", "OpenStreetMap (Cycle)",
2eb18edc 63 "name", "OSM-Cycle",
12b68116 64 "hostname", "tile.opencyclemap.org",
218cdecd 65 "url", "/cycle/%d/%d/%d.png",
6693f5f9 66 "check-file-server-time", TRUE,
05dbd9ba 67 "use-etag", FALSE,
82c3dd37 68 "copyright", "Tiles courtesy of Andy Allan © OpenStreetMap contributors",
53ac8302
GB
69 "license", "CC-BY-SA",
70 "license-url", "http://www.openstreetmap.org/copyright",
0f08bd0d 71 NULL));
5c9e34b9
RN
72 VikMapSource *transport_type =
73 VIK_MAP_SOURCE(g_object_new(VIK_TYPE_SLIPPY_MAP_SOURCE,
74 "id", 20,
75 "label", "OpenStreetMap (Transport)",
2eb18edc 76 "name", "OSM-Transport",
12b68116 77 "hostname", "tile2.opencyclemap.org",
5c9e34b9
RN
78 "url", "/transport/%d/%d/%d.png",
79 "check-file-server-time", TRUE,
80 "use-etag", FALSE,
81 "copyright", "Tiles courtesy of Andy Allan © OpenStreetMap contributors",
82 "license", "CC-BY-SA",
83 "license-url", "http://www.openstreetmap.org/copyright",
84 NULL));
427976e5
RN
85 VikMapSource *mapquest_type =
86 VIK_MAP_SOURCE(g_object_new(VIK_TYPE_SLIPPY_MAP_SOURCE,
87 "id", 19,
2eb18edc 88 "name", "OSM-MapQuest",
427976e5
RN
89 "label", "OpenStreetMap (MapQuest)",
90 "hostname", "otile1.mqcdn.com",
91 "url", "/tiles/1.0.0/osm/%d/%d/%d.png",
92 "check-file-server-time", TRUE,
93 "use-etag", FALSE,
94 "copyright", "Tiles Courtesy of MapQuest © OpenStreetMap contributors",
95 "license", "MapQuest Specific",
96 "license-url", "http://developer.mapquest.com/web/info/terms-of-use",
97 NULL));
b18a7f39
RN
98 VikMapSource *hot_type =
99 VIK_MAP_SOURCE(g_object_new(VIK_TYPE_SLIPPY_MAP_SOURCE,
100 "id", 22,
2eb18edc 101 "name", "OSM-Humanitarian",
b18a7f39
RN
102 "label", "OpenStreetMap (Humanitarian)",
103 "hostname", "c.tile.openstreetmap.fr",
104 "url", "/hot/%d/%d/%d.png",
105 "check-file-server-time", TRUE,
106 "use-etag", FALSE,
107 "copyright", "© OpenStreetMap contributors. Tiles courtesy of Humanitarian OpenStreetMap Team",
108 "license", "CC-BY-SA",
109 "license-url", "http://www.openstreetmap.org/copyright",
110 NULL));
427976e5 111
2673b29d
RN
112 // NB no cache needed for this type!!
113 VikMapSource *direct_type =
114 VIK_MAP_SOURCE(g_object_new(VIK_TYPE_SLIPPY_MAP_SOURCE,
115 "id", 21,
116 "label", _("On Disk OSM Tile Format"),
117 // For using your own generated data assumed you know the license already!
118 "copyright", "© OpenStreetMap contributors", // probably
119 "use-direct-file-access", TRUE,
120 NULL));
121
0fb11294
RN
122 // NB no cache needed for this type!!
123 VikMapSource *mbtiles_type =
124 VIK_MAP_SOURCE(g_object_new(VIK_TYPE_SLIPPY_MAP_SOURCE,
125 "id", 23,
126 "label", _("MBTiles File"),
127 // For using your own generated data assumed you know the license already!
128 "copyright", "© OpenStreetMap contributors", // probably
129 "use-direct-file-access", TRUE,
130 "is-mbtiles", TRUE,
131 NULL));
132
427976e5 133 maps_layer_register_map_source (mapquest_type);
db03733a 134 maps_layer_register_map_source (mapnik_type);
db03733a 135 maps_layer_register_map_source (cycle_type);
5c9e34b9 136 maps_layer_register_map_source (transport_type);
b18a7f39 137 maps_layer_register_map_source (hot_type);
2673b29d 138 maps_layer_register_map_source (direct_type);
0fb11294 139 maps_layer_register_map_source (mbtiles_type);
92806042
GB
140
141 // Webtools
142 VikWebtoolCenter *webtool = NULL;
a22002e9 143 webtool = vik_webtool_center_new_with_members ( _("OSM (view)"), "http://openstreetmap.org/?lat=%s&lon=%s&zoom=%d" );
92806042
GB
144 vik_ext_tools_register ( VIK_EXT_TOOL ( webtool ) );
145 g_object_unref ( webtool );
146
147 webtool = vik_webtool_center_new_with_members ( _("OSM (edit)"), "http://www.openstreetmap.org/edit?lat=%s&lon=%s&zoom=%d" );
148 vik_ext_tools_register ( VIK_EXT_TOOL ( webtool ) );
149 g_object_unref ( webtool );
150
151 webtool = vik_webtool_center_new_with_members ( _("OSM (render)"), "http://www.informationfreeway.org/?lat=%s&lon=%s&zoom=%d&layers=B0000F000F" );
152 vik_ext_tools_register ( VIK_EXT_TOOL ( webtool ) );
153 g_object_unref ( webtool );
5149a69d 154
e1506f37
RN
155 VikWebtoolBounds *webtoolbounds = NULL;
156 // Example: http://127.0.0.1:8111/load_and_zoom?left=8.19&right=8.20&top=48.605&bottom=48.590&select=node413602999
157 // JOSM or merkaartor must already be running with remote interface enabled
158 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" );
159 vik_ext_tools_register ( VIK_EXT_TOOL ( webtoolbounds ) );
160 g_object_unref ( webtoolbounds );
161
a3dcc49e
RN
162 VikWebtoolFormat *vwtf = NULL;
163 vwtf = vik_webtool_format_new_with_members ( _("Geofabrik Map Compare"),
164 "http://tools.geofabrik.de/mc/#%s/%s/%s",
165 "ZAO" );
166 vik_ext_tools_register ( VIK_EXT_TOOL ( vwtf ) );
167 g_object_unref ( vwtf );
168
2241ad12 169 // Datasource
82993cc7 170 VikWebtoolDatasource *vwtds = NULL;
5910b4fb
RN
171 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 );
172 vik_ext_tool_datasources_register ( VIK_EXT_TOOL ( vwtds ) );
173 g_object_unref ( vwtds );
174
5149a69d
GB
175 // Goto
176 VikGotoXmlTool *nominatim = VIK_GOTO_XML_TOOL ( g_object_new ( VIK_GOTO_XML_TOOL_TYPE, "label", "OSM Nominatim",
177 "url-format", "http://nominatim.openstreetmap.org/search?q=%s&format=xml",
178 "lat-path", "/searchresults/place",
179 "lat-attr", "lat",
180 "lon-path", "/searchresults/place",
181 "lon-attr", "lon",
182 NULL ) );
183 vik_goto_register ( VIK_GOTO_TOOL ( nominatim ) );
184 g_object_unref ( nominatim );
54cef17b
GB
185
186 VikGotoXmlTool *namefinder = VIK_GOTO_XML_TOOL ( g_object_new ( VIK_GOTO_XML_TOOL_TYPE, "label", "OSM Name finder",
187 "url-format", "http://gazetteer.openstreetmap.org/namefinder/search.xml?find=%s&max=1",
188 "lat-path", "/searchresults/named",
189 "lat-attr", "lat",
190 "lon-path", "/searchresults/named",
191 "lon-attr", "lon",
192 NULL ) );
193 vik_goto_register ( VIK_GOTO_TOOL ( namefinder ) );
194 g_object_unref ( namefinder );
3346da31
RN
195
196 // Not really OSM but can't be bothered to create somewhere else to put it...
197 webtool = vik_webtool_center_new_with_members ( _("Wikimedia Toolserver GeoHack"), "http://toolserver.org/~geohack/geohack.php?params=%s;%s" );
198 vik_ext_tools_register ( VIK_EXT_TOOL ( webtool ) );
199 g_object_unref ( webtool );
5ae894dc 200
5ec699da
GB
201 /* See API references: https://github.com/DennisOSRM/Project-OSRM/wiki/Server-api */
202 VikRoutingEngine *osrm = g_object_new ( VIK_ROUTING_WEB_ENGINE_TYPE,
203 "id", "osrm",
204 "label", "OSRM",
205 "format", "gpx",
206 "url-base", "http://router.project-osrm.org/viaroute?output=gpx",
207 "url-start-ll", "&loc=%s,%s",
208 "url-stop-ll", "&loc=%s,%s",
209 "url-via-ll", "&loc=%s,%s",
210 NULL);
5ae894dc
GB
211 vik_routing_register ( VIK_ROUTING_ENGINE ( osrm ) );
212 g_object_unref ( osrm );
67209ca8
GB
213}
214