【问题标题】:Cloud database architecture for a location-based app基于位置的应用程序的云数据库架构
【发布时间】:2019-05-28 22:21:43
【问题描述】:

我目前正在为我的基于位置的 Android 应用程序规划我的数据库(未来某个时候的 iOS 应用程序的愿景)。

我想知道以下结构是否适合我的需要。快速了解我的应用程序所涉及的内容:在 2 公里半径(地理围栏)内找到用户并显示他们的个人资料(类似于在 Tinder 上与某人匹配)。

所以我的设想是每个用户通过谷歌地图 API 将他们的LatLon 位置上传到我的数据库 - 并且 Android 会查询数据库以在地理围栏内找到用户。

PS:在地理围栏内查询用户的最佳方式是什么?

我建议的数据库是Google Firestore,文档设置如下:

users: {
    2394824972439 (facebook_id): {
      gender: "male"
      currentLat: 37.234234,
      currentLon: 157.192835,
      profileImg1: googlecloudstorage.com/url/to/img1.png,
      profileImg2: googlecloudstorage.com/url/to/img2.png,
      bio: "This is my bio",
      alreadyMatchedWith: [42304823423, 23423423432, 023948230]
  }
    7388824972439: {
      gender: "female"
      currentLat: 34.234234,
      currentLon: 157.132835,
      profileImg1: googlecloudstorage.com/url/to/img1.png,
      profileImg2: googlecloudstorage.com/url/to/img2.png,
      bio: "Another bio",
      alreadyMatchedWith: [82304823423, 33423423432, 923948230]
  }
}

因此,查询还将确保其他用户的 facebook ID(我使用 facebook 登录)尚未匹配。如果尚未匹配,则数据库将返回该用户的文档并显示他们的个人资料信息以及来自谷歌云的个人资料图片。贮存。

我应该关注此设置是否有任何危险信号 - 或任何更好的替代方案?

【问题讨论】:

    标签: android google-maps


    【解决方案1】:

    由于您没有提到 GeoFire,并且您假装进行与地理相关的查询,因此 GeoFire 可能是最好的选择,

    GeoFire for Android/Java

    https://github.com/firebase/geofire-java

    // creates a new query around [37.7832, -122.4056] with a radius of 2.0 kilometers
    GeoQuery geoQuery = geoFire.queryAtLocation(new GeoLocation(37.7832, -122.4056), 2.0);
    

    如果您必须为 IOS 实现相同的功能:

    Objective-C 的 GeoFire

    https://github.com/firebase/geofire-objc

    【讨论】:

    • 太棒了-谢谢。这是为 Firestore 复制 GeoFire 的库:github.com/imperiumlabs/GeoFirestore 我会试试的
    • 酷。我不知道 Firestore 已经可以使用相同的地理功能。是时候迁移我在 Firebase 上运行的项目了!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-08-17
    • 1970-01-01
    • 2011-09-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多