本文整理汇总了C++中FilterContext::setProfile方法的典型用法代码示例。如果您正苦于以下问题:C++ FilterContext::setProfile方法的具体用法?C++ FilterContext::setProfile怎么用?C++ FilterContext::setProfile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FilterContext
的用法示例。
在下文中一共展示了FilterContext::setProfile方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
// reads a chunk of features into a memory cache; do this for performance
// and to avoid needing the OGR Mutex every time
void
FeatureCursorOGR::readChunk()
{
if ( !_resultSetHandle )
return;
OGR_SCOPED_LOCK;
while( _queue.size() < _chunkSize && !_resultSetEndReached )
{
FeatureList filterList;
while( filterList.size() < _chunkSize && !_resultSetEndReached )
{
OGRFeatureH handle = OGR_L_GetNextFeature( _resultSetHandle );
if ( handle )
{
osg::ref_ptr<Feature> feature = OgrUtils::createFeature( handle, _profile.get() );
if (feature.valid() &&
!_source->isBlacklisted( feature->getFID() ) &&
validateGeometry( feature->getGeometry() ))
{
filterList.push_back( feature.release() );
}
OGR_F_Destroy( handle );
}
else
{
_resultSetEndReached = true;
}
}
// preprocess the features using the filter list:
if ( !_filters.empty() )
{
FilterContext cx;
cx.setProfile( _profile.get() );
if (_query.bounds().isSet())
{
cx.extent() = GeoExtent(_profile->getSRS(), _query.bounds().get());
}
else
{
cx.extent() = _profile->getExtent();
}
for( FeatureFilterList::const_iterator i = _filters.begin(); i != _filters.end(); ++i )
{
FeatureFilter* filter = i->get();
cx = filter->push( filterList, cx );
}
}
for(FeatureList::const_iterator i = filterList.begin(); i != filterList.end(); ++i)
{
_queue.push( i->get() );
}
}
}
示例2: createFeatureCursor
FeatureCursor* createFeatureCursor( const Symbology::Query& query )
{
FeatureCursor* result = 0L;
std::string url = createURL( query );
// check the blacklist:
if ( Registry::instance()->isBlacklisted(url) )
return 0L;
OE_DEBUG << LC << url << std::endl;
URI uri(url);
// read the data:
ReadResult r = uri.readString( _dbOptions.get() );
const std::string& buffer = r.getString();
const Config& meta = r.metadata();
bool dataOK = false;
FeatureList features;
if ( !buffer.empty() )
{
// Get the mime-type from the metadata record if possible
const std::string& mimeType = r.metadata().value( IOMetadata::CONTENT_TYPE );
dataOK = getFeatures( buffer, mimeType, features );
}
if ( dataOK )
{
OE_DEBUG << LC << "Read " << features.size() << " features" << std::endl;
}
//If we have any filters, process them here before the cursor is created
if (!_options.filters().empty())
{
// preprocess the features using the filter list:
if ( features.size() > 0 )
{
FilterContext cx;
cx.setProfile( getFeatureProfile() );
for( FeatureFilterList::const_iterator i = _options.filters().begin(); i != _options.filters().end(); ++i )
{
FeatureFilter* filter = i->get();
cx = filter->push( features, cx );
}
}
}
//result = new FeatureListCursor(features);
result = dataOK ? new FeatureListCursor( features ) : 0L;
if ( !result )
Registry::instance()->blacklist( url );
return result;
}
示例3: Read_Data_Directly
void FeatureCursorCDBV::Read_Data_Directly(void)
{
FeatureList preProcessList;
OGR_SCOPED_LOCK;
OGR_L_ResetReading(_layerHandle);
OGRFeatureH feat_handle;
OGRLayer * thislayer = (OGRLayer *)_layerHandle;
int totalCount = thislayer->GetFeatureCount();
int fcount = -1;
while ((feat_handle = OGR_L_GetNextFeature(_layerHandle)) != NULL)
{
++fcount;
if (feat_handle)
{
osg::ref_ptr<Feature> f = OgrUtils::createFeature(feat_handle, _profile.get());
if (f.valid() && !_source->isBlacklisted(f->getFID()))
{
if (isGeometryValid(f->getGeometry()))
{
_queue.push(f);
if (_filters.size() > 0)
{
preProcessList.push_back(f.release());
}
}
else
{
OE_DEBUG << LC << "Skipping feature with invalid geometry: " << f->getGeoJSON() << std::endl;
}
}
OGR_F_Destroy(feat_handle);
}
}
// preprocess the features using the filter list:
if (preProcessList.size() > 0)
{
FilterContext cx;
cx.setProfile(_profile.get());
for (FeatureFilterList::const_iterator i = _filters.begin(); i != _filters.end(); ++i)
{
FeatureFilter* filter = i->get();
cx = filter->push(preProcessList, cx);
}
}
}
示例4: getFeatureProfile
void
FeatureSource::applyFilters(FeatureList& features, const GeoExtent& extent) const
{
// apply filters before returning.
if ( !getFilters().empty() )
{
FilterContext cx;
cx.setProfile( getFeatureProfile() );
cx.extent() = extent;
for(FeatureFilterList::const_iterator filter = getFilters().begin(); filter != getFilters().end(); ++filter)
{
cx = filter->get()->push( features, cx );
}
}
}
示例5: getFeatureProfile
void
FeatureSource::applyFilters(FeatureList& features, const GeoExtent& extent) const
{
// apply filters before returning.
if (_filters.valid() && _filters->empty() == false)
{
FilterContext cx;
cx.setProfile( getFeatureProfile() );
cx.extent() = extent;
for(FeatureFilterChain::const_iterator filter = _filters->begin(); filter != _filters->end(); ++filter)
{
cx = filter->get()->push( features, cx );
}
}
}
示例6: Feature
Feature*
GeometryFeatureCursor::nextFeature()
{
if ( hasMore() )
{
_lastFeature = new Feature( _geom.get(), _featureProfile.valid() ? _featureProfile->getSRS() : 0L );
if ( _featureProfile && _featureProfile->geoInterp().isSet() )
_lastFeature->geoInterp() = _featureProfile->geoInterp().get();
FilterContext cx;
cx.setProfile( _featureProfile.get() );
FeatureList list;
list.push_back( _lastFeature.get() );
for( FeatureFilterList::const_iterator i = _filters.begin(); i != _filters.end(); ++i )
{
cx = i->get()->push( list, cx );
}
_geom = 0L;
}
return _lastFeature.get();
}
示例7:
// reads a chunk of features into a memory cache; do this for performance
// and to avoid needing the OGR Mutex every time
void
FeatureCursorCDBV::readChunk()
{
if ( !_resultSetHandle )
return;
FeatureList preProcessList;
OGR_SCOPED_LOCK;
if ( _nextHandleToQueue )
{
osg::ref_ptr<Feature> f = OgrUtils::createFeature( _nextHandleToQueue, _profile.get() );
if ( f.valid() && !_source->isBlacklisted(f->getFID()) )
{
f->setFID(_s_CDBV_FeatureID);
++_s_CDBV_FeatureID;
if ( isGeometryValid( f->getGeometry() ) )
{
_queue.push( f );
if ( _filters.size() > 0 )
{
preProcessList.push_back( f.release() );
}
}
else
{
OE_DEBUG << LC << "Skipping feature with invalid geometry: " << f->getGeoJSON() << std::endl;
}
}
OGR_F_Destroy( _nextHandleToQueue );
_nextHandleToQueue = 0L;
}
unsigned handlesToQueue = _chunkSize - _queue.size();
bool resultSetEndReached = false;
for( unsigned i=0; i<handlesToQueue; i++ )
{
OGRFeatureH handle = OGR_L_GetNextFeature( _resultSetHandle );
if ( handle )
{
osg::ref_ptr<Feature> f = OgrUtils::createFeature( handle, _profile.get() );
if ( f.valid() && !_source->isBlacklisted(f->getFID()) )
{
f->setFID(_s_CDBV_FeatureID);
++_s_CDBV_FeatureID;
if (isGeometryValid( f->getGeometry() ) )
{
_queue.push( f );
if ( _filters.size() > 0 )
{
preProcessList.push_back( f.release() );
}
}
else
{
OE_DEBUG << LC << "Skipping feature with invalid geometry: " << f->getGeoJSON() << std::endl;
}
}
OGR_F_Destroy( handle );
}
else
{
resultSetEndReached = true;
break;
}
}
// preprocess the features using the filter list:
if ( preProcessList.size() > 0 )
{
FilterContext cx;
cx.setProfile( _profile.get() );
for( FeatureFilterList::const_iterator i = _filters.begin(); i != _filters.end(); ++i )
{
FeatureFilter* filter = i->get();
cx = filter->push( preProcessList, cx );
}
}
// read one more for "more" detection:
if (!resultSetEndReached)
_nextHandleToQueue = OGR_L_GetNextFeature( _resultSetHandle );
else
_nextHandleToQueue = 0L;
//OE_NOTICE << "read " << _queue.size() << " features ... " << std::endl;
}
示例8: xform
bool
BillboardExtension::connect(MapNode* mapNode)
{
if ( !mapNode )
{
OE_WARN << LC << "Illegal: MapNode cannot be null." << std::endl;
return false;
}
OE_INFO << LC << "Connecting to MapNode.\n";
if ( !_options.imageURI().isSet() )
{
OE_WARN << LC << "Illegal: image URI is required" << std::endl;
return false;
}
if ( !_options.featureOptions().isSet() )
{
OE_WARN << LC << "Illegal: feature source is required" << std::endl;
return false;
}
_features = FeatureSourceFactory::create( _options.featureOptions().value() );
if ( !_features.valid() )
{
OE_WARN << LC << "Illegal: no valid feature source provided" << std::endl;
return false;
}
//if ( _features->getGeometryType() != osgEarth::Symbology::Geometry::TYPE_POINTSET )
//{
// OE_WARN << LC << "Illegal: only points currently supported" << std::endl;
// return false;
//}
_features->initialize( _dbOptions );
osg::Vec3dArray* verts;
if ( _features->getFeatureProfile() )
{
verts = new osg::Vec3dArray();
OE_NOTICE << "Reading features...\n";
osg::ref_ptr<FeatureCursor> cursor = _features->createFeatureCursor();
while ( cursor.valid() && cursor->hasMore() )
{
Feature* f = cursor->nextFeature();
if ( f && f->getGeometry() )
{
if ( f->getGeometry()->getComponentType() == Geometry::TYPE_POLYGON )
{
FilterContext cx;
cx.setProfile( new FeatureProfile(_features->getFeatureProfile()->getExtent()) );
ScatterFilter scatter;
scatter.setDensity( _options.density().get() );
scatter.setRandom( true );
FeatureList featureList;
featureList.push_back(f);
scatter.push( featureList, cx );
}
// Init a filter to tranform feature in desired SRS
if (!mapNode->getMapSRS()->isEquivalentTo(_features->getFeatureProfile()->getSRS()))
{
FilterContext cx;
cx.setProfile( new FeatureProfile(_features->getFeatureProfile()->getExtent()) );
TransformFilter xform( mapNode->getMapSRS() );
FeatureList featureList;
featureList.push_back(f);
cx = xform.push(featureList, cx);
}
GeometryIterator iter(f->getGeometry());
while(iter.hasMore()) {
const Geometry* geom = iter.next();
osg::ref_ptr<osg::Vec3dArray> fVerts = geom->createVec3dArray();
verts->insert(verts->end(), fVerts->begin(), fVerts->end());
}
}
}
}
else
{
OE_WARN << LC << "Illegal: feature source has no SRS" << std::endl;
return false;
}
if ( verts && verts->size() > 0 )
{
OE_NOTICE << LC << "Read " << verts->size() << " points.\n";
//localize all the verts
GeoPoint centroid;
_features->getFeatureProfile()->getExtent().getCentroid(centroid);
centroid = centroid.transform(mapNode->getMapSRS());
//.........这里部分代码省略.........
示例9: renderFeaturesForStyle
//override
bool renderFeaturesForStyle(
const Style& style,
const FeatureList& features,
osg::Referenced* buildData,
const GeoExtent& imageExtent,
osg::Image* image )
{
// A processing context to use with the filters:
FilterContext context;
context.setProfile( getFeatureSource()->getFeatureProfile() );
const LineSymbol* masterLine = style.getSymbol<LineSymbol>();
const PolygonSymbol* masterPoly = style.getSymbol<PolygonSymbol>();
// sort into bins, making a copy for lines that require buffering.
FeatureList polygons;
FeatureList lines;
for(FeatureList::const_iterator f = features.begin(); f != features.end(); ++f)
{
if ( f->get()->getGeometry() )
{
if ( masterPoly || f->get()->style()->has<PolygonSymbol>() )
{
polygons.push_back( f->get() );
}
if ( masterLine || f->get()->style()->has<LineSymbol>() )
{
Feature* newFeature = new Feature( *f->get() );
if ( !newFeature->getGeometry()->isLinear() )
{
newFeature->setGeometry( newFeature->getGeometry()->cloneAs(Geometry::TYPE_RING) );
}
lines.push_back( newFeature );
}
}
}
// initialize:
RenderFrame frame;
frame.xmin = imageExtent.xMin();
frame.ymin = imageExtent.yMin();
frame.xf = (double)image->s() / imageExtent.width();
frame.yf = (double)image->t() / imageExtent.height();
if ( lines.size() > 0 )
{
// We are buffering in the features native extent, so we need to use the
// transformed extent to get the proper "resolution" for the image
const SpatialReference* featureSRS = context.profile()->getSRS();
GeoExtent transformedExtent = imageExtent.transform(featureSRS);
double trans_xf = (double)image->s() / transformedExtent.width();
double trans_yf = (double)image->t() / transformedExtent.height();
// resolution of the image (pixel extents):
double xres = 1.0/trans_xf;
double yres = 1.0/trans_yf;
// downsample the line data so that it is no higher resolution than to image to which
// we intend to rasterize it. If you don't do this, you run the risk of the buffer
// operation taking forever on very high-res input data.
if ( _options.optimizeLineSampling() == true )
{
ResampleFilter resample;
resample.minLength() = osg::minimum( xres, yres );
context = resample.push( lines, context );
}
// now run the buffer operation on all lines:
BufferFilter buffer;
double lineWidth = 1.0;
if ( masterLine )
{
buffer.capStyle() = masterLine->stroke()->lineCap().value();
if ( masterLine->stroke()->width().isSet() )
{
lineWidth = masterLine->stroke()->width().value();
GeoExtent imageExtentInFeatureSRS = imageExtent.transform(featureSRS);
double pixelWidth = imageExtentInFeatureSRS.width() / (double)image->s();
// if the width units are specified, process them:
if (masterLine->stroke()->widthUnits().isSet() &&
masterLine->stroke()->widthUnits().get() != Units::PIXELS)
{
const Units& featureUnits = featureSRS->getUnits();
const Units& strokeUnits = masterLine->stroke()->widthUnits().value();
// if the units are different than those of the feature data, we need to
// do a units conversion.
if ( featureUnits != strokeUnits )
{
if ( Units::canConvert(strokeUnits, featureUnits) )
{
// linear to linear, no problem
lineWidth = strokeUnits.convertTo( featureUnits, lineWidth );
//.........这里部分代码省略.........
示例10: createFeatureCursor
FeatureCursor* createFeatureCursor(const Symbology::Query& query, ProgressCallback* progress)
{
FeatureCursor* result = 0L;
std::string url = createURL( query );
// the URL wil lbe empty if it was invalid or outside the level bounds of the layer.
if (url.empty())
return 0L;
OE_DEBUG << LC << url << std::endl;
URI uri(url, _options.url()->context());
// read the data:
ReadResult r = uri.readString(_readOptions.get(), progress);
const std::string& buffer = r.getString();
const Config& meta = r.metadata();
bool dataOK = false;
FeatureList features;
if ( !buffer.empty() )
{
// Get the mime-type from the metadata record if possible
std::string mimeType = r.metadata().value( IOMetadata::CONTENT_TYPE );
//If the mimetype is empty then try to set it from the format specification
if (mimeType.empty())
{
if (_options.format().value() == "json") mimeType = "json";
else if (_options.format().value().compare("gml") == 0) mimeType = "text/xml";
else if (_options.format().value().compare("pbf") == 0) mimeType = "application/x-protobuf";
}
dataOK = getFeatures( buffer, *query.tileKey(), mimeType, features );
}
if ( dataOK )
{
OE_DEBUG << LC << "Read " << features.size() << " features" << std::endl;
}
//If we have any filters, process them here before the cursor is created
if (getFilters() && !getFilters()->empty() && !features.empty())
{
FilterContext cx;
cx.setProfile(getFeatureProfile());
cx.extent() = query.tileKey()->getExtent();
for (FeatureFilterChain::const_iterator i = getFilters()->begin(); i != getFilters()->end(); ++i)
{
FeatureFilter* filter = i->get();
cx = filter->push(features, cx);
}
}
// If we have any features and we have an fid attribute, override the fid of the features
if (_options.fidAttribute().isSet())
{
for (FeatureList::iterator itr = features.begin(); itr != features.end(); ++itr)
{
std::string attr = itr->get()->getString(_options.fidAttribute().get());
FeatureID fid = as<long>(attr, 0);
itr->get()->setFID( fid );
}
}
result = new FeatureListCursor(features);
return result;
}