Qt位置开放街道地图插件

Qt Location Open Street Map Plugin

Qt位置开放街道地图插件

Overview

概述

This geo services plugin allows applications to access Open Street Map location based services using the Qt Location API.

​此地理服务插件允许应用程序使用Qt location API访问基于Open Street Map位置的服务。

Data, imagery and map information provided by ThunderForestOpenStreetMap and contributors. The data is available under the Open Database License.

​数据、图像和地图信息由ThunderForest、OpenStreetMap和贡献者提供。数据在开放数据库许可证下可用。

The Open Street Map geo services plugin can be loaded by using the plugin key "osm".

可以使用插件键“osm”加载Open Street Map地理服务插件。

Note: The standard map types rely on (partially) free data providers. We try to keep the selection useful for evaluation and development purposes, but it is your responsibility to select a data provider that fits your needs in production. It is highly recommended to carefully read and adhere to the terms of service of the respective providers. A list of alternative data providers is available in the OpenStreetMap wiki. The available map types offered by this plugin may change (or be removed) without notice depending on the actual availability of a viable openly accessible provider for each type. This also implies that providers serving tiles over HTTPS may be used. This becomes relevant when using the OSM plugin on platforms, such as Android, for which SSL support is not built into Qt by default. To prevent these changes, either a different geo service plugin should be used, or the plugin parameter osm.mapping.providersrepository.address should be set to a user-specified repository, in order to take full control over selecting the provider that is used for each map type. Since Qt 5.9.6, the default nominatim endpoint, used for geocoding and places, has also changed to HTTPS-only.


注意:标准地图类型依赖于(部分)免费的数据提供者。我们努力使选择对评估和开发目的有用,但您有责任选择一个适合在生产中需求的数据提供商。强烈建议仔细阅读并遵守各提供商的服务条款。OpenStreetMap维基中提供了替代数据提供者的列表。此插件提供的可用地图类型可能会更改(或删除),恕不另行通知,具体取决于每种类型的可行开放访问提供商的实际可用性。这也意味着可以使用通过HTTPS提供磁贴的提供商。在Android等平台上使用OSM插件时,这一点变得很重要,默认情况下Qt中没有内置SSL支持。为了防止这些更改,应使用不同的地理服务插件,或者应将插件参数osm.maping.providerstore.address设置为用户指定的存储库,以便完全控制选择用于每种地图类型的提供程序。自Qt 5.9.6以来,用于地理编码和地点的默认nominatim端点也更改为仅HTTPS。

Parameters

参数

Optional parameters

可选参数

The following table lists optional parameters that can be passed to the Open Street Map plugin.

下表列出了可以传递给Open Street Map插件的可选参数。

Note: Since Qt 5.5 all parameters below must be prefixed with osm. Previous versions did not require a prefix.

注意:自Qt 5.5以来,以下所有参数都必须以osm作为前缀。以前的版本不需要前缀。

ParameterDescription
osm.geocoding.host

Url string set when making network requests to the geocoding server. This parameter should be set to a valid server url with the correct OSM API. If not specified the default url will be used.


向地理编码服务器发出网络请求时设置的Url字符串。此参数应设置为具有正确OSM API的有效服务器url。如果未指定,将使用默认网址。

Note: The API documentation is available at Project OSM Nominatim.

注:API文件可在项目OSM Nomatim处获得。

osm.geocoding.debug_query

Instructs the plugin to inject the query url to nominatim into the geocode reply, for debugging purposes.

指示插件将nominatim的查询url注入到地理编码回复中,以进行调试。

osm.geocoding.include_extended_data

Instructs the plugin to include Nominatim-specific information (such as geometry and class) into the returned Location objects, exposed as extendedAttributes.

指示插件将特定于Nomnatim的信息(如几何体和类)包含在返回的Location对象中,以extendedAttributes的形式公开。

osm.mapping.cache.directory

Absolute path to map tile cache directory used as network disk cache.

用作网络磁盘缓存的映射图块缓存目录的绝对路径。

The default place for the cache is the QtLocation/osm subdirectory in the location returned by QStandardPaths::writableLocation(), called with QStandardPaths::GenericCacheLocation as a parameter. On systems that have no concept of a shared cache, the application-specific QStandardPaths::CacheLocation is used instead.

​缓存的默认位置是QStandardPaths::writableLocation()返回的位置中的QtLocation/osm子目录,使用QStandardPaths::GenericCacheLocation作为参数调用。在没有共享缓存概念的系统上,将使用特定于应用程序的QStandardPaths::CacheLocation。

osm.mapping.cache.disk.cost_strategy

The cost strategy to use to cache map tiles on disk. Valid values are bytesize and unitary. Using bytesize, the related size parameter (osm.mapping.cache.disk.size) will be interpreted as bytes. Using unitary, they will be interpreted as number of tiles. The default value for this parameter is bytesize.

用于在磁盘上缓存映射图块的成本策略。有效值为bytesize和unity。使用bytesize,相关的大小参数(osm.mapping.cache.disk.size)将被解释为字节。使用单位,它们将被解释为瓦片的数量。此参数的默认值是bytesize。

osm.mapping.cache.disk.size

Disk cache size for map tiles. The default size of the cache is 50 MiB when bytesize is the cost strategy for this cache, or 1000 tiles, when unitary is the cost strategy.

地图图块的磁盘缓存大小。当bytesize是此缓存的成本策略时,缓存的默认大小为50 MiB,或者当unity是成本策略时为1000个图块。

osm.mapping.cache.memory.cost_strategy

The cost strategy to use to cache map tiles in memory. Valid values are bytesize and unitary. Using bytesize, the related size parameter (osm.mapping.cache.memory.size) will be interpreted as bytes. Using unitary, they will be interpreted as number of tiles. The default value for this parameter is bytesize.

用于在内存中缓存映射图块的成本策略。有效值为bytesize和unity。使用bytesize,相关的大小参数(osm.mapping.cache.memory.size)将被解释为字节。使用unitary,它们将被解释为瓷砖的数量。此参数的默认值是bytesize。

osm.mapping.cache.memory.size

Memory cache size for map tiles. The default size of the cache is 3 MiB when bytesize is the cost strategy for this cache, or 100 tiles, when unitary is the cost strategy.

地图图块的内存缓存大小。当bytesize是此缓存的成本策略时,缓存的默认大小为3 MiB,或者当unity是成本策略时为100个图块。

osm.mapping.cache.texture.cost_strategy

The cost strategy to use to cache decompressed map tiles in memory. Valid values are bytesize and unitary. Using bytesize, the related size parameter (osm.mapping.cache.texture.size) will be interpreted as bytes. Using unitary, they will be interpreted as number of tiles. The default value for this parameter is bytesize.

用于在内存中缓存解压缩地图块的成本策略。有效值为bytesize和unity。使用bytesize,相关的大小参数(osm.mapping.cache.treaty.size)将被解释为字节。使用单位,它们将被解释为瓷砖的数量。此参数的默认值是bytesize。

osm.mapping.cache.texture.size

Texture cache size for map tiles. The default size of the cache is 6 MiB when bytesize is the cost strategy for this cache, or 30 tiles, when unitary is the cost strategy. Note that the texture cache has a hard minimum size which depends on the size of the map viewport (it must contain enough data to display the tiles currently visible on the display). This value is the amount of cache to be used in addition to the bare minimum.

贴图图块的纹理缓存大小。当bytesize是此缓存的成本策略时,缓存的默认大小为6 MiB,或者当unity是成本策略时为30个图块。请注意,纹理缓存有一个硬最小大小,这取决于地图视口的大小(它必须包含足够的数据来显示当前在显示器上可见的图块)。此值是除最小值之外要使用的缓存量。

osm.mapping.custom.datacopyright

Custom data copryright string is used when setting the Map::activeMapType to MapType.CustomMap via urlprefix parameter. This copyright will only be used when using the CustomMap from above. If empty no data copyright will be displayed for the custom map.

​将Map::activeMapType设置为MapType时,使用自定义数据共版权字符串。通过urlprefix参数自定义映射。此版权仅在使用上述CustomMap时使用。如果为空,则不会显示自定义地图的数据版权。

osm.mapping.custom.host

The url string of a custom tile server. This parameter should be set to a valid server url offering the correct OSM API. The postfix "%z/%x/%y.png" will be added to the url. Since 6.5 the postfix will not be added if the url ends with ".png". If the server requires an apikey, it has to be added to the url string. To use this server, the Map::activeMapType parameter of the Map should be set to the supported map type whose type is MapType.CustomMap. This map type is only be available if this plugin parameter is set, in which case it is always Map::supportedMapTypes[supportedMapTypes.length - 1].


自定义互动程序服务器的url字符串。此参数应设置为提供正确OSM API的有效服务器url。后缀“%z/%x/%y.png”将被添加到url中。从6.5开始,如果url以“.png”结尾,则不会添加后缀。如果服务器需要apikey,则必须将其添加到url字符串中。要使用此服务器,Map的Map::activeMapType参数应设置为支持的映射类型,其类型为MapType。自定义地图。只有设置了此插件参数,此映射类型才可用,在这种情况下,它始终是map::supportedMapTypes[supportedMapTypes.length-1]。

Note: Setting the mapping.custom.host parameter to a new server renders the map tile cache useless for the old custommap style.

注意:将mapping.custom.host参数设置为新服务器会使映射图块缓存对旧的custommap样式无效。

osm.mapping.custom.mapcopyright

Custom map copryright string is used when setting the Map::activeMapType to MapType.CustomMap via urlprefix parameter. This copyright will only be used when using the CustomMap from above. If empty no map copyright will be displayed for the custom map.

​将map::activeMapType设置为MapType时,使用自定义映射共版权字符串。通过urlprefix参数自定义映射。此版权仅在使用上述CustomMap时使用。如果为空,则不会显示自定义地图的地图版权。

osm.mapping.highdpi_tiles

Whether or not to request high dpi tiles. Valid values are true and false. The default value is false. Please note that not all map types are available in high dpi. Setting this parameter to true might even have no effect if no map type is available in high dpi at the moment. Provider information files for high dpi tiles are named street-hiressatellite-hirescycle-hirestransit-hiresnight-transit-hiresterrain-hires and hiking-hires. These are fetched from the same location used for the low dpi counterparts.

是否请求高dpi磁贴。有效值为true和false。默认值为false。请注意,并非所有地图类型都提供高dpi。如果目前没有高dpi的地图类型可用,将此参数设置为true甚至可能没有效果。高分辨率磁贴的提供商信息文件被命名为街道租用、卫星租用、自行车租用、交通租用、夜间交通租用、地形租用和徒步旅行租用。这些是从用于低dpi副本的相同位置获取的。

osm.mapping.offline.directory

Absolute path to a directory containing map tiles used as an offline storage. If specified, it will work together with the network disk cache, but tiles won't get automatically inserted, removed or updated. The format of the tiles is the same used by the network disk cache. There is no default value, and if this property is not set, no directory will be indexed and only the network disk cache will be used to reduce network usage or to act as an offline storage for the currently cached tiles.

包含用作脱机存储的映射图块的目录的绝对路径。如果指定,它将与网络磁盘缓存一起工作,但磁贴不会自动插入、删除或更新。磁贴的格式与网络磁盘缓存使用的格式相同。没有默认值,如果未设置此属性,则不会对任何目录进行索引,只会使用网络磁盘缓存来减少网络使用或作为当前缓存磁贴的脱机存储。

osm.mapping.prefetching_style

This parameter allows to provide a hint how tile prefetching is to be performed by the engine. The default value, TwoNeighbourLayers, makes the engine prefetch tiles for the layer above and the one below the current tile layer, providing ready tiles when zooming in or out from the current zoom level. OneNeighbourLayer only prefetches the one layer closest to the current zoom level. Finally, NoPrefetching allows to disable the prefetching, so only tiles that are visible will be fetched. Note that, depending on the active map type, this hint might be ignored.

此参数允许提供引擎如何执行图块预取的提示。默认值TwoNeighborLayers使引擎预取当前图块层上方和下方的图块,在从当前缩放级别放大或缩小时提供就绪图块。OneNeighborLayer仅预取最接近当前缩放级别的一层。最后,NoPrefetching允许禁用预取,因此只会提取可见的图块。请注意,根据活动映射类型,此提示可能会被忽略。

osm.mapping.providersrepository.address

The OpenStreetMap plugin retrieves the provider's information from a remote repository. This is done to prevent using hardcoded servers by default, which may become unavailable. By default this information is fetched from maps-redirect.qt.io. Setting this parameter changes the provider repository address to a user-specified one, which must contain the files streetsatellitecycletransitnight-transitterrain and hiking, each of which must contain valid provider information.

​OpenStreetMap插件从远程存储库检索提供者的信息。这样做是为了防止默认情况下使用硬编码服务器,因为硬编码服务器可能不可用。默认情况下,此信息从maps-redirect.qt.io获取。设置此参数会将提供程序存储库地址更改为用户指定的地址,其中必须包含文件街道、卫星、自行车、交通、夜间交通、地形和徒步旅行,每个文件都必须包含有效的提供程序信息。

osm.mapping.providersrepository.disabled

By default, the OpenStreetMap plugin retrieves the provider's information from a remote repository to avoid a loss of service due to unavailability of hardcoded services. The plugin, however, still contains fallback hardcoded provider data, in case the provider repository becomes unreachable. Setting this parameter to true makes the plugin use the hardcoded urls only and therefore prevents the plugin from fetching provider data from the remote repository.

默认情况下,OpenStreetMap插件从远程存储库检索提供者的信息,以避免因硬编码服务不可用而导致服务丢失。然而,该插件仍然包含回退硬编码的提供者数据,以防提供者存储库无法访问。将此参数设置为true会使插件仅使用硬编码的url,从而阻止插件从远程存储库获取提供者数据。

osm.places.debug_query

Set this parameter to true to have an extended attribute in each result named "requestUrl", and containing the url used for the query. Default is false.

将此参数设置为true,以便在每个结果中都有一个名为“requestUrl”的扩展属性,并包含用于查询的url。默认值为false。

osm.places.host

Url string set when making network requests to the places server. This parameter should be set to a valid server url with the correct OSM API. If not specified the default url will be used.

向地点服务器发出网络请求时设置的Url字符串。此参数应设置为具有正确OSM API的有效服务器url。如果未指定,将使用默认网址。

Note: The API documentation is available at Project OSM Nominatim.


注:API文件可在项目OSM Nomatim处获得。

osm.places.page_size

The amount of results in a page. Note that this value might be clamped server side. The typical maximum in standard nominatim instances is 50.

页面中的结果数量。请注意,此值可能在服务器端被钳制。标准命名实例中的典型最大值为50。

osm.routing.apiversion

String defining the api version of the (custom) OSRM server. Valid values are v4 and v5. The default is v5. This parameter should be set only if osm.routing.host is set, and is an OSRM v4 server.

定义(自定义)OSRM服务器的api版本的字符串。有效值为v4和v5。默认值为v5。仅当设置了osm.routing.host并且是OSRM v4服务器时,才应设置此参数。

osm.routing.host

Url string set when making network requests to the routing server. This parameter should be set to a valid server url with the correct OSRM API. If not specified the default url will be used.

向路由服务器发出网络请求时设置的Url字符串。此参数应设置为具有正确OSRM API的有效服务器url。如果未指定,将使用默认网址。

Note: The API documentation and sources are available at Project OSRM.

​注:API文件和资料来源可从项目OSRM获取。

osm.useragent

User agent string set when making network requests. This parameter should be set to a value that uniquely identifies the application. Note that providers might block applications not setting this parameter, leaving it to the stock plugin user agent (e.g., Nominatim for geocoding)


发出网络请求时设置的用户代理字符串。此参数应设置为唯一标识应用程序的值。请注意,提供者可能会阻止未设置此参数的应用程序,将其留给股票插件用户代理(例如,用于地理编码的Nomination)

Parameter Usage Example

参数使用示例

The following example shows how to create an OSM plugin instance with parameters supplied for an useragent, and if necessary, a custom server url plus the corresponding copyright information for the tile provider. Additionally, it is possible to choose another routing server than the public osrm one.

以下示例显示了如何使用为用户代理提供的参数创建OSM插件实例,如有必要,还可以创建自定义服务器url以及磁贴提供者的相应版权信息。此外,可以选择公共osrm服务器之外的另一个路由服务器。

QML

Plugin {
    name: "osm"
    PluginParameter { name: "osm.useragent"; value: "My great Qt OSM application" }
    PluginParameter { name: "osm.mapping.host"; value: "http://osm.tile.server.address/" }
    PluginParameter { name: "osm.mapping.copyright"; value: "All mine" }
    PluginParameter { name: "osm.routing.host"; value: "http://osrm.server.address/viaroute" }
    PluginParameter { name: "osm.geocoding.host"; value: "http://geocoding.server.address" }
}

Other Plugin-specific Information

其他插件特定信息

Tile cache

磁贴缓存

The tiles are cached in a QtLocation/osm directory in QStandardPaths::writableLocation (QStandardPaths::GenericCacheLocation). On systems that have no concept of a shared cache, the application-specific QStandardPaths::CacheLocation is used instead.

​这些图块缓存在QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation)中的QtLocation/osm目录中。在没有共享缓存概念的系统上,将使用特定于应用程序的QStandardPaths::CacheLocation。

GeoServicesItems Overlay Plugin

© 2024 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值