]>
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> | |
a482007a | 5 | * Copyright (C) 2007, 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" |
92806042 | 35 | #include "vikexttools.h" |
5149a69d GB |
36 | #include "vikgotoxmltool.h" |
37 | #include "vikgoto.h" | |
4f92972b | 38 | |
67209ca8 GB |
39 | /* initialisation */ |
40 | void osm_init () { | |
0f08bd0d GB |
41 | VikMapSource *mapnik_type = |
42 | VIK_MAP_SOURCE(g_object_new(VIK_TYPE_SLIPPY_MAP_SOURCE, | |
43 | "id", 13, | |
44 | "label", "OpenStreetMap (Mapnik)", | |
45 | "hostname", "tile.openstreetmap.org", | |
46 | "url", "/%d/%d/%d.png", | |
05dbd9ba JJ |
47 | "check-file-server-time", FALSE, |
48 | "use-etag", TRUE, | |
82aa018d | 49 | "copyright", "© OpenStreetMap contributors", |
53ac8302 GB |
50 | "license", "CC-BY-SA", |
51 | "license-url", "http://www.openstreetmap.org/copyright", | |
0f08bd0d | 52 | NULL)); |
0f08bd0d GB |
53 | VikMapSource *cycle_type = |
54 | VIK_MAP_SOURCE(g_object_new(VIK_TYPE_SLIPPY_MAP_SOURCE, | |
55 | "id", 17, | |
56 | "label", "OpenStreetMap (Cycle)", | |
218cdecd GB |
57 | "hostname", "b.tile.opencyclemap.org", |
58 | "url", "/cycle/%d/%d/%d.png", | |
6693f5f9 | 59 | "check-file-server-time", TRUE, |
05dbd9ba | 60 | "use-etag", FALSE, |
82c3dd37 | 61 | "copyright", "Tiles courtesy of Andy Allan © OpenStreetMap contributors", |
53ac8302 GB |
62 | "license", "CC-BY-SA", |
63 | "license-url", "http://www.openstreetmap.org/copyright", | |
0f08bd0d | 64 | NULL)); |
5c9e34b9 RN |
65 | VikMapSource *transport_type = |
66 | VIK_MAP_SOURCE(g_object_new(VIK_TYPE_SLIPPY_MAP_SOURCE, | |
67 | "id", 20, | |
68 | "label", "OpenStreetMap (Transport)", | |
69 | "hostname", "c.tile2.opencyclemap.org", | |
70 | "url", "/transport/%d/%d/%d.png", | |
71 | "check-file-server-time", TRUE, | |
72 | "use-etag", FALSE, | |
73 | "copyright", "Tiles courtesy of Andy Allan © OpenStreetMap contributors", | |
74 | "license", "CC-BY-SA", | |
75 | "license-url", "http://www.openstreetmap.org/copyright", | |
76 | NULL)); | |
bf6152e8 | 77 | VikMapSource *wms_type = |
50713970 GB |
78 | VIK_MAP_SOURCE(g_object_new(VIK_TYPE_WMSC_MAP_SOURCE, |
79 | "id", 18, | |
80 | "label", "OpenStreetMap (WMS)", | |
81 | "hostname", "full.wms.geofabrik.de", | |
82 | "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", | |
83 | "check-file-server-time", FALSE, | |
82aa018d | 84 | "copyright", "© OpenStreetMap contributors", |
53ac8302 GB |
85 | "license", "CC-BY-SA", |
86 | "license-url", "http://www.openstreetmap.org/copyright", | |
50713970 | 87 | NULL)); |
db03733a | 88 | |
427976e5 RN |
89 | VikMapSource *mapquest_type = |
90 | VIK_MAP_SOURCE(g_object_new(VIK_TYPE_SLIPPY_MAP_SOURCE, | |
91 | "id", 19, | |
92 | "label", "OpenStreetMap (MapQuest)", | |
93 | "hostname", "otile1.mqcdn.com", | |
94 | "url", "/tiles/1.0.0/osm/%d/%d/%d.png", | |
95 | "check-file-server-time", TRUE, | |
96 | "use-etag", FALSE, | |
97 | "copyright", "Tiles Courtesy of MapQuest © OpenStreetMap contributors", | |
98 | "license", "MapQuest Specific", | |
99 | "license-url", "http://developer.mapquest.com/web/info/terms-of-use", | |
100 | NULL)); | |
101 | ||
2673b29d RN |
102 | // NB no cache needed for this type!! |
103 | VikMapSource *direct_type = | |
104 | VIK_MAP_SOURCE(g_object_new(VIK_TYPE_SLIPPY_MAP_SOURCE, | |
105 | "id", 21, | |
106 | "label", _("On Disk OSM Tile Format"), | |
107 | // For using your own generated data assumed you know the license already! | |
108 | "copyright", "© OpenStreetMap contributors", // probably | |
109 | "use-direct-file-access", TRUE, | |
110 | NULL)); | |
111 | ||
427976e5 | 112 | maps_layer_register_map_source (mapquest_type); |
db03733a | 113 | maps_layer_register_map_source (mapnik_type); |
db03733a | 114 | maps_layer_register_map_source (cycle_type); |
5c9e34b9 | 115 | maps_layer_register_map_source (transport_type); |
50713970 | 116 | maps_layer_register_map_source (wms_type); |
2673b29d | 117 | maps_layer_register_map_source (direct_type); |
92806042 GB |
118 | |
119 | // Webtools | |
120 | VikWebtoolCenter *webtool = NULL; | |
121 | webtool = vik_webtool_center_new_with_members ( _("OSM (view)"), "http://openstreetmap.org/?lat=%s&lon=%s&zoom=%d&layers=B000FTF" ); | |
122 | vik_ext_tools_register ( VIK_EXT_TOOL ( webtool ) ); | |
123 | g_object_unref ( webtool ); | |
124 | ||
125 | webtool = vik_webtool_center_new_with_members ( _("OSM (edit)"), "http://www.openstreetmap.org/edit?lat=%s&lon=%s&zoom=%d" ); | |
126 | vik_ext_tools_register ( VIK_EXT_TOOL ( webtool ) ); | |
127 | g_object_unref ( webtool ); | |
128 | ||
129 | webtool = vik_webtool_center_new_with_members ( _("OSM (render)"), "http://www.informationfreeway.org/?lat=%s&lon=%s&zoom=%d&layers=B0000F000F" ); | |
130 | vik_ext_tools_register ( VIK_EXT_TOOL ( webtool ) ); | |
131 | g_object_unref ( webtool ); | |
5149a69d | 132 | |
e1506f37 RN |
133 | VikWebtoolBounds *webtoolbounds = NULL; |
134 | // Example: http://127.0.0.1:8111/load_and_zoom?left=8.19&right=8.20&top=48.605&bottom=48.590&select=node413602999 | |
135 | // JOSM or merkaartor must already be running with remote interface enabled | |
136 | 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" ); | |
137 | vik_ext_tools_register ( VIK_EXT_TOOL ( webtoolbounds ) ); | |
138 | g_object_unref ( webtoolbounds ); | |
139 | ||
5149a69d GB |
140 | // Goto |
141 | VikGotoXmlTool *nominatim = VIK_GOTO_XML_TOOL ( g_object_new ( VIK_GOTO_XML_TOOL_TYPE, "label", "OSM Nominatim", | |
142 | "url-format", "http://nominatim.openstreetmap.org/search?q=%s&format=xml", | |
143 | "lat-path", "/searchresults/place", | |
144 | "lat-attr", "lat", | |
145 | "lon-path", "/searchresults/place", | |
146 | "lon-attr", "lon", | |
147 | NULL ) ); | |
148 | vik_goto_register ( VIK_GOTO_TOOL ( nominatim ) ); | |
149 | g_object_unref ( nominatim ); | |
54cef17b GB |
150 | |
151 | VikGotoXmlTool *namefinder = VIK_GOTO_XML_TOOL ( g_object_new ( VIK_GOTO_XML_TOOL_TYPE, "label", "OSM Name finder", | |
152 | "url-format", "http://gazetteer.openstreetmap.org/namefinder/search.xml?find=%s&max=1", | |
153 | "lat-path", "/searchresults/named", | |
154 | "lat-attr", "lat", | |
155 | "lon-path", "/searchresults/named", | |
156 | "lon-attr", "lon", | |
157 | NULL ) ); | |
158 | vik_goto_register ( VIK_GOTO_TOOL ( namefinder ) ); | |
159 | g_object_unref ( namefinder ); | |
67209ca8 GB |
160 | } |
161 |