本文整理汇总了C++中query类的典型用法代码示例。如果您正苦于以下问题:C++ query类的具体用法?C++ query怎么用?C++ query使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了query类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: features
featureset_ptr shape_datasource::features(query const& q) const
{
#ifdef MAPNIK_STATS
mapnik::progress_timer __stats__(std::clog, "shape_datasource::features");
#endif
filter_in_box filter(q.get_bbox());
if (indexed_)
{
std::unique_ptr<shape_io> shape_ptr = std::make_unique<shape_io>(shape_name_);
return featureset_ptr
(new shape_index_featureset<filter_in_box>(filter,
std::move(shape_ptr),
q.property_names(),
desc_.get_encoding(),
shape_name_,
row_limit_));
}
else
{
return std::make_shared<shape_featureset<filter_in_box> >(filter,
shape_name_,
q.property_names(),
desc_.get_encoding(),
file_length_,
row_limit_);
}
}
示例2: features
featureset_ptr shape_datasource::features(const query& q) const
{
if (!is_bound_) bind();
filter_in_box filter(q.get_bbox());
if (indexed_)
{
shape_->shp().seek(0);
// TODO - use boost::make_shared - #760
return featureset_ptr
(new shape_index_featureset<filter_in_box>(filter,
*shape_,
q.property_names(),
desc_.get_encoding(),
shape_name_,
row_limit_));
}
else
{
return boost::make_shared<shape_featureset<filter_in_box> >(filter,
shape_name_,
q.property_names(),
desc_.get_encoding(),
file_length_,
row_limit_);
}
}
示例3: features
featureset_ptr shape_datasource::features(const query& q) const
{
#ifdef MAPNIK_STATS
mapnik::progress_timer __stats__(std::clog, "shape_datasource::features");
#endif
filter_in_box filter(q.get_bbox());
if (indexed_)
{
shape_->shp().seek(0);
// TODO - use std::make_shared - #760
return featureset_ptr
(new shape_index_featureset<filter_in_box>(filter,
*shape_,
q.property_names(),
desc_.get_encoding(),
shape_name_,
row_limit_));
}
else
{
return std::make_shared<shape_featureset<filter_in_box> >(filter,
shape_name_,
q.property_names(),
desc_.get_encoding(),
file_length_,
row_limit_);
}
}
示例4: features
featureset_ptr ogr_datasource::features(query const& q) const
{
if (! is_bound_) bind();
if (dataset_ && layer_.is_valid())
{
OGRLayer* layer = layer_.layer();
if (indexed_)
{
filter_in_box filter(q.get_bbox());
return featureset_ptr(new ogr_index_featureset<filter_in_box>(*dataset_,
*layer,
filter,
index_name_,
desc_.get_encoding(),
multiple_geometries_));
}
else
{
return featureset_ptr(new ogr_featureset (*dataset_,
*layer,
q.get_bbox(),
desc_.get_encoding(),
multiple_geometries_));
}
}
return featureset_ptr();
}
示例5: main
int main(int argc, char *argv[])
{
if(argc < 2)
{
puts("Usage : ./megatron201001015 schema.txt");
return 0;
}
D.load_schema(argv[1]);
//D.print_schema();
D.load_data();
//D.save_data();
int b1,b2,b3;
while(printf("\n$"))
{
cin.getline(inp_query, MAX_QSZ);
if(strcasecmp(inp_query, "quit") == 0)
break;
if((b1=Q.syntax_check(inp_query)) && (b2=Q.valid()) && (b3=Q.parse_condition()))
Q.process_query();
else
{
puts("Query not processed");
printf("%d%d%d\n",b1,b2,b3);
//Q.print_debug();
}
}
return 0;
}
示例6: policy_
raster_featureset<LookupPolicy>::raster_featureset(LookupPolicy const& policy,query const& q)
: policy_(policy),
id_(1),
extent_(q.get_bbox()),
t_(q.get_width(),q.get_height(),extent_),
curIter_(policy_.query(extent_)),
endIter_(policy_.end())
{}
示例7: features
featureset_ptr shape_datasource::features(const query& q) const
{
filter_in_box filter(q.get_bbox());
if (indexed_)
{
return featureset_ptr(new shape_index_featureset<filter_in_box>(filter,shape_name_,q.property_names()));
}
return featureset_ptr(new shape_featureset<filter_in_box>(filter,shape_name_,q.property_names(),file_length_));
}
示例8: features
featureset_ptr osm_datasource::features(const query& q) const
{
filter_in_box filter(q.get_bbox());
// so we need to filter osm features by bbox here...
return std::make_shared<osm_featureset<filter_in_box> >(filter,
osm_data_,
q.property_names(),
desc_.get_encoding());
}
示例9: features
featureset_ptr ogr_datasource::features(query const& q) const
{
if (!is_bound_) bind();
if (dataset_ && layer_)
{
// TODO - actually filter fields!
// http://trac.osgeo.org/gdal/wiki/rfc29_desired_fields
// http://trac.osgeo.org/gdal/wiki/rfc28_sqlfunc
#if 0
std::ostringstream s;
s << "select ";
std::set<std::string> const& props=q.property_names();
std::set<std::string>::const_iterator pos=props.begin();
std::set<std::string>::const_iterator end=props.end();
while (pos != end)
{
s <<",\""<<*pos<<"\"";
++pos;
}
s << " from " << layerName_ ;
// execute existing SQL
OGRLayer* layer = dataset_->ExecuteSQL (s.str(), poly);
// layer must be freed
dataset_->ReleaseResultSet (layer);
#endif
if (indexed_)
{
filter_in_box filter(q.get_bbox());
return featureset_ptr(new ogr_index_featureset<filter_in_box> (*dataset_,
*layer_,
filter,
index_name_,
desc_.get_encoding(),
multiple_geometries_));
}
else
{
return featureset_ptr(new ogr_featureset (*dataset_,
*layer_,
q.get_bbox(),
desc_.get_encoding(),
multiple_geometries_));
}
}
return featureset_ptr();
}
示例10:
raster_featureset<LookupPolicy>::raster_featureset(LookupPolicy const& policy,
box2d<double> const& extent,
query const& q)
: policy_(policy),
feature_id_(1),
ctx_(std::make_shared<mapnik::context_type>()),
extent_(extent),
bbox_(q.get_bbox()),
curIter_(policy_.begin()),
endIter_(policy_.end()),
filter_factor_(q.get_filter_factor())
{
}
示例11: validate_attribute_names
void validate_attribute_names(query const& q, std::vector<attribute_descriptor> const& names )
{
std::set<std::string> const& attribute_names = q.property_names();
std::set<std::string>::const_iterator pos = attribute_names.begin();
std::set<std::string>::const_iterator end_names = attribute_names.end();
for ( ;pos != end_names; ++pos)
{
bool found_name = false;
for (auto const& attr_info : names)
{
if (attr_info.get_name() == *pos)
{
found_name = true;
break;
}
}
if (! found_name)
{
std::ostringstream s;
s << "OGR Plugin: no attribute named '" << *pos << "'. Valid attributes are: ";
for (auto const& attr_info2 : names)
{
s << attr_info2.get_name() << std::endl;
}
throw mapnik::datasource_exception(s.str());
}
}
}
示例12: features
featureset_ptr geos_datasource::features(query const& q) const
{
if (!is_bound_) bind();
const mapnik::box2d<double> extent = q.get_bbox();
std::ostringstream s;
s << "POLYGON(("
<< extent.minx() << " " << extent.miny() << ","
<< extent.maxx() << " " << extent.miny() << ","
<< extent.maxx() << " " << extent.maxy() << ","
<< extent.minx() << " " << extent.maxy() << ","
<< extent.minx() << " " << extent.miny()
<< "))";
#ifdef MAPNIK_DEBUG
clog << "GEOS Plugin: using extent: " << s.str() << endl;
#endif
return boost::make_shared<geos_featureset>(*geometry_,
GEOSGeomFromWKT(s.str().c_str()),
geometry_id_,
geometry_data_,
geometry_data_name_,
desc_.get_encoding(),
multiple_geometries_);
}
示例13: features
featureset_ptr raster_datasource::features(query const& q) const
{
if (! is_bound_) bind();
mapnik::CoordTransform t(width_, height_, extent_, 0, 0);
mapnik::box2d<double> intersect = extent_.intersect(q.get_bbox());
mapnik::box2d<double> ext = t.forward(intersect);
const int width = int(ext.maxx() + 0.5) - int(ext.minx() + 0.5);
const int height = int(ext.maxy() + 0.5) - int(ext.miny() + 0.5);
#ifdef MAPNIK_DEBUG
std::clog << "Raster Plugin: BOX SIZE(" << width << " " << height << ")" << std::endl;
#endif
if (multi_tiles_)
{
#ifdef MAPNIK_DEBUG
std::clog << "Raster Plugin: MULTI-TILED policy" << std::endl;
#endif
tiled_multi_file_policy policy(filename_, format_, tile_size_, extent_, q.get_bbox(), width_, height_, tile_stride_);
return boost::make_shared<raster_featureset<tiled_multi_file_policy> >(policy, extent_, q);
}
else if (width * height > 512*512)
{
#ifdef MAPNIK_DEBUG
std::clog << "Raster Plugin: TILED policy" << std::endl;
#endif
tiled_file_policy policy(filename_, format_, 256, extent_, q.get_bbox(), width_, height_);
return boost::make_shared<raster_featureset<tiled_file_policy> >(policy, extent_, q);
}
else
{
#ifdef MAPNIK_DEBUG
std::clog << "Raster Plugin: SINGLE FILE" << std::endl;
#endif
raster_info info(filename_, format_, extent_, width_, height_);
single_file_policy policy(info);
return boost::make_shared<raster_featureset<single_file_policy> >(policy, extent_, q);
}
}
示例14: __stats__
featureset_ptr ogr_datasource::features(query const& q) const
{
if (! is_bound_) bind();
#ifdef MAPNIK_STATS
mapnik::progress_timer __stats__(std::clog, "ogr_datasource::features");
#endif
if (dataset_ && layer_.is_valid())
{
// First we validate query fields: https://github.com/mapnik/mapnik/issues/792
std::vector<attribute_descriptor> const& desc_ar = desc_.get_descriptors();
// feature context (schema)
mapnik::context_ptr ctx = boost::make_shared<mapnik::context_type>();
std::vector<attribute_descriptor>::const_iterator itr = desc_ar.begin();
std::vector<attribute_descriptor>::const_iterator end = desc_ar.end();
for (; itr!=end; ++itr) ctx->push(itr->get_name()); // TODO only push query attributes
validate_attribute_names(q, desc_ar);
OGRLayer* layer = layer_.layer();
if (indexed_)
{
filter_in_box filter(q.get_bbox());
return featureset_ptr(new ogr_index_featureset<filter_in_box>(ctx,
*layer,
filter,
index_name_,
desc_.get_encoding()));
}
else
{
return featureset_ptr(new ogr_featureset(ctx,
*layer,
q.get_bbox(),
desc_.get_encoding()));
}
}
return featureset_ptr();
}
示例15: reduce_and_sort
/**< select best result of each files and sort all of them by ranker */
void reduce_and_sort(query &result,unordered_map<string,int> &ranker)
{
vector<word_position*> vals;
result.for_each([&vals](word_position* p) mutable
{
if(none_of(vals.begin(),vals.end(),[p](word_position* pos) {
return pos->document==p->document;
}))
vals.push_back(p);
});
sort(vals.begin(),vals.end(),[&ranker](word_position *i,word_position *j) {
return ranker[i->document]>ranker[j->document];
});
result=query(vals,result.get_query_words());
}