]> git.street.me.uk Git - andy/viking.git/blob - src/osm.c
Add function to return an average moving speed for a track.
[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, Guilhem Bonnefille <guilhem.bonnefille@gmail.com>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20  *
21  */
22 #ifdef HAVE_CONFIG_H
23 #include "config.h"
24 #endif
25
26 #include <glib/gi18n.h>
27
28 #include "osm.h"
29 #include "vikmapslayer.h"
30 #include "vikslippymapsource.h"
31 #include "vikwmscmapsource.h"
32 #include "vikwebtoolcenter.h"
33 #include "vikwebtoolbounds.h"
34 #include "vikexttools.h"
35 #include "vikgotoxmltool.h"
36 #include "vikgoto.h"
37
38 /* initialisation */
39 void osm_init () {
40   VikMapSource *osmarender_type = 
41     VIK_MAP_SOURCE(g_object_new(VIK_TYPE_SLIPPY_MAP_SOURCE,
42                                 "id", 12,
43                                 "label", "OpenStreetMap (Osmarender)",
44                                 "hostname", "tah.openstreetmap.org",
45                                 "url", "/Tiles/tile/%d/%d/%d.png",
46                                 "check-file-server-time", TRUE,
47                                 "use-etag", FALSE,
48                                 "copyright", "© OpenStreetMap contributors",
49                                 "license", "CC-BY-SA",
50                                 "license-url", "http://www.openstreetmap.org/copyright",
51                                 NULL));
52   VikMapSource *mapnik_type =
53     VIK_MAP_SOURCE(g_object_new(VIK_TYPE_SLIPPY_MAP_SOURCE,
54                                 "id", 13,
55                                 "label", "OpenStreetMap (Mapnik)",
56                                 "hostname", "tile.openstreetmap.org",
57                                 "url", "/%d/%d/%d.png",
58                                 "check-file-server-time", FALSE,
59                                 "use-etag", TRUE,
60                                 "copyright", "© OpenStreetMap contributors",
61                                 "license", "CC-BY-SA",
62                                 "license-url", "http://www.openstreetmap.org/copyright",
63                                 NULL));
64   VikMapSource *maplint_type =
65     VIK_MAP_SOURCE(g_object_new(VIK_TYPE_SLIPPY_MAP_SOURCE,
66                                 "id", 14,
67                                 "label", "OpenStreetMap (Maplint)",
68                                 "hostname", "tah.openstreetmap.org",
69                                 "url", "/Tiles/maplint.php/%d/%d/%d.png",
70                                 "check-file-server-time", TRUE,
71                                 "use-etag", FALSE,
72                                 "copyright", "© OpenStreetMap contributors",
73                                 "license", "CC-BY-SA",
74                                 "license-url", "http://www.openstreetmap.org/copyright",
75                                 NULL));
76   VikMapSource *cycle_type =
77     VIK_MAP_SOURCE(g_object_new(VIK_TYPE_SLIPPY_MAP_SOURCE,
78                                 "id", 17,
79                                 "label", "OpenStreetMap (Cycle)",
80                                 "hostname", "b.tile.opencyclemap.org",
81                                 "url", "/cycle/%d/%d/%d.png",
82                                 "check-file-server-time", TRUE,
83                                 "use-etag", FALSE,
84                                 "copyright", "© OpenStreetMap contributors",
85                                 "license", "CC-BY-SA",
86                                 "license-url", "http://www.openstreetmap.org/copyright",
87                                 NULL));
88   VikMapSource *wms_type =
89     VIK_MAP_SOURCE(g_object_new(VIK_TYPE_WMSC_MAP_SOURCE,
90                                 "id", 18,
91                                 "label", "OpenStreetMap (WMS)",
92                                 "hostname", "full.wms.geofabrik.de",
93                                 "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",
94                                 "check-file-server-time", FALSE,
95                                 "copyright", "© OpenStreetMap contributors",
96                                 "license", "CC-BY-SA",
97                                 "license-url", "http://www.openstreetmap.org/copyright",
98                                 NULL));
99
100   VikMapSource *mapquest_type =
101     VIK_MAP_SOURCE(g_object_new(VIK_TYPE_SLIPPY_MAP_SOURCE,
102                                 "id", 19,
103                                 "label", "OpenStreetMap (MapQuest)",
104                                 "hostname", "otile1.mqcdn.com",
105                                 "url", "/tiles/1.0.0/osm/%d/%d/%d.png",
106                                 "check-file-server-time", TRUE,
107                                 "use-etag", FALSE,
108                                 "copyright", "Tiles Courtesy of MapQuest © OpenStreetMap contributors",
109                                 "license", "MapQuest Specific",
110                                 "license-url", "http://developer.mapquest.com/web/info/terms-of-use",
111                                 NULL));
112
113   maps_layer_register_map_source (mapquest_type);
114   maps_layer_register_map_source (osmarender_type);
115   maps_layer_register_map_source (mapnik_type);
116   maps_layer_register_map_source (maplint_type);
117   maps_layer_register_map_source (cycle_type);
118   maps_layer_register_map_source (wms_type);
119
120   // Webtools
121   VikWebtoolCenter *webtool = NULL;
122   webtool = vik_webtool_center_new_with_members ( _("OSM (view)"), "http://openstreetmap.org/?lat=%s&lon=%s&zoom=%d&layers=B000FTF" );
123   vik_ext_tools_register ( VIK_EXT_TOOL ( webtool ) );
124   g_object_unref ( webtool );
125
126   webtool = vik_webtool_center_new_with_members ( _("OSM (edit)"), "http://www.openstreetmap.org/edit?lat=%s&lon=%s&zoom=%d" );
127   vik_ext_tools_register ( VIK_EXT_TOOL ( webtool ) );
128   g_object_unref ( webtool );
129
130   webtool = vik_webtool_center_new_with_members ( _("OSM (render)"), "http://www.informationfreeway.org/?lat=%s&lon=%s&zoom=%d&layers=B0000F000F" );
131   vik_ext_tools_register ( VIK_EXT_TOOL ( webtool ) );
132   g_object_unref ( webtool );
133
134   VikWebtoolBounds *webtoolbounds = NULL;
135   // Example: http://127.0.0.1:8111/load_and_zoom?left=8.19&right=8.20&top=48.605&bottom=48.590&select=node413602999
136   // JOSM or merkaartor must already be running with remote interface enabled
137   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" );
138   vik_ext_tools_register ( VIK_EXT_TOOL ( webtoolbounds ) );
139   g_object_unref ( webtoolbounds );
140
141   // Goto
142   VikGotoXmlTool *nominatim = VIK_GOTO_XML_TOOL ( g_object_new ( VIK_GOTO_XML_TOOL_TYPE, "label", "OSM Nominatim",
143     "url-format", "http://nominatim.openstreetmap.org/search?q=%s&format=xml",
144     "lat-path", "/searchresults/place",
145     "lat-attr", "lat",
146     "lon-path", "/searchresults/place",
147     "lon-attr", "lon",
148     NULL ) );
149     vik_goto_register ( VIK_GOTO_TOOL ( nominatim ) );
150     g_object_unref ( nominatim );
151
152   VikGotoXmlTool *namefinder = VIK_GOTO_XML_TOOL ( g_object_new ( VIK_GOTO_XML_TOOL_TYPE, "label", "OSM Name finder",
153     "url-format", "http://gazetteer.openstreetmap.org/namefinder/search.xml?find=%s&max=1",
154     "lat-path", "/searchresults/named",
155     "lat-attr", "lat",
156     "lon-path", "/searchresults/named",
157     "lon-attr", "lon",
158     NULL ) );
159     vik_goto_register ( VIK_GOTO_TOOL ( namefinder ) );
160     g_object_unref ( namefinder );
161 }
162