本文整理汇总了C++中mapnik::feature_ptr方法的典型用法代码示例。如果您正苦于以下问题:C++ mapnik::feature_ptr方法的具体用法?C++ mapnik::feature_ptr怎么用?C++ mapnik::feature_ptr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mapnik
的用法示例。
在下文中一共展示了mapnik::feature_ptr方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: next
feature_ptr gdal_featureset::next()
{
if (first_)
{
first_ = false;
#ifdef MAPNIK_DEBUG
std::clog << "GDAL Plugin: featureset, dataset = " << &dataset_ << std::endl;
#endif
query *q = boost::get<query>(&gquery_);
if (q)
{
return get_feature(*q);
}
else
{
coord2d *p = boost::get<coord2d>(&gquery_);
if (p)
{
return get_feature_at_point(*p);
}
}
// should never reach here
}
return feature_ptr();
}
示例2: next
feature_ptr gdal_featureset::next()
{
if (first_)
{
first_ = false;
MAPNIK_LOG_DEBUG(gdal) << "gdal_featureset: Next feature in Dataset=" << &dataset_;
query *q = boost::get<query>(&gquery_);
if (q)
{
return get_feature(*q);
}
else
{
coord2d *p = boost::get<coord2d>(&gquery_);
if (p)
{
return get_feature_at_point(*p);
}
}
// should never reach here
}
return feature_ptr();
}
示例3: get_feature
feature_ptr rasterlite_featureset::get_feature(mapnik::query const& q)
{
MAPNIK_LOG_DEBUG(rasterlite) << "rasterlite_featureset: Running get_feature";
feature_ptr feature(feature_factory::create(ctx_,1));
double x0, y0, x1, y1;
rasterliteGetExtent (dataset_, &x0, &y0, &x1, &y1);
box2d<double> raster_extent(x0, y0, x1, y1);
box2d<double> intersect = raster_extent.intersect(q.get_bbox());
const int width = static_cast<int>(std::get<0>(q.resolution()) * intersect.width() + 0.5);
const int height = static_cast<int>(std::get<0>(q.resolution()) * intersect.height() + 0.5);
const double pixel_size = (intersect.width() >= intersect.height()) ?
(intersect.width() / (double) width) : (intersect.height() / (double) height);
MAPNIK_LOG_DEBUG(rasterlite) << "rasterlite_featureset: Raster extent=" << raster_extent;
MAPNIK_LOG_DEBUG(rasterlite) << "rasterlite_featureset: View extent=" << q.get_bbox();
MAPNIK_LOG_DEBUG(rasterlite) << "rasterlite_featureset: Intersect extent=" << intersect;
MAPNIK_LOG_DEBUG(rasterlite) << "rasterlite_featureset: Query resolution=" << std::get<0>(q.resolution()) << "," << std::get<1>(q.resolution());
MAPNIK_LOG_DEBUG(rasterlite) << "rasterlite_featureset: Size=" << width << " " << height;
MAPNIK_LOG_DEBUG(rasterlite) << "rasterlite_featureset: Pixel Size=" << pixel_size;
if (width > 0 && height > 0)
{
int size = 0;
void* raster = 0;
if (rasterliteGetRawImageByRect(dataset_,
intersect.minx(),
intersect.miny(),
intersect.maxx(),
intersect.maxy(),
pixel_size,
width,
height,
GAIA_RGBA_ARRAY,
&raster,
&size) == RASTERLITE_OK)
{
if (size > 0)
{
mapnik::image_rgba8 image(width,height);
unsigned char* raster_data = static_cast<unsigned char*>(raster);
std::memcpy(image.bytes(), raster_data, size);
feature->set_raster(std::make_shared<mapnik::raster>(intersect, std::move(image), 1.0));
MAPNIK_LOG_DEBUG(rasterlite) << "rasterlite_featureset: Done";
}
else
{
MAPNIK_LOG_ERROR(rasterlite) << "Rasterlite Plugin: Error " << rasterliteGetLastError (dataset_);
}
}
return feature;
}
return feature_ptr();
}
示例4: next
feature_ptr sqlite_featureset::next()
{
if (rs_->is_valid () && rs_->step_next ())
{
int size;
const char* data = (const char *) rs_->column_blob (0, size);
int feature_id = rs_->column_integer (1);
#ifdef MAPNIK_DEBUG
// clog << "feature_oid=" << feature_id << endl;
#endif
feature_ptr feature(new Feature(feature_id));
geometry_utils::from_wkb(*feature,data,size,multiple_geometries_,format_);
for (int i = 2; i < rs_->column_count (); ++i)
{
const int type_oid = rs_->column_type (i);
const char* fld_name = rs_->column_name (i);
switch (type_oid)
{
case SQLITE_INTEGER:
{
boost::put(*feature,fld_name,rs_->column_integer (i));
break;
}
case SQLITE_FLOAT:
{
boost::put(*feature,fld_name,rs_->column_double (i));
break;
}
case SQLITE_TEXT:
{
UnicodeString ustr = tr_->transcode (rs_->column_text (i));
boost::put(*feature,fld_name,ustr);
break;
}
case SQLITE_BLOB:
case SQLITE_NULL:
break;
default:
#ifdef MAPNIK_DEBUG
clog << "unhandled type_oid=" << type_oid << endl;
#endif
break;
}
}
return feature;
}
return feature_ptr();
}
示例5: next
feature_ptr rasterlite_featureset::next()
{
if (first_)
{
first_ = false;
MAPNIK_LOG_DEBUG(gdal) << "rasterlite_featureset: Next feature in Dataset=" << &dataset_;
return mapnik::util::apply_visitor(query_dispatch(*this), gquery_);
}
return feature_ptr();
}
示例6: next
feature_ptr gdal_featureset::next()
{
if (first_)
{
first_ = false;
MAPNIK_LOG_DEBUG(gdal) << "gdal_featureset: Next feature in Dataset=" << &dataset_;
return boost::apply_visitor(query_dispatch(*this), gquery_);
}
return feature_ptr();
}
示例7: get_feature_at_point
feature_ptr gdal_featureset::get_feature_at_point(mapnik::coord2d const& pt)
{
CPLErr raster_io_error = CE_None;
if (band_ > 0)
{
unsigned raster_xsize = dataset_.GetRasterXSize();
unsigned raster_ysize = dataset_.GetRasterYSize();
double gt[6];
dataset_.GetGeoTransform(gt);
double det = gt[1] * gt[5] - gt[2] * gt[4];
// subtract half a pixel width & height because gdal coord reference
// is the top-left corner of a pixel, not the center.
double X = pt.x - gt[0] - gt[1]/2;
double Y = pt.y - gt[3] - gt[5]/2;
double det1 = gt[1]*Y + gt[4]*X;
double det2 = gt[2]*Y + gt[5]*X;
unsigned x = static_cast<unsigned>(det2/det);
unsigned y = static_cast<unsigned>(det1/det);
if (x < raster_xsize && y < raster_ysize)
{
MAPNIK_LOG_DEBUG(gdal) << "gdal_featureset: pt.x=" << pt.x << " pt.y=" << pt.y;
MAPNIK_LOG_DEBUG(gdal) << "gdal_featureset: x=" << x << " y=" << y;
GDALRasterBand* band = dataset_.GetRasterBand(band_);
int raster_has_nodata;
double nodata = band->GetNoDataValue(&raster_has_nodata);
double value;
raster_io_error = band->RasterIO(GF_Read, x, y, 1, 1, &value, 1, 1, GDT_Float64, 0, 0);
if (raster_io_error == CE_Failure) {
throw datasource_exception(CPLGetLastErrorMsg());
}
if (! raster_has_nodata || value != nodata)
{
// construct feature
feature_ptr feature = feature_factory::create(ctx_,1);
feature->set_geometry(mapnik::geometry::point<double>(pt.x,pt.y));
feature->put_new("value",value);
if (raster_has_nodata)
{
feature->put_new("nodata",nodata);
}
return feature;
}
}
}
return feature_ptr();
}
示例8: get_feature_at_point
feature_ptr gdal_featureset::get_feature_at_point(mapnik::coord2d const& pt)
{
if (band_ > 0)
{
unsigned raster_xsize = dataset_.GetRasterXSize();
unsigned raster_ysize = dataset_.GetRasterYSize();
double gt[6];
dataset_.GetGeoTransform(gt);
double det = gt[1] * gt[5] - gt[2] * gt[4];
// subtract half a pixel width & height because gdal coord reference
// is the top-left corner of a pixel, not the center.
double X = pt.x - gt[0] - gt[1]/2;
double Y = pt.y - gt[3] - gt[5]/2;
double det1 = gt[1]*Y + gt[4]*X;
double det2 = gt[2]*Y + gt[5]*X;
unsigned x = static_cast<unsigned>(det2/det);
unsigned y = static_cast<unsigned>(det1/det);
if (x < raster_xsize && y < raster_ysize)
{
MAPNIK_LOG_DEBUG(gdal) << "gdal_featureset: pt.x=" << pt.x << " pt.y=" << pt.y;
MAPNIK_LOG_DEBUG(gdal) << "gdal_featureset: x=" << x << " y=" << y;
GDALRasterBand* band = dataset_.GetRasterBand(band_);
int raster_has_nodata;
double nodata = band->GetNoDataValue(&raster_has_nodata);
double value;
band->RasterIO(GF_Read, x, y, 1, 1, &value, 1, 1, GDT_Float64, 0, 0);
if (! raster_has_nodata || value != nodata)
{
// construct feature
feature_ptr feature = feature_factory::create(ctx_,1);
std::unique_ptr<geometry_type> point = std::make_unique<geometry_type>(mapnik::geometry_type::types::Point);
point->move_to(pt.x, pt.y);
feature->add_geometry(point.release());
feature->put_new("value",value);
if (raster_has_nodata)
{
feature->put_new("nodata",nodata);
}
return feature;
}
}
}
return feature_ptr();
}
示例9: get_feature_at_point
feature_ptr gdal_featureset::get_feature_at_point(mapnik::coord2d const& pt)
{
if (band_ > 0)
{
unsigned raster_xsize = dataset_.GetRasterXSize();
unsigned raster_ysize = dataset_.GetRasterYSize();
double gt[6];
dataset_.GetGeoTransform(gt);
double det = gt[1] * gt[5] - gt[2] * gt[4];
// subtract half a pixel width & height because gdal coord reference
// is the top-left corner of a pixel, not the center.
double X = pt.x - gt[0] - gt[1]/2;
double Y = pt.y - gt[3] - gt[5]/2;
double det1 = gt[1]*Y + gt[4]*X;
double det2 = gt[2]*Y + gt[5]*X;
unsigned x = det2/det, y = det1/det;
if (x < raster_xsize && y < raster_ysize)
{
#ifdef MAPNIK_DEBUG
std::clog << boost::format("GDAL Plugin: pt.x=%f pt.y=%f") % pt.x % pt.y << std::endl;
std::clog << boost::format("GDAL Plugin: x=%f y=%f") % x % y << std::endl;
#endif
GDALRasterBand* band = dataset_.GetRasterBand(band_);
int hasNoData;
double nodata = band->GetNoDataValue(&hasNoData);
double value;
band->RasterIO(GF_Read, x, y, 1, 1, &value, 1, 1, GDT_Float64, 0, 0);
if (! hasNoData || value != nodata)
{
// construct feature
feature_ptr feature(new Feature(1));
geometry_type * point = new geometry_type(mapnik::Point);
point->move_to(pt.x, pt.y);
feature->add_geometry(point);
(*feature)["value"] = value;
return feature;
}
}
}
return feature_ptr();
}
示例10: next
feature_ptr rasterlite_featureset::next()
{
if (first_)
{
first_ = false;
query *q = boost::get<query>(&gquery_);
if(q) {
return get_feature(*q);
} else {
coord2d *p = boost::get<coord2d>(&gquery_);
if(p) {
return get_feature_at_point(*p);
}
}
// should never reach here
}
return feature_ptr();
}
示例11: next
feature_ptr kismet_featureset::next()
{
if (knd_list_it != knd_list_.end ())
{
const kismet_network_data& knd = *knd_list_it;
const std::string key = "internet_access";
std::string value;
if (knd.crypt_ == crypt_none)
{
value = "wlan_uncrypted";
}
else if (knd.crypt_ == crypt_wep)
{
value = "wlan_wep";
}
else
{
value = "wlan_crypted";
}
feature_ptr feature(feature_factory::create(feature_id_));
++feature_id_;
geometry_type* pt = new geometry_type(mapnik::Point);
pt->move_to(knd.bestlon_, knd.bestlat_);
feature->add_geometry(pt);
boost::put(*feature, key, tr_->transcode(value.c_str()));
++knd_list_it;
return feature;
}
return feature_ptr();
}
示例12: next
feature_ptr ogr_featureset::next()
{
OGRFeature *poFeature;
while ((poFeature = layer_.GetNextFeature()) != NULL)
{
// ogr feature ids start at 0, so add one to stay
// consistent with other mapnik datasources that start at 1
const int feature_id = (poFeature->GetFID() + 1);
feature_ptr feature(feature_factory::create(ctx_,feature_id));
OGRGeometry* geom = poFeature->GetGeometryRef();
if (geom && ! geom->IsEmpty())
{
ogr_converter::convert_geometry(geom, feature);
}
else
{
MAPNIK_LOG_DEBUG(ogr) << "ogr_featureset: Feature with null geometry="
<< poFeature->GetFID();
OGRFeature::DestroyFeature( poFeature );
continue;
}
++count_;
int fld_count = layerdef_->GetFieldCount();
for (int i = 0; i < fld_count; i++)
{
OGRFieldDefn* fld = layerdef_->GetFieldDefn(i);
const OGRFieldType type_oid = fld->GetType();
const std::string fld_name = fld->GetNameRef();
switch (type_oid)
{
case OFTInteger:
{
feature->put( fld_name, poFeature->GetFieldAsInteger(i));
break;
}
case OFTReal:
{
feature->put( fld_name, poFeature->GetFieldAsDouble(i));
break;
}
case OFTString:
case OFTWideString: // deprecated !
{
UnicodeString ustr = tr_->transcode(poFeature->GetFieldAsString(i));
feature->put( fld_name, ustr);
break;
}
case OFTIntegerList:
case OFTRealList:
case OFTStringList:
case OFTWideStringList: // deprecated !
{
MAPNIK_LOG_WARN(ogr) << "ogr_featureset: Unhandled type_oid=" << type_oid;
break;
}
case OFTBinary:
{
MAPNIK_LOG_WARN(ogr) << "ogr_featureset: Unhandled type_oid=" << type_oid;
//feature->put(name,feat->GetFieldAsBinary (i, size));
break;
}
case OFTDate:
case OFTTime:
case OFTDateTime: // unhandled !
{
MAPNIK_LOG_WARN(ogr) << "ogr_featureset: Unhandled type_oid=" << type_oid;
break;
}
default: // unknown
{
MAPNIK_LOG_WARN(ogr) << "ogr_featureset: Unknown type_oid=" << type_oid;
break;
}
}
}
OGRFeature::DestroyFeature( poFeature );
return feature;
}
MAPNIK_LOG_DEBUG(ogr) << "ogr_featureset: " << count_ << " features";
return feature_ptr();
}
示例13: next
feature_ptr occi_featureset::next()
{
while (rs_ != nullptr && rs_->next() == oracle::occi::ResultSet::DATA_AVAILABLE)
{
feature_ptr feature(feature_factory::create(ctx_, feature_id_));
if (use_wkb_)
{
Blob blob = rs_->getBlob(1);
blob.open(oracle::occi::OCCI_LOB_READONLY);
unsigned int size = blob.length();
if (buffer_.size() < size)
{
buffer_.resize(size);
}
oracle::occi::Stream* instream = blob.getStream(1, 0);
instream->readBuffer(buffer_.data(), size);
blob.closeStream(instream);
blob.close();
if (! geometry_utils::from_wkb(feature->paths(), buffer_.data(), size))
{
continue;
}
}
else
{
const std::unique_ptr<SDOGeometry> geom(dynamic_cast<SDOGeometry*>(rs_->getObject(1)));
if (geom.get())
{
convert_geometry(geom.get(), feature);
}
else
{
continue;
}
}
std::vector<MetaData> listOfColumns = rs_->getColumnListMetaData();
for (unsigned int i = 1; i < listOfColumns.size(); ++i)
{
MetaData columnObj = listOfColumns[i];
std::string fld_name = columnObj.getString(MetaData::ATTR_NAME);
int type_oid = columnObj.getInt(MetaData::ATTR_DATA_TYPE);
/*
int type_code = columnObj.getInt(MetaData::ATTR_TYPECODE);
if (type_code == OCCI_TYPECODE_OBJECT)
{
continue;
}
*/
switch (type_oid)
{
case oracle::occi::OCCIBOOL:
feature->put(fld_name, (rs_->getInt(i + 1) != 0));
break;
case oracle::occi::OCCIINT:
case oracle::occi::OCCIUNSIGNED_INT:
feature->put(fld_name, static_cast<mapnik::value_integer>(rs_->getInt(i + 1)));
break;
case oracle::occi::OCCIFLOAT:
case oracle::occi::OCCIBFLOAT:
feature->put(fld_name, (double)rs_->getFloat(i + 1));
break;
case oracle::occi::OCCIDOUBLE:
case oracle::occi::OCCIBDOUBLE:
case oracle::occi::OCCINUMBER:
case oracle::occi::OCCI_SQLT_NUM:
feature->put(fld_name, rs_->getDouble(i + 1));
break;
case oracle::occi::OCCICHAR:
case oracle::occi::OCCISTRING:
case oracle::occi::OCCI_SQLT_AFC:
case oracle::occi::OCCI_SQLT_AVC:
case oracle::occi::OCCI_SQLT_CHR:
case oracle::occi::OCCI_SQLT_LNG:
case oracle::occi::OCCI_SQLT_LVC:
case oracle::occi::OCCI_SQLT_STR:
case oracle::occi::OCCI_SQLT_VCS:
case oracle::occi::OCCI_SQLT_VNU:
case oracle::occi::OCCI_SQLT_VBI:
case oracle::occi::OCCI_SQLT_VST:
case oracle::occi::OCCIROWID:
case oracle::occi::OCCI_SQLT_RDD:
case oracle::occi::OCCI_SQLT_RID:
case oracle::occi::OCCIDATE:
case oracle::occi::OCCI_SQLT_DAT:
case oracle::occi::OCCI_SQLT_DATE:
case oracle::occi::OCCI_SQLT_TIME:
case oracle::occi::OCCI_SQLT_TIME_TZ:
case oracle::occi::OCCITIMESTAMP:
case oracle::occi::OCCI_SQLT_TIMESTAMP:
case oracle::occi::OCCI_SQLT_TIMESTAMP_LTZ:
case oracle::occi::OCCI_SQLT_TIMESTAMP_TZ:
//.........这里部分代码省略.........
示例14: get_feature
feature_ptr gdal_featureset::get_feature(mapnik::query const& q)
{
feature_ptr feature = feature_factory::create(ctx_,1);
int raster_has_nodata = 0;
double raster_nodata = 0;
GDALRasterBand * red = 0;
GDALRasterBand * green = 0;
GDALRasterBand * blue = 0;
GDALRasterBand * alpha = 0;
GDALRasterBand * grey = 0;
CPLErr raster_io_error = CE_None;
/*
#ifdef MAPNIK_LOG
double tr[6];
dataset_.GetGeoTransform(tr);
const double dx = tr[1];
const double dy = tr[5];
MAPNIK_LOG_DEBUG(gdal) << "gdal_featureset: dx_=" << dx_ << " dx=" << dx << " dy_=" << dy_ << "dy=" << dy;
#endif
*/
view_transform t(raster_width_, raster_height_, raster_extent_, 0, 0);
box2d<double> intersect = raster_extent_.intersect(q.get_bbox());
box2d<double> box = t.forward(intersect);
//size of resized output pixel in source image domain
double margin_x = 1.0 / (std::fabs(dx_) * std::get<0>(q.resolution()));
double margin_y = 1.0 / (std::fabs(dy_) * std::get<1>(q.resolution()));
if (margin_x < 1)
{
margin_x = 1.0;
}
if (margin_y < 1)
{
margin_y = 1.0;
}
//select minimum raster containing whole box
int x_off = rint(box.minx() - margin_x);
int y_off = rint(box.miny() - margin_y);
int end_x = rint(box.maxx() + margin_x);
int end_y = rint(box.maxy() + margin_y);
//clip to available data
if (x_off < 0)
{
x_off = 0;
}
if (y_off < 0)
{
y_off = 0;
}
if (end_x > (int)raster_width_)
{
end_x = raster_width_;
}
if (end_y > (int)raster_height_)
{
end_y = raster_height_;
}
int width = end_x - x_off;
int height = end_y - y_off;
// don't process almost invisible data
if (box.width() < 0.5)
{
width = 0;
}
if (box.height() < 0.5)
{
height = 0;
}
//calculate actual box2d of returned raster
box2d<double> feature_raster_extent(x_off, y_off, x_off + width, y_off + height);
intersect = t.backward(feature_raster_extent);
MAPNIK_LOG_DEBUG(gdal) << "gdal_featureset: Raster extent=" << raster_extent_;
MAPNIK_LOG_DEBUG(gdal) << "gdal_featureset: View extent=" << intersect;
MAPNIK_LOG_DEBUG(gdal) << "gdal_featureset: Query resolution=" << std::get<0>(q.resolution()) << "," << std::get<1>(q.resolution());
MAPNIK_LOG_DEBUG(gdal) << "gdal_featureset: StartX=" << x_off << " StartY=" << y_off << " Width=" << width << " Height=" << height;
if (width > 0 && height > 0)
{
double width_res = std::get<0>(q.resolution());
double height_res = std::get<1>(q.resolution());
int im_width = int(width_res * intersect.width() + 0.5);
int im_height = int(height_res * intersect.height() + 0.5);
double filter_factor = q.get_filter_factor();
im_width = int(im_width * filter_factor + 0.5);
im_height = int(im_height * filter_factor + 0.5);
// case where we need to avoid upsampling so that the
// image can be later scaled within raster_symbolizer
if (im_width >= width || im_height >= height)
{
im_width = width;
//.........这里部分代码省略.........
示例15: next
feature_ptr geos_featureset::next()
{
if (! already_rendered_)
{
already_rendered_ = true;
if (GEOSisValid(geometry_) && ! GEOSisEmpty(geometry_))
{
bool render_geometry = true;
if (*extent_ != NULL && GEOSisValid(*extent_) && ! GEOSisEmpty(*extent_))
{
const int type = GEOSGeomTypeId(*extent_);
render_geometry = false;
switch (type)
{
case GEOS_POINT:
if (GEOSIntersects(*extent_, geometry_))
{
render_geometry = true;
}
break;
case GEOS_POLYGON:
if (GEOSContains(*extent_, geometry_)
|| GEOSWithin(geometry_, *extent_)
|| GEOSEquals(geometry_, *extent_))
{
render_geometry = true;
}
break;
default:
MAPNIK_LOG_DEBUG(geos) << "geos_featureset: Unknown extent geometry_type=" << type;
break;
}
}
if (render_geometry)
{
geos_wkb_ptr wkb(geometry_);
if (wkb.is_valid())
{
feature_ptr feature(feature_factory::create(ctx_,feature_id_));
if (geometry_utils::from_wkb(feature->paths(),
wkb.data(),
wkb.size())
&& field_ != "")
{
feature->put(field_name_, tr_->transcode(field_.c_str()));
}
return feature;
}
}
}
}
return feature_ptr();
}