나는 우편 번호 배열을 통해 반복하고 대상에 가장 가까운 우편 번호를 찾는 방법을 찾으려고 노력 중이다. 우편 번호는 또한 대상까지의 거리를 계산하는 데 사용되는 위도와 경도를 포함합니다. 가장 가까운 거리를 저장하고 가장 가까운 배열의 우편 번호를 반환하는 배열을 반복하는 방법을 알아 내야합니다. 제가 생각할 수있는 모든 것을 시도했기 때문에 어떤 도움도 좋을 것입니다. doc에 따르면가장 가까운 거리를 찾기 위해 배열을 반복하는 방법은 무엇입니까?
는* Finds and returns the zip code of a postal zone in the collection
* whose centroid is closest to a given location.
*
* @param target the target location.
*
* @return returns zipCode of the postal zone whose centroid is closest;
* returns COLLECTION_EMPTY if no zones are in the collection.
*/
public String findClosestZone(Location target)
{
int counter = 0;
String closeZip = COLLECTION_EMPTY;
double closestDistance = 100.0;
for (int i = 0; i < this.zoneCount; i++)
{
if (this.zones[i].getZoneLocation()
.calcDistance(target) < closestDistance)
{
closeZip = this.zones[i].getZoneZipCode();
closestDistance = this.zones[i]
.getZoneLocation().calcDistance(target);
counter++;
return closeZip;
}
}
return closeZip;
}
안녕하세요. 여기, [투어] (http://stackoverflow.com/about)를 가져 가라. 여기에 아무런 질문이 없습니다 ... –