覆盖率分析器¶
- 作者
杰罗姆·布伊
NAME¶
mapcache_detail -mapcache sqlite缓存的覆盖率分析
SYNOPSIS¶
mapcache_detail [ options ]
DESCRIPTION¶
mapcache_detail
主要用例是希望离线使用覆盖给定地理区域的mapcache缓存的一部分的用户。为此,他们需要从现有缓存中标识相关文件,检查这些文件中是否缺少磁贴(如有必要,可能会播种丢失的部分),并提取这些文件以构建所请求区域的新缓存。
mapcache_detail
,帮助用户完成其中一些活动。它与sqlite缓存一起工作,其中一个文件可能包含数千个图块。它能够:
确定需要缓存中的哪些 SQLite 文件覆盖给定缩放级别范围内的给定地理区域;
计算覆盖区域所需的切片数量以及每个文件中已经存在的切片数量,给出文件级别、缩放级别和全局级别的覆盖率;
估计丢失的图块的数据大小,这些图块需要下载以完全覆盖请求的区域,再次覆盖文件级别、缩放级别和全局级别。
mapcache_detail
能够处理mapcache本身处理的所有类型的sqlite缓存,即:
Single SQLite caches ,其中只有一个sqlite数据库包含整个缓存;
Multiple SQLite caches ,其中缓存根据给定的模板拆分为多个sqlite数据库;
Composite SQLite caches ,它是单个和多个sqlite缓存的组合,具体取决于缩放级别。
mapcache_detail
采用使用mapcache库的独立CLI可执行文件的形式。建议将其作为对MapCache项目的简单贡献 contrib/mapcache_detail/
文件夹,由于其特定用途(仅处理sqlite缓存)。
OPTIONS¶
有些选项的语法和含义与 mapcache_seeder utility .
杂项设置¶
- -h, --help
显示帮助消息并退出。
- -o, --short-output
(可选)如果存在此选项,则只报告现有的sqlite文件,对于级别和全局覆盖率,仍会考虑缺少的sqlite文件。
用于指定要分析的缓存的选项¶
- -c, --config mapcache配置文件
(必需)设置指定要分析的缓存的mapcache配置文件。
- -t, --tileset 小菜名
(必需)设置要分析的tileset。
- -g, --grid 网格名称
(必需)设置要分析的网格。
- -D, --dimension DIMENSION_NAME=VALUE
(可选)设置维度的值。此选项可多次用于多个维度。
- -q, --query <值>
(可选)设置SQL查询以计算矩形中的平铺数。下面给出的默认值与SQLite缓存的默认模式一起使用。
SELECT count(rowid) FROM tiles WHERE (x between :minx and :maxx) AND (y between :miny and :maxy) AND (z=:z) AND tileset=:tileset AND grid=:grid AND dim=:dim;
用于指定要覆盖的区域的选项¶
- -z, --zoom [最小缩放[,最大缩放]]
(可选)设置要分析的最小和最大缩放级别,用逗号分隔,例如:12、15。如果 最大缩放 不存在,仅由指定的缩放级别 微型变焦镜头 进行了分析。默认值为 0 .
矩形区域¶
- -e, --extent minx,miny,maxx,maxy
(可选)设置要分析的范围。默认值是整个网格范围。此选项不能用于 --ogr-datasource 选择权。
多边形区域¶
- -d, --ogr-datasource OGR数据源
(可选)设置要从中获取功能的OGR数据源。任何 OGR Vector Format 可以使用。如果不存在,则使用 --extent 选项,可能是其默认值。此选项不能用于 -范围 选择权。
- -l, --ogr-layer 图层
(可选)选择OGR数据源内的层。此选项仅在以下情况下有效 --ogr-datasource 已指定。此选项不能用于 –ogr-sql 选择权。
- -w, --ogr-where filter
(可选)设置要应用于OGR图层功能的过滤器。此选项仅在以下情况下有效 --ogr-datasource 已指定。此选项不能用于 –ogr-sql 选项。
- -s, --ogr-sql SQL 查询
(可选)用于筛选OGR数据源内部的SQL查询。此选项仅在以下情况下有效 --ogr-datasource 已指定。此选项不能用于 –ogr-layer或–ogr-where 。
计数切片¶
为了说明这个过程,这里有一个虚构的网格示例。瓷砖由网格上最小的正方形表示。每个25块的大正方形表示SQLite文件。小索引表示平铺坐标,而大索引表示数据库坐标。彩色矩形表示请求的缓存提取区域。较暗的平铺表示缓存中存在的平铺。

以切片、区域坐标表示 (xmin、ymin、xmax、ymax) 是(11,7,27,20)。用sqlite文件表示,这些坐标是(2,1,5,4)。包含坐标在(2,1)和(5,4)之间的所有文件应是缓存提取的一部分。坐标在(11,7)和(27,20)之间的所有切片应计入区域覆盖范围。
下表根据工具的流程给出了所请求区域的图块计数和覆盖率:
SQLite文件 |
(2,1) |
(2,2) |
(2,3) |
(2,4) |
(3,1) |
(3,2) |
(3,3) |
(3、4) |
(4,1) |
(4,2) |
(4,3) |
(4,4) |
(5,1) |
(5,2) |
(5,3) |
(5、4) |
合计 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
缓存和覆盖区域中存在的磁贴 |
0 |
4 |
3 |
0 |
4 |
9 |
8 |
0 |
4 |
6 |
3 |
0 |
2 |
0 |
0 |
0 |
43 |
完全覆盖区域所需的切片 |
12 |
20 |
20 |
4 |
15 |
25 |
25 |
5 |
15 |
25 |
25 |
5 |
9 |
15 |
15 |
3 |
238 |
新闻报道 |
0 |
0.2 |
0.15 |
0 |
0.267 |
0.36 |
0.32 |
0 |
0.267 |
0.24 |
0.12 |
0 |
0.222 |
0 |
0 |
0 |
0.181 |
输出报告¶
该工具的输出采用JSON格式,为用户提供要从缓存中提取的sqlite文件列表。详细说明了有助于区域覆盖的切片数量。还为每个缩放级别和全局级别提供了合成。
下面是一个虚构的例子,描述了工具输出中存在的信息。
{ _______________________________________
"layer": "example", | Report starts with general information
"grid": "local", | on cache and requested region
"unit": "m",
"region": {
"bounding_box": [ 11, 7, 27, 20 ],
"geometry": {
"type": "Polygon",
"coordinates": [[ [11,7], [11,20], [27,20], [27,7], [11,7] ]]
}
},
"zoom-levels": [ {
"level": 1,
"files": [ { _______________________________________
| For each file, output report gives:
| its name, its size, its bounding box
| and intersection of that bounding box
| with requested region
"file_name": "/path/to/cache/example/1/2-1.sqlite",
"file_size": 54632,
"file_bounding_box": [ 10, 5, 14, 9 ],
"region_in_file": {
"bounding_box": [ 11, 7, 14, 9 ],
"geometry": {
"type": "Polygon",
"coordinates":
[[ [11,7], [11,9], [14,9], [14,7], [11,7] ]]
}
},
"nb_tiles_in_region": { ___________________________________
| Measures associated to a SQLite file
| are: number of tiles belonging to
| requested region and present in file,
| number of tiles belonging to region
| present or not in file, and resulting
| coverage ratio
"cached_in_file": 0,
"max_in_file": 12,
"coverage": 0
}
}, {
"file_name": ...
...
} ],
"nb_tiles_in_region": { _______________________________________
| Measures associated to a zoom level
| are the sum of the ones for each SQLite
| file of that level
"cached_in_level": 43,
"max_in_level": 238,
"coverage": 0.1807
}
}, {
"level": 2,
...
} ],
"nb_tiles_in_region": { _______________________________________
"cached_in_cache": 43, | Global measures are the sum of all
"max_in_cache": 238, | zoom level measures
"coverage": 0.1807
},
"sizes": { _______________________________________
| At global level estimations about
| cache size to be extracted for a full
| region coverage are also given. These
| estimations are based on the mean size
| of a tile obtained from all SQLite file
| sizes and how many tiles they contain
"total_size_of_files": 1599442,
"total_nb_tiles_in_files": 60,
"average_tile_size": 26658,
"estimated_max_cache_size": 6344604,
"estimated_cached_cache_size": 1146294,
"estimated_missing_cache_size": 5198310
}
}
EXAMPLES¶
分析tileset的切片覆盖率 osm 与 g 网格。默认范围是整个世界,默认缩放级别为0:
mapcache_detail --config mapcache.xml --tileset osm --grid g
与之前相同,显式缩放级别为9到12,显式范围覆盖瑞士:
mapcache_detail --config mapcache.xml --tileset osm --grid g --zoom 9,12 --extent 663000,5751230,1167680,6075050