Point problems

Client SDK Android

Application ID 0557210D-0CD5-4724-FFDB-DB6B680CA200

Expected Behavior

Object in table created and no errors

Actual Behavior

Object is being created in table and saved on the server properly, then server gives an error:
“invalid gis data provided. correct string as wkt or string with geoJSON object is required both type and coordinates should be present in GeoJSON”

class Marker{
private Integer numberOfPeople;
    private String creator;
    private String type;
    private String title;
    private Date created;
    private String objectId;
    private String ownerId;
    private Date updated;
    private List<BackendlessUser> confirmedBy;
    private Point location;

// getters and setters
}

// USAGE

private void createMarker(final LatLng location, final String title, final int peopleNum, boolean isPredefined) {       
 Point point = new Point();
                point.setLatitude(location.latitude);
                point.setLongitude(location.longitude);

        Marker marker = new Marker();
        marker.setTitle(title);
        marker.setCreator(ApplicationClass.user.getProperty("username").toString());
        if (isPredefined)
            marker.setType(Constants.MARKER_TYPE);
        else
            marker.setType(typeChosen);
        marker.setNumberOfPeople(peopleNum);
        marker.setLocation(point);

        Backendless.Data.of(Marker.class).save(marker,
                new AsyncCallback<Marker>() {
                    @Override
                    public void handleResponse(final Marker responseMarker) {
                        arrl_markers.add(responseMarker);

                        LatLng position = new LatLng(responseMarker.getLocation().getLatitude(),
                                responseMarker.getLocation().getLongitude());
                        ClusterItem item = new ClusterItem(responseMarker.getTitle(), position,
                                responseMarker.getType(), Constants.ClusterType.MARKER);
                        clusterManager.addItem(item);
                        clusterManager.cluster();

                        ToastClass toast = new ToastClass(getApplicationContext());
                        toast.Show(getResources().getString(R.string.addedMarker),
                                ToastClass.TypeOfMessage.CONFIRMATION, ToastClass.Length.SHORT);
                    }

                    @Override
                    public void handleFault(BackendlessFault fault) {
                        ToastClass toast = new ToastClass(getApplicationContext());
                        toast.Show(getString(R.string.markerError),
                                ToastClass.TypeOfMessage.ERROR, ToastClass.Length.SHORT);
                    }
                });

}

So I’m doing like this page suggest and I’m not sure what am I doing wrong?

Hi @Jakub_Mirota

We are looking into it.

Best Regards,
Maksym

Hi @Jakub_Mirota

I’ve successfully created the marker with your code sample.
Can you specify:

  • how do you get this error? Do you catch it in AsyncCallback? Can you provide full stacktrace?
  • what version of sdk do you use?

Also it will be very helpful if you can provide the values of location.latitude and location.longitude you get inside your createMarker method.

Best Regards,
Maksym

1 Like

After going through all the code I think I have finally found the error, I was using Backendless.UserService.update() instead of Backendless.Data.of(BackendlessUser.class).save() to update values in user table after creating markers and this caused errors. Thank you for your feedback and I’m sorry for trouble.

To get location.latitude and location.longitude Im using GoogleMap.OnMapLongClickListener

@Override
    public void onMapLongClick(LatLng latLng) {
        //eg.
        createMarker(latLng, "title", 0, false);
    }

Using LatLng gives huge accuracy, about 16 digits after decimal point, can it be a problem? Because when creating point with Backendless console it only creates 8 digits after decimal point

Hello @Jakub_Mirota,

please provide the code that you are using to call backendless API. I suppose it should be the method createMarker. Please also show the error that you get

i had this error : “invalid gis data provided. correct string as wkt or string with geoJSON object is required both type and coordinates should be present in GeoJSON” but everything works now. Thank you

Hello, I am starting to get this error all of the sudden. Has anything changed with this regard on the server?

Hi @snakeeyes

Deprecated Geolocation Service has been replaced by a new spatial data types:

So if you use it in your project consider updating Android SDK to the new version and updating your code.

Best Regards,
Maksym

Yes I am using the spatial data type. Infact the column I have is spacial and here is the code that adds to the map

map.put(“locationGeo”, new Point().setLatitude(lat).setLongitude(lng));

I am getting the error on save

BackendlessException{ code: '1312', message: 'Invalid GIS data provided. Correct string with WKT or string with GeoJSON or just GeoJSON object is required.', extendedData: '{}', detail: 'Invalid GIS data provided. Correct string with WKT or string with GeoJSON or just GeoJSON object is required.' }
        at com.backendless.Invoker$SyncResponder.errorHandler(Invoker.java:122)
        at com.backendless.persistence.MapDrivenDataStore$MapDrivenResponder.responseHandler(MapDrivenDataStore.java:902)
        at weborb.client.ioEngine.HttpIOEngine.processAMFResponse(HttpIOEngine.java:289)
        at weborb.client.ioEngine.HttpIOEngine.send(HttpIOEngine.java:210)
        at weborb.client.ioEngine.HttpIOEngine.invoke(HttpIOEngine.java:140)
        at weborb.client.WeborbClient.invoke(WeborbClient.java:138)
        at com.backendless.Invoker.invokeSync(Invoker.java:95)
        at com.backendless.persistence.MapDrivenDataStore.save(MapDrivenDataStore.java:101)
        at com.backendless.persistence.MapDrivenDataStore.save(MapDrivenDataStore.java:50)
        at .....

Hi @snakeeyes !

I was able to reproduce your problem. I have created internal ticket BKNDLSS-24444 for it. We will fix it as soon as possible. We will notify you when fix will be available.
Sorry for inconvenience.

Regards, Andriy

Thank you. Do you have an ETA for it or a work around? Essentially no user can save a location . I am okay with work around untill the fix is there unless the fix is coming soon. This is a broken existing functionality so you know :slight_smile:

You can try to bypass this error by using spatial string representations instead of objects. Point can be defined in next way - “POINT({longitude} {latitude})”. In this way it should work.

About error. We have made fix for it yesterday. I think that it will be included to the release which we expecting to have till the end of next week

Regards, Andriy

1 Like

Hi, @snakeeyes

We’ve just updated cloud servers with a fix for the issue you described above. Could you kindly let us know whether fix works for you well?

Regards, Marina

1 Like

Thank you. It is working now