【发布时间】:2015-06-23 11:39:07
【问题描述】:
我的程序在 WGS84 中为 google 计算新坐标(经度和纬度)。如何验证这些坐标下是街道还是地址。
【问题讨论】:
-
您正在寻找反向地理编码。
标签: android delphi delphi-xe8
我的程序在 WGS84 中为 google 计算新坐标(经度和纬度)。如何验证这些坐标下是街道还是地址。
【问题讨论】:
标签: android delphi delphi-xe8
此功能由 TGeocoder 类提供 - 可在此处找到文档:
用于处理地理编码和反向地理编码。
地理编码是将地址、邮政编码等地理数据转换为地理坐标的过程。反向地理编码是将地理坐标转换为其他地理数据(例如地址)的过程。在第一次通过 Current 属性使用 TGeocoder 之前,必须使用 Initialize 过程。 Supported 函数决定是否可以实现地理编码。 Authorized 确定应用程序是否被授权使用该服务。
您可能想要的方法:TGeocoder.GeocodeReverse
请求与指定地理坐标匹配的地址。
要创建特定于您的平台/设备的TGeocoder 类的实例,请使用.Current 类属性as described in the documentation。
// ... in your class
private
FGeocoder: TGeocoder;
procedure OnGeocodeReverseEvent(const Address: TCivicAddress);
然后
// Setup an instance of TGeocoder
if not Assigned(FGeocoder) then
begin
if Assigned(TGeocoder.Current) then
FGeocoder := TGeocoder.Current.Create;
if Assigned(FGeocoder) then
FGeocoder.OnGeocodeReverse := OnGeocodeReverseEvent;
end;
【讨论】:
OnGeocodeReverse 在没有地理编码的情况下会触发吗(例如,传递的TCivicAddress 结构的空字段)?或者它如何表明这种情况?错误,它通常如何指示错误(如果它是异步的)?这让我觉得这门课缺少一些东西。 [只是好奇,这似乎是要走的路:)]
TGeocoder.Current属性(source)获得(默认?)实现(对于当前平台?)。
OnGeocodeReverse 就会被解雇——这似乎由后代类来决定。 windows 默认实现实际上并没有实现反向地理编码(实现是空的,但有// do nothing 注释)。我没有移动设备的来源来说明它在 android 上的工作原理......