@Transient
public static list<article> querybyposition (Positioninfo pinfo) {
SYSTEM.OUT.PRINTLN ("------Query-----");
String hql= "from article Art where art.author.id=" +UID;
Double r = 6371;//Earth radius km
Double dis = 0.5;//0.5 km distance
Double dlng = 2*math.asin (Math.sin (dis/(2*r))/math.cos (pinfo.latitude*math.pi/180));
DLNG = dlng*180/math.pi;//Angle converted to radians
Double Dlat = dis/r;
Dlat = Dlat*180/math.pi;
Double Minlat = Pinfo.latitude-dlat;
Double Maxlat = Pinfo.latitude+dlat;
Double minlng = pinfo.longitude-dlng;
Double maxlng = pinfo.longitude + dlng;
String hql = "from article Art where art.longitude>=" +minlng+ "and Art.longitude <=" +maxlng+ "and art.latitude>=" +minlat+ "and art.latitude<=" +maxlat+ "and art.state=1";
if (pinfo.lastid>0) {
HQL + = "and art.id<" + Pinfo.lastid;
}
Return dbutil.findlistbyhql (Hql,pinfo.size, Article.class);
}
This finds the scope in the database to get the collection
Latitude and longitude coordinates of the andriod front end to query class data in 500M around the database coordinates