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