微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

从很大的对象数组列表中查找所需的数据

如何解决从很大的对象数组列表中查找所需的数据

一个数组列表包含190,000个结构对象

 {
   srno: 51,health_facility_name: "keeraipatti",address: "Keeraipatti building",street: "keeraipatti",landmark: "keeraipatti",locality: "keeraipatti",pincode: 636903,landline_number: "NA",latitude: 12.005075,longitude: 78.533949,altitude: 394.6894,facility_type: "SubCentre",state_name: "Tamil Nadu",district_name: "Dharmapuri",taluka_name: "Harur",block_name: "Harur"
} 

我使用HTML Gelocation API获取用户的当前位置,并通过JavaScript(window.location.href ='......')将用户的经度和纬度发送到端点

@GetMapping("/nearHospitals/{lattitude}/{longitude}")
public String nearHospitalsHandler(@PathVariable("lattitude")double lattitude,@PathVariable("longitude") double longitude)
{
    //call service method to get List of 20 Hospital Objects closest to the user's 
    //location and put it inside the Modal for the view to render
    //what should be the logic here 
    return "nearHospitalsView";
}

现在,我有一种方法可以计算出医院(ArrayList中的Object)与用户当前位置之间的距离。

现在我应该如何进行下去,找到最近的20家医院并返回其清单的有效方法是什么。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。