Qt 6.x
The Qt SDK
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
13This geo services plugin allows applications to access
14\l {http://openstreetmap.org}{Open Street Map} location based services using the
15Qt Location API.
16
17Data, imagery and map information provided by
18\l {http://www.thunderforest.com/}{ThunderForest},
19\l {http://www.openstreetmap.org/copyright}{OpenStreetMap} and contributors.
20The data is available under the
21\l {http://www.opendatacommons.org/licenses/odbl}{Open Database License}.
22
23The 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
27keep the selection useful for evaluation and development purposes, but it is
28your responsibility to select a data provider that fits your needs in
29production. It is highly recommended to carefully read and adhere to the terms
30of service of the respective providers. A list of alternative data providers is
31available in the
32\l{https://wiki.openstreetmap.org/wiki/Raster_tile_providers}{OpenStreetMap
33wiki}. The available map types offered by this plugin may change (or be
34removed) without notice depending on the actual availability of a viable openly
35accessible provider for each type. This also implies that providers serving
36tiles over HTTPS may be used. This becomes relevant when using the OSM plugin
37on platforms, such as Android, for which SSL support is not built into Qt by
38default. To prevent these changes, either a different geo service plugin should
39be used, or the plugin parameter \e osm.mapping.providersrepository.address
40should be set to a user-specified repository, in order to take full control
41over selecting the provider that is used for each map type. Since Qt 5.9.6, the
42default nominatim endpoint, used for geocoding and places, has also changed to
43HTTPS-only.
44
45\section1 Parameters
46
47\section2 Optional parameters
48The following table lists optional parameters that can be passed to the Open
49Street Map plugin.
50
51\note Since Qt 5.5 all parameters below must be prefixed with \c osm. Previous
52versions 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". To use this server, the
139 \l{Map::activeMapType} parameter of the \l Map should be set to the
140 supported map type whose type is \l{mapType::style}{MapType.CustomMap}.
141 This map type is only be available if this plugin parameter is set, in
142 which case it is always
143 \l{Map::supportedMapTypes}[supportedMapTypes.length - 1].
144 \note Setting the mapping.custom.host parameter to a new server renders
145 the map tile cache useless for the old custommap style.
146\row
147 \li osm.mapping.custom.mapcopyright
148 \li Custom map copryright string is used when setting the
149 \l{Map::activeMapType} to \l{mapType::style}{MapType.CustomMap} via
150 urlprefix parameter. This copyright will only be used when using the
151 CustomMap from above. If empty no map copyright will be displayed for
152 the custom map.
153\row
154 \li osm.mapping.highdpi_tiles
155 \li Whether or not to request high dpi tiles. Valid values are \b true and
156 \b false. The default value is \b false. Please note that not all map
157 types are available in high dpi. Setting this parameter to true might
158 even have no effect if no map type is available in high dpi at the
159 moment. Provider information files for high dpi tiles are named
160 \tt{street-hires}, \tt{satellite-hires}, \tt{cycle-hires},
161 \tt{transit-hires}, \tt{night-transit-hires}, \tt{terrain-hires} and
162 \tt{hiking-hires}. These are fetched from the same location used for the
163 low dpi counterparts.
164\row
165 \li osm.mapping.offline.directory
166 \li Absolute path to a directory containing map tiles used as an offline
167 storage. If specified, it will work together with the network disk
168 cache, but tiles won't get automatically inserted, removed or updated.
169 The format of the tiles is the same used by the network disk cache.
170 There is no default value, and if this property is not set, no directory
171 will be indexed and only the network disk cache will be used to reduce
172 network usage or to act as an offline storage for the currently cached
173 tiles.
174\row
175 \li osm.mapping.prefetching_style
176 \li This parameter allows to provide a hint how tile prefetching is to be
177 performed by the engine. The default value, \tt{TwoNeighbourLayers},
178 makes the engine prefetch tiles for the layer above and the one below
179 the current tile layer, providing ready tiles when zooming in or out
180 from the current zoom level. \tt{OneNeighbourLayer} only prefetches the
181 one layer closest to the current zoom level. Finally, \tt{NoPrefetching}
182 allows to disable the prefetching, so only tiles that are visible will
183 be fetched. Note that, depending on the active map type, this hint might
184 be ignored.
185\row
186 \li osm.mapping.providersrepository.address
187 \li The OpenStreetMap plugin retrieves the provider's information from a
188 remote repository. This is done to prevent using hardcoded servers by
189 default, which may become unavailable. By default this information is
190 fetched from \l {http://maps-redirect.qt.io} {maps-redirect.qt.io}.
191 Setting this parameter changes the provider repository address to a
192 user-specified one, which must contain the files \tt{street},
193 \tt{satellite}, \tt{cycle}, \tt{transit}, \tt{night-transit},
194 \tt{terrain} and \tt{hiking}, each of which must contain valid provider
195 information.
196\row
197 \li osm.mapping.providersrepository.disabled
198 \li By default, the OpenStreetMap plugin retrieves the provider's
199 information from a remote repository to avoid a loss of service due to
200 unavailability of hardcoded services. The plugin, however, still
201 contains fallback hardcoded provider data, in case the provider
202 repository becomes unreachable. Setting this parameter to \b true makes
203 the plugin use the hardcoded urls only and therefore prevents the plugin
204 from fetching provider data from the remote repository.
205
206\row
207 \li osm.places.debug_query
208 \li Set this parameter to true to have an extended attribute in each result
209 named "requestUrl", and containing the url used for the query. Default
210 is \b false.
211\row
212 \li osm.places.host
213 \li Url string set when making network requests to the places server.
214 This parameter should be set to a valid server url with the correct OSM
215 API. If not specified the default
216 \l {http://nominatim.openstreetmap.org/search}{url} will be used.
217 \note The API documentation is available at
218 \l {https://wiki.openstreetmap.org/wiki/Nominatim}{Project OSM Nominatim}.
219\row
220 \li osm.places.page_size
221 \li The amount of results in a page. Note that this value might be clamped
222 server side. The typical maximum in standard nominatim instances is 50.
223
224\row
225 \li osm.routing.apiversion
226 \li String defining the api version of the (custom) OSRM server. Valid
227 values are \b{v4} and \b{v5}. The default is \b{v5}. This parameter
228 should be set only if \tt{osm.routing.host} is set, and is an OSRM v4
229 server.
230\row
231 \li osm.routing.host
232 \li Url string set when making network requests to the routing server.
233 This parameter should be set to a valid server url with the correct OSRM
234 API. If not specified the default
235 \l {http://router.project-osrm.org/route/v1/driving/}{url} will be used.
236 \note The API documentation and sources are available at
237 \l {http://project-osrm.org/}{Project OSRM}.
238
239\row
240 \li osm.useragent
241 \li User agent string set when making network requests. This parameter
242 should be set to a value that uniquely identifies the application. Note
243 that providers might block applications not setting this parameter,
244 leaving it to the stock plugin user agent (e.g.,
245 \l {http://wiki.openstreetmap.org/wiki/Nominatim_usage_policy}{Nominatim}
246 for geocoding)
247\endtable
248
249\section1 Parameter Usage Example
250
251The following example shows how to create an OSM plugin instance with parameters
252supplied for an useragent, and if necessary, a custom server url plus the
253corresponding copyright information for the tile provider. Additionally, it is
254possible to choose another routing server than the public osrm one.
255
256\section2 QML
257
258\code
259Plugin {
260 name: "osm"
261 PluginParameter { name: "osm.useragent"; value: "My great Qt OSM application" }
262 PluginParameter { name: "osm.mapping.host"; value: "http://osm.tile.server.address/" }
263 PluginParameter { name: "osm.mapping.copyright"; value: "All mine" }
264 PluginParameter { name: "osm.routing.host"; value: "http://osrm.server.address/viaroute" }
265 PluginParameter { name: "osm.geocoding.host"; value: "http://geocoding.server.address" }
266}
267\endcode
268
269\section1 Other Plugin-specific Information
270
271\section2 Tile cache
272
273The tiles are cached in a \c{QtLocation/osm} directory in
274\l {QStandardPaths::writableLocation()}{QStandardPaths::writableLocation}
275(\l{QStandardPaths::GenericCacheLocation}). On systems that have no concept of a
276shared cache, the application-specific \l{QStandardPaths::CacheLocation} is used
277instead.
278*/