Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
osm.qdoc
Go to the documentation of this file.
1
// Copyright (C) 2015 Aaron McCarthy <mccarthy.aaron@gmail.com>
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3
4
/*!
5
\page location-plugin-osm.html
6
\title Qt Location Open Street Map Plugin
7
\ingroup QtLocation-plugins
8
9
\brief Uses Open Street Map and related services.
10
11
\section1 Overview
12
13
This geo services plugin allows applications to access
14
\l {http://openstreetmap.org}{Open Street Map} location based services using the
15
Qt Location API.
16
17
Data, imagery and map information provided by
18
\l {http://www.thunderforest.com/}{ThunderForest},
19
\l {http://www.openstreetmap.org/copyright}{OpenStreetMap} and contributors.
20
The data is available under the
21
\l {http://www.opendatacommons.org/licenses/odbl}{Open Database License}.
22
23
The Open Street Map geo services plugin can be loaded by using the plugin key
24
"osm".
25
26
\note The standard map types rely on (partially) free data providers. We try to
27
keep the selection useful for evaluation and development purposes, but it is
28
your responsibility to select a data provider that fits your needs in
29
production. It is highly recommended to carefully read and adhere to the terms
30
of service of the respective providers. A list of alternative data providers is
31
available in the
32
\l{https://wiki.openstreetmap.org/wiki/Raster_tile_providers}{OpenStreetMap
33
wiki}. The available map types offered by this plugin may change (or be
34
removed) without notice depending on the actual availability of a viable openly
35
accessible provider for each type. This also implies that providers serving
36
tiles over HTTPS may be used. This becomes relevant when using the OSM plugin
37
on platforms, such as Android, for which SSL support is not built into Qt by
38
default. To prevent these changes, either a different geo service plugin should
39
be used, or the plugin parameter \e osm.mapping.providersrepository.address
40
should be set to a user-specified repository, in order to take full control
41
over selecting the provider that is used for each map type. Since Qt 5.9.6, the
42
default nominatim endpoint, used for geocoding and places, has also changed to
43
HTTPS-only.
44
45
\section1 Parameters
46
47
\section2 Optional parameters
48
The following table lists optional parameters that can be passed to the Open
49
Street Map plugin.
50
51
\note Since Qt 5.5 all parameters below must be prefixed with \c osm. Previous
52
versions did not require a prefix.
53
54
\table
55
\header
56
\li Parameter
57
\li Description
58
\row
59
\li osm.geocoding.host
60
\li Url string set when making network requests to the geocoding server.
61
This parameter should be set to a valid server url with the correct OSM
62
API. If not specified the default
63
\l {http://nominatim.openstreetmap.org/}{url} will be used.
64
\note The API documentation is available at
65
\l {https://wiki.openstreetmap.org/wiki/Nominatim}{Project OSM Nominatim}.
66
\row
67
\li osm.geocoding.debug_query
68
\li Instructs the plugin to inject the query url to nominatim into the
69
geocode reply, for debugging purposes.
70
\row
71
\li osm.geocoding.include_extended_data
72
\li Instructs the plugin to include Nominatim-specific information (such as
73
geometry and class) into the returned Location objects, exposed as
74
extendedAttributes.
75
\row
76
\li osm.mapping.cache.directory
77
\li Absolute path to map tile cache directory used as network disk cache.
78
79
The default place for the cache is the \c{QtLocation/osm} subdirectory in
80
the location returned by QStandardPaths::writableLocation(), called with
81
QStandardPaths::GenericCacheLocation as a parameter. On systems that have
82
no concept of a shared cache, the application-specific
83
\l{QStandardPaths::CacheLocation} is used instead. \row
84
\li osm.mapping.cache.disk.cost_strategy
85
\li The cost strategy to use to cache map tiles on disk.
86
Valid values are \b bytesize and \b unitary.
87
Using \b bytesize, the related size parameter
88
(\b osm.mapping.cache.disk.size) will be interpreted as bytes. Using
89
\b unitary, they will be interpreted as number of tiles. The default
90
value for this parameter is \b bytesize.
91
\row
92
\li osm.mapping.cache.disk.size
93
\li Disk cache size for map tiles. The default size of the cache is 50 MiB
94
when \b bytesize is the cost strategy for this cache, or 1000 tiles,
95
when \b unitary is the cost strategy.
96
\row
97
\li osm.mapping.cache.memory.cost_strategy
98
\li The cost strategy to use to cache map tiles in memory.
99
Valid values are \b bytesize and \b unitary.
100
Using \b bytesize, the related size parameter
101
(\b osm.mapping.cache.memory.size) will be interpreted as bytes.
102
Using \b unitary, they will be interpreted as number of tiles.
103
The default value for this parameter is \b bytesize.
104
\row
105
\li osm.mapping.cache.memory.size
106
\li Memory cache size for map tiles. The default size of the cache is 3 MiB
107
when \b bytesize is the cost strategy for this cache, or 100 tiles, when
108
\b unitary is the cost strategy.
109
\row
110
\li osm.mapping.cache.texture.cost_strategy
111
\li The cost strategy to use to cache decompressed map tiles in memory.
112
Valid values are \b bytesize and \b unitary.
113
Using \b bytesize, the related size parameter
114
(\b osm.mapping.cache.texture.size) will be interpreted as bytes.
115
Using \b unitary, they will be interpreted as number of tiles.
116
The default value for this parameter is \b bytesize.
117
\row
118
\li osm.mapping.cache.texture.size
119
\li Texture cache size for map tiles. The default size of the cache is 6 MiB
120
when \b bytesize is the cost strategy for this cache, or 30 tiles, when
121
\b unitary is the cost strategy. Note that the texture cache has a hard
122
minimum size which depends on the size of the map viewport (it must
123
contain enough data to display the tiles currently visible on the
124
display). This value is the amount of cache to be used in addition to
125
the bare minimum.
126
\row
127
\li osm.mapping.custom.datacopyright
128
\li Custom data copryright string is used when setting the
129
\l{Map::activeMapType} to \l{mapType::style}{MapType.CustomMap} via
130
urlprefix parameter. This copyright will only be used when using the
131
CustomMap from above. If empty no data copyright will be displayed for
132
the custom map.
133
\row
134
\li osm.mapping.custom.host
135
\li The url string of a custom tile server. This parameter should be set to a
136
valid server url offering the correct OSM API. The postfix
137
"%z/%x/%y.png" will be added to the url. Since 6.5 the postfix will not
138
be added if the url ends with ".png". If the server requires an apikey, it
139
has to be added to the url string. To use this server, the
140
\l{Map::activeMapType} parameter of the \l Map should be set to the
141
supported map type whose type is \l{mapType::style}{MapType.CustomMap}.
142
This map type is only be available if this plugin parameter is set, in
143
which case it is always
144
\l{Map::supportedMapTypes}[supportedMapTypes.length - 1].
145
\note Setting the mapping.custom.host parameter to a new server renders
146
the map tile cache useless for the old custommap style.
147
\row
148
\li osm.mapping.custom.mapcopyright
149
\li Custom map copryright string is used when setting the
150
\l{Map::activeMapType} to \l{mapType::style}{MapType.CustomMap} via
151
urlprefix parameter. This copyright will only be used when using the
152
CustomMap from above. If empty no map copyright will be displayed for
153
the custom map.
154
\row
155
\li osm.mapping.highdpi_tiles
156
\li Whether or not to request high dpi tiles. Valid values are \b true and
157
\b false. The default value is \b false. Please note that not all map
158
types are available in high dpi. Setting this parameter to true might
159
even have no effect if no map type is available in high dpi at the
160
moment. Provider information files for high dpi tiles are named
161
\tt{street-hires}, \tt{satellite-hires}, \tt{cycle-hires},
162
\tt{transit-hires}, \tt{night-transit-hires}, \tt{terrain-hires} and
163
\tt{hiking-hires}. These are fetched from the same location used for the
164
low dpi counterparts.
165
\row
166
\li osm.mapping.offline.directory
167
\li Absolute path to a directory containing map tiles used as an offline
168
storage. If specified, it will work together with the network disk
169
cache, but tiles won't get automatically inserted, removed or updated.
170
The format of the tiles is the same used by the network disk cache.
171
There is no default value, and if this property is not set, no directory
172
will be indexed and only the network disk cache will be used to reduce
173
network usage or to act as an offline storage for the currently cached
174
tiles.
175
\row
176
\li osm.mapping.prefetching_style
177
\li This parameter allows to provide a hint how tile prefetching is to be
178
performed by the engine. The default value, \tt{TwoNeighbourLayers},
179
makes the engine prefetch tiles for the layer above and the one below
180
the current tile layer, providing ready tiles when zooming in or out
181
from the current zoom level. \tt{OneNeighbourLayer} only prefetches the
182
one layer closest to the current zoom level. Finally, \tt{NoPrefetching}
183
allows to disable the prefetching, so only tiles that are visible will
184
be fetched. Note that, depending on the active map type, this hint might
185
be ignored.
186
\row
187
\li osm.mapping.providersrepository.address
188
\li The OpenStreetMap plugin retrieves the provider's information from a
189
remote repository. This is done to prevent using hardcoded servers by
190
default, which may become unavailable. By default this information is
191
fetched from \l {http://maps-redirect.qt.io} {maps-redirect.qt.io}.
192
Setting this parameter changes the provider repository address to a
193
user-specified one, which must contain the files \tt{street},
194
\tt{satellite}, \tt{cycle}, \tt{transit}, \tt{night-transit},
195
\tt{terrain} and \tt{hiking}, each of which must contain valid provider
196
information.
197
\row
198
\li osm.mapping.providersrepository.disabled
199
\li By default, the OpenStreetMap plugin retrieves the provider's
200
information from a remote repository to avoid a loss of service due to
201
unavailability of hardcoded services. The plugin, however, still
202
contains fallback hardcoded provider data, in case the provider
203
repository becomes unreachable. Setting this parameter to \b true makes
204
the plugin use the hardcoded urls only and therefore prevents the plugin
205
from fetching provider data from the remote repository.
206
207
\row
208
\li osm.places.debug_query
209
\li Set this parameter to true to have an extended attribute in each result
210
named "requestUrl", and containing the url used for the query. Default
211
is \b false.
212
\row
213
\li osm.places.host
214
\li Url string set when making network requests to the places server.
215
This parameter should be set to a valid server url with the correct OSM
216
API. If not specified the default
217
\l {http://nominatim.openstreetmap.org/search}{url} will be used.
218
\note The API documentation is available at
219
\l {https://wiki.openstreetmap.org/wiki/Nominatim}{Project OSM Nominatim}.
220
\row
221
\li osm.places.page_size
222
\li The amount of results in a page. Note that this value might be clamped
223
server side. The typical maximum in standard nominatim instances is 50.
224
225
\row
226
\li osm.routing.apiversion
227
\li String defining the api version of the (custom) OSRM server. Valid
228
values are \b{v4} and \b{v5}. The default is \b{v5}. This parameter
229
should be set only if \tt{osm.routing.host} is set, and is an OSRM v4
230
server.
231
\row
232
\li osm.routing.host
233
\li Url string set when making network requests to the routing server.
234
This parameter should be set to a valid server url with the correct OSRM
235
API. If not specified the default
236
\l {https://project-osrm.org/docs/v5.24.0/api/#}{url} will be used.
237
\note The API documentation and sources are available at
238
\l {https://project-osrm.org/}{Project OSRM}.
239
240
\row
241
\li osm.useragent
242
\li User agent string set when making network requests. This parameter
243
should be set to a value that uniquely identifies the application. Note
244
that providers might block applications not setting this parameter,
245
leaving it to the stock plugin user agent (e.g.,
246
\l {http://wiki.openstreetmap.org/wiki/Nominatim_usage_policy}{Nominatim}
247
for geocoding)
248
\endtable
249
250
\section1 Parameter Usage Example
251
252
The following example shows how to create an OSM plugin instance with parameters
253
supplied for an useragent, and if necessary, a custom server url plus the
254
corresponding copyright information for the tile provider. Additionally, it is
255
possible to choose another routing server than the public osrm one.
256
257
\section2 QML
258
259
\code
260
Plugin {
261
name: "osm"
262
PluginParameter { name: "osm.useragent"; value: "My great Qt OSM application" }
263
PluginParameter { name: "osm.mapping.host"; value: "http://osm.tile.server.address/" }
264
PluginParameter { name: "osm.mapping.copyright"; value: "All mine" }
265
PluginParameter { name: "osm.routing.host"; value: "http://osrm.server.address/viaroute" }
266
PluginParameter { name: "osm.geocoding.host"; value: "http://geocoding.server.address" }
267
}
268
\endcode
269
270
\section1 Other Plugin-specific Information
271
272
\section2 Tile cache
273
274
The tiles are cached in a \c{QtLocation/osm} directory in
275
\l {QStandardPaths::writableLocation()}{QStandardPaths::writableLocation}
276
(\l{QStandardPaths::GenericCacheLocation}). On systems that have no concept of a
277
shared cache, the application-specific \l{QStandardPaths::CacheLocation} is used
278
instead.
279
*/
qtlocation
src
location
doc
src
plugins
osm.qdoc
Generated on
for Qt by
1.14.0