Airbnb 在哪里存储它的位置?
Where does Airbnb store it´s places?
我想知道Airbnb是如何存储出租房的地理位置信息的。
他们将其存储在 Google 服务或它自己的服务器中?
你可以看看Google Cloud Platform. In concrete you can be interested in Cloud Datastore。
您可以将 GeoPt
添加到 Entity
并执行地理空间查询。来自 the documentation:
To add a GeoPt property to an entity, use the GeoPt class, specifying latitude and longitude:
Entity station = new Entity("GasStation");
station.setProperty("brand", "Ocean Ave Shell");
station.setProperty("location", new GeoPt(37.7913156f, -122.3926051f));
datastore.put(station);
Use the datastore query filter StContainsFilter
to test if a GeoPt
is contained in a given GeoRegion
, for example:
// 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);
我想知道Airbnb是如何存储出租房的地理位置信息的。
他们将其存储在 Google 服务或它自己的服务器中?
你可以看看Google Cloud Platform. In concrete you can be interested in Cloud Datastore。
您可以将 GeoPt
添加到 Entity
并执行地理空间查询。来自 the documentation:
To add a GeoPt property to an entity, use the GeoPt class, specifying latitude and longitude:
Entity station = new Entity("GasStation"); station.setProperty("brand", "Ocean Ave Shell"); station.setProperty("location", new GeoPt(37.7913156f, -122.3926051f)); datastore.put(station);
Use the datastore query filter
StContainsFilter
to test if aGeoPt
is contained in a givenGeoRegion
, for example:// 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);