I added a GeoPoint as one of the columns in my Vehicle table. In one of your examples I saw that I needed to represent this column as a GeoPoint data object in my Vehicle class. But in another example I saw a different approach. (the GeoPoint data object wasn’t included in the class)
In this Architect class the GeoPoint data object is not included
public class Architect { private String nationality; private String name; private Date birthday; private String objectId; public void setName(String name) { this.name = name; } public String getName() { return name; } public void setBirthday(Date birthday) { this.birthday = birthday; } public Date getBirthday() { return birthday; } public void setNationality(String nationality) { this.nationality = nationality; } public String getNationality() { return nationality; } public String getObjectId() { return objectId; } public void setObjectId(String objectId) { this.objectId = objectId; } }
//But saving and retrieval works just fine
Architect gustaveEiffel = new Architect(); gustaveEiffel.setName(“Gustave Eiffel”); Calendar calendar = Calendar.getInstance(); calendar.set(1923, 11, 27); gustaveEiffel.setBirthday(calendar.getTime()); gustaveEiffel.setNationality(“French”); Backendless.Data.of(Architect.class).save(gustaveEiffel, new AsyncCallback() { @Override public void handleResponse(Architect savedArchitect) { GeoPoint eiffelTower = new GeoPoint(48.85815, 2.29452); eiffelTower.addCategory(“towers”); eiffelTower.addCategory(“placesToVisit”); eiffelTower.addMetadata(“name”, “Eiffel Tower”); eiffelTower.addMetadata(“architect”, savedArchitect); Backendless.Geo.savePoint(eiffelTower, new AsyncCallback() { @Override public void handleResponse(GeoPoint geoPoint) { Log.i(TAG, "Geo point has been saved - " + geoPoint.getObjectId()); } @Override public void handleFault(BackendlessFault fault) { Log.i(TAG, fault.getMessage()); } }); } @Override public void handleFault(BackendlessFault fault) { Log.e(TAG, fault.getMessage()); } });
Which approach is recommended?
And I really don’t understand what the addMetadata, and addCategory does. How do they affect data retrieval. I want to be able to Geotag each record with a GeoPoint and then be able to retrieve records sorted by my proximity to each record. That is, I want the records with GeoPoints closest to me to appear first. Just like ride hailing app, but I don’t want to set this criteria in whereclause, I want to do it in sort order as explained above.