问题描述
是否可以获取瓷砖 LngLat 边界框? (如果可能,还有中心/宽度)
即给定任何图块“id”(例如 6/33/24
),计算所需坐标。我非常渴望得到答案,以至于我什至不在乎它是用什么语言编写的。
上下文
磁贴“id”有 3 个部分:6/33/24
(z/x/y
)。
z
是地板缩放 (0-24) 和 x/y
来自左/上原点的图块编号。
当缩放为 1 时,整个地图被分成 4 个相等的图块(如图所示)。每次缩放 (z
) 增加时,每个图块都会细分为 4 个相等的图块(例如缩放 2 = 16 个图块)。
_______________________
| | |
| 1/0/0 | 1/1/0 |
| | |
|__________|___________|
| | |
| 1/0/1 | 1/1/1 |
| | |
|__________|___________|
为什么?
我想实现客户端标记缓存并将它们绑定到图块似乎是最合理的解决方案。我知道如何获取磁贴(循环 sourceCaches
磁贴或使用少量 transform
方法),但我不知道如何从磁贴矩阵或磁贴 ID 获取 LngLat 数据。
标记缓存的超级基本 JavaScript 概念(用于上下文):
const markerCache = {
cache: {},getMarkersForTile: function(key) { // tiles have unique keys
if (this.cache[key]) {
return Promise.resolve(this.cache[key]);
}
// ??? what should be in "getTileBounds"?
const bounds = getTileBounds(key);
return fetchMarkersForTile(bounds).then(markers => {
this.cache[key] = markers;
return markers;
});
}
};
解决方法
我相信您正在寻找 Slippy Map Tilenames
中提到的 https://docs.mapbox.com/api/maps/vector-tiles/ 规格链接中有很多编程语言的实现
Java 示例
Option Explicit
Sub replaceFormulasWithCriteria()
Const wsName As String = "Sheet1"
Const FirstCellAddress As String = "A2"
Const Criteria As String = "X"
' Define Criteria Column Range.
Dim rng As Range
With ThisWorkbook.Worksheets(wsName).Range(FirstCellAddress)
Set rng = .Resize(.Worksheet.Cells(.Worksheet.Rows.Count,.Column) _
.End(xlUp).Row - .Row + 1)
End With
' Write values from Criteria Column Range to Criteria Array.
Dim Crit As Variant: Crit = rng.Value
' Define Data Column Range.
Set rng = rng.Offset(,1)
' Write formulas from Data Column Range to Data Array.
Dim Data As Variant: Data = rng.Formula
Dim i As Long
' Loop through rows of Criteria/Data Column Range.
For i = 1 To UBound(Data,1)
' Check if Criteria is found in current row in Criteria Array.
If Crit(i,1) = Criteria Then
' Write Criteria to current row in Data Array.
Data(i,1) = Criteria
End If
Next i
' Write modified values from Data Array to Data Column Range.
rng.Value = Data
' or:
'rng.Formula = Data
End Sub
,
我相信您正在寻找这个库:
https://github.com/mapbox/tilebelt
它包含 <TextBlock>
<TextBlock.Style>
<Style TargetType="{x:Type TextBlock}" BasedOn="{StaticResource textReplyMessageStyle}">
<Setter Property="Text" Value="{Binding Message,Mode = OneWay,FallbackValue = ''}" />
<Style.Triggers>
<DataTrigger Binding="{Binding AnswerMessageSelected}" Value="False">
<Setter Property="Text" Value="{StaticResource Answer_Message_Not_Selected}" />
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
函数,该函数将返回给定图块的边界框。
用法:
tileToBBOX(tile)