Note that there are some explanatory texts on larger screens.

plurals
  1. POGeoSpatial Radius Search Using Objectify
    primarykey
    data
    text
    <p>I am developing an application using <a href="https://code.google.com/p/javageomodel/" rel="noreferrer">GeoModel</a>. I need to perform search in a particular radius based on the given latitude and longitude. I am able to generate the GeoCells in the datastore using Objectify, but not able to get back the results in a particular radius.</p> <p>I am sharing my code below.</p> <p><strong>Entity Class</strong></p> <pre><code>@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&lt;String&gt; cells; // getter and setters ... } </code></pre> <p><strong>Custom GeocellQueryEngine Class</strong> <a href="https://gist.github.com/handstandsam/2421461" rel="noreferrer">From This Source</a></p> <pre><code>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 &lt;T&gt; List&lt;T&gt; query(GeocellQuery baseQuery, List&lt;String&gt; geocells, Class&lt;T&gt; entityClass) { StringTokenizer st; int tokenNo = 0; Query&lt;T&gt; 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(); } } </code></pre> <p><strong>Fetching Data Here</strong></p> <pre><code> Point p = new Point(24.8993714, 79.5839124); // Generates the list of GeoCells List&lt;String&gt; cells = GeocellManager.generateGeoCell(p); List&lt;Object&gt; params = new ArrayList&lt;Object&gt;(); params.add("Movies"); GeocellQuery baseQuery = new GeocellQuery("topic == topic", "String topic",params); ObjectifyGeocellQueryEngine objectifyGeocellQueryEngine = new ObjectifyGeocellQueryEngine(ofy(), "cells"); List&lt;NewsFeed&gt; list = objectifyGeocellQueryEngine.query(baseQuery, cells, NewsFeed.class); List&lt;NewsFeed&gt; list2 = GeocellManager.proximitySearch(p, 10, 10000,NewsFeed.class, baseQuery, objectifyGeocellQueryEngine, GeocellManager.MAX_GEOCELL_RESOLUTION); System.out.println(list+" : "+list2); </code></pre> <p>Now the problem is I am not getting any results out from here. Can you people please help me with this as I am not getting any exception, just getting the empty list.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload