简体   繁体   English

比较两个街道地址的最佳方法是什么?

[英]What's the best way to compare two street addresses?

I want to compare two postal addresses, Will it be a bad practice to consider addresses as strings and compare the similarity between them.我想比较两个邮政地址,将地址视为字符串并比较它们之间的相似性是否是一种不好的做法。 Is there a standard algorithm that to implement in the programming language I use?是否有标准算法可以在我使用的编程语言中实现? or is there a free api to do that (with quota limit)?或者是否有免费的 api 来做到这一点(有配额限制)? In reality I am open to any idea or advice I am not posting my problem to be solved here but to receive index that guides my search.实际上,我对任何想法或建议持开放态度,我不是在这里发布要解决的问题,而是接收指导我搜索的索引。 Thank you for reading that.谢谢你阅读。

If I am not wrong, then what you are looking for is "GeoCoding" to learn more click here如果我没有猜错,那么您正在寻找的是“地理编码”以了解更多信息,请单击此处

In simple terms what you need to do is, convert the address into Geocodes ie longitude and latitude similar to (latitude 37.423021 and longitude -122.083739) and then you will need to have the addresses you want to check against already converted into geocodes with which you can check against like a normal array comparison.简单来说,您需要做的是,将地址转换为地理编码,即经度和纬度类似于(纬度 37.423021 和经度 -122.083739),然后您需要将要检查的地址转换为地理编码可以像普通数组比较一样进行检查。

If you need to check if an address belongs to a particular region then you will need to have geocoding information for each region and then you can geocode the host address and use any vector algorithm that check if the given point fall's into it or not!如果您需要检查地址是否属于特定区域,那么您需要拥有每个区域的地理编码信息,然后您可以对主机地址进行地理编码并使用任何矢量算法来检查给定的点是否落入其中!

You can temporarily change it into one big string, for example if you had an address at 1935 Eastwood Road, you could do:您可以暂时将其更改为一个大字符串,例如,如果您的地址位于 1935 Eastwood Road,则可以执行以下操作:

var num = "1935";
var road = "Eastwood";
var roadname = "Road";

var fullRoadName = num + " " + road + " " + roadname;
console.log(fullRoadName);
//Console will print out '1935 Eastwood Road'

Assuming instead of setting all the variables manually they are grabbed from a database or such.假设不是手动设置所有变量,而是从数据库等中获取它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 比较两个对象中选定属性的最佳方法是什么 - what's the best way to compare selected properties in two objects 比较 Google 表格中两列数据和 output 只有使用 Google 脚本的不匹配数据的最佳方法是什么? - What's the best way to compare two columns of data in Google Sheets and output ONLY the non-matching using Google Scripts? 在这种情况下比较两个对象布尔的更好方法是什么? - What's a better way to compare two object booleans in this scenario? 比较两个对象的值的最有效方法是什么? - What's the most efficient way to compare values of two objects? 按值对二维矩阵排序的最佳方法是什么? - What's the best way to sort a two-dimensional matrix by values? 修复两个具有相同名称的AngularJS指令的最佳方法是什么? - What's the best way to fix two AngularJS directives with the same name? 在二维数组中找到最短数组的最佳方法是什么? - What's the best way to find the shortest array in a two dimensional array? 在两个带有衰落的div之间切换的最佳方法是什么? - What's the best way to switch between two divs with fading? 将值与'undefined'进行比较的最佳方法是什么? - What is the best way to compare a value against 'undefined'? 在Javascript中比较两个列表的最佳方法是什么,就像在Python中一样? - What is the best way to compare two lists in Javascript as you would do in Python?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM