本文整理汇总了C++中GeoPoint::Decode方法的典型用法代码示例。如果您正苦于以下问题:C++ GeoPoint::Decode方法的具体用法?C++ GeoPoint::Decode怎么用?C++ GeoPoint::Decode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GeoPoint
的用法示例。
在下文中一共展示了GeoPoint::Decode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GeoSearch
int Ardb::GeoSearch(const DBID& db, const Slice& key, const GeoSearchOptions& options, ValueDataDeque& results)
{
uint64 start_time = get_current_epoch_micros();
GeoHashBitsSet ress;
double x = options.x, y = options.y;
if (options.coord_type == GEO_WGS84_TYPE)
{
x = GeoHashHelper::GetMercatorX(options.x);
y = GeoHashHelper::GetMercatorY(options.y);
}
if (options.by_member)
{
ValueData score, attr;
int err = ZGetNodeValue(db, key, options.member, score, attr);
if (0 != err)
{
return err;
}
Buffer attr_content(const_cast<char*>(attr.bytes_value.data()), 0, attr.bytes_value.size());
GeoPoint point;
point.Decode(attr_content);
x = point.x;
y = point.y;
}
ZSetCacheElementSet subset;
if (options.in_members)
{
StringSet::const_iterator sit = options.submembers.begin();
while (sit != options.submembers.end())
{
ZSetCaheElement ele;
ValueData score, attr;
if (0 == ZGetNodeValue(db, key, *sit, score, attr))
{
ele.score = score.NumberValue();
Buffer buf1, buf2;
ValueData vv;
vv.SetValue(*sit, true);
vv.Encode(buf1);
attr.Encode(buf2);
ele.value.assign(buf1.GetRawReadBuffer(), buf1.ReadableBytes());
ele.attr.assign(buf2.GetRawReadBuffer(), buf2.ReadableBytes());
subset.insert(ele);
}
sit++;
}
}
GeoHashHelper::GetAreasByRadius(GEO_MERCATOR_TYPE, y, x, options.radius, ress);
/*
* Merge areas if possible to avoid disk search
*/
std::vector<ZRangeSpec> range_array;
GeoHashBitsSet::iterator rit = ress.begin();
GeoHashBitsSet::iterator next_it = ress.begin();
next_it++;
while (rit != ress.end())
{
GeoHashBits& hash = *rit;
GeoHashBits next = hash;
next.bits++;
while (next_it != ress.end() && next.bits == next_it->bits)
{
next.bits++;
next_it++;
rit++;
}
ZRangeSpec range;
range.contain_min = true;
range.contain_max = false;
range.min.SetIntValue(GeoHashHelper::Allign52Bits(hash));
range.max.SetIntValue(GeoHashHelper::Allign52Bits(next));
range_array.push_back(range);
rit++;
next_it++;
}
DEBUG_LOG("After areas merging, reduce searching area size from %u to %u", ress.size(), range_array.size());
GeoPointArray points;
std::vector<ZRangeSpec>::iterator hit = range_array.begin();
Iterator* iter = NULL;
while (hit != range_array.end())
{
ZSetQueryOptions z_options;
z_options.withscores = false;
z_options.withattr = true;
ValueDataArray values;
if (options.in_members)
{
ZSetCache::GetRangeInZSetCache(subset, *hit, z_options.withscores, z_options.withattr,
ZSetValueStoreCallback, &values);
}
else
{
ZRangeByScoreRange(db, key, *hit, iter, z_options, true, ZSetValueStoreCallback, &values);
}
ValueDataArray::iterator vit = values.begin();
while (vit != values.end())
{
GeoPoint point;
vit->ToString(point.value);
//.........这里部分代码省略.........