int Ardb::GeoAdd(const DBID& db, const Slice& key, const GeoAddOptions& options) { GeoHashRange lat_range, lon_range; GeoHashHelper::GetCoordRange(options.coord_type, lat_range, lon_range); if (options.x < lon_range.min || options.x > lon_range.max || options.y < lat_range.min || options.y > lat_range.max) { return ERR_INVALID_ARGS; } GeoPoint point; point.x = options.x; point.y = options.y; if (options.coord_type == GEO_WGS84_TYPE) { point.x = GeoHashHelper::GetMercatorX(options.x); point.y = GeoHashHelper::GetMercatorY(options.y); GeoHashHelper::GetCoordRange(GEO_MERCATOR_TYPE, lat_range, lon_range); } point.attrs = options.attrs; GeoHashBits hash; geohash_encode(&lat_range, &lon_range, point.y, point.x, 26, &hash); GeoHashFix52Bits score = hash.bits; ValueData score_value; score_value.SetIntValue((int64) score); Buffer content; point.Encode(content); Slice content_value(content.GetRawReadBuffer(), content.ReadableBytes()); return ZAdd(db, key, score_value, options.value, content_value); }