GeoModelを使用してアプリケーションを開発しています。私は与えられた緯度と経度に基づいて特定の半径で検索を実行する必要があります。 Objectifyを使用してデータストア内にGeoCellを生成することはできますが、特定の半径で結果を戻すことはできません。Objectifyを使用したGeoSpatial半径の検索
私は以下のコードを共有しています。ここで
エンティティークラス
@Entity
public class NewsFeed implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Index
private Long feedID;
@Index
private String topic;
@Index
private String title;
private String description;
@Index
private Date createDate;
private String imageOrVideo;
private String imageUrl;
private String blobKey;
@Latitude
private Double latitude;
@Longitude
private Double longitude;
@Geocells
private List<String> cells;
// getter and setters ...
}
カスタムGeocellQueryEngineクラスFrom This Source
public class ObjectifyGeocellQueryEngine implements GeocellQueryEngine {
private String geocellsProperty;
private Objectify ofy;
public static final String DEFAULT_GEOCELLS_PROPERTY = "cells";
public ObjectifyGeocellQueryEngine(Objectify ofy) {
this(ofy, DEFAULT_GEOCELLS_PROPERTY);
}
public ObjectifyGeocellQueryEngine(Objectify ofy, String geocellsProperty) {
this.ofy = ofy;
this.geocellsProperty = geocellsProperty;
}
@Override
public <T> List<T> query(GeocellQuery baseQuery, List<String> geocells, Class<T> entityClass) {
StringTokenizer st;
int tokenNo = 0;
Query<T> query = ofy.query(entityClass);
if (baseQuery != null) {
st = new StringTokenizer(baseQuery.getBaseQuery(), ",");
while (st.hasMoreTokens()) {
query.filter(st.nextToken(), baseQuery.getParameters().get(tokenNo++));
}
}
return query.filter(geocellsProperty + " IN", geocells).list();
}
}
データのフェッチ
Point p = new Point(24.8993714, 79.5839124);
// Generates the list of GeoCells
List<String> cells = GeocellManager.generateGeoCell(p);
List<Object> params = new ArrayList<Object>();
params.add("Movies");
GeocellQuery baseQuery = new GeocellQuery("topic == topic", "String topic",params);
ObjectifyGeocellQueryEngine objectifyGeocellQueryEngine = new ObjectifyGeocellQueryEngine(ofy(), "cells");
List<NewsFeed> list = objectifyGeocellQueryEngine.query(baseQuery, cells, NewsFeed.class);
List<NewsFeed> list2 = GeocellManager.proximitySearch(p, 10, 10000,NewsFeed.class, baseQuery, objectifyGeocellQueryEngine, GeocellManager.MAX_GEOCELL_RESOLUTION);
System.out.println(list+" : "+list2);
今問題は私がここから結果を得ることではないということです。あなたは人々が空リストを取得するだけで、私は例外を取得していないので、これで私を助けてください。
私は、最新のアップデートからほぼ2年後のことを信じません。 Javaで遊んだことはありませんので、私に聞いてはいけません:) – Lipis
それは素晴らしい質問ですが、おそらくPythonでもっと助けになるでしょう(私は自分自身のために話します) –