39 lines
956 B
Java
39 lines
956 B
Java
package com.mosty.yjzl.cluster;
|
|
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Set;
|
|
|
|
public class DistanceRunnable implements Runnable {
|
|
|
|
private WGS84Point point;
|
|
private Set<WGS84Point> points;
|
|
private List<NeighborDTO> neighborList;
|
|
private long scope;
|
|
|
|
public DistanceRunnable(WGS84Point point, Set<WGS84Point> points, List<NeighborDTO> neighborList, long scope) {
|
|
super();
|
|
this.point = point;
|
|
this.points = points;
|
|
this.neighborList = neighborList;
|
|
this.scope = scope;
|
|
}
|
|
|
|
@Override
|
|
public void run() {
|
|
Map<WGS84Point, Long> map = new HashMap<>();
|
|
for (WGS84Point point2 : points) {
|
|
if (point.equals(point2)) {
|
|
continue;
|
|
}
|
|
long distance = PositionUtil.getDistance(point.getLatitude(), point.getLongitude(), point2.getLatitude(), point2.getLongitude());
|
|
if (distance < scope) {
|
|
map.put(point2, distance);
|
|
}
|
|
}
|
|
neighborList.add(new NeighborDTO(point, map));
|
|
}
|
|
|
|
}
|