]>
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" |
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" |
82993cc7 | 35 | #include "vikwebtool_datasource.h" |
92806042 | 36 | #include "vikexttools.h" |
82993cc7 | 37 | #include "vikexttool_datasources.h" |
5149a69d GB |
38 | #include "vikgotoxmltool.h" |
39 | #include "vikgoto.h" | |
5ae894dc | 40 | #include "vikrouting.h" |
5ec699da | 41 | #include "vikroutingwebengine.h" |
4f92972b | 42 | |
67209ca8 GB |
43 | /* initialisation */ |
44 | void osm_init () { | |
0f08bd0d GB |
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", | |
05dbd9ba JJ |
51 | "check-file-server-time", FALSE, |
52 | "use-etag", TRUE, | |
82aa018d | 53 | "copyright", "© OpenStreetMap contributors", |
53ac8302 GB |
54 | "license", "CC-BY-SA", |
55 | "license-url", "http://www.openstreetmap.org/copyright", | |
0f08bd0d | 56 | NULL)); |
0f08bd0d GB |
57 | VikMapSource *cycle_type = |
58 | VIK_MAP_SOURCE(g_object_new(VIK_TYPE_SLIPPY_MAP_SOURCE, | |
59 | "id", 17, | |
60 | "label", "OpenStreetMap (Cycle)", | |
218cdecd GB |
61 | "hostname", "b.tile.opencyclemap.org", |
62 | "url", "/cycle/%d/%d/%d.png", | |
6693f5f9 | 63 | "check-file-server-time", TRUE, |
05dbd9ba | 64 | "use-etag", FALSE, |
82c3dd37 | 65 | "copyright", "Tiles courtesy of Andy Allan © OpenStreetMap contributors", |
53ac8302 GB |
66 | "license", "CC-BY-SA", |
67 | "license-url", "http://www.openstreetmap.org/copyright", | |
0f08bd0d | 68 | NULL)); |
5c9e34b9 RN |
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", "c.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)); | |
db03733a | 81 | |
427976e5 RN |
82 | VikMapSource *mapquest_type = |
83 | VIK_MAP_SOURCE(g_object_new(VIK_TYPE_SLIPPY_MAP_SOURCE, | |
84 | "id", 19, | |
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, | |
89 | "use-etag", FALSE, | |
90 | "copyright", "Tiles Courtesy of MapQuest © OpenStreetMap contributors", | |
91 | "license", "MapQuest Specific", | |
92 | "license-url", "http://developer.mapquest.com/web/info/terms-of-use", | |
93 | NULL)); | |
94 | ||
2673b29d RN |
95 | // NB no cache needed for this type!! |
96 | VikMapSource *direct_type = | |
97 | VIK_MAP_SOURCE(g_object_new(VIK_TYPE_SLIPPY_MAP_SOURCE, | |
98 | "id", 21, | |
99 | "label", _("On Disk OSM Tile Format"), | |
100 | // For using your own generated data assumed you know the license already! | |
101 | "copyright", "© OpenStreetMap contributors", // probably | |
102 | "use-direct-file-access", TRUE, | |
103 | NULL)); | |
104 | ||
427976e5 | 105 | maps_layer_register_map_source (mapquest_type); |
db03733a | 106 | maps_layer_register_map_source (mapnik_type); |
db03733a | 107 | maps_layer_register_map_source (cycle_type); |
5c9e34b9 | 108 | maps_layer_register_map_source (transport_type); |
2673b29d | 109 | maps_layer_register_map_source (direct_type); |
92806042 GB |
110 | |
111 | // Webtools | |
112 | VikWebtoolCenter *webtool = NULL; | |
113 | webtool = vik_webtool_center_new_with_members ( _("OSM (view)"), "http://openstreetmap.org/?lat=%s&lon=%s&zoom=%d&layers=B000FTF" ); | |
114 | vik_ext_tools_register ( VIK_EXT_TOOL ( webtool ) ); | |
115 | g_object_unref ( webtool ); | |
116 | ||
117 | webtool = vik_webtool_center_new_with_members ( _("OSM (edit)"), "http://www.openstreetmap.org/edit?lat=%s&lon=%s&zoom=%d" ); | |
118 | vik_ext_tools_register ( VIK_EXT_TOOL ( webtool ) ); | |
119 | g_object_unref ( webtool ); | |
120 | ||
121 | webtool = vik_webtool_center_new_with_members ( _("OSM (render)"), "http://www.informationfreeway.org/?lat=%s&lon=%s&zoom=%d&layers=B0000F000F" ); | |
122 | vik_ext_tools_register ( VIK_EXT_TOOL ( webtool ) ); | |
123 | g_object_unref ( webtool ); | |
5149a69d | 124 | |
e1506f37 RN |
125 | VikWebtoolBounds *webtoolbounds = NULL; |
126 | // Example: http://127.0.0.1:8111/load_and_zoom?left=8.19&right=8.20&top=48.605&bottom=48.590&select=node413602999 | |
127 | // JOSM or merkaartor must already be running with remote interface enabled | |
128 | 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" ); | |
129 | vik_ext_tools_register ( VIK_EXT_TOOL ( webtoolbounds ) ); | |
130 | g_object_unref ( webtoolbounds ); | |
131 | ||
2241ad12 | 132 | // Datasource |
82993cc7 | 133 | VikWebtoolDatasource *vwtds = NULL; |
5910b4fb RN |
134 | 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 ); |
135 | vik_ext_tool_datasources_register ( VIK_EXT_TOOL ( vwtds ) ); | |
136 | g_object_unref ( vwtds ); | |
137 | ||
82993cc7 RN |
138 | 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 ); |
139 | vik_ext_tool_datasources_register ( VIK_EXT_TOOL ( vwtds ) ); | |
140 | g_object_unref ( vwtds ); | |
141 | ||
5149a69d GB |
142 | // Goto |
143 | VikGotoXmlTool *nominatim = VIK_GOTO_XML_TOOL ( g_object_new ( VIK_GOTO_XML_TOOL_TYPE, "label", "OSM Nominatim", | |
144 | "url-format", "http://nominatim.openstreetmap.org/search?q=%s&format=xml", | |
145 | "lat-path", "/searchresults/place", | |
146 | "lat-attr", "lat", | |
147 | "lon-path", "/searchresults/place", | |
148 | "lon-attr", "lon", | |
149 | NULL ) ); | |
150 | vik_goto_register ( VIK_GOTO_TOOL ( nominatim ) ); | |
151 | g_object_unref ( nominatim ); | |
54cef17b GB |
152 | |
153 | VikGotoXmlTool *namefinder = VIK_GOTO_XML_TOOL ( g_object_new ( VIK_GOTO_XML_TOOL_TYPE, "label", "OSM Name finder", | |
154 | "url-format", "http://gazetteer.openstreetmap.org/namefinder/search.xml?find=%s&max=1", | |
155 | "lat-path", "/searchresults/named", | |
156 | "lat-attr", "lat", | |
157 | "lon-path", "/searchresults/named", | |
158 | "lon-attr", "lon", | |
159 | NULL ) ); | |
160 | vik_goto_register ( VIK_GOTO_TOOL ( namefinder ) ); | |
161 | g_object_unref ( namefinder ); | |
3346da31 RN |
162 | |
163 | // Not really OSM but can't be bothered to create somewhere else to put it... | |
164 | webtool = vik_webtool_center_new_with_members ( _("Wikimedia Toolserver GeoHack"), "http://toolserver.org/~geohack/geohack.php?params=%s;%s" ); | |
165 | vik_ext_tools_register ( VIK_EXT_TOOL ( webtool ) ); | |
166 | g_object_unref ( webtool ); | |
5ae894dc | 167 | |
5ec699da GB |
168 | /* See API references: https://github.com/DennisOSRM/Project-OSRM/wiki/Server-api */ |
169 | VikRoutingEngine *osrm = g_object_new ( VIK_ROUTING_WEB_ENGINE_TYPE, | |
170 | "id", "osrm", | |
171 | "label", "OSRM", | |
172 | "format", "gpx", | |
173 | "url-base", "http://router.project-osrm.org/viaroute?output=gpx", | |
174 | "url-start-ll", "&loc=%s,%s", | |
175 | "url-stop-ll", "&loc=%s,%s", | |
176 | "url-via-ll", "&loc=%s,%s", | |
177 | NULL); | |
5ae894dc GB |
178 | vik_routing_register ( VIK_ROUTING_ENGINE ( osrm ) ); |
179 | g_object_unref ( osrm ); | |
67209ca8 GB |
180 | } |
181 |