经纬网地理编码问题
我正在尝试使用经纬网对地址进行地理编码,但遇到了一个恼人的问题。对美国地址进行地理编码时,该位置的区域属性是两个字母缩写而不是全名(OH 而不是俄亥俄州)。有什么办法可以找回全名吗?
I'm attempting to use Graticule to geocode an address but I'm running into an annoying problem. When geocoding an address in the US, the region attribute from the location is the two letter abbreviation instead of the full name (OH instead of Ohio). Is there any way to retrieve the full name?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来 Graticule 只是传递来自各种服务的原始结果,仅规范化属性名称。因此,简短的答案是:仅使用当前在 Graticule 映射到该服务的区域的字段中返回全名的服务。
很长的答案(或者确实是建议)。
我会使用哈希替换该值,例如,
可能希望将其包装在国家/地区检查中,但是您必须确保涵盖服务中所有可能的国家/地区值,例如,
这会让您一些稳定性,因此更改服务或更改其结果的服务,以后不会让您感到惊讶。
如果您感觉勇敢,可以分叉 Graticule 并添加region_name和region_abbr方法(或类似的),因为当前的“区域”具有可变的含义/结果并发送拉取请求...
Looks like Graticule just passes through the raw results from the various services, only normalizing the attribute names. So the short answer is: only by using a service that currently returns the full name in the field Graticule is mapping to region for that service.
Long answer (or suggestion really).
I'd replace the value using a Hash, e.g.,
Probably would want to wrap that in a check for country, but then you'd have to be sure to cover all the possible country values from the services, e.g.,
That would get you some stability so changing services, or services changing their results, won't surprise you later on.
If you were feeling intrepid, could fork Graticule and add region_name and region_abbr methods (or the like) since the current 'region' has variable meanings/results and send a pull request...