我想知道Airbnb如何存储租赁房间的地理位置信息。
他们将其存储在Google服务或自己的服务器中?
答案 0 :(得分:1)
您可以查看Google Cloud Platform。具体来说,您可以对Cloud Datastore感兴趣。
您可以向GeoPt
添加Entity
并执行地理空间查询。来自the documentation:
要向实体添加GeoPt属性,请使用GeoPt类,指定纬度和经度:
Entity station = new Entity("GasStation"); station.setProperty("brand", "Ocean Ave Shell"); station.setProperty("location", new GeoPt(37.7913156f, -122.3926051f)); datastore.put(station);
使用数据存储区查询过滤器
StContainsFilter
来测试给定GeoPt
中是否包含GeoRegion
,例如:// Testing for containment within a circle GeoPt center = new GeoPt(latitude, longitude); double radius = r; // Value is in meters. Filter f1 = new StContainsFilter("location", new Circle(center, radius)); Query q1 = new Query("GasStation").setFilter(f1); // Testing for containment within a rectangle GeoPt southwest = new GeoPt(swLat, swLon); GeoPt northeast = new GeoPt(neLat, neLon); Filter f2 = new StContainsFilter("location", new Rectangle(southwest, northeast)); Query q2 = new Query("GasStation").setFilter(f2);