QuickBlox / quickblox-android-sdk-releases

This repository contains binary distributions of Android products released by QuickBlox.
BSD 3-Clause "New" or "Revised" License
31 stars 15 forks source link

"QBRequestGetBuilder().near()" not working for Location data ( QBDialogCustomData ) of QBDialog #5

Closed regmoraes closed 3 years ago

regmoraes commented 8 years ago

I have a QBDialog with a Location custom data. I'm saving the custom data this way ( in Kotlin )

    val dialog: QBDialog = QBDialog()
    dialog.name = name
    dialog.setOccupantsIds(ArrayList(chatMembers))

    dialog.customData = QBDialogCustomData("JsRoom")
    dialog.customData.putLocation("room_location", listOf(location.latitude, location.longitude) )

This goes fine, and the dialog is created correctly. But when I try to retrieve the nearest (50 meters of radius around me) dialogs by calling:

val lastLocationArray = arrayOf(location.latitude, location.longitude)
val requestBuilder = QBRequestGetBuilder()
requestBuilder.limit = 10
requestBuilder.near("room_location", lastLocationArray, 50)

Observable.fromCallable {

     QBChatService.getChatDialogs(QBDialogType.PUBLIC_GROUP, requestBuilder, Bundle())

}.subscribeOn(Schedulers.io())

the QBSDK makes this inline request

   GET https://api.quickblox.com/chat/Dialog.json?data[room_location][near]=-22.9068924%2C-43.1329527%3B50&limit=10&type=1

and I receive this inline response

'{"total_entries":1,"skip":0,"limit":10,"items":[{"_id":"57225abda0eb472bcd00006f","created_at":"2016-04-28T18:47:25Z","data":{"location":[-22.502199,-41.9246502],"class_name":"JsRoom","room_location":[-22.502199,-41.9246502]},"last_message":"vvb","last_message_date_sent":1462152806,"last_message_user_id":12122574,"name":"Test","occupants_ids":[],"photo":null,"type":1,"updated_at":"2016-05-02T01:33:26Z","user_id":12122574,"xmpp_room_jid":"28632_57225abda0eb472bcd00006f@muc.chat.quickblox.com","unread_messages_count":0}]}'

As you can see, my current location where I made the request is -22.9068924, -43.1329527 and even making a request of dialogs 50 meters close to me, the response returns me a dialog where the location is -22.502199,-41.9246502 . If you calculate the distance between these two points, you'll see that it's about 131.9 km !! Much more than 50 meters.

Here's a photo of google maps to see the distance