imperiumlabs / GeoFirestore-iOS

GeoFirestore for iOS - Realtime location queries with Firestore
MIT License
127 stars 46 forks source link

Query not working if stored as GeoPoint #20

Open michaeltheshah opened 5 years ago

michaeltheshah commented 5 years ago

I'm using GeoFirestore in both Android and iOS. With Android, to set a location the only option is to upload as a GeoPoint e.g. [0º N 0º E]. It looks like with iOS either a GeoPoint or an array of Double can be uploaded. This causes issues when querying since the iOS client is looking for an array of doubles.

internal func childAdded(_ snapshot: DocumentSnapshot?) {
        let lockQueue = DispatchQueue(label: "self")
        lockQueue.sync {

            let l = snapshot?.get("l") as? [Double?]
            if let lat = l?[0], let lon = l?[1], let key = snapshot?.documentID {
                let location = CLLocation(latitude: lat, longitude: lon)
                updateLocationInfo(location, forKey: key)
            }else{
                //TODO: error??
            }

        }
    }

This causes all queries to fail.

michaeltheshah commented 5 years ago

Created a pull request to address this

shijilsmb commented 5 years ago

@mochat97 have you find any solution for this?

michaeltheshah commented 5 years ago

@shijilsmb yeah I pushed a pull request that was merged. #22