在下面的代码中,我使用RiderLocationRepository
从数据库中获取纬度和经度现在我想要不仅返回距离而且还要返回纬度经度和rider_id,我看到了不同的解决方案但我不明白我该怎么办?它
有人可以解决这个问题吗?
RiderService
@Component
public class RiderService {
@Autowired RiderLocationRepository riderLocationRepository;
public List Location(Double lattitude,Double longitude)
{
RiderLocation rl = null;
List <Double> distance=new ArrayList<>();
List<RiderLocation> allRidersLocation = riderLocationRepository.findAll();
for (RiderLocation riderLocation : allRidersLocation) {
Double oneRiderDist=distFrom(riderLocation.getLatitude(), riderLocation.getLongitude(), lattitude, longitude);
distance.add(oneRiderDist);
}
return distance;
}
RiderLocation.java
@Entity
public class RiderLocation implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@ManyToOne
private User rider;
private Double latitude;
private Double longitude;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public User getRider() {
return rider;
}
public void setRider(User rider) {
this.rider = rider;
}
public Double getLatitude() {
return latitude;
}
public void setLatitude(Double latitude) {
this.latitude = latitude;
}
public Double getLongitude() {
return longitude;
}
public void setLongitude(Double longitude) {
this.longitude = longitude;
}
}