]>
Commit | Line | Data |
---|---|---|
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, 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 "vikexttools.h" | |
36 | #include "vikgotoxmltool.h" | |
37 | #include "vikgoto.h" | |
38 | ||
39 | /* initialisation */ | |
40 | void osm_init () { | |
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", | |
47 | "check-file-server-time", FALSE, | |
48 | "use-etag", TRUE, | |
49 | "copyright", "© OpenStreetMap contributors", | |
50 | "license", "CC-BY-SA", | |
51 | "license-url", "http://www.openstreetmap.org/copyright", | |
52 | NULL)); | |
53 | VikMapSource *cycle_type = | |
54 | VIK_MAP_SOURCE(g_object_new(VIK_TYPE_SLIPPY_MAP_SOURCE, | |
55 | "id", 17, | |
56 | "label", "OpenStreetMap (Cycle)", | |
57 | "hostname", "b.tile.opencyclemap.org", | |
58 | "url", "/cycle/%d/%d/%d.png", | |
59 | "check-file-server-time", TRUE, | |
60 | "use-etag", FALSE, | |
61 | "copyright", "Tiles courtesy of Andy Allan © OpenStreetMap contributors", | |
62 | "license", "CC-BY-SA", | |
63 | "license-url", "http://www.openstreetmap.org/copyright", | |
64 | NULL)); | |
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)); | |
77 | VikMapSource *wms_type = | |
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, | |
84 | "copyright", "© OpenStreetMap contributors", | |
85 | "license", "CC-BY-SA", | |
86 | "license-url", "http://www.openstreetmap.org/copyright", | |
87 | NULL)); | |
88 | ||
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 | ||
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 | ||
112 | maps_layer_register_map_source (mapquest_type); | |
113 | maps_layer_register_map_source (mapnik_type); | |
114 | maps_layer_register_map_source (cycle_type); | |
115 | maps_layer_register_map_source (transport_type); | |
116 | maps_layer_register_map_source (wms_type); | |
117 | maps_layer_register_map_source (direct_type); | |
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 ); | |
132 | ||
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 | ||
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 ); | |
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 ); | |
160 | ||
161 | // Not really OSM but can't be bothered to create somewhere else to put it... | |
162 | webtool = vik_webtool_center_new_with_members ( _("Wikimedia Toolserver GeoHack"), "http://toolserver.org/~geohack/geohack.php?params=%s;%s" ); | |
163 | vik_ext_tools_register ( VIK_EXT_TOOL ( webtool ) ); | |
164 | g_object_unref ( webtool ); | |
165 | } | |
166 |