]>
Commit | Line | Data |
---|---|---|
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" |
5ae894dc | 30 | #include "osrm.h" |
f7d8a3c2 | 31 | #include "vikmapslayer.h" |
8eb12ac6 | 32 | #include "vikslippymapsource.h" |
50713970 | 33 | #include "vikwmscmapsource.h" |
92806042 | 34 | #include "vikwebtoolcenter.h" |
e1506f37 | 35 | #include "vikwebtoolbounds.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 GB |
41 | #include "vikrouting.h" |
42 | #include "osrm.h" | |
4f92972b | 43 | |
67209ca8 GB |
44 | /* initialisation */ |
45 | void 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)", | |
50 | "hostname", "tile.openstreetmap.org", | |
51 | "url", "/%d/%d/%d.png", | |
05dbd9ba JJ |
52 | "check-file-server-time", FALSE, |
53 | "use-etag", TRUE, | |
82aa018d | 54 | "copyright", "© OpenStreetMap contributors", |
53ac8302 GB |
55 | "license", "CC-BY-SA", |
56 | "license-url", "http://www.openstreetmap.org/copyright", | |
0f08bd0d | 57 | NULL)); |
0f08bd0d GB |
58 | VikMapSource *cycle_type = |
59 | VIK_MAP_SOURCE(g_object_new(VIK_TYPE_SLIPPY_MAP_SOURCE, | |
60 | "id", 17, | |
61 | "label", "OpenStreetMap (Cycle)", | |
218cdecd GB |
62 | "hostname", "b.tile.opencyclemap.org", |
63 | "url", "/cycle/%d/%d/%d.png", | |
6693f5f9 | 64 | "check-file-server-time", TRUE, |
05dbd9ba | 65 | "use-etag", FALSE, |
82c3dd37 | 66 | "copyright", "Tiles courtesy of Andy Allan © OpenStreetMap contributors", |
53ac8302 GB |
67 | "license", "CC-BY-SA", |
68 | "license-url", "http://www.openstreetmap.org/copyright", | |
0f08bd0d | 69 | NULL)); |
5c9e34b9 RN |
70 | VikMapSource *transport_type = |
71 | VIK_MAP_SOURCE(g_object_new(VIK_TYPE_SLIPPY_MAP_SOURCE, | |
72 | "id", 20, | |
73 | "label", "OpenStreetMap (Transport)", | |
74 | "hostname", "c.tile2.opencyclemap.org", | |
75 | "url", "/transport/%d/%d/%d.png", | |
76 | "check-file-server-time", TRUE, | |
77 | "use-etag", FALSE, | |
78 | "copyright", "Tiles courtesy of Andy Allan © OpenStreetMap contributors", | |
79 | "license", "CC-BY-SA", | |
80 | "license-url", "http://www.openstreetmap.org/copyright", | |
81 | NULL)); | |
bf6152e8 | 82 | VikMapSource *wms_type = |
50713970 GB |
83 | VIK_MAP_SOURCE(g_object_new(VIK_TYPE_WMSC_MAP_SOURCE, |
84 | "id", 18, | |
85 | "label", "OpenStreetMap (WMS)", | |
86 | "hostname", "full.wms.geofabrik.de", | |
87 | "url", "/std/demo_key?LAYERS=osm-full&FORMAT=image/png&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=&SRS=EPSG:4326&BBOX=%s,%s,%s,%s&WIDTH=256&HEIGHT=256", | |
88 | "check-file-server-time", FALSE, | |
82aa018d | 89 | "copyright", "© OpenStreetMap contributors", |
53ac8302 GB |
90 | "license", "CC-BY-SA", |
91 | "license-url", "http://www.openstreetmap.org/copyright", | |
50713970 | 92 | NULL)); |
db03733a | 93 | |
427976e5 RN |
94 | VikMapSource *mapquest_type = |
95 | VIK_MAP_SOURCE(g_object_new(VIK_TYPE_SLIPPY_MAP_SOURCE, | |
96 | "id", 19, | |
97 | "label", "OpenStreetMap (MapQuest)", | |
98 | "hostname", "otile1.mqcdn.com", | |
99 | "url", "/tiles/1.0.0/osm/%d/%d/%d.png", | |
100 | "check-file-server-time", TRUE, | |
101 | "use-etag", FALSE, | |
102 | "copyright", "Tiles Courtesy of MapQuest © OpenStreetMap contributors", | |
103 | "license", "MapQuest Specific", | |
104 | "license-url", "http://developer.mapquest.com/web/info/terms-of-use", | |
105 | NULL)); | |
106 | ||
2673b29d RN |
107 | // NB no cache needed for this type!! |
108 | VikMapSource *direct_type = | |
109 | VIK_MAP_SOURCE(g_object_new(VIK_TYPE_SLIPPY_MAP_SOURCE, | |
110 | "id", 21, | |
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, | |
115 | NULL)); | |
116 | ||
427976e5 | 117 | maps_layer_register_map_source (mapquest_type); |
db03733a | 118 | maps_layer_register_map_source (mapnik_type); |
db03733a | 119 | maps_layer_register_map_source (cycle_type); |
5c9e34b9 | 120 | maps_layer_register_map_source (transport_type); |
50713970 | 121 | maps_layer_register_map_source (wms_type); |
2673b29d | 122 | maps_layer_register_map_source (direct_type); |
92806042 GB |
123 | |
124 | // Webtools | |
125 | VikWebtoolCenter *webtool = NULL; | |
126 | webtool = vik_webtool_center_new_with_members ( _("OSM (view)"), "http://openstreetmap.org/?lat=%s&lon=%s&zoom=%d&layers=B000FTF" ); | |
127 | vik_ext_tools_register ( VIK_EXT_TOOL ( webtool ) ); | |
128 | g_object_unref ( webtool ); | |
129 | ||
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 ); | |
133 | ||
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 ); | |
5149a69d | 137 | |
e1506f37 RN |
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 ); | |
144 | ||
82993cc7 RN |
145 | // NB: THERE MUST BE AT LEAST ONE VikWebtoolDatasource defined otherwise the parsing of the datasource.xml will fail |
146 | // since it won't know about such a GObject type existing! | |
147 | // (in fact this is a problem in the vikgobjectbuilder -> g_markup_parse_context_parse -> _start_element -> g_type_from_name ) | |
148 | VikWebtoolDatasource *vwtds = NULL; | |
5910b4fb RN |
149 | 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 ); |
150 | vik_ext_tool_datasources_register ( VIK_EXT_TOOL ( vwtds ) ); | |
151 | g_object_unref ( vwtds ); | |
152 | ||
82993cc7 RN |
153 | 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 ); |
154 | vik_ext_tool_datasources_register ( VIK_EXT_TOOL ( vwtds ) ); | |
155 | g_object_unref ( vwtds ); | |
156 | ||
5149a69d GB |
157 | // Goto |
158 | VikGotoXmlTool *nominatim = VIK_GOTO_XML_TOOL ( g_object_new ( VIK_GOTO_XML_TOOL_TYPE, "label", "OSM Nominatim", | |
159 | "url-format", "http://nominatim.openstreetmap.org/search?q=%s&format=xml", | |
160 | "lat-path", "/searchresults/place", | |
161 | "lat-attr", "lat", | |
162 | "lon-path", "/searchresults/place", | |
163 | "lon-attr", "lon", | |
164 | NULL ) ); | |
165 | vik_goto_register ( VIK_GOTO_TOOL ( nominatim ) ); | |
166 | g_object_unref ( nominatim ); | |
54cef17b GB |
167 | |
168 | VikGotoXmlTool *namefinder = VIK_GOTO_XML_TOOL ( g_object_new ( VIK_GOTO_XML_TOOL_TYPE, "label", "OSM Name finder", | |
169 | "url-format", "http://gazetteer.openstreetmap.org/namefinder/search.xml?find=%s&max=1", | |
170 | "lat-path", "/searchresults/named", | |
171 | "lat-attr", "lat", | |
172 | "lon-path", "/searchresults/named", | |
173 | "lon-attr", "lon", | |
174 | NULL ) ); | |
175 | vik_goto_register ( VIK_GOTO_TOOL ( namefinder ) ); | |
176 | g_object_unref ( namefinder ); | |
3346da31 RN |
177 | |
178 | // Not really OSM but can't be bothered to create somewhere else to put it... | |
179 | webtool = vik_webtool_center_new_with_members ( _("Wikimedia Toolserver GeoHack"), "http://toolserver.org/~geohack/geohack.php?params=%s;%s" ); | |
180 | vik_ext_tools_register ( VIK_EXT_TOOL ( webtool ) ); | |
181 | g_object_unref ( webtool ); | |
5ae894dc GB |
182 | |
183 | OsrmRouting *osrm = osrm_routing_new ( ); | |
184 | vik_routing_register ( VIK_ROUTING_ENGINE ( osrm ) ); | |
185 | g_object_unref ( osrm ); | |
67209ca8 GB |
186 | } |
187 |