Найти точки в радиусе с привязкой к центральной точке, выполнив запрос ниже, получая точки на расстоянии - PullRequest
0 голосов
/ 27 апреля 2020

Как решить эту проблему?

С уважением, Киран Веера

вот код

SELECT distinct cst.sample_ID,cst.latest_test_date,vm.vehicle_no,cg.district_Id,cg.Block_Id,
cg.panchayat_id,cg.village_Id,cg.habitation_Id,cg.gps_latitude,cg.gps_longitude,dt.type_name,
case when cst.is_pass = 0 then 'Pass' else 'Fail' end as status,cst.parameter_id_1,cst.parameter_id_2,
cst.parameter_id_3,cst.parameter_id_4,cst.parameter_id_5,cst.parameter_id_6,cst.parameter_id_7,
cst.parameter_id_8,cst.parameter_id_9,cst.parameter_id_10,cst.parameter_id_11,cst.parameter_id_12,
cst.parameter_id_13,cst.parameter_id_14,cst.parameter_id_15,cst.parameter_id_16,cst.parameter_id_17,
cst.parameter_id_18,cst.parameter_id_19 FROM public.user_data ud, login_txns lt,upjn_data cd,
upjn_sample_txns cst,upjn_geotaginfo Cg,upjn_device cid,parameters_m pm,device_type dt,upjn_vehicle_m vm 
JOIN(SELECT  26.8467  AS latpoint,80.9462 AS longpoint,220 AS radius,111.045 AS distance_unit)
AS p ON 1 = 1 WHERE cg.gps_latitude BETWEEN p.latpoint - (p.radius / p.distance_unit) AND p.latpoint +
(p.radius / p.distance_unit) AND cg.gps_longitude BETWEEN p.longpoint - (p.radius / 
(p.distance_unit * COS(RADIANS(p.latpoint)))) AND p.longpoint + (p.radius / (p.distance_unit* 
 COS(RADIANS(p.latpoint)))) and ud.user_id=lt.user_id and cst.sample_id= cg.sample_ID and 
 ud.user_id= cid.user_iD and  dt.type_id= cid.device_uid and vm.vehicle_id=cid.vehicle_id 
 and pm.parameter_Id in (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19) and lt.session_Id = 1 
 and cst.latest_test_date between '2020-01-01' and '2020-04-08' and cst.is_pass <> 2 order by
 cst.latest_test_date
...